1D Heat Equation Solver

Animated finite-difference solution of the diffusion equation ∂u/∂t = α·∂²u/∂x²

Parameters

ⓘ
m²/sⓘ
sⓘ
Show Trail

Controls

xⓘ

Calculated Values

Number of grid points:
60.00;60.00;
Time steps:
80.00;80.00;
Domain:
1.00;m1.00;m

Examples

Gaussian hotspot

Initial concentrated heat at center diffuses outward.

  • Grid: 60.0060.00

Step function

Sharp temperature discontinuity smooths out.

  • Grid: 60.0060.00

Visualization

Solving the Heat Equation Numerically

The 1D heat equation ∂u/∂t = α·∂²u/∂x² describes how temperature u evolves in time due to thermal diffusion. α is the thermal diffusivity of the material.

The FTCS (Forward Time, Central Space) scheme discretizes the PDE: u_i^{n+1} = u_i^n + C(u_{i+1}^n − 2u_i^n + u_{i-1}^n) where C = αΔt/Δx².

Stability requires C ≤ 0.5 (von Neumann condition). If C > 0.5, numerical oscillations appear and amplify. The animation shows the temperature profile smoothly diffusing from hot to cold regions.

Boundary conditions: u(0,t) = u(L,t) = 0 (Dirichlet). The initial heat pulse spreads until the rod reaches uniform temperature.

The same algorithm models neutron diffusion, pollutant dispersion, and financial option pricing (Black-Scholes).

Key Concepts

  • FTCS: explicit, first-order in time, second-order in space
  • CFL condition: C = αΔt/Δx² ≤ 0.5 for stability
  • Dirichlet BCs: fixed temperature at boundaries
  • Gaussian, step, and sine initial conditions
  • Conservation of thermal energy (area under curve decreases to 0)

Real-World Applications

  • Heat flow in a metal rod
  • Ground temperature penetration
  • Chemical diffusion in fluids
  • Neutron diffusion in nuclear reactors

Explore Further

More computational physics tools

  • Gradient Descent

    Iteratively minimize f(x) by following the negative gradient with animated path visualization.

  • 1D Wave Equation

    Leapfrog finite-difference solution to the wave equation with animated wave propagation.

  • Numerical Integration

    Trapezoidal and Simpson rules to approximate definite integrals with error vs exact solutions.

  • ODE Solver

    Euler and Runge-Kutta 4 methods for first-order ODEs with comparison to analytic solutions.

  • Monte Carlo Intro

    Estimate π and integrals by random sampling — introduction to stochastic computational physics.

  • Newton-Raphson

    Solve nonlinear equations f(x) = 0 with tangent-line iterations — fast when the guess is good.

Physics Equations

PDE:
∂u∂t=α∂2u∂x2\frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2}
FTCS:
uin+1=uin+C(ui+1n−2uin+ui−1n)u_i^{n+1} = u_i^n + C(u_{i+1}^n - 2u_i^n + u_{i-1}^n)
CFL:
C=αΔtΔx2≤0.5C = \frac{\alpha \Delta t}{\Delta x^2} \leq 0.5

Step-by-Step Solution

See how the main results are calculated.

1

Step 1: The heat equation

Diffusivity α = 0.01 m²/s on a rod of length L = 1 m with an initial half-sine and ends held at u = 0.

Equation:

∂u∂t=α ∂2u∂x2\frac{\partial u}{\partial t} = \alpha\,\frac{\partial^2 u}{\partial x^2}
2

Step 2: Explicit (FTCS) scheme

Equation:

uin+1=uin+r (ui+1n−2uin+ui−1n)u_i^{n+1} = u_i^n + r\,(u_{i+1}^n - 2u_i^n + u_{i-1}^n)

Explanation:

Forward difference in time, central difference in space, with r = α·Δt/Δx².

3

Step 3: Stability condition

Calculation:

r=α Δt/Δx2=0.0870r = \alpha\,\Delta t/\Delta x^2 = 0.0870

Result:

r ≤ 0.5 — the scheme is stable

Explanation:

The explicit FTCS scheme requires r ≤ ½, otherwise the solution oscillates and diverges.

4

Step 4: Result after t = 0.2 s

Calculation:

peak temperature: 1.000→0.980\text{peak temperature: } 1.000 \rightarrow 0.980

Result:

Heat diffuses outward, the peak decays, and the profile flattens toward equilibrium.

Frequently Asked Questions (FAQ)

What does instability look like?

Oscillations that grow with time — reduce Δt or increase Δx to satisfy CFL ≤ 0.5.

What is thermal diffusivity α?

α = k/(ρc_p) where k is thermal conductivity, ρ density, and c_p specific heat capacity.

How is this different from the wave equation?

Heat is diffusive (smooths out), waves are hyperbolic (propagate). Heat dissipates energy; waves conserve it.

Practice MCQs

  1. FTCS stands for:
  2. CFL condition for heat equation requires:
  3. The heat equation is a ___ PDE:
  4. Increasing α makes diffusion:
  5. Steady-state solution (t → ∞) with u=0 BCs:
  6. Von Neumann stability for FTCS yields condition:
  7. If the CFL number exceeds 0.5, the solution will:
  8. The heat equation is classified as parabolic because:
  9. Doubling the number of grid points requires Δt to:
  10. The FTCS scheme is ___ in time and ___ in space: