A charged sphere beside a block of glass

A section through the potential of a conducting sphere at the potential one, with a block of glass next to it.

import sympy as sp
import pdemagic as pm
from pdemagic import shapes

x, y, z = sp.symbols("x y z", real=True)
U = sp.Function("U")(x, y, z)
sphere = pm.Conductor(shapes.Sphere(radius=1.0), potential=1.0, name="sphere")
glass = pm.Dielectric(
    shapes.Box(lower=(1.6, -1, -1), upper=(2.6, 1, 1)), permittivity=5.0, name="glass"
)
charged = pm.Problem(
    sp.Eq(pm.laplacian(U), 0), domain=pm.FreeSpace(x, y, z), bodies=[sphere, glass]
)
plan = pm.plan(charged)
plan.method.panels = 600
plan.grid.shape = (48, 48, 5)
around = pm.solve(charged, plan)

axes = around.plot()
xs, ys, _ = around.axes
axes.contour(xs, ys, around[U][:, :, 2].T, levels=14, colors="gray", linewidths=0.6)
The figure that the example above draws. The figure that the example above draws.

What it shows

Laplace’s equation in space, around two bodies with sharp surfaces. The sphere is a conductor: the potential is one on it and all through it. The glass carries no charge, and the field of the sphere polarises it. The grey lines are lines of equal potential, which close to the sphere are circles. At the faces of the block, between \(x = 1.6\) and \(x = 2.6\), they bend, and inside it they lie further apart: the glass weakens the field. The picture is the section through the middle of both bodies, the plane \(z = 0\).

What pdemagic decided

A problem with bodies is solved by boundary elements (boundary_elements): the surfaces are divided into triangles, and the charge on them is the unknown. The planner would take about 2000 triangles. The example asks for 600, which is enough for a picture, and for a flat grid of 48 by 48 by 5 points, whose middle layer is the section. That grid only says where the potential is evaluated: the accuracy depends on the triangles.

More