A12 · Lesson 48 · Finite differences and stability
Replacing derivatives with differences, and the step size that blows up
Most PDEs engineers meet have no closed-form solution: odd shapes, varying materials, nonlinear terms. They're solved on a grid, by replacing each derivative with a difference between neighboring values. The method is simple enough to write in an afternoon, and it has one trap that catches everyone the first time: take a time step a little too large, and a tiny wiggle at the grid's finest scale doubles every step until the answer is garbage. The von Neumann stability analysis predicts exactly when that happens, and the same reasoning sets the time step of every FDTD field solver (C10).
- The explicit scheme for the heat equation on 21 grid points, after N steps. The start is a smooth sine plus a barely visible wiggle at the finest scale the grid can hold. The curve is the exact solution.
- With below 0.5, the wiggle dies at once and the computed points follow the exact curve.
- Push r past 0.5 and step N forward: the wiggle's amplification factor (the readout) passes −1, and it grows by that factor every step, alternating in sign, until it swamps everything.
Predict
The explicit heat scheme is stable for . If you halve the grid spacing Δx, what happens to the largest stable time step?
A quarter: . A twice-finer grid needs four times as many steps, each on twice as many points: eight times the work in 1D. That cost is why implicit schemes, which have no such limit, are used for diffusion.
Name it
Differences
With grid spacing h:
| Derivative | Difference | Error |
|---|---|---|
| , forward | ||
| , central | ||
| : |
The explicit (FTCS) heat scheme
Von Neumann analysis
Put into the scheme: each Fourier mode is multiplied every step by
Stability needs for every mode. The worst is the finest, , with , so the condition is .
Other schemes
- Implicit (backward Euler): use the new values in the difference; , stable for every r, at the cost of solving a tridiagonal system each step.
- Crank–Nicolson: average the two; , stable for every r and second-order accurate in time.
- The wave equation (leapfrog, FDTD): stable when the Courant number ; information mustn't skip a cell in one step.
- Laplace's equation: no time step at all; iterate (Jacobi, Gauss–Seidel, SOR) until the grid settles.
Worked example
A copper bar (α = 1.1 × 10⁻⁴ m²/s) is modeled with Δx = 1 mm. What's the largest stable explicit time step, and how many steps does 10 s take?
Show the solution
- The stability limit.
- The number of steps. So 10 s takes at least 2200 steps.
- A finer grid. At Δx = 0.1 mm it would be 220 000.
Answer the largest stable step is 4.5 ms, so 10 s takes at least 2200 steps.
Worked example
Check the second difference on at x = 1 with h = 0.5.
Show the solution
- The second difference. against the exact .
- The error. It is 0.5, which is as the table predicts.
Answer the second difference gives 12.5 against the exact 12, and the error of 0.5 is what predicts.
Worked example
With , how do the explicit, backward Euler and Crank–Nicolson schemes treat the grid's finest wiggle ()?
Show the solution
- The truth. The true heat equation would shrink that wiggle by per step.
- Explicit. With , the amplification factor per step is so the explicit scheme blows the wiggle up sevenfold per step.
- Backward Euler. It damps the wiggle strongly, though less than the truth.
- Crank–Nicolson. It is stable, but it only shrinks the wiggle by 0.6 and flips its sign each step, so sharp starting data leaves a slowly fading checkerboard.
- In practice. That's why Crank–Nicolson runs often take a few backward Euler steps first.
Answer per step, the explicit scheme multiplies the wiggle by −7 (it blows up), backward Euler by , and Crank–Nicolson by (stable, but a slowly fading checkerboard).
Check
An explicit heat solver uses Δx = 1 mm on a material with α = 2 × 10⁻⁵ m²/s. What's the largest stable time step?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
With r = 0.6, what's the amplification factor of the finest grid wiggle () per step?
Check
An explicit heat run with r = 0.75 starts with a tiny wiggle at the grid's finest scale. By what factor has its size grown after 10 steps?
Check
A 1D FDTD simulation of free space uses cells of 5 mm. What's the largest stable time step?
Write units the way you normally would: 1.5 ps and 0.0015 ns are the same answer.
Check
What does the second difference give for at x = 1 with h = 0.5?
Check
A second-order scheme's error goes as . By what factor does the error shrink when the grid is made 3 times finer?
Check
Which of these schemes for the heat equation is stable for every time step?
Check
A heat solver runs with = 1. Consider the grid's finest wiggle, .
(a)
What is Crank–Nicolson's amplification factor for it?
(b)
What is backward Euler's?
Check
Substitute into a heat scheme, with (write θ as t).
Step 1
What is G for the explicit scheme?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
And for backward Euler?
Explain why
Why does an explicit scheme blow up when its time step is too large, even though each step is a reasonable approximation?
Every grid function is a sum of Fourier modes, and a linear scheme multiplies each mode by its own factor every step. For the explicit heat scheme that factor is . The true equation damps the finest modes hardest, but if the scheme overshoots for those modes: it subtracts too much and flips them with a size greater than 1. Rounding error always puts a little of every mode into the grid, so that finest wiggle grows geometrically, alternating in sign, until it swamps the solution. The accuracy of a single step doesn't matter; what matters is whether errors grow from step to step, which is the stability condition.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.