Put a conductor in a field

Use this when Poisson’s equation in three-dimensional free space has metal in it: an electrode that is held at a potential, or a body that floats in the field of others.

Steps

  1. Make each body from a shape of pdemagic.shapes and what it is: pm.Conductor(shape, potential=1.0) is held at a potential, and pm.Conductor(shape, flux=0.0) floats and carries a given charge.

  2. Hand the bodies to the problem: bodies=[...].

  3. Set the number of triangles on the surfaces in the plan, plan.method.panels. It decides the accuracy and the time.

  4. Solve, and read solution.bodies for the charge and the potential of each body.

Example

An electrode at the potential 1, and an uncharged metal sphere that floats beside it:

import math

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)

electrode = pm.Conductor(shapes.Sphere(radius=1.0), potential=1.0, name="electrode")
floating = pm.Conductor(
    shapes.Sphere(centre=(3, 0, 0), radius=1.0), flux=0.0, name="floating"
)
problem = pm.Problem(
    sp.Eq(pm.laplacian(phi), 0),
    domain=pm.FreeSpace(x, y, z),
    bodies=[electrode, floating],
)

plan = pm.plan(problem)
assert plan.method.kind == "boundary_elements"
plan.method.panels = 400
plan.grid.shape = (24, 16, 16)
solution = pm.solve(problem, plan)
solution.plot()

sphere = solution.bodies["floating"]
assert abs(sphere.flux) < 1e-10  # it carries no charge
# Its potential is near 1/3, that of the electrode at this distance.
assert 0.3 < sphere.potential < 0.4
# It raises the capacitance of the electrode above that of a sphere alone.
assert solution.bodies["electrode"].flux > 4 * math.pi
The figure that the example above draws. The figure that the example above draws.

Notes

  • The flux of a body is its charge in the units of the equation: for \(\nabla^2\varphi = -4\pi\rho\) it is \(4\pi\) times the charge.

  • Four times as many triangles halve their size and divide the error by four. The planner starts with about 1000, which this example lowers to stay quick.

  • Without a free charge the grid plays no part in the solve: it only says where the potential is given.

  • The right-hand side may hold a free charge, as long as it does not reach a surface. The diagnostic source_surface_ratio tells.

  • The shapes are Sphere, Ellipsoid, Box and Cylinder, and shapes.Mesh takes triangles from a mesh generator. pm.Dielectric(shape, permittivity=5.0) is a body of glass.

  • Bodies are for Poisson’s equation in free space in three dimensions. They must not touch.

  • Bodies explains more, and the reference lists the arguments. The gallery has a sphere beside glass, and the method is boundary elements.