🌡️ Heat Equation — 2D Temperature Distribution

Draw heat sources and cold sinks on a 2D plate, then watch the temperature field evolve. Toggle between transient (time-stepping) and steady-state (iterative Gauss-Seidel) modes to explore how heat conducts through materials.

🇺🇦 Українська

Drawing Tool

Simulation

Temperature (°C)

Max
Min
Mean
Step0
50°100°
∂T/∂t = α·∇²T
FDM: T[i][j]n+1 = Tn +
α·Δt/Δx²·(Tleft+Tright+
Tup+Tdown−4·T)
Stability: α·Δt/Δx² ≤ 0.25

Heat Conduction Physics

The heat equation ∂T/∂t = α∇²T describes how temperature diffuses in a medium, where α = k/(ρcₚ) is the thermal diffusivity (thermal conductivity divided by density × specific heat). The finite difference method (FDM) approximates derivatives on a discrete grid: the Laplacian ∇²T ≈ (Ti+1,j + Ti-1,j + Ti,j+1 + Ti,j-1 − 4Ti,j) / Δx². For explicit time-stepping, the stability condition α·Δt/Δx² ≤ 0.25 must be satisfied to prevent numerical blow-up. The steady-state (∂T/∂t = 0, Laplace equation ∇²T = 0) can be found iteratively using Gauss-Seidel relaxation.

About Heat Equation Visualiser

The heat equation, ∂u/∂t = α∇²u, is one of the most fundamental partial differential equations in mathematical physics. It describes how a quantity — originally temperature, but also concentration in diffusion problems — evolves over time under the influence of its spatial Laplacian. Joseph Fourier derived it in 1822 while studying heat flow in solids.

Solutions to the heat equation exhibit characteristic smoothing behaviour: sharp discontinuities in the initial temperature distribution are immediately smoothed out, and the solution converges to a steady state determined by the boundary conditions. Analytical solutions exist for simple geometries using Fourier series, while complex domains require numerical methods.

Beyond thermodynamics, the heat equation describes Brownian motion, option pricing in finance (the Black–Scholes equation is a transformed heat equation), diffusion of chemicals in tissue, and the spread of electrical signals in neurons. Its versatility makes it one of the most studied equations in applied mathematics.

Frequently Asked Questions

What does the Laplacian operator represent in the heat equation?

The Laplacian ∇²u measures the difference between the value of u at a point and its average in a surrounding neighbourhood. Where ∇²u > 0 (a local minimum), heat flows in and temperature rises; where ∇²u < 0 (a local maximum), heat flows out and temperature drops.

What is the steady-state solution of the heat equation?

As t → ∞, the time derivative vanishes and the heat equation reduces to Laplace's equation ∇²u = 0. The steady-state temperature distribution is harmonic — smooth, with no local maxima or minima inside the domain.

How does the heat equation relate to random walks?

The heat equation is the continuum limit of a random walk on a lattice. If particles diffuse randomly in equal steps, the probability density of finding a particle at position x and time t satisfies the same equation as the temperature field, connecting diffusion, probability theory, and heat transfer.

What numerical methods solve the heat equation?

Common methods include explicit finite differences (forward Euler, simple but conditionally stable), implicit methods (backward Euler, unconditionally stable), and the Crank–Nicolson scheme (second-order accurate and unconditionally stable). Finite element methods handle irregular domains.

Can the heat equation model cooling of the Earth?

Yes. Geophysicists use the heat equation to model how primordial heat escapes through the Earth's crust and mantle. Lord Kelvin famously used it to estimate Earth's age at 20–100 million years, though he was unaware of radioactive heating, which is the main source of internal heat today.

About this simulation

This simulation solves the two-dimensional heat equation ∂T/∂t = α∇²T on an 80×80 grid using an explicit finite-difference method. Paint hot sources, cold sinks and insulating walls directly onto the canvas, then watch temperature diffuse outward as the solver repeatedly applies the five-point Laplacian stencil. A separate Gauss–Seidel relaxation routine lets you jump straight to the steady-state distribution — the harmonic field described by Laplace's equation ∇²T = 0 once all transients have died away.

🔬 What it shows

Every animation frame recomputes each free cell's temperature from its four neighbours using T ← T + (α·Δt/Δx²)·(Tleft+Tright+Tup+Tdown−4T), colour-mapped from deep blue (0°C) through green and yellow to white (100°C). Hot cells stay pinned at 100°C, cold cells at 0°C, and walls sit at a fixed 20°C while blocking diffusion across them. The Max, Min and Mean readouts and the step counter update every frame.

🎮 How to use

Pick Hot, Cold or Wall, then click-drag on the canvas to paint sources at the chosen brush size; Erase returns cells to free diffusion. The Diffusivity α slider (0.01–0.48) sets how fast heat spreads, while the code caps the effective time step so α·Δt/Δx² never exceeds about 0.24. Steady-state runs 3000 Gauss–Seidel sweeps instantly; Clear resets the plate to a uniform 20°C; the Rod and Room buttons load ready-made presets.

💡 Did you know?

Joseph Fourier introduced this equation in 1822 in his Théorie analytique de la chaleur. The same mathematics, with temperature relabelled as probability density, describes Brownian motion and underlies the Black–Scholes option-pricing formula used throughout modern finance.

Frequently asked questions

What does the Diffusivity α slider control?

Alpha sets the thermal diffusivity in ∂T/∂t = α∇²T, controlling how quickly heat spreads through the plate each step. The simulation automatically scales its internal time step so that α·Δt/Δx² never exceeds about 0.24, keeping the explicit finite-difference update numerically stable even at the slider's maximum value of 0.48.

How are walls different from hot and cold sources?

Hot and cold cells are pinned at fixed temperatures (100°C and 0°C) and act as continuous sources or sinks that keep injecting or removing heat every step. Walls are held at a constant 20°C, but more importantly the stencil treats a neighbouring wall cell as equal to the current cell's own temperature, so it effectively blocks heat flow across the boundary like an insulator.

What happens when I click Steady-state?

The Steady-state button stops the animated time-stepping and instead runs 3000 iterations of Gauss–Seidel relaxation, repeatedly averaging each free cell with its four neighbours. This converges toward the solution of Laplace's equation ∇²T = 0 — the distribution the plate would eventually settle into if left running indefinitely — computed almost instantly rather than frame by frame.

What do the Rod and Room presets show?

Preset: Rod places a vertical column of 100°C hot cells near the left edge and a 0°C cold wall along the right edge, with insulating top and bottom walls, illustrating simple conduction across a plate between a heat source and a heat sink. Preset: Room places an 80°C "radiator" strip along the bottom and a 0°C "window" strip in the upper right, enclosed by insulating walls, showing how heat spreads unevenly through a room.

Why does the simulation limit the effect of the diffusivity slider on speed?

Explicit finite-difference schemes for the heat equation are only numerically stable when α·Δt/Δx² stays below 0.25; above that threshold, small errors amplify every step and the temperature field oscillates and diverges instead of smoothing out. The code enforces this by capping the effective ratio at 0.24 regardless of how high the Diffusivity slider is set.