Heat Equation

AI authored to showcase ironpad capabilities.

🔥 2D Heat Equation

This notebook simulates the 2D heat equation on an 800×800 grid using explicit finite differences.

The Equation

\frac{\partial u}{\partial t} = \alpha \nabla^2 u = \alpha \left( \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} \right)

where u(x, y, t) is the temperature field and \alpha is the thermal diffusivity. The discrete update (explicit Euler, 5-point stencil) is:

u_{i,j}^{n+1} = u_{i,j}^{n} + \alpha \, \Delta t \left( u_{i+1,j}^{n} + u_{i-1,j}^{n} + u_{i,j+1}^{n} + u_{i,j-1}^{n} - 4\, u_{i,j}^{n} \right)

Stability requires 4 \alpha \, \Delta t < 1 (CFL condition for 2D diffusion).

Initial Conditions

  • Hot spots — several circular regions start at high temperature (white/yellow).
  • Cool spots — circular regions start at zero (dark blue).
  • Warm bottom edge — the entire bottom row is held at constant high temperature, continuously feeding heat upward.
  • Orbiting source — a roving hot spot orbits the centre of the grid, gently leaking heat into the cells it passes over.

Boundary Conditions

EdgeCondition
TopCold (u = 0) — heat sink
LeftCold (u = 0) — heat sink
RightCold (u = 0) — heat sink
BottomWarm (u = 1) — constant source

The diffusion coefficient \alpha = 0.25 with 10 sub-steps per frame keeps the simulation stable while evolving quickly enough to watch.

Heat Diffusion