I’m an electrical engineer (power systems - 20 years). I have some familiarity with commercial FEM programs. I’ve been interested in learning NGSolve, but am finding my background too far removed from the language and concepts of the examples and documentation. Clearly the developers are brilliant folks and have worked very hard. Even with that, I’ve had a hard time getting traction. That said, I’m motivated to persist as it seems NGSolve has several advantages over other platforms I’ve looked at for my particular applications. Perhaps there are others in the same boat.

My goal with this thread is to get some basic 2D and 3D examples going in the area of electrostatics. Hopefully over time this can serve as supplementary documentation for folks like myself who are a bit overwhelmed by trial functions, test functions, bilinear forms, Galerkin methods etc.

I’ll start with the simple capacitor example in the figure below. The top and bottom of the unit square are capacitor plates.

As a first attempt I tried to adapt the Poisson example (for those unfamiliar with these concepts, the Laplace equation is a special case of Poisson equation with no source (no space charge) in the dielectric region. The faulty output result follows.

https://ngsolve.org/media/kunena/attachments/1333/CapExample1_2020-04-19.py

```
import netgen.gui
from ngsolve import *
from netgen.geom2d import unit_square
#geo.SetMaterial (1, "dielectric") #
mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))
fes = H1(mesh, order=2, dirichlet="top|bottom")
u = fes.TrialFunction() # symbolic object
v = fes.TestFunction() # symbolic object
gfu = GridFunction(fes) # solution
#attempt to set constant value boundary conditions
gfu.Set(1000.0, definedon=mesh.Boundaries("top"))
gfu.Set(0.0, definedon=mesh.Boundaries("bottom"))
a = BilinearForm(fes, symmetric=True)
a += grad(u)*grad(v)*dx
a.Assemble()
#seems this should be set to zero for Laplace,
#but setting to zero did not work
f = LinearForm(fes)
f += v*dx
f.Assemble()
gfu.vec.data = \
a.mat.Inverse(freedofs=fes.FreeDofs()) * f.vec
Draw(gfu)
```

Questions:

[ol]

[li]What is the syntax for defining permittivity for the dielectric region?[/li]

[li]Boundary conditions didn’t work - how can these be implemented correctly?[/li]

[li]Seems like the linearform equation should be set to zero to implement the Laplace equation, but that didn’t work when I tried it (not shown here) - any suggestions?[/li]

[li]Once the space potential is found can a simple grad() function be used to find the e-field?[/li]

[li]Suggestions for syntax to calculate the plate surface charge density?[/li]

[/ol]

Attachment: CapExample1_2020-04-19.py

Attachment: CapExample1_FaultyResult_2020-04-19.jpg

Attachment: SimpleCapProblem_2020-04-19-2.jpg