Bodies¶
Matter in the domain of Poisson’s equation: conductors, and dielectrics with a sharp surface. A body is a shape and what it is made of, and a problem takes a list of them. This page is about such bodies. A permittivity that varies smoothly needs none: it is a coefficient of the equation, on the page about media and potentials.
import numpy as np
import sympy as sp
import pdemagic as pm
from pdemagic import shapes
x, y, z = sp.symbols("x y z", real=True)
phi = sp.Function("phi")(x, y, z)
A shape and what it is made of¶
In three-dimensional free space a problem can contain bodies: conductors, and dielectrics with a constant permittivity. An electrode at the potential 1 beside a block of glass:
electrode = pm.Conductor(shapes.Sphere(radius=1.0), potential=1.0, name="electrode")
glass = pm.Dielectric(
shapes.Box(lower=(2, -1, -1), upper=(3, 1, 1)), permittivity=5.0, name="glass"
)
charged = pm.Problem(
sp.Eq(pm.laplacian(phi), 0),
domain=pm.FreeSpace(x, y, z),
bodies=[electrode, glass],
)
body_plan = pm.plan(charged)
assert body_plan.method.kind == "boundary_elements"
The equation is Poisson’s, as without bodies. Its right-hand side may
hold a free charge, as long as the charge does not cross a surface: the
grid cannot follow a jump of the charge there. The diagnostic
source_surface_ratio says how much of the charge lies on the surfaces,
relative to its maximum.
The shapes are Sphere, Ellipsoid, Box and Cylinder. Any other
body is a shapes.Mesh of triangles, from whatever mesh generator you
use:
tetrahedron = shapes.Mesh(
vertices=[(0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)],
triangles=[(0, 2, 1), (0, 1, 3), (0, 3, 2), (1, 2, 3)],
)
Triangles on the surfaces¶
pdemagic divides the surfaces into triangles and solves for the charge
on them. The number of triangles is an entry of the plan,
method.panels, and it decides the accuracy: four times as many halve
the size of the triangles and divide the error by four.
body_plan.method.panels = 600
with_bodies = pm.solve(charged, body_plan)
with_bodies.plot()
The plot is a section through the middle of the box. Without a free
charge the grid plays no part in the solve: it only says where the
solution is evaluated. A shape shows its triangles with
shape.mesh(panels=...), which returns a shapes.Mesh with the arrays
vertices and triangles:
surface = shapes.Sphere(radius=1.0).mesh(panels=200)
assert surface.vertices.shape[1] == 3 and surface.triangles.shape[1] == 3
What each body carries¶
solution.bodies reports for each body the charge on its surface, as a
flux, and the potential of a conductor. The flux is the charge in the
units of the equation: for \(\nabla^2\varphi = -4\pi\rho\), \(4\pi\) times
the charge.
electrode_result = with_bodies.bodies["electrode"]
assert electrode_result.potential == 1.0
# The glass raises the capacitance above that of the sphere alone, 4 pi.
assert 4 * sp.pi < electrode_result.flux < 1.1 * 4 * sp.pi
# It carries no net charge itself.
assert abs(with_bodies.bodies["glass"].flux) < 1e-3
Conductors that float¶
A conductor is held at a potential, or it floats and carries a given
flux. A second sphere without a charge, beside the electrode, takes a
potential of its own, which the solution reports:
floating = pm.Conductor(
shapes.Sphere(centre=(3, 0, 0), radius=1.0), flux=0.0, name="floating"
)
pair = pm.Problem(
sp.Eq(pm.laplacian(phi), 0),
domain=pm.FreeSpace(x, y, z),
bodies=[electrode, floating],
)
pair_plan = pm.plan(pair)
pair_plan.method.panels = 600
between = pm.solve(pair, pair_plan)
# The potential of the electrode alone is 1/3 at the centre of the sphere.
assert abs(between.bodies["floating"].potential - 1 / 3) < 0.01
assert abs(between.bodies["floating"].flux) < 1e-10
What does not work yet¶
Bodies with sharp surfaces are taken in three-dimensional free space, and for Poisson’s equation alone. Not yet: bodies that touch, a permittivity that varies inside such a body or around it, problems in time, and complex sources. The known limits list them all.
See also¶
Media and potentials, for a permittivity that varies smoothly.
Accuracy and diagnostics, for what second order means here.
Reference: Conductor, Dielectric and BodyResult.
Gallery: a charged sphere beside a block of glass.
Methods: conductors and sharp-surfaced bodies.