Stationary equations¶
An equation without time: Poisson’s equation and its relatives. This page says which linear equations with constant coefficients are solved, and on which domain. Coefficients that vary, nonlinear terms, waves of one frequency and plates each have a page of their own.
import numpy as np
import sympy as sp
import pdemagic as pm
x, y, z = sp.symbols("x y z", real=True)
Poisson’s equation¶
Poisson’s equation, \(\nabla^2 u = -f\), is solved on every domain. In free space the solution is the potential of its source. A Gaussian charge in space:
phi = sp.Function("phi")(x, y, z)
rho = sp.exp(-(x**2 + y**2 + z**2) / 2) / (2 * sp.pi) ** sp.Rational(3, 2)
space = pm.FreeSpace(x, y, z)
unscreened = pm.solve(
pm.Problem(sp.Eq(pm.laplacian(phi), -4 * sp.pi * rho), domain=space)
)
unscreened.plot()
Laplace’s equation is the same without a source, and has something to solve for only where a boundary condition gives values.
Screened and weighted Poisson equations¶
The unknown itself may appear, which screens the potential: the Yukawa or Debye–Hückel equation.
yukawa = pm.solve(
pm.Problem(sp.Eq(pm.laplacian(phi) - 4 * phi, -4 * sp.pi * rho), domain=space)
)
assert yukawa.plan.notes[0].startswith("The equation is a screened Poisson equation")
# The screened potential lies below the unscreened one everywhere.
assert (yukawa[phi] < unscreened[phi]).all()
The second derivatives may also carry different weights, as in
sp.Derivative(u, x, 2) + 4 * sp.Derivative(u, y, 2). Periodic
directions work as in free space.
Any linear equation on a periodic box¶
On a domain that is periodic in every direction, any linear equation with constant coefficients is solved, of any order:
box = pm.Space(x, y, periodic={x: (0, 2 * sp.pi), y: (0, 2 * sp.pi)})
w = sp.Function("w")(x, y)
plate = pm.Problem(
sp.Eq(
pm.laplacian(pm.laplacian(w)) + sp.Derivative(w, x) + w,
sp.cos(x) * sp.sin(2 * y),
),
domain=box,
)
bent = pm.solve(plate)
assert bent.plan.notes[0].startswith("The equation is a linear equation of order 4")
If such an equation has no unique solution on the box, pdemagic says so and names the wave that causes it.
Diffusion with drift between walls¶
On a box with walls each coordinate may have a second and a first derivative, beside a term with the unknown itself:
That covers Poisson’s and Laplace’s equation, screened ones, the Helmholtz equation, and diffusion with drift. The coefficients may be complex. A first derivative is a drift: something that spreads while a steady wind carries it along. Here the wind blows towards the right wall, and the substance gathers there:
v = sp.Function("v")(x)
windy = pm.Problem(
sp.Eq(-v.diff(x, 2) + 4 * v.diff(x), 1),
domain=pm.Box({x: (0, 1)}),
boundary=sp.Eq(v, 0),
)
carried = pm.solve(windy)
carried.plot()
(xs,) = carried.axes
exact = xs / 4 - np.expm1(4 * xs) / (4 * np.expm1(4))
assert abs(carried[v] - exact).max() < 1e-12
assert xs[np.argmax(carried[v])] > 0.6
Which form is solved where¶
Domain |
Linear stationary equations with constant coefficients |
|---|---|
Free space, also with periodic directions |
\(\sum_i a_i\,\partial_i^2 u + c\,u = f\): Poisson’s equation in any dimension, its screened form and the Helmholtz equation in up to three |
A box that is periodic in every direction |
any linear equation, of any order |
the form above with first derivatives, a mixed derivative, and the plate equation |
|
A round domain with conditions |
\(a\,\nabla^2 u + c\,u = f\), written with |
A round domain with vacuum outside |
Poisson’s equation |
any elliptic equation of second order: a drift, directions that differ, a mixed derivative |
The reference has the complete table, with what each domain adds: what is solved where.
The relatives of these equations are on their own pages:
Waves of one frequency: the Helmholtz equation, \(\nabla^2 u + k^2 u = -f\).
Media and potentials: coefficients that vary in space, and mixed derivatives.
Beams and plates: the equation of fourth order between walls.
Complex unknowns: an equation or a source with
sp.I.
When the solution is not unique¶
Some problems leave a constant open. On a box that is periodic in every direction, and between walls that all give the slope, Poisson’s equation fixes its solution up to a constant only, and needs a source that balances. pdemagic returns the solution with zero mean and reports what it took off the source: see free space and periodic directions and boundary conditions.
A problem that leaves more than a constant open is refused, with
pm.InvalidProblemError: a box that resonates is one.
What does not work yet¶
With free directions: first derivatives, mixed derivatives, and orders above the second.
Between walls, a first derivative that dominates the second by far. The solution then has a thin layer at a wall, which the method cannot follow: the plan says that the solution is not resolved.
Stationary systems on domains with free directions.
See also¶
Reference: what is solved where, and the known limits of stationary equations.
Gallery: two charges, a screened charge, a heated plate, a crystal that conducts askew.
Methods: Poisson’s equation by Fourier convolution, linear equations with constant coefficients, boxes and round domains with boundary conditions, shapes in the plane.
Recipes for single tasks.