A1248 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 r=αΔt/Δx2 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 r≤1/2. If you halve the grid spacing Δx, what happens to the largest stable time step?

Name it

Differences

With grid spacing h:

DerivativeDifferenceError
u′, forwardui+1−uihO(h)
u′, centralui+1−ui−12hO(h2)
u′′ui+1−2ui+ui−1h2O(h2): h212u′′′′

The explicit (FTCS) heat scheme

uin+1=uin+r(ui+1n−2uin+ui−1n),r=αΔtΔx2

Von Neumann analysis

Put uin=GnejkiΔx into the scheme: each Fourier mode is multiplied every step by

G(k)=1−4rsin2⁡kΔx2

Stability needs |G|≤1 for every mode. The worst is the finest, kΔx=π, with G=1−4r, so the condition is r≤12.

Other schemes

  • Implicit (backward Euler): use the new values in the difference; G=11+4rsin2⁡(kΔx/2), stable for every r, at the cost of solving a tridiagonal system each step.
  • Crank–Nicolson: average the two; G=1−2rsin2⁡(kΔx/2)1+2rsin2⁡(kΔx/2), stable for every r and second-order accurate in time.
  • The wave equation (leapfrog, FDTD): stable when the Courant number C=cΔt/Δx≤1; 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
  1. The stability limit. Δt≤(10−3)22×1.1×10−4s=4.5ms
  2. The number of steps. So 10 s takes at least 2200 steps.
  3. 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 u=x4 at x = 1 with h = 0.5.

Show the solution
  1. The second difference. D2u=1.54−2+0.540.25=5.0625−2+0.06250.25=12.5 against the exact u′′=12.
  2. The error. It is 0.5, which is h212u′′′′=0.2512×24 as the table predicts.

Answer the second difference gives 12.5 against the exact 12, and the error of 0.5 is what h212u′′′′ predicts.

Worked example

With r=αΔt/Δx2=2, how do the explicit, backward Euler and Crank–Nicolson schemes treat the grid's finest wiggle (kΔx=π)?

Show the solution
  1. The truth. The true heat equation would shrink that wiggle by e−r(kΔx)2=e−2π2≈3×10−9 per step.
  2. Explicit. With s=sin2⁡(kΔx/2)=1, the amplification factor per step is G=1−4rs=−7 so the explicit scheme blows the wiggle up sevenfold per step.
  3. Backward Euler. G=11+4rs=19 It damps the wiggle strongly, though less than the truth.
  4. Crank–Nicolson. G=1−2rs1+2rs=−35 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.
  5. 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 19, and Crank–Nicolson by −35 (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 (kΔx=π) 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 u(x+h)−2u(x)+u(x−h)h2 give for u=x4 at x = 1 with h = 0.5?

Check

A second-order scheme's error goes as h2. 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 r=αΔt/Δx2 = 1. Consider the grid's finest wiggle, kΔx=π.

(a)

What is Crank–Nicolson's amplification factor for it?

(b)

What is backward Euler's?

Check

Substitute ujn=Gneijθ into a heat scheme, with θ=kΔx (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°.

Explain why

Why does an explicit scheme blow up when its time step is too large, even though each step is a reasonable approximation?

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.