← Iris
Paint heat

Simulation

Time step 0
Max temp 0.0
Min temp 0.0
Mean temp 0.0
Boundary Dirichlet

Parameters

Diffusivity 0.25
Brush radius 8

Color scale

Cold (0) Hot (1)
Click/drag to paint heat  ·  Shift+click or select “Paint cold” for cold  ·  Right-click also paints cold  ·  Toggle “Draw walls” to paint insulating barriers

About this lab

The heat equation

The heat equation is one of the most fundamental partial differential equations in physics:

∂T/∂t = α ∇²T

Here T(x,y,t) is the temperature at position (x,y) and time t, α is the thermal diffusivity of the material, and ∇²T is the Laplacian — the sum of second spatial derivatives. The equation says that temperature changes at a rate proportional to how much hotter or cooler a point is compared to its immediate neighbors. Hot spots cool down; cold spots warm up; equilibrium is reached when temperature is uniform (or satisfies the boundary conditions).

Finite difference method

This simulation solves the heat equation numerically using the explicit finite difference method. Space is discretized into a grid, and time advances in small steps. At each step, the new temperature at grid point (i,j) is computed from its four neighbors:

T_new[i][j] = T[i][j] + α · dt · (
    T[i+1][j] + T[i-1][j] +
    T[i][j+1] + T[i][j-1] - 4·T[i][j]
)

This is the discrete Laplacian: each cell’s update depends on the average of its four neighbors minus its own value. The method is stable when α · dt / dx² ≤ 0.25 (the CFL condition in two dimensions). This lab enforces that constraint automatically.

Boundary conditions

Dirichlet (fixed temperature): The edges are held at zero temperature. Heat that reaches the boundary is absorbed — like the edges of a metal plate clamped to ice-cold walls. The system always relaxes to uniform zero.

Neumann (insulated): The edges have zero heat flux — no energy enters or leaves. The temperature gradient at the boundary is zero, as if the edges were perfectly insulated. The system relaxes to a uniform temperature equal to the spatial average of the initial condition (conservation of energy).

Connection to random walks

The heat equation has a deep probabilistic interpretation. The temperature at a point equals the expected value of initial temperature visited by a random walker starting at that point. The discrete Laplacian is exactly the transition operator of a simple random walk on a grid. Brownian motion — continuous random walking — is the process whose probability density solves the heat equation. Einstein’s 1905 paper on Brownian motion established this connection, simultaneously proving the existence of atoms and founding the theory of stochastic processes.

Diffusion and the universal equation

The same equation describes the diffusion of chemicals (Fick’s second law), the spread of probability density, the pricing of financial options (Black-Scholes), and the smoothing of signals (Gaussian blur is literally one time step of the heat equation). Its solutions are Gaussian functions that spread over time — the bell curve is the fundamental solution of diffusion.