Cool Stuff · pattern formation
Turing Patterns
Two chemicals that react and spread out at different speeds can turn a nearly uniform mixture into spots, stripes and labyrinths. Nothing in the rules says "make a spot".
1The idea
In 1952 Alan Turing asked how an embryo, which starts out nearly uniform, can develop a pattern. His answer, in "The Chemical Basis of Morphogenesis", was that diffusion, usually a smoothing process, can make a uniform state unstable when it is combined with chemical reactions. If one substance spreads faster than the other, small random bumps grow into a regular pattern with its own preferred size.
The Gray–Scott model is a simple reaction–diffusion system that shows this behaviour. A substrate \(U\) is fed in from outside; an activator \(V\) consumes \(U\) to make more of itself and is removed at its own rate:
\[ \begin{align} \frac{\partial U}{\partial t} &= D_u \nabla^2 U - U V^2 + F\,(1-U), \tag{1}\label{eq:u} \\ \frac{\partial V}{\partial t} &= D_v \nabla^2 V + U V^2 - (F+k)\,V. \tag{2}\label{eq:v} \end{align} \]\(F\) is the feed rate and \(k\) the kill rate. The term \(UV^2\) is the reaction: one \(U\) and two \(V\) make three \(V\). With \(D_u = 2D_v\) the substrate spreads twice as fast as the activator. Pearson (1993) mapped the \((F,k)\) plane and found a whole zoo of patterns in it.
2Try it
The simulator below is a JavaScript copy of turing.py, with the same grid, stencil, parameters and presets. It starts from three random square seeds. Pick a preset, or move the \(F\) and \(k\) sliders while it runs. Click or drag on the picture to add more activator.
| Preset | F | k |
|---|
3The code
turing.py solves no differential equation in symbolic form. Diffusion is a 9-point neighbour average (a discrete Laplacian), and the reaction is a few lines of array arithmetic. One explicit Euler step of Eqs. \eqref{eq:u}–\eqref{eq:v} is:
def laplacian(Z):
return (-Z
+ 0.2 * (roll(Z, 1, 0) + roll(Z, -1, 0) + roll(Z, 1, 1) + roll(Z, -1, 1))
+ 0.05 * (four diagonal neighbours))
def gray_scott_step(U, V, F, k):
reaction = U * V * V
U_new = U + (DU * laplacian(U) - reaction + F * (1 - U))
V_new = V + (DV * laplacian(V) + reaction - (F + k) * V)
return clip(U_new, 0, 1), clip(V_new, 0, 1)
The full program adds a matplotlib window with sliders for \(F\), \(k\) and grid size, play / step / reset buttons, and the preset buttons. It needs Python with NumPy and matplotlib.
Download turing.py (9 kB), then run:
python3 turing.py --F 0.03 --k 0.0575
4Further reading
- A. M. Turing, "The chemical basis of morphogenesis", Phil. Trans. R. Soc. Lond. B 237, 37 (1952).
- P. Gray and S. K. Scott, "Autocatalytic reactions in the isothermal, continuous stirred tank reactor", Chem. Eng. Sci. 39, 1087 (1984).
- J. E. Pearson, "Complex patterns in a simple system", Science 261, 189 (1993).
- R. Munafo, xmorphia, a catalogue of Gray–Scott patterns.