Mathematician + Developer + Cat DadMath, code, cats, books and faith. Since 2024.
Reaction Diffusion
Watch organic patterns emerge from math -- then reach in and stir them. Drag on the canvas to paint into the simulation, press Space to pause, and try growing your name or the spacecat.
Simulation
WebGL2 not available -- running CPU fallback (200x200)
Controls
About the simulations
Every simulation here uses periodic boundary conditions, so the domain is
topologically a torus. The View button chooses the geometry:
Flat view uses the flat Laplacian, while Torus view renders the surface in
3D and swaps in the torus Laplace-Beltrami operator (in conservative flux
form), so diffusion feels the donut's surface geometry. Drag the background
to spin the torus, or drag on the donut itself to paint on it. Toggle views
mid-simulation and watch the pattern re-equilibrate.
Vector and tensor models (Oseen-Frank, Q-Tensor) get the scalar operator
applied componentwise; proper tangent-plane transport is a future upgrade.
These simulations are based on reaction-diffusion models of the form
where represents one or more chemical concentrations or phase fields evolving in a spatial domain. Different choices of the reaction term and the number of fields give rise to qualitatively different patterns.
The Gray-Scott model tracks two chemicals and with the stoichiometry
Species is fed into the system at rate and is removed at kill rate , giving the PDE
Different produce spots, stripes, spirals, and coral-like branching -- all called Turing patterns. The display shows .
The Pearson Map preset lets the parameters vary across the
canvas: feed rises from bottom to top and kill rises from left to right, so
every regime grows side by side -- spots, worms, self-replicating mitosis,
waves and holes -- like a live version of Pearson's 1993 classification
chart. Hover over it to read off the local feed and kill values. Try the
1024 grid for a finer map.
The FitzHugh-Nagumo model (FitzHugh 1961, Nagumo 1962) is a simplified model of excitable media:
The fast variable plays the role of membrane potential; the slow variable is a recovery variable. For small the two fields evolve on very different timescales. In two dimensions the model supports rotating spiral waves -- the same patterns seen in cardiac electrophysiology and the Belousov-Zhabotinsky reaction. The display shows the field.
Here place the rest state firmly in the excitable regime: the homogeneous fixed point is stable, so the medium sits quietly until a wave passes rather than oscillating everywhere at once. A wave front that is broken -- has a free end -- curls around that end into a rotating spiral. Spirals seeds a single broken front and grows one clean rotating spiral; Turbulence seeds many excited blobs over a patchy refractory field, nucleating a sea of spirals that continually break and re-form.
Numerical scheme: Forward Euler, 9-point Laplacian, periodic BCs. sits at the optimal stability point of the 9-point stencil; the inhibitor does not diffuse ().
Allen-Cahn is the simplest gradient flow equation, describing interface motion by mean curvature:
The phase field labels two phases; the double-well potential has minima at . Allen-Cahn is the gradient flow of the Ginzburg-Landau energy
meaning decreases monotonically in exact arithmetic. Coarsening starts from random noise and the domains grow over time (Ostwald ripening). Two Bubbles places a large and a small circle of phase tangent to each other: the smaller bubble has higher curvature so its interface moves faster, and you can watch the contact point evolve as both bubbles shrink. The display shows the field; dark = phase , bright = phase .
Numerical scheme: Forward Euler, 9-point Laplacian, periodic BCs. Only conditionally stable -- large with small can cause blow-up.
Research connection: This energy-dissipation structure is the starting point for Justin's dissertation work on energy-stable schemes. See /p/research/ for the unconditionally stable variants.
References: Allen and Cahn (1979), Cahn and Hilliard (1958).
The Brusselator (Prigogine and Lefever, 1968) is a theoretical model
for an autocatalytic chemical reaction that produces Turing patterns -- stationary
spatial structures driven by diffusion-driven instability:
The homogeneous steady state is . When is
small enough and exceeds a critical threshold
, diffusion destabilizes this state and
spatial patterns (spots, mazes) emerge -- Turing's original mechanism.
When the uniform state undergoes a Hopf bifurcation instead
and the system oscillates, producing spiral waves and target patterns with
equal diffusivities. The display shows the field.
Numerical scheme: Forward Euler, 9-point Laplacian, periodic BCs.
Seeded near the steady state with small random noise; patterns grow from
the Turing or Hopf instability over many steps.
Cahn-Hilliard (Cahn and Hilliard, 1958) describes phase separation in a binary mixture
through a conserved order parameter that labels the two phases:
The chemical potential is the variational derivative of the Ginzburg-Landau energy,
so Cahn-Hilliard is the gradient flow of
Unlike Allen-Cahn, the total mass is conserved -- the two phases can
only rearrange, not appear or disappear. Starting from near-uniform noise
(Spinodal preset), the mixture spontaneously separates into
interconnected bicontinuous domains, then slowly coarsens: smaller features
dissolve and feed the growth of larger ones. In the
Off-Critical preset the minority phase instead forms isolated
droplets. The Ostwald Ripening preset quenches an off-critical
mixture straight into a dense emulsion of small droplets, then lets it
coarsen: larger droplets grow while smaller ones dissolve and vanish, all while
the total droplet area stays fixed -- the conserved-dynamics counterpart of the
Allen-Cahn coarsening above, where domains simply shrink and disappear.
Dark = phase , bright = phase .
Numerical scheme: Two-pass forward Euler split -- pass 1 computes from
via the chemical potential equation and stores in an intermediate texture;
pass 2 samples that texture to advance via . Periodic BCs.
Only conditionally stable -- large or small can cause blow-up.
Research connection: Cahn-Hilliard is a central model in Justin's dissertation on
energy-stable schemes for gradient flow problems. The scheme here is forward Euler -- only
conditionally stable and not guaranteed to decrease . The dissertation develops
semi-implicit schemes that are unconditionally energy-stable. See
/p/research/.
References: Cahn and Hilliard (1958), J. W. Cahn (1961), L.-Q. Chen (2002).
The Oseen-Frank model describes a nematic liquid crystal using a
director field -- a unit vector giving the local average molecular
orientation (with since molecules have no head or tail).
In the one-constant approximation all elastic modes cost the same energy, giving
The overdamped (no-flow) gradient flow of this energy subject to is
The projection term enforces the
unit-norm constraint. The display maps director angle to hue with period
(reflecting ); defect cores appear as points
where the hue cycles rapidly.
Topological defects are points where cannot be
continuously defined. In 2D nematics the fundamental defects have half-integer
winding numbers . Integer () defects also appear; the
radial ("hedgehog" or "aster") and the hyperbolic ("saddle") are
shown in the Hedgehog preset as an attracting pair -- watch them
collide and annihilate. Annihilation shows two
and two defects in a symmetric cross pattern; each
is nearest to a , so two simultaneous annihilation events occur.
Coarsening starts from random directors -- many defect pairs
nucleate and annihilate until only a few survive.
Numerical scheme: Forward Euler, 9-point Laplacian on each director
component, with projection and renormalization each step. Stable for
(stencil max eigenvalue ); current parameters give margin .
Research connection: The Oseen-Frank model breaks down inside defect cores
where . The full Landau-de Gennes Q-tensor model regularizes the
core by allowing the order parameter to melt there -- that is the model in Justin's
dissertation work, and you can run it here: select Q-Tensor (LC)
in the model dropdown above. See /p/research/.
References: Oseen (1933), Frank (1958), de Gennes and Prost
"The Physics of Liquid Crystals" (1993).
The Landau-de Gennes Q-tensor model describes a nematic liquid
crystal with a symmetric, traceless tensor order parameter instead of a unit
director. In 2D the tensor has two independent components,
where is the director angle and is the scalar order parameter --
how aligned the molecules are. Crucially, is free to vary: means
the material locally melts into the isotropic phase. Because the director
angle enters doubled, is built into the
representation and half-integer defects are native -- no branch cuts.
In strict 2D, identically, so the one-constant
Landau-de Gennes energy reduces to
and its gradient flow, written in the components , is just a
two-species reaction-diffusion system:
With the isotropic state is unstable and the system orders with
-- this is exactly the vector Ginzburg-Landau equation,
the tensorial cousin of Allen-Cahn above.
Quench drops the system from the isotropic phase into the nematic:
order develops locally, incompatible regions meet, and a gas of
defects nucleates and coarsens by pair annihilation.
+1 Splits in Two is the showpiece: a radial defect costs
elastic energy proportional to its winding number squared, so splitting
into two defects (each costing a quarter) halves the energy.
Watch the core fission and the halves repel. The vector Oseen-Frank model above
cannot do this -- a unit vector field has no half-integer windings, so its
is artificially stable. Pair Annihilation shows a
and attracting and annihilating.
Displays:Director maps director angle to hue (period
) and dims by , so defect cores appear as dark points with hue
pinwheels around them. Order shows the field directly --
watch the cores melt. Schlieren simulates the view between crossed
polarizers, : dark brushes meet at defects, two
brushes for half-integer charges and four for integer ones, just like a real
microscope image.
Numerical scheme: Forward Euler, 9-point Laplacian on each component,
periodic BCs. Conditionally stable ( for this stencil);
defect core radius is about 2 pixels at the default parameters.
Research connection: This is the model from Justin's dissertation -- there
in 3D, with energy-stable semi-implicit schemes that unconditionally dissipate
instead of the conditionally stable forward Euler used here.
See /p/research/.
References: de Gennes and Prost "The Physics of Liquid Crystals" (1993),
Mottram and Newton "Introduction to Q-tensor theory" (2014), Schopohl and Sluckin (1987).
The complex Ginzburg-Landau equation governs a complex field
and is the universal amplitude equation: near any Hopf
bifurcation, an oscillatory medium reduces to it, which is why so many of the
spiral patterns on this page have it lurking underneath. In one-constant form,
The linear term grows any small perturbation; the cubic term saturates it at
. The two real parameters (linear dispersion) and
(nonlinear dispersion) control everything. The field is stored as its real and
imaginary parts in the same two channels the Q-tensor uses -- and indeed this is
the oscillatory, non-variational cousin of that gradient flow: same complex
field, completely different dynamics.
The whole phase diagram turns on the sign of , the
Benjamin-Feir-Newell criterion. When ,
plane waves are stable and the field freezes into a Spiral Lattice:
a tiling of rotating spirals, each a phase defect where . When
, plane waves are unstable and the medium turns chaotic.
Just past the line you get Phase Turbulence -- the amplitude stays
near while the phase wanders, so a few large spirals persist in a restless
background. Push further and amplitude defects proliferate into full
Defect Turbulence: a spatiotemporal chaos of spirals endlessly
nucleating and annihilating. All three grow from the same tiny random seed.
Displays:Phase maps to hue and dims by the
amplitude , so defect cores show as dark points. Amplitude
shows directly -- the holes are the defects. Pure Phase
drops the dimming for an undimmed phase portrait.
Numerical scheme: Forward Euler, 9-point Laplacian, periodic BCs. The
dispersive Laplacian tightens stability to
, so the turbulent presets
() step with a smaller than the lattice ().
References: Aranson and Kramer, "The world of the complex Ginzburg-Landau
equation," Rev. Mod. Phys. (2002); Cross and Hohenberg (1993).
Research connection
Several models here connect directly to Justin's dissertation on energy-stable schemes for gradient flow problems. Allen-Cahn and (upcoming) Cahn-Hilliard are canonical gradient flows; the versions in this toy use forward Euler for simplicity. The energy-stable semi-implicit schemes that unconditionally preserve the free energy appear in the dissertation -- see /p/research/.