Augustin Grudet

The Gray-Scott specimen: reaction-diffusion

Two chemical species that react and diffuse are enough to grow spots, mazes and corals. The equations, the (F, k) map and how the specimen engine implements them.

  • 7 min read
  • #specimens
  • #maths
  • #simulation

This post was machine-translated from the original version.

Contents

Gray-Scott is the default family of the specimens: any post with no tag mapped to another family gets one. This post’s banner carries the label specimen 0x92ca · gray-scott · f=0.0384 k=0.0584. Those two numbers point to a chemistry model published in 1984 and to a map of regimes drawn up in 1993.

specimen 0xe2b9 · gray-scott · f=0.0466 k=0.0635
Gray-Scott reaction-diffusion on the character grid. Changing F and k moves the system across the map of regimes.

Two species, two reactions

The Gray-Scott model describes a continuously fed reactor in which two species UU and VV react:

U+2V⟶3V,V⟶P.U + 2V \longrightarrow 3V, \qquad V \longrightarrow P.

The first reaction is autocatalytic: VV feeds on UU to multiply. The second takes VV out of play as an inert product PP. Adding diffusion in the plane, as Pearson does, gives two partial differential equations for the concentrations uu and vv:

∂u∂t=Du∇2u−uv2+F (1−u)∂v∂t=Dv∇2v+uv2−(F+k) v\begin{aligned} \frac{\partial u}{\partial t} &= D_u \nabla^2 u - u v^2 + F\,(1 - u) \\ \frac{\partial v}{\partial t} &= D_v \nabla^2 v + u v^2 - (F + k)\,v \end{aligned}

Each term has a simple physical meaning:

  • Du∇2uD_u \nabla^2 u and Dv∇2vD_v \nabla^2 v: diffusion, which smooths out differences in concentration. UU diffuses twice as fast as VV (Du=2DvD_u = 2 D_v in Pearson’s paper and in the engine);
  • uv2u v^2: the rate of the autocatalytic reaction, proportional to the concentration of UU and to the square of that of VV;
  • F (1−u)F\,(1 - u): the feed. A reservoir at concentration 1 replenishes UU at rate FF;
  • (F+k) v(F + k)\,v: the removal of VV, by the outflow (rate FF) and by the reaction V→PV \to P (rate kk, Karl Sims’s kill rate).

Without diffusion, the state u=1,v=0u = 1, v = 0 (all UU, no VV) is always stable. In one region of the (F,k)(F, k) plane a second stable state, rich in VV, coexists with it: the system is bistable1. Patterns form on the boundary between these two states.

Turing, and what is not quite Turing

In 1952 Turing showed that a stable chemical equilibrium can be destabilised by diffusion itself, as long as the species diffuse at different rates. A tiny perturbation then grows up to a preferred wavelength: stripes and spots appear on their own out of an almost uniform medium. He saw in it a possible mechanism for morphogenesis, from the spots on an animal’s coat to the gastrulation of the embryo.

Gray-Scott inherits this idea but cannot be reduced to it. In Pearson’s setting the trivial state (1,0)(1, 0) stays linearly stable: nothing grows out of infinitesimal noise. It takes a finite perturbation, a square where u=1/2u = 1/2 and v=1/4v = 1/4, from which the pattern spreads as a front. Munafo reserves the name “true” Turing patterns for only part of class δ; elsewhere, spots that divide, worms that lengthen and chaotic waves come from other mechanisms. Pearson himself noted that it was not clear these patterns lend themselves to the standard tools of bifurcation theory.

The (F, k) map

Pearson swept the (F,k)(F, k) plane and classified the behaviours he saw with Greek letters; Munafo corrected and extended that classification. The engine does not draw (F,k)(F, k) at random in the plane, where most points give a uniform field, but picks a preset among eight known regimes:

The engine's presets (Du/Dv = 2) and a nearby example from Pearson's classification as extended by Munafo (class, F, k).
PresetFkNearby example (Munafo)What you see
coral0.05450.062κ (0.058, 0.063)stripes branching into corals
mitosis0.03670.0649λ (0.034, 0.065)spots that divide
fingerprint0.0370.06θ (0.038, 0.061)parallel stripes, loops
worms0.0460.063μ (0.046, 0.065)worms that grow at both ends
maze0.0290.057θ (0.030, 0.057)a maze of stripes
solitons0.030.062λ (0.026, 0.061)isolated spots spreading out
holes0.0390.059δ (0.042, 0.059)a lattice of holes in a solid ground
wormspots0.0340.0618η (0.034, 0.063)a mix of spots and worms

The seed adds a small jitter, uniform within ±0.0012\pm 0.0012 on FF and ±0.0006\pm 0.0006 on kk, rounded to four decimals: two specimens from the same preset are cousins, not twins. The range is tighter on kk because the regimes are narrower in that direction. This banner, for instance, comes from the holes preset: F=0.0384F = 0.0384 and k=0.0584k = 0.0584.

The second example below pins the mitosis preset, the one where spots grow and then split in two.

specimen 0xe2b9 · gray-scott · f=0.0367 k=0.0649
Mitosis preset: F = 0.0367, k = 0.0649.

Discretisation

The Laplacian on a character grid

The simulation runs on a torus (periodic edges) whose width is the number of columns and in which each text row is split in two. A cell is therefore 0.6 wide and 0.5 tall, in units of line height: a monospace character cell measures about 0.6 × 1. The five-point Laplacian accounts for this by weighting the vertical direction:

