Loading the engineShared by all simulations, so the next one opens instantly.
The physics

Joseph Fourier wrote down the heat equation in 1822, and Adolf Fick used the same equation in 1855 for the diffusion of salt in water. Fifty years later Albert Einstein derived it from the random motion of particles and connected the diffusion coefficient to molecular quantities, which let Jean Perrin measure Avogadro’s number by watching small particles jiggle under a microscope. The equation is linear and its solutions are known exactly: every bump spreads out as a Gaussian whose width grows with the square root of time, so a pattern ten times wider takes a hundred times longer to smooth out.

What you see

The color shows the concentration c on a grid of 200 by 200 cells. With the default color map the scale is fixed from 0 (black) through blue, cyan, green, yellow and red to 1 (white), so the field darkens as it spreads; the other color maps stretch from the lowest to the highest value in the current frame. Each frame advances 6 steps of Δt=1, 360 steps per second at 60 frames per second.

Governing equation

∂c∂t=D∇2c.

A point source spreads as

c(𝐫,t)=M4πDtexp⁡(−|𝐫|24Dt),

a Gaussian whose variance grows by 2D per unit time in each direction while its peak falls as 1/t. A Gaussian blob of initial width σ0 behaves like a point source that started σ02/2D earlier. On a grid with edges that wrap around, nothing is lost and the total amount stays constant.

The grid is advanced with the explicit forward-time, centered-space scheme on a five-point Laplacian, Δx=Δt=1. It is stable for DΔt/Δx2≤1/4, and at exactly 1/4 a checkerboard pattern no longer decays, so the slider stops at 0.24. The scheme spreads the variance by exactly 2D per step, as the continuous equation does.

Presets

All presets use D=0.18 cells² per step.

Three blobs: three Gaussians with widths of 15, 10 and 12 cells and peaks of 0.9, 0.75 and 0.85 on a grid whose edges wrap around. The highest value drops to 0.57 after one second, 0.23 after 5 and 0.15 after 10 as the blobs merge, and the field approaches the uniform level of 0.063. The total stays constant to five digits.

Single Gaussian: one blob of width 6 cells and peak 1 in the center. Its variance per direction grows from 35 to 165 cells² in the first second, as 35+2Dt predicts, so the width doubles to 12.8 cells and the peak falls to 0.22. After 5 seconds the width is about 26 cells and the peak 0.05.

Absorbing edges: the three blobs with solid edges held at zero. Concentration that reaches the edge leaves the grid: 6% is gone after 5 seconds and 18% after 10. Late in the run only the smoothest mode, a single hump filling the grid, is left, and it decays at the rate 2Dπ2/L2 with L=201, so the total halves every 22 seconds.

Flux arrows: the three blobs with arrows for the flux 𝐉=−D∇c. The arrows point downhill, from high to low concentration, and are scaled to the longest arrow in the current frame.

Parameters

Diffusion coefficient D (cells² per step): from 0.01 to 0.24. The variance of every blob grows by 2D per step in each direction.

Boundary: periodic edges wrap around, so the grid is a torus and the total is conserved. Solid edges hold the concentration at zero just outside the grid, so the field drains out through them.

Flux arrows: shows or hides the arrows for 𝐉=−D∇c. It only changes the picture.

Resolution: the side length of the grid, 50 to 400 cells. The blobs scale with the grid, but D is measured in cells, so on a finer grid the same pattern takes longer to spread. Changing it restarts the simulation.

The other controls act immediately on the running simulation.