Hello,

In the code below I tried to create a simple parallel plate capacitor and calculate the charge on both plates.

The problem I faced is that the charge is not the same on both plates which actually should be the case. I tried locally refining the mesh and it did improve the solution but still there was a 10% drift error and even more on a 3D mesh.

Is there a way to increase the accuracy of the solution other than refining the mesh ???

Thank you in advance

mesh = RectangleMesh(Point(0, 0),Point(400, 50), 80, 10)

V = FunctionSpace(mesh, ‘CG’, 1)

tol = 1e-14

class Up(SubDomain):

def inside(self, x, on_boundary):

return on_boundary and x[1] >= box_height - tol

class Down(SubDomain):

def inside(self, x, on_boundary):

return on_boundary and x[1] < tol

and x[0] >= 100 and x[0] <= 300

up = Up()

down = Down()

bcs = [DirichletBC(V, Constant(5.0), up),DirichletBC(V, Constant(0.0), down)]

u = TrialFunction(V)

v = TestFunction(V)

f = Constant(0)

a = dot(grad(u), grad(v))dxv*dx

L = f

u = Function(V)

solve(a == L, u, bcs)

boundaries = MeshFunction(“size_t”, mesh,mesh.topology().dim()-1)

boundaries.set_all(0)

up.mark(boundaries, 1)

down.mark(boundaries, 2)

ds = Measure(“ds”)[boundaries]

n = FacetNormal(mesh)

m1 = dot(n,grad(u))*ds(1)

Q1 = assemble(m1)

—>Q1= 24.75939799680508

m2 = dot(n,grad(u))*ds(2)

Q2 = assemble(m2)

—>Q2 = -22.287241237050743