∇2ui,j≈(ui−1,j+ui+1,j−2ui,j)+ay(ui,j−1+ui,j+1−2ui,j),ay=(0.60.5)2=1.44,\nabla^2 u_{i,j} \approx \left(u_{i-1,j} + u_{i+1,j} - 2u_{i,j}\right) + a_y \left(u_{i,j-1} + u_{i,j+1} - 2u_{i,j}\right), \qquad a_y = \left(\frac{0.6}{0.5}\right)^2 = 1.44,

with the cell width as the unit of length. Without this coefficient, spots would be stretched vertically on screen. Each character shows the mean of its two half-cells.

Explicit Euler and stability

As in Pearson’s paper, integration uses an explicit Euler scheme with a time step Δt=1\Delta t = 1:

const lu = u[row + xl] + u[row + xr] - 2 * ui + AY * (u[up + x] + u[dn + x] - 2 * ui);
const lv = v[row + xl] + v[row + xr] - 2 * vi + AY * (v[up + x] + v[dn + x] - 2 * vi);
const uvv = ui * vi * vi;
u2[i] = ui + du * lu - uvv + f * (1 - ui);
v2[i] = vi + dv * lv + uvv - (f + k) * vi;

The coefficients are Du=0.2097⋅sD_u = 0.2097 \cdot s and Dv=0.105⋅sD_v = 0.105 \cdot s. The base values are Pearson’s, converted to grid units: Du=2×10−5D_u = 2 \times 10^{-5} on a domain of side 2.5 discretised into 256 points gives Du/h2=2×10−5×(256/2.5)2≈0.2097D_u / h^2 = 2 \times 10^{-5} \times (256 / 2.5)^2 \approx 0.2097. The factor ss, drawn in [0.45,0.75][0.45, 0.75], sets the scale: the pattern’s characteristic lengths vary as D\sqrt{D}, so a smaller ss gives finer patterns, which Karl Sims describes as the ratio between reaction speed and diffusion speed.

For diffusion alone, a von Neumann analysis gives the amplification factor of the most oscillating mode (the checkerboard): 1−2D(2+2ay)1 - 2 D (2 + 2 a_y). It has to stay above −1-1, that is

Du (2+2ay)<1  ⟺  s<10.2097×4.88≈0.977.D_u \, (2 + 2 a_y) < 1 \iff s < \frac{1}{0.2097 \times 4.88} \approx 0.977.

The engine caps ss at 0.95; with s≤0.75s \le 0.75 it stays at about 77% of the limit. The reaction terms, of the order of FF and kk, are too small to change the conclusion.

Seeding and rendering

The initial condition follows Pearson’s, except that there are several seeds. Everywhere u=1u = 1 and v=0v = 0, except in rectangles 3 to 7 cells wide and 4 to 9 tall, where u=0.5±0.05u = 0.5 \pm 0.05 and v=0.25±0.05v = 0.25 \pm 0.05. There are about one of them per 300 cells, multiplied by a density between 0.6 and 1.6 set by the secondary tags. Pearson integrated 200,000 steps from a single central square; the engine stops at 3,600 steps. The specimen therefore shows growth in progress rather than an asymptotic state, and the many seeds make sure the grid is filled.

Two special cases. With mirror symmetry (probability 0.3), every write of the initial condition is duplicated on both sides of the vertical axis; since the stencil is symmetric and floating-point addition is commutative, the pattern stays exactly symmetric for the whole simulation. A strip 3 rows tall, almost one-dimensional, would kill most patterns: grids shorter than 8 rows run on a torus 16 rows tall and show its middle.

The field on display is vv, normalised between its minimum and maximum. If that span drops below 0.05, the plate has died out or filled evenly, and stretching it would draw rounding noise: vv is then simply divided by 0.4, so a dead plate stays empty and a full one stays even. The field is then turned into characters by one of three ramps:

 .:-=+*#%@
 ·:;=+*%#@
 .,:~=+*#%

In the browser, the simulation replays its 3,600 steps at constant speed: what you watch is chemical time going by. The pointer then drops, along its path, round patches about three characters in radius where u=0.5u = 0.5 and v=0.25v = 0.25, like the initial seeds; the reaction starts up again locally, then the field fades back to its final state.

Notes

  1. Pearson (1993), figure 1: for fixed kk, the nontrivial state loses stability through a saddle-node bifurcation as FF increases, or through a Hopf bifurcation as FF decreases. ↩

Sources

  1. J. E. Pearson, Complex patterns in a simple system, Science 261 (1993) 189-192 (Nov 25, 2026)
  2. J. E. Pearson, Complex patterns in a simple system, preprint arXiv:patt-sol/9304003 (Nov 25, 2026)
  3. A. M. Turing, The chemical basis of morphogenesis, Phil. Trans. R. Soc. Lond. B 237 (1952) 37-72 (Nov 25, 2026)
  4. P. Gray, S. K. Scott, Autocatalytic reactions in the isothermal, continuous stirred tank reactor, Chem. Eng. Sci. 39 (1984) 1087-1097 (Nov 25, 2026)
  5. K. Sims, Reaction-Diffusion Tutorial (Nov 25, 2026)
  6. R. Munafo, Reaction-Diffusion by the Gray-Scott Model: Pearson's Parametrization (Xmorphia) (Nov 25, 2026)
  7. R. Munafo, Pearson's Classification (Extended) of Gray-Scott System Parameter Values (Nov 25, 2026)