HomeThermodynamicsFourier Heat Equation — Diffusion & Boundary Conditions

🌡️ Fourier Heat Equation — Diffusion & Boundary Conditions

Solve the heat equation numerically. Watch temperature profiles evolve with Dirichlet/Neumann/periodic boundary conditions. See Fourier series convergence in real time.

Thermodynamics3DModerate60 FPS
fourier-heat ↗ Open standalone

Physics & Equations

The 1D heat equation is ∂T/∂t = α·∂²T/∂x². Explicit finite difference: T_i^(n+1) = T_i^n + r·(T_{i+1}^n − 2T_i^n + T_{i-1}^n) where r = α·dt/dx². Stability requires r ≤ 0.5. Analytical solution: T(x,t) = Σ aₙ·sin(nπx/L)·e^(−(nπ/L)²·α·t).

Boundary Conditions

Dirichlet (fixed temperature): the bar ends are held at constant temperature — like a metal rod with its ends in ice water and boiling water. Neumann (insulated): no heat flux through the ends — temperature gradient is zero at boundaries. Periodic: the bar wraps around, as if it were a ring.

Fourier Decomposition

Any initial temperature distribution can be decomposed into sine modes T(x,0) = Σ aₙ·sin(nπx/L). Higher modes (larger n) decay exponentially faster: amplitude ~ e^(−n²t). This is why heat spreads and smooths out — fine-scale features disappear first, leaving only the slowest-decaying fundamental mode.

About this simulation

This simulation numerically solves the 1D heat equation ∂T/∂t = α·∂²T/∂x² on a 200-point rod using an explicit finite-difference scheme. You choose an initial temperature profile and a boundary condition, then watch heat diffuse and smooth out in real time. A live bar chart decomposes the temperature curve into its first five Fourier sine modes, showing directly why higher-frequency features fade away fastest.

🔬 What it shows

A rod of 200 grid points evolving under T_i^(n+1) = T_i^n + r·(T_{i+1} − 2T_i + T_{i-1}), with r = α·dt/dx² and dt chosen automatically at 80% of the stability limit (r ≤ 0.5). The colour strip and the profile plot track the same temperature array; a separate bar chart shows the magnitude of Fourier sine modes n = 1 to 5 extracted from the current profile.

🎮 How to use

Set the Thermal Diffusivity α slider (0.01–0.5), pick an Initial Condition (Gaussian Pulse, Step Function, Sine Wave, Hot End) and a Boundary type (Dirichlet fixed-temperature, Neumann insulated, or Periodic), then press Run. The four preset buttons load ready-made combinations — try Hot End with Dirichlet to watch a heat front spread from one end, or Periodic with a sine wave to see a single mode decay cleanly.

💡 Did you know?

The Fourier mode chart is not decoration — it is the same sine decomposition Joseph Fourier introduced in 1822 to solve exactly this equation. Because each mode n decays as e^(−(nπ/L)²·α·t), higher modes vanish roughly n² times faster than the fundamental, which is why any rough initial profile always relaxes into a single smooth bump.

Frequently asked questions

What equation does this simulation actually solve?

It solves the 1D heat (diffusion) equation ∂T/∂t = α·∂²T/∂x² on a rod of 200 grid points, using an explicit finite-difference scheme: each new temperature value is the old value plus a correction proportional to the curvature of its neighbours, scaled by r = α·dt/dx². The time step dt is recalculated from the diffusivity α and fixed automatically at 80% of the stability limit (r ≤ 0.5), so the simulation never blows up no matter how you set the diffusivity slider.

What do the three boundary conditions mean physically?

Dirichlet holds both ends of the rod at a fixed temperature — 1.0 at the hot end for the "Hot End" preset, 0.0 otherwise — like a rod with its tips clamped to a heater and an ice bath. Neumann sets a zero temperature gradient at each end (T_new[0]=T_new[1], T_new[N-1]=T_new[N-2]), modelling a perfectly insulated rod that cannot exchange heat with its surroundings. Periodic wraps the rod into a ring, so heat that would exit the right end re-enters on the left.

How does the Thermal Diffusivity slider change the behaviour?

The α slider (range 0.01 to 0.5) sets how fast heat spreads: it appears directly in the finite-difference update and in the automatically computed time step dt = 0.8 × 0.4 × dx² / α. Larger α smooths the temperature profile faster in simulated time, and because dt scales inversely with α, the simulation also advances through more physical time per rendered frame at high diffusivity.

What do the four initial conditions represent?

Gaussian Pulse starts with a bell-shaped hot spot centred at the middle of the rod; Step Function starts as a flat-topped hot region between x=0.3 and x=0.7; Sine Wave starts as a single half-period sine curve, which is a pure Fourier mode and therefore the simplest case to watch decay; Hot End clamps only the leftmost 5% of the rod to maximum temperature, simulating one end held against a heat source.

Why does the Fourier mode chart matter, and how is it computed?

For each mode n from 1 to 5, the simulation numerically integrates the current temperature array against sin(nπx/L) to extract that mode's amplitude, exactly the discrete version of a Fourier sine series coefficient. It matters because the exact analytical solution of the heat equation is T(x,t) = Σ aₙ·sin(nπx/L)·e^(−(nπ/L)²·α·t): every mode decays exponentially, with higher n decaying far faster, which is precisely the smoothing behaviour visible in the rod and profile plots.

⚙ Under the hood

Solve the 1D Fourier heat equation by finite differences. Set Dirichlet or Neumann boundary conditions and watch heat diffuse through a rod, revealing exponential mode decay.

heat equationdiffusionFourierfinite differenceboundary conditions

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)