Poisson’s equation with conductors and sharp-surfaced bodies¶
This page explains how pdemagic solves Poisson’s equation in three-dimensional free space when there are bodies in it: conductors, and dielectrics of constant permittivity with a sharp surface.
The method¶
A body in vacuum changes the potential only through the charge that sits on its surface: the charge that gathers on a conductor, or the polarization charge on the surface of a dielectric. The potential is therefore
where \(u_0\) is the potential of the free charge alone and \(\sigma\) is a charge density on the surfaces \(\Gamma\) of all bodies. The integral satisfies Laplace’s equation away from the surfaces and decays at infinity. The vacuum condition is therefore exact, and nothing but the surfaces needs a mesh.
What \(\sigma\) is follows from the condition on each surface.
On a conductor the potential is constant: \(u_0 + S\sigma = V\), where \(S\sigma\) is the integral above. For a conductor held at a potential, \(V\) is given. For a floating conductor \(V\) is one more unknown, and the total charge \(\int \sigma \, dS\) is given in its place.
On a dielectric with permittivity \(\varepsilon\) the normal component of \(\varepsilon \nabla u\) is continuous. The normal derivative of \(S\sigma\) jumps by \(\sigma\) across the surface, which turns the condition into
\[ \frac{\sigma}{2} + \lambda \, \partial_n \left( u_0 + S\sigma \right) = 0, \qquad \lambda = \frac{\varepsilon - 1}{\varepsilon + 1},\]with the normal derivative of \(S\sigma\) taken as its principal value on the surface.
Any number of bodies of either kind are solved for together.
The free charge¶
\(u_0\) comes from the Fourier method. Inside a dielectric the free charge acts with \(1/\varepsilon\) of its strength, the rest being cancelled by the polarization of the material around it, so the source of \(u_0\) is the free charge divided by \(\varepsilon\) there. Free charge inside a conductor is dropped: the conductor screens it.
\(u_0\) and its gradient are computed on the grid and interpolated to the triangles with cubic polynomials.
Discretization¶
Each surface is a mesh of flat triangles, and \(\sigma\) is constant on each triangle. The equations are imposed at the centres of the triangles. The integrals of \(1/|\mathbf{x} - \mathbf{y}|\) and of its gradient over a flat triangle have closed forms, which are used for every entry of the matrix, so no quadrature is involved and nearby triangles need no special care.
The matrix is dense. It is solved by LU factorization with the faer crate.
Two details matter for the accuracy.
Shapes are meshed with the right volume. A mesh with its corners on a sphere encloses less than the sphere. pdemagic moves the corners outwards until the volume is exact, which removes most of the error of the flat triangles. The capacitance of a sphere is then four times as accurate.
Gauss’s law holds on the mesh. A flat triangle exerts no normal field on its own centre, while a curved piece of surface does. The diagonal of the dielectric equations is set so that every triangle sends exactly half of its flux into the body it belongs to, as Gauss’s law demands. This restores the missing curvature term and makes the polarization charge of a body without free charge inside vanish to rounding error. For the same reason the fields of the free charge and of other bodies enter a dielectric equation averaged over the triangle and not at its centre: next to a charged conductor the spurious net charge of a dielectric block fell from 3e-3 of the conductor’s charge to 1e-6.
Accuracy¶
The method is second-order accurate on smooth surfaces: quadrupling the number of triangles divides the error by four. For a conducting sphere of radius 1 at potential 1, whose exact potential is \(1/r\) and whose charge is \(4\pi\):
Triangles |
Error of the charge |
Largest error of the potential |
|---|---|---|
80 |
5.3e-3 |
7.7e-3 |
320 |
1.6e-3 |
2.1e-3 |
1280 |
4.4e-4 |
5.7e-4 |
5120 |
1.2e-4 |
1.5e-4 |
The potential is compared at grid points more than 0.15 away from the surface. Closer to it the flat triangles show.
Further tests, each against a closed form:
A charge beside a grounded sphere induces its image charge, and the potential outside is that of the charge and its image. With 500 triangles the induced charge is right to 4e-4 and the potential to 2e-5 of the charge’s own.
A neutral floating sphere beside a charge takes the potential the charge has at its centre.
A charge at the centre of a dielectric sphere is screened inside by \(1/\varepsilon\) and is not changed outside. The polarization charge on the surface is \(q (1 - 1/\varepsilon)\).
A dielectric sphere beside a point charge is compared with its Legendre series.
Edges and corners lower the order, because the charge density is singular there. The capacitance of a cube converges to the published value 0.6606785 (in units of \(4\pi\varepsilon_0\) times the edge length) like this:
Triangles |
Error of the capacitance |
|---|---|
192 |
1.1e-2 |
768 |
4.6e-3 |
3072 |
1.9e-3 |
What the planner chooses¶
The triangles. Each body that is given as a shape gets about 1000, and all of them together no more than 4000. They are divided among the bodies in proportion to their areas. A body given as a mesh keeps its triangles.
The box holds the bodies with a margin of half their extent, and the free charge if there is any.
The grid has at least 32 points along the longest side. With a free charge it is refined until it resolves the charge.
Without a free charge the grid has no influence on the accuracy. It only says where the solution is evaluated, and can be placed anywhere.
What the solution reports¶
For every body the diagnostics hold the number of triangles, the flux of \(-\nabla u\) that the charge on its surface sends out, and for a conductor its potential. The flux is the charge in the units of the equation: for \(-\nabla^2 u = \rho\) it is the charge itself, for \(\nabla^2 \varphi = -4\pi\rho\) it is \(4\pi\) times the charge.
With a free charge, source_surface_ratio is the largest magnitude of the
charge density on the surfaces relative to its peak. It should be tiny, see
the limits below.
Cost¶
With \(P\) triangles and \(N\) grid points:
filling the matrix takes \(P^2\) closed-form integrals, and solving it \(P^3/3\) operations;
evaluating the solution on the grid takes \(P \cdot N\) integrals, which is the larger part on fine grids.
On one core, 1000 triangles and a 32³ grid take about one second, a 64³ grid eight seconds, and 4000 triangles five seconds before the grid is evaluated.
Limits¶
Three-dimensional free space only. No periodic directions, and no other dimension.
Constant permittivity inside each body. A permittivity that varies inside a body with a sharp surface needs a volume mesh, which pdemagic does not have yet. A smooth permittivity without sharp surfaces is covered by the iterative method, but not together with bodies.
The free charge must not cross a surface. It is solved for on the grid, which cannot follow the jump of the effective charge density at the surface of a body. A charge density that is smooth and does not vanish on a surface is solved to low order only.
source_surface_ratiotells.Bodies must not touch or overlap, and a body cannot lie inside another.
Dense matrix. The number of triangles is limited to 12 000, about 1 GB.
Second order at best. High accuracy near edges and corners needs many triangles.