# A cloud of ions between two plates A cloud of ions between two grounded plates pushes itself apart, at five times. ```python import sympy as sp import pdemagic as pm x, t = sp.symbols("x t", real=True) n = sp.Function("n")(x, t) phi = sp.Function("phi")(x, t) cloud = pm.Problem( sp.Eq(n.diff(t), n.diff(x, 2) / 4 + (n * phi.diff(x)).diff(x)), sp.Eq(phi.diff(x, 2), -n), domain=pm.Box({x: (-4, 4)}), time=(t, 0, 0.4), initial={n: 6 * sp.exp(-(x**2))}, boundary=[sp.Eq(n, 0), sp.Eq(phi, 0)], ) pm.solve(cloud).plot(unknown=n) ``` ## What it shows Ions of one sign, with the density $n$, diffuse and drift in the electric field. The field is their own: the potential $\varphi$ obeys Poisson's equation with their charge as its source, at every instant, and both plates are grounded. An ion that reaches a plate is neutralised there, so the density is zero on the plates. The cloud repels itself. Its middle sinks and its flanks move outwards far faster than diffusion alone would take them: without the field the peak would still stand at 5 at the time 0.4, and here it is at 1.8. The density flattens into an arch, the shape of a charge that expands freely, and by the last time the plates have begun to take ions away. The second equation has no derivative in time. It is a constraint: it fixes $\varphi$ from $n$ at every time, and $\varphi$ has no initial value. ## What pdemagic decided One equation in time and a constraint between walls are stepped together (`exponential_runge_kutta`). The diffusion of $n$ is exact in its modes of the box. The drift, $\partial_x(n\,\partial_x\varphi)$, is stepped, and at every evaluation of it the constraint is solved for $\varphi$, in the modes of $\varphi$ with its own conditions, which costs two transforms. The grid has 96 Chebyshev points. The stepping takes 309 steps: the drift holds a derivative of $n$, and a term with a derivative limits the step on a grid whose points crowd at the walls. ## More - [Systems of equations](../topics/systems.md) - [Nonlinear equations in time](../topics/nonlinear-time.md) - [Systems between walls, the method](../methods/systems-between-walls.md) - [What is solved on boxes with walls](../ref/equations-boxes.md)