I'm trying to set up a demo that has a dielectric inside of some capacitor plates to show how it alters the electric field when a dielectric body is present. However, it seems like the dielectric body is set to zero voltage instead.
There are two regions, basically a rectangle with an irregular shape in the center. The solution voltage inside of the irregular shape that is in the center always shows up as zero voltage. It doesn't seem to change if I set the voltage boundary conditions differently - or if I set the dielectric constant differently.
Is it that I am not doing the boundary conditions correctly?
#-------------------------------#
# Construct Mesh, FunctionSpace #
#-------------------------------#
mesh = Mesh("mesh.xml.gz")
V = FunctionSpace(mesh, "Lagrange", 1)
#----------------------#
# Dielectric Materials #
#----------------------#
D = FunctionSpace(mesh, "DG", 0)
epsilon = Function(D)
materials = MeshFunction("size_t", mesh, "material.xml.gz")
helper = numpy.asarray(materials.array(), dtype=numpy.int32) - 1
dm = D.dofmap()
for cell in cells(mesh):
helper[dm.cell_dofs(cell.index())] = materials[cell] - 1
epsilon.vector()[:] = numpy.choose(helper, (3, 1))
# if I plot epsilon here, I get what I expect to get ...
#-------------------------------#
# Dirichlet boundary conditions #
#-------------------------------#
dirichlet_bcs = []
dirichlet_bcs.append(DirichletBC(V, Constant(1), TopBoundary))
dirichlet_bcs.append(DirichletBC(V, Constant(-1), BottomBoundary))
#------------#
# Define PDE #
#------------#
u = TrialFunction(V)
v = TestFunction(V)
a = epsilon*inner(grad(u), grad(v))*dx
L = Constant(0.0)*v*dx
A, b = assemble_system(a, L, dirichlet_bcs)
u = Function(V)
U = u.vector()
# Compute solution
solve(A, U, b)
# Save solution in VTK format
f = File("problem.pvd")
f << u
# Plot solution
plot(u, interactive=True)