This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Von Neumann and Dirichlet conditions on the same boundary: Is it possible?

0 votes

Below is a short script that solves the poisson equation with solution u on a unit square. On one side of the square, the source term f is

f(x,y) = 1.0

The Dirichlet boundary condition is

u(1,y) = 0.0

I would also like to implement the Von Neumann boundary condition

d u(1,y) / dx = 0.0

Is this possible? Note that the script below already satisfies the boundary condition

d u(0,y) / dx = 0.0

The script:

from dolfin import *

# Create mesh and define function space
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)

# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
    return x[0] > 1.0 - DOLFIN_EPS

# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(1.0)
g = Constant(0.0)
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds

# Compute solution
u = Function(V)
solve(a == L, u, bc)

# Save solution in VTK format
file = File("poisson.pvd")
file << u

# Plot solution
plot(u, interactive=True)
asked Apr 2, 2017 by sixtysymbols FEniCS User (2,280 points)

Are you sure you don't want to enforce a Robin boundary condition?

1 Answer

+4 votes

Not possible. The PDE is fully characterized by, e.g., the equation on the interior and Dirichlet boundary conditions. The unique solution has $n\dot\nabla u$ on the boundary, so demanding it to be anything else wouldn't make sense.

answered Apr 2, 2017 by nschloe FEniCS User (7,120 points)
...