Welcome, space traveler!

Mathematician + Developer + Cat DadMath, code, cats, books and faith. Since 2024.

Reaction Diffusion

Watch organic patterns emerge from math -- then reach in and stir them. Drag on the canvas to paint into the simulation, press Space to pause, and try growing your name or the spacecat.

Simulation

Controls

Brush
Look
Simulation
Grow something

About the simulations

Every simulation here uses periodic boundary conditions, so the domain is topologically a torus. The View button chooses the geometry: Flat view uses the flat Laplacian, while Torus view renders the surface in 3D and swaps in the torus Laplace-Beltrami operator (in conservative flux form), so diffusion feels the donut's surface geometry. Drag the background to spin the torus, or drag on the donut itself to paint on it. Toggle views mid-simulation and watch the pattern re-equilibrate. Vector and tensor models (Oseen-Frank, Q-Tensor) get the scalar operator applied componentwise; proper tangent-plane transport is a future upgrade.

These simulations are based on reaction-diffusion models of the form

∂u∂t=γΔu+g(u)
where u represents one or more chemical concentrations or phase fields evolving in a spatial domain. Different choices of the reaction term g and the number of fields give rise to qualitatively different patterns.

The Gray-Scott model tracks two chemicals u and v with the stoichiometry

U+2V→3V,V→P.
Species U is fed into the system at rate f and V is removed at kill rate k, giving the PDE
{∂u∂t=γuΔu−uv2+f(1−u),∂v∂t=γvΔv+uv2−(f+k)v.
Different (γu,γv,f,k) produce spots, stripes, spirals, and coral-like branching -- all called Turing patterns. The display shows |u−v|.

The Pearson Map preset lets the parameters vary across the canvas: feed rises from bottom to top and kill rises from left to right, so every regime grows side by side -- spots, worms, self-replicating mitosis, waves and holes -- like a live version of Pearson's 1993 classification chart. Hover over it to read off the local feed and kill values. Try the 1024 grid for a finer map.

Numerical scheme: Forward Euler, 9-point Laplacian, periodic BCs.

References: MIT GrayScott, Karl Sims, Pearson (1993).

Research connection

Several models here connect directly to Justin's dissertation on energy-stable schemes for gradient flow problems. Allen-Cahn and (upcoming) Cahn-Hilliard are canonical gradient flows; the versions in this toy use forward Euler for simplicity. The energy-stable semi-implicit schemes that unconditionally preserve the free energy appear in the dissertation -- see /p/research/.

Source code: github

Prime clock

2

a new prime every two seconds