Gray-Scott Reaction-Diffusion
In 1952 Alan Turing published The Chemical Basis of Morphogenesis, proposing that a pair of reacting, diffusing chemicals could spontaneously break spatial symmetry and produce the patterns we see in nature — from leopard spots to zebra stripes. The Gray-Scott model (1983) is the cleanest two-species realisation of this idea:
dV/dt = Dv·∇²V + U·V² − (F+k)·V
Species U (activator, shown in low concentrations) is continuously fed into the domain at rate F. Species V (inhibitor) is autocatalytically produced from U (the U·V² term is the irreversible reaction U + 2V → 3V) and killed at rate F+k. The ratio Du/Dv = 2 ensures V diffuses twice as fast — the classic Turing condition for creating structure.
The feed-kill parameter pair (F, k) acts as a 2-D phase space. By sweeping it you can find coral-like growths, self-replicating spots, oscillating worm-like domains, travelling solitons and labyrinths.
Turing Instability
A uniform steady state becomes unstable to small spatial perturbations when Du/Dv is large enough, triggering spontaneous pattern formation at a characteristic wavenumber.
Self-Organisation
No external template guides the pattern. Only initial random noise, local chemistry, and the diffusion asymmetry determine whether spots, stripes, or waves appear.
Phase Diagram
Pearson (1993) mapped the (F, k) plane into 12 qualitatively different regimes. The simulator lets you traverse this landscape in real-time.
Biological Relevance
Turing mechanisms are now confirmed in fish skin pigmentation (Ocelots, Zebrafish), finger digit spacing, palatal rugae formation, and hair-follicle patterning.
Preset Chemical Regimes
Each preset corresponds to a distinct region of the (F, k) phase space. The Du and Dv values are kept at their standard Gray-Scott ratio of 2:1.
| Preset | F value | k value | Pattern Type | Biological Analogue |
|---|---|---|---|---|
| Coral Reef | 0.0545 | 0.0620 | Dendritic coral-like networks | Coral polyp growth morphology |
| Spots | 0.0350 | 0.0650 | Stable polka-dot domains | Jaguar / cheetah spots |
| Stripes | 0.0400 | 0.0600 | Quasi-periodic stripe bands | Zebra stripe pigmentation |
| Mitosis | 0.0367 | 0.0649 | Self-replicating spot division | Cell division topology |
| Solitons | 0.0300 | 0.0620 | Travelling solitary V pulses | Nerve impulse propagation |
| Labyrinthine | 0.0630 | 0.0609 | Branching maze-like tunnels | Mammalian cortical folding |
Numerical Method
For a 256×256 grid the simulator uses explicit forward-Euler time integration with periodic boundary conditions:
∇²U[i,j] ≈ U[i+1,j] + U[i−1,j] + U[i,j+1] + U[i,j−1] − 4·U[i,j]
Two Float32Array buffers are ping-ponged to avoid in-place updating artefacts. Each animation frame runs 12 substeps to achieve the visual impression of continuous evolution. Values are clamped to [0, 1] to prevent blow-up near the Turing instability boundary.
A V-concentration lookup table (256 entries × RGBA) maps the scalar field to colour without per-pixel branching, allowing smooth interactive framerates on a 65 536-cell grid.
Grid Size
256 × 256 = 65 536 cells. Each cell stores U and V as 32-bit floats, totalling ≈ 0.5 MB per double buffer.
Stability
The explicit Euler scheme is stable for Δt = 1 with standard Gray-Scott Du = 0.2097, Dv = 0.105. Larger Δt values cause oscillation blow-up.
Substeps
12 PDE steps per rAF frame give roughly 720 simulation steps/second at 60 fps — enough to see pattern convergence within seconds.
Colour LUT
Four pre-built 256-entry RGBA LUTs (Purple, Fire, Greyscale, Ocean) map V ∈ [0, 0.5] to visible colour with O(1) lookup.
Mathematical Background
Linear Stability Analysis
The uniform steady state (u*, v*) of the Gray-Scott equations is found by setting ∂U/∂t = ∂V/∂t = 0. Perturbing this steady state by δu = εexp(σt + iq·x) yields a 2×2 Jacobian whose eigenvalues σ(q) determine stability. The Turing condition is satisfied when a purely real mode q_c > 0 first becomes unstable — giving a band of growing wavenumbers and thus a preferred spatial scale.
Pearson's Phase Diagram
John Pearson's 1993 Science paper catalogued 12 dynamical regimes by sweeping the (F, k) plane at fixed Du/Dv = 2, labelling them with letters A–L. The simulator's presets sample regimes from the "self-replicating" (μ and ζ) and "oscillatory" (β and γ) zones.
Relationship to Activator-Inhibitor Systems
Though written as a chemical feed-kill system, Gray-Scott is mathematically equivalent to Gierer-Meinhardt activator-inhibitor kinetics under a variable change. Both belong to the broader class of reaction-diffusion systems whose stationary spatial solutions are called Turing patterns.
The characteristic length of Turing patterns is given by λ ≈ 2π / q_c, where q_c is the most unstable wavenumber. It scales as √(D/k), so slower reactions produce larger patterns.
Algorithm Summary
| Step | Operation | Complexity |
|---|---|---|
| 1 | Compute Laplacians ∇²U, ∇²V via 5-point stencil with periodic BC | O(N²) |
| 2 | Evaluate nonlinear reaction term U·V² | O(N²) |
| 3 | Forward-Euler update → write to secondary buffer | O(N²) |
| 4 | Swap primary/secondary Float32Array references | O(1) |
| 5 | Map V field to RGBA via LUT, call putImageData | O(N²) |
| 6 | Scale canvas to CSS display size (pixel art mode) | O(1) |
Applications & Real-World Pattern Formation
| Domain | Turing Mechanism | Evidence |
|---|---|---|
| Developmental Biology | Finger digit spacing, limb bud patterning | Sheth et al. 2012 (Science) |
| Skin Pigmentation | Zebrafish stripe formation via Fgf signalling | Kondo & Miura 2010 (Science) |
| Hair Follicle Spacing | Wnt activator + Dkk inhibitor diffusion | Sick et al. 2006 (Science) |
| Palatal Rugae | Ridge spacing in mammalian palate formation | Economou et al. 2012 (Nature Genetics) |
| Electrochemistry | Catalyst surface CO oxidation patterns | Ertl Nobel Lecture 2007 |
| Material Science | Periodic nanoscale surface structures (dewetting) | Karma & Rappel 1999 |
Curriculum Context
| Level | Prerequisite | Concepts Illustrated |
|---|---|---|
| A-Level / Sixth Form | Basic calculus, differential equations | Coupled ODEs, concept of steady state |
| Undergraduate Year 2 | Partial differential equations | Reaction-diffusion PDEs, Laplacian, stability |
| Undergraduate Year 3 | Linear algebra, Fourier analysis | Turing instability, dispersion relation, wavenumber |
| Postgraduate / Research | Bifurcation theory | Pearson phase diagram, pattern selection, weakly-nonlinear analysis |