Two charges in the plane¶
The potential of a positive and a negative charge in free space, with nothing around them.
import sympy as sp
import pdemagic as pm
x, y = sp.symbols("x y", real=True)
phi = sp.Function("phi")(x, y)
charges = sp.exp(-((x - 1) ** 2 + y**2)) - sp.exp(-((x + 1) ** 2 + y**2))
problem = pm.Problem(sp.Eq(pm.laplacian(phi), -charges), domain=pm.FreeSpace(x, y))
pm.solve(problem).plot()
What it shows¶
Poisson’s equation, \(\nabla^2\varphi = -\rho\), for two clouds of charge of opposite sign. The potential is positive around the one and negative around the other, and zero on the line half-way between them. It falls off slowly: the picture ends where the grid ends, not where the potential does. There is no box to choose and no boundary condition to invent, because the domain is all of the plane.
What pdemagic decided¶
The planner recognised a Poisson equation in free space and chose the
Fourier method for it (fourier). It put the box where the charges have
fallen to \(10^{-12}\) of their maximum, and took the coarsest grid that
resolves them: 64 by 54 points.