Skip to main content

Reaction–diffusion: from concentrations to spots and mazes

Open reaction–diffusion. Drag to seed a disturbance and watch spots split, extend or join into bands. Following Karl Sims’ reaction–diffusion tutorial, the experiment evolves concentrations of two virtual substances on a grid rather than individual molecules.

Controls

Maze, Spots and Coral select different parameters and reseed the field. Dragging adds a patch with high B concentration. With the canvas focused, use the arrows to move the cursor and Enter or Space to seed. Pause and Step expose changes along local edges.

Reset restores Maze parameters and the default seeds. Initialization already performs 160 reaction steps, so the first image is not the freshly seeded circles. Preset names describe typical appearances; seeds, disturbances and elapsed time still affect the shape.

Gray–Scott updates

For concentrations a,ba,b, the model uses:

at=Da2aab2+f(1a),bt=Db2b+ab2(k+f)b.\frac{\partial a}{\partial t}=D_a\nabla^2a-ab^2+f(1-a), \qquad \frac{\partial b}{\partial t}=D_b\nabla^2b+ab^2-(k+f)b.

This implementation sets Da=1D_a=1, Db=0.5D_b=0.5 and time step 1. Its nine-point diffusion stencil weights the center 1-1, axial neighbors 0.20.2 each and diagonal neighbors 0.050.05 each. The feed parameter ff replenishes A; kk and ff contribute to removing B.

Presetffkk
Maze0.0290.057
Spots0.0350.065
Coral0.05450.062

Grid and color

The 160×112160\times112 grid wraps at its edges. Each simulation update, including Step, performs six reaction steps. Alternating float buffers keep newly updated neighbors out of the current calculation. Concentrations are clamped to [0,1][0,1] after each step as a numerical guard for this display implementation.

Color maps only B: b/0.4b/0.4 is clipped to [0,1][0,1] and passed through a smooth curve before palette lookup. The legend ends at 0.4+0.4+ because larger concentrations share the endpoint color. The pixel field is smoothly enlarged; a larger canvas does not increase simulation resolution.

Unlike the binary cells of the Game of Life, neighboring sites exchange continuous concentrations here. This texture model is not calibrated to the physical units or rates of a specific chemical reaction.

Explore connectionsOpen network