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.
Two species, two reactions
The Gray-Scott model describes a continuously fed reactor in which two species and react:
The first reaction is autocatalytic: feeds on to multiply. The second takes out of play as an inert product . Adding diffusion in the plane, as Pearson does, gives two partial differential equations for the concentrations and :
Each term has a simple physical meaning:
- and : diffusion, which smooths out differences in concentration. diffuses twice as fast as ( in Pearson’s paper and in the engine);
- : the rate of the autocatalytic reaction, proportional to the concentration of and to the square of that of ;
- : the feed. A reservoir at concentration 1 replenishes at rate ;
- : the removal of , by the outflow (rate ) and by the reaction (rate , Karl Sims’s kill rate).
Without diffusion, the state (all , no ) is always stable. In one region of the plane a second stable state, rich in , 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 stays linearly stable: nothing grows out of infinitesimal noise. It takes a finite perturbation, a square where and , 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 plane and classified the behaviours he saw with Greek letters; Munafo corrected and extended that classification. The engine does not draw at random in the plane, where most points give a uniform field, but picks a preset among eight known regimes:
| Preset | F | k | Nearby example (Munafo) | What you see |
|---|---|---|---|---|
| coral | 0.0545 | 0.062 | κ (0.058, 0.063) | stripes branching into corals |
| mitosis | 0.0367 | 0.0649 | λ (0.034, 0.065) | spots that divide |
| fingerprint | 0.037 | 0.06 | θ (0.038, 0.061) | parallel stripes, loops |
| worms | 0.046 | 0.063 | μ (0.046, 0.065) | worms that grow at both ends |
| maze | 0.029 | 0.057 | θ (0.030, 0.057) | a maze of stripes |
| solitons | 0.03 | 0.062 | λ (0.026, 0.061) | isolated spots spreading out |
| holes | 0.039 | 0.059 | δ (0.042, 0.059) | a lattice of holes in a solid ground |
| wormspots | 0.034 | 0.0618 | η (0.034, 0.063) | a mix of spots and worms |
The seed adds a small jitter, uniform within on and on , rounded to four decimals: two specimens from the same preset are cousins, not twins. The range is tighter on because the regimes are narrower in that direction. This banner, for instance, comes from the holes preset: and .
The second example below pins the mitosis preset, the one where spots grow and then split in two.
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:
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 :
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 and . The base values are Pearson’s, converted to grid units: on a domain of side 2.5 discretised into 256 points gives . The factor , drawn in , sets the scale: the pattern’s characteristic lengths vary as , so a smaller 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): . It has to stay above , that is
The engine caps at 0.95; with it stays at about 77% of the limit. The reaction terms, of the order of and , are too small to change the conclusion.
Seeding and rendering
The initial condition follows Pearson’s, except that there are several seeds. Everywhere and , except in rectangles 3 to 7 cells wide and 4 to 9 tall, where and . 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 , 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: 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 and , like the initial seeds; the reaction starts up again locally, then the field fades back to its final state.
Notes
-
Pearson (1993), figure 1: for fixed , the nontrivial state loses stability through a saddle-node bifurcation as increases, or through a Hopf bifurcation as decreases. ↩