Hi andrew,

the problem with the different boundary condition after the first refinement was that you first set u to u1 and then set the right boundary condition for u1. You have to switch these lines to

```
def SolveBVP():
a.Assemble()
#first set u1
u1.Set(voltage, definedon=mesh.Boundaries("outer"))# Boundary sources
u.vec.data = u1.vec
```

I also observed different behavior when commented out the mesh generation function. I am not an expert of merging meshing, so I don’t really have a clue where this behavior comes from.

However, for this geometry, you can simplifying the mesh generation by only using CSG geometries

```
cube = OrthoBrick( Pnt(-outer_rad,-outer_rad,-leng/2), Pnt(outer_rad,outer_rad,2.0*quarterleng) )
cylb = Cylinder ( Pnt(0.0, 0.0, -leng), Pnt(0.0, 0.0, 0.0), outer_rad)
cube2 = OrthoBrick( Pnt(-inner_rad,-inner_rad,-leng/4), Pnt(inner_rad,inner_rad,quarterleng) )
cyli = Cylinder ( Pnt(0.0, 0.0, -leng), Pnt(0.0, 0.0, 0.0), inner_rad)
inner = (cyli*cube2).bc('inner')
outer = (cylb*cube-inner).bc('outer')
geo = CSGeometry()
geo.Add(outer)
#geo.Add(inner)
mesh = Mesh(geo.GenerateMesh (maxh=h))
```

Is there a reason why you mesh also the inner part? The solution seems to be always zero there.

With this, you can now use strings to identify your boundaries and you can also Curve your mesh.

With the attached code I get the following output:

ndof = 10423

maxerr = 0.13384372761117735 , toterr = 2.267302450023096

ndof = 15180

maxerr = 0.027621924443630222 , toterr = 1.809503014134304

ndof = 26375

maxerr = 0.007188620406700055 , toterr = 1.3764282981704608

ndof = 52185

maxerr = 0.007488492893794685 , toterr = 0.8460445676985052

ndof = 53249

maxerr = 0.001808892090986848 , toterr = 0.8097602634799458

ndof = 83743

maxerr = 0.0005241508456320649 , toterr = 0.64365894648496

ndof = 141903

maxerr = 0.00018470303727374993 , toterr = 0.5030248548701931

ndof = 245948

maxerr = 9.058668270776927e-05 , toterr = 0.37027924480707936

ndof = 326343

maxerr = 4.618238944138729e-05 , toterr = 0.30930491094782586

ndof = 418213

maxerr = 2.0765179180659515e-05 , toterr = 0.2665229929125358

ndof = 594250

maxerr = 1.1146830833658861e-05 , toterr = 0.22296841251806954

Capacitance = 2.3274 pF

which is quite near to your expected capacitance of 2.326 pF

Best,

Michael

https://ngsolve.org/media/kunena/attachments/889/proc_cyl3_2020-02-17.py

Attachment: proc_cyl3_2020-02-17.py