Chapter 24 — Instructor Notes
Teaching Notes
Why this chapter is the pivot. This is the project climax: twenty-three chapters of scaffolding pay off
when step becomes a real solver. Teach it as an arrival. Open by pulling up the Ch. 6/8 placeholder
step (numbers 0,10,10,0) and promising that by the end of class those numbers will be real physics with a
principled timestep. Close by showing the checkpoint's 28,32,28 — same machinery, real answer.
The three ideas to emphasize, in order:
1. A stencil is a scaled comparison of neighbours. The neighbour sum is Ch. 5's array exercise; the
1/h^2 is the physics. Students who miss this write a solver whose answer changes when they refine the
mesh. Drive it home with the u = x^2+y^2 → 4 check (example-01): the discrete Laplacian equals the exact
one, for any h, only because of the scaling.
2. Explicit stepping is just forward-Euler on the method-of-lines system. Connect hard to Ch. 23. This
demystifies the update — it is not new machinery, it is Euler applied per grid point — and sets up "swap
the integrator" (RK4, implicit) as a modular change.
3. The CFL cliff is a threshold, not a slope. This is the one students under-weight. Most numerical
error is graceful (smaller step, smaller error); instability is a cliff. Spend the most time here.
Misconceptions to preempt:
- "Smaller dt is just slower." False for stability — above the limit, no dt-shrinking within the unstable
regime helps; you must cross below r=1/4. Show the blow-up.
- "CFL is the heat-equation stability condition." Technically it's the wave condition; the heat limit is a
von Neumann/diffusion-number condition. The chapter is honest about this (boxed note). Decide how deep to
go by audience; for a programming course, "explicit schemes have a timestep limit; here it's r ≤ 1/4" is
enough, with the caveat noted.
- "Refining the grid is free." The dt ~ h² tax means 2D work grows 16× per halving. Make them derive it
(F20).
- "I can update u in place." No — that silently becomes Gauss–Seidel. This is a real bug that produces
plausible wrong answers, the worst kind.
- Boundary/interior off-by-one. do i=1,n reads off-grid. Turn on -fcheck=all in class and let it catch
the crash live.
Live-coding demo (25–30 min). Build the blow-up live.
1. Start from example-02-ftcs-1d.f90 (stable, r=0.25). Run it; watch the rod warm. Good.
2. Change r to 0.6. Predict together (worst mode factor 1-4r = -1.4, grows). Run ~40 steps. Watch it
oscillate and overflow. The "aha."
3. Fix it by deriving dt: dt = 0.9*dx**2/(2*alpha) (1D). Show it's stable again.
4. If time: turn on -ffpe-trap=overflow so the unstable run dies with a backtrace instead of printing
NaN — connects to Ch. 13.
NOTE for the instructor: the book never runs code, but in a live class you obviously do — this is the one
place where actually watching the overflow is worth a thousand words. Hand-verify the first two steps on the
board first (the 1→2→4→8 doubling of the 2D checkerboard, or the 1D version) so students trust the machine.
Time budget (≈ 6 h, matching the estimate): - §24.1 equations + method-of-lines link — 45 min - §24.2 stencil + example-01 hand check — 60 min - §24.3 FTCS + example-02 — 45 min - §24.4 CFL/stability + the blow-up demo — 90 min (the heart; do not rush) - §24.5 boundary conditions — 45 min - §24.6 + Project Checkpoint (assemble the real solver) — 60 min - Exercises/case studies — homework
Prerequisites to review before teaching: Ch. 5 (array sections, column-major — the stencil leans on
both), Ch. 9 (field_t, % access), Ch. 23 (Euler, method of lines). A 10-minute warm-up recalling the Ch. 5
whole-array Laplacian is the ideal on-ramp — this chapter literally adds the 1/h^2 and the time loop to it.
Assessment tip. The single best exam question is Case Study 1's scenario: "This code worked at n=26 and NaNs at n=51; nothing else changed. Diagnose and fix in two lines." It tests the whole chapter — stencil recognition, the diffusion number, r ∝ 1/h², and the derive-dt fix — in one realistic problem.