Back

Linear advection: four schemes on the same square pulse

What you are seeing: the simplest PDE in numerical analysis, ut+cux=0u_t + c\,u_x = 0, solved four different ways on the same square pulse. The exact solution just translates the pulse to the right at speed cc forever, no distortion. The four numerical schemes all try to do that. They all fail in different, instructive ways.

FTCS (forward-time, centered-space) is the obvious first guess and is unconditionally unstable; the solution blows up. Upwind is first-order accurate and dissipative; the pulse smears out but stays positive. Lax-Wendroff is second-order; it preserves the pulse shape better but produces visible oscillations near the discontinuity (Gibbs-like). MacCormack is a predictor-corrector second-order method; similar accuracy to LW. The dashed green curve is the exact solution.

Figure 1. 1D linear advection ut+cux=0u_t + c u_x = 0 on a periodic domain, square pulse initial condition. Four schemes side-by-side: FTCS, upwind, Lax-Wendroff, MacCormack.
c1.00
CFL0.80
speed3

WHAT TO TRY

  • Vary each control and watch the rail readouts respond.
  • Compare the diagnostic plot against the live scene.