A reaction in a dish¶
Two substances that diffuse and react in a round dish whose rim lets nothing out: a ring that spreads from a seed, and buckles where it meets the rim.
import sympy as sp
import pdemagic as pm
r, phi, t = sp.symbols("r phi t", real=True)
a = sp.Function("a")(r, phi, t)
b = sp.Function("b")(r, phi, t)
dish = pm.Disk(r, phi, radius=0.5)
X, Y = dish.cartesian
seed = sp.exp(-((X - 0.15) ** 2 + Y**2) / 0.01)
reaction = pm.Problem(
sp.Eq(a.diff(t), 2e-5 * pm.laplacian(a) - a * b**2 + 0.037 * (1 - a)),
sp.Eq(b.diff(t), 1e-5 * pm.laplacian(b) + a * b**2 - 0.097 * b),
domain=dish,
time=(t, 0.0, 3000.0),
initial={a: 1 - seed / 2, b: seed / 2},
boundary=[sp.Eq(a.diff(r), 0), sp.Eq(b.diff(r), 0)],
)
plan = pm.plan(reaction)
plan.grid.shape = [64, 128]
plan.times.count = 2
plan.method.tolerance = 1e-4
pm.solve(reaction, plan).plot(b)
What it shows¶
The Gray–Scott model, as in
patterns from a reaction, but in a dish
with a rim: a system of two nonlinear equations on a disk, with a
condition for each substance. The slope along the radius is zero at the
rim, so neither substance passes it. The seed of b lies off the
centre. The reaction spreads from it as a ring, which is still round
where it has room. On the near side it has met the rim. There it stops,
since it finds nothing to feed on beyond, and the ring breaks up into
fingers. The picture shows b at the end of the time span.
What pdemagic decided¶
The planner chose exponential time stepping of fourth order
(exponential_runge_kutta), in the modes of the disk: each substance
has its own modes, in which its diffusion and its condition at the rim
are exact, and the reaction is stepped. The plan changes three entries:
the grid has 64 points along the radius and 128 around, because the
ring is finer than the seed, which is all the planner knows, only the
first and the last time are recorded, and the tolerance of a step is
\(10^{-4}\) in place of \(10^{-10}\), which is plenty for a picture. The
diagnostic solution_tail is \(2\cdot10^{-3}\): the ring is resolved,
though not to many digits.