Heat Conduction
Solve the 2D heat equation in real time. Paint hot and cold sources on a grid and watch thermal diffusion spread colour from red-hot to icy blue.
About this simulation
This simulator solves the 2D heat equation ∂T/∂t = α∇²T on a 160×160 grid in real time. Heat spreads by conduction: each cell exchanges thermal energy with its four neighbours, so sharp hot and cold spots gradually smooth out until the field relaxes toward equilibrium. The grid is updated with the explicit FTCS finite-difference scheme, a classic numerical method for diffusion problems, letting you watch how thermal diffusivity governs the pace at which temperature gradients dissolve across a surface.
🔬 What it shows
It visualises diffusion of temperature on a square grid governed by the heat equation ∂T/∂t = α∇²T. Each step applies the Forward-Time Central-Space (FTCS) update, where a cell's new value is its old value plus α times the discrete Laplacian of its four neighbours. The colour map runs from black (zero) through red, yellow and white for hot regions, and through blue to cyan for cold regions. The boundary is held fixed at 0 °C (Dirichlet condition).
🎮 How to use
Pick the Hot or Cold brush, then click or drag on the grid to paint heat sources. The Brush temp slider sets magnitude (10–200 °C) and Brush radius sets the painted disc (1–8 cells). Under Physics, Diffusivity α (0.05–0.50) controls how fast heat spreads, and Steps / frame (1–20) sets the simulation speed. The Statistics panel reports max, min and average temperature and the step count; "Clear grid" resets the field to zero.
💡 Did you know?
The explicit FTCS scheme is only conditionally stable: in 2D the dimensionless number α·dt/dx² must stay below 0.25, or rounding errors amplify each step and the solution blows up. That is why the diffusivity slider here is capped at 0.50 with dt = dx = 1, keeping the method on the edge of its stability limit.
Frequently asked questions
What is the heat equation this simulation solves?
It is the 2D heat (or diffusion) equation, written ∂T/∂t = α∇²T, where T is temperature, t is time, α is the thermal diffusivity and ∇² is the Laplacian. It states that the rate of temperature change at a point is proportional to how much that point differs from the average of its surroundings, which makes heat flow from hot regions to cold ones.
How does the FTCS method actually compute each step?
Forward-Time Central-Space replaces the derivatives with finite differences on the grid. Each cell's next temperature equals its current value plus α times the sum of its four neighbours minus four times itself. Because the new field depends only on the old field, every cell can be updated independently in a single explicit pass, which is fast but limited by a stability condition.
What do the diffusivity and speed sliders change?
Diffusivity α scales how strongly each cell pulls toward the average of its neighbours, so higher α makes heat spread faster and reach equilibrium sooner. Steps / frame sets how many FTCS updates run before each redraw, effectively a time-speed control: more steps per frame advances simulated time faster but does not change the underlying physics.
Is this physically accurate?
The model is a faithful discretisation of the ideal heat equation for an isotropic, homogeneous medium with fixed-temperature (Dirichlet) edges at 0 °C. It is a teaching tool, so it uses dimensionless grid units rather than real material constants, and it ignores convection, radiation and temperature-dependent properties. The qualitative behaviour of conductive heat flow is, however, captured correctly.
Why does heat eventually fade to zero?
The four edges of the grid are clamped to 0 °C, so they continually drain thermal energy out of the domain. With no internal heat source sustaining it, conduction smooths every gradient and energy leaks through these fixed boundaries until the whole field relaxes to the boundary value of zero. Repainting hot or cold spots injects fresh energy and restarts the diffusion.
Frequently Asked Questions
What is thermal conductivity and how does it vary between materials?
Thermal conductivity (k) measures how readily a material conducts heat, in W/(m·K). Metals like copper (~400 W/m·K) are excellent conductors, while air (~0.025 W/m·K) and aerogels (~0.015 W/m·K) are excellent insulators.
What is the difference between heat conduction and convection?
Conduction transfers heat through direct particle-to-particle contact within a stationary material. Convection transfers heat by the bulk movement of a fluid (liquid or gas). Both often occur together, but the heat equation models conduction specifically.
What is thermal diffusivity?
Thermal diffusivity (α = k/ρcₚ) combines conductivity, density, and specific heat to measure how quickly a temperature disturbance spreads through a material. High diffusivity means rapid temperature equalisation — metals diffuse heat much faster than wood or plastic.
What boundary conditions are used in heat conduction simulations?
Common boundary conditions include fixed temperature (Dirichlet), fixed heat flux (Neumann), or convective cooling (Robin/Newton's law of cooling). The choice depends on the physical setup — for example, a surface cooled by a fan uses the convective condition.
How do insulators reduce heat conduction?
Insulators have very low thermal conductivity, so the temperature gradient must be steep to drive even a small heat flux. Materials like fibreglass, foam, and aerogel trap still air in tiny pockets, preventing both conduction and convection, achieving very low effective k values.
Solve the 2D heat equation in real time with FTCS finite differences. Paint hot and cold sources on a grid and watch thermal energy diffuse from red-hot to icy blue.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install