🎨 3D Reaction-Diffusion Patterns

Gray-Scott reaction-diffusion model in a 2D grid rendered on canvas. Two morphogens U and V generate spots, stripes, and spirals depending on feed/kill parameters.

ChemistryInteractive
Click to seed V · P pause · R reset

How it Works

The Gray-Scott model describes two reacting chemicals U and V on a discrete grid. U diffuses faster and is fed from an external reservoir; V diffuses more slowly and is produced by the reaction U + 2V → 3V. The competition between local activation (V catalyzes its own production) and global inhibition (U is depleted faster than it diffuses back) creates self-organizing spatial patterns.

Each step: compute the Laplacian of each cell using a 9-point weighted stencil, then update U and V simultaneously using the forward Euler method. Multiple steps are taken per animation frame to accelerate pattern formation.

∂u/∂t = Du∙∇²u - u∙v² + f∙(1-u)
∂v/∂t = Dv∙∇²v + u∙v² - (f+k)∙v
∇²u[i,j] = 0.2∙(u[i±1,j]+u[i,j±1]) + 0.05∙diag - u[i,j]

The color of each pixel encodes the concentration of chemical V: low V appears dark blue, high V appears bright amber or white depending on the selected color map. Clicking on the canvas seeds a small patch of high V concentration, triggering new pattern growth from that point.

Frequently Asked Questions

What is the Gray-Scott reaction-diffusion model?

The Gray-Scott model describes two chemical species U and V that react and diffuse. U is converted to V when they meet: U + 2V → 3V, and V decays at rate k. U is replenished at feed rate f. Depending on f and k, the system produces spots, stripes, spirals, or labyrinthine patterns.

What are Turing patterns?

Turing patterns are spatial patterns that emerge from a reaction-diffusion system where an activator and an inhibitor diffuse at different rates. Alan Turing proposed in 1952 that this mechanism could explain biological pattern formation such as animal coat markings, fish stripe patterns, and organ development.

What do the feed rate f and kill rate k control?

The feed rate f controls how fast chemical U is replenished from an external reservoir. The kill rate k controls how fast chemical V is removed. Different (f,k) pairs produce dramatically different patterns: low f/k gives spots, intermediate gives stripes, high gives worms or mazes.

What are the Gray-Scott PDEs?

∂u/∂t = Du∙∇²u - u∙v² + f∙(1-u); ∂v/∂t = Dv∙∇²v + u∙v² - (f+k)∙v. Here Du and Dv are diffusion coefficients (Du > Dv), ∇² is the Laplacian, f is feed rate, and k is kill rate.

How is the Laplacian computed on a discrete grid?

On a 2D grid, the 9-point stencil with diagonal weights 0.05 and cardinal weights 0.2 is used: ∇²u ≈ 0.2∙(N+S+E+W) + 0.05∙(NE+NW+SE+SW) - u[i,j]. This gives smoother results than the basic 4-neighbor stencil.

Why does reaction-diffusion produce animal coat patterns?

During embryonic development, morphogens diffuse through tissue and react according to activator-inhibitor kinetics. The local-activation long-range-inhibition principle creates regular spacing in spots or stripes that mirror real animal markings like cheetah spots or zebra stripes.

What is morphogenesis?

Morphogenesis is the biological process by which an organism develops its shape. Reaction-diffusion systems are one mathematical model for how simple chemical gradients can create complex, reproducible spatial patterns without any top-down blueprint.

How do diffusion coefficients affect the pattern?

The ratio Du/Dv is critical. If both species diffuse equally, patterns cannot form. The activator (V) must diffuse more slowly than the inhibitor (U). Typically Du ≈ 2∙Dv. A larger ratio produces finer patterns; a smaller ratio makes patterns coarser.

Can reaction-diffusion systems produce chaos?

Yes. Near bifurcation points, reaction-diffusion systems can exhibit spatio-temporal chaos — patterns that continually break up and reform in unpredictable ways. This is related to chemical chaos in the Belousov-Zhabotinsky reaction.

What is the Belousov-Zhabotinsky reaction?

The Belousov-Zhabotinsky (BZ) reaction is a real chemical oscillator where concentrations oscillate between oxidized and reduced states. In a thin layer of liquid, it produces expanding spiral waves — a vivid physical demonstration of reaction-diffusion dynamics.

About this simulation

A 9-point weighted stencil computes the Laplacian of two chemicals U and V on every grid cell, five Euler steps run per animation frame, and the resulting concentration of V is painted through one of three colour maps. Because the five built-in Preset options only change two numbers, feed rate f and kill rate k, the exact same reaction-diffusion equation can settle into spots, stripes, spirals, worms or mazes purely from where those two dials sit relative to each other.

🔬 What it shows

A Gray-Scott reaction-diffusion pattern growing outward from a seeded centre patch, self-organising into spots, stripes or labyrinths as an activator chemical V and inhibitor U race to diffuse and react across the grid.

🎮 How to use

Pick a Preset or hand-tune Feed rate f, Kill rate k, Du and Dv, switch Color Map between Heat/Cool/Plasma, click the canvas to seed new V concentration anywhere, or press P/R to pause/reset.

💡 Did you know?

Alan Turing proposed this exact activator-inhibitor mechanism in 1952 to explain how a uniform embryo can spontaneously develop non-uniform patterns — the same maths behind leopard spots and zebra stripes runs live in your browser here.

Frequently asked questions

Why do different presets produce spots versus stripes versus mazes?

applyPreset() only changes the feed rate f and kill rate k values fed into the same Gray-Scott equations, and the Gray-Scott parameter space is famously sensitive - small shifts in that (f,k) pair push the same reaction into entirely different steady-state pattern families.

What happens when I click on the canvas?

Clicking sets u=0.5 and v=0.25 in a small circular patch of cells around the cursor, artificially seeding a fresh reaction site that then grows and interacts with the existing pattern.

Why does the simulation run 5 steps per animation frame?

stepRD(5) is called once per requestAnimationFrame call, running the reaction-diffusion update five times before each redraw so the pattern visibly evolves and stabilises much faster than one step per frame would allow.

Why must Du be larger than Dv for patterns to form?

U must diffuse faster than V so that local activation by V can outpace long-range inhibition by U; if both diffusion coefficients were equal the two chemicals would blend into a flat, patternless equilibrium.

What does the 9-point stencil in laplacian() actually compute?

It weights the four cardinal neighbours at 0.2 and the four diagonal neighbours at 0.05, giving a smoother, more isotropic approximation of the continuous Laplacian than a simple 4-neighbour average would.