Solve the 1D heat equation on a grid

Approximate one-dimensional heat diffusion from a centred grid impulse with fixed-zero endpoints.

freeworks offlinenothing uploaded
Tool1D Heat Equation Solver
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Each interior value advances by the forward-time centred-space difference uᵢⁿ⁺¹ = uᵢⁿ + r(uᵢ₋₁ⁿ − 2uᵢⁿ + uᵢ₊₁ⁿ). The time-step count keeps r = diffusivity × Δt ÷ Δx² at or below 0.45 while endpoint values stay zero.

Formula
r = diffusivity × Δt ÷ Δx² ≤ 0.45
  • The 0.45 ceiling sits below the explicit one-dimensional stability bound of 0.5.
  • Length, grid points, diffusivity, elapsed time, and peak remain physical modelling inputs rather than defaults.

Worked example

Solve the 1D heat equation on a grid
Input
											Length: 1
Points: 11
Diffusivity: 0.01
Seconds: 1
Initial peak: 100
										
Output
												X    Value
---  ---------
0    0
0.1  0
0.2  3.703704
0.3  11.111111
0.4  22.222222
0.5  25.925926
0.6  22.222222
0.7  11.111111
0.8  3.703704
0.9  0
1    0
											

When to use this

Numerical-method lessons demonstrate diffusion, convergence exercises refine the spatial grid, and heat prototypes export samples for a plot.

Edge cases

  • Changing grid density changes the physical width and total quantity represented by the one-node initial peak.
  • Fixed-zero endpoints model permanent sinks rather than insulated boundaries.
  • Stability prevents blow-up but does not prove spatial accuracy or agreement with an analytic solution.