This simulator solves the constant-speed linear advection equation u_t + c u_x = 0 on a periodic one-dimensional grid. The exact solution is just a translated initial pulse, so numerical artifacts are easy to see. The first-order upwind scheme uses information from the incoming direction and is monotone for ν = cΔt/Δx ≤ 1, but it introduces numerical diffusion that visibly smears square pulses. Lax–Wendroff adds a second-order correction term and greatly reduces diffusion, but discontinuities reveal dispersive oscillations (overshoot and undershoot). MacCormack is a predictor-corrector method with similar second-order accuracy for smooth waves and similar ringing near sharp fronts. The page advances all three schemes side by side, overlays the exact translated profile, and plots pointwise error below the solution so students can separate diffusion from dispersion.
Who it's for: Students in numerical PDEs, CFD, signal transport, and computational physics learning CFL limits, upwinding, and the trade-off between monotonicity and second-order accuracy.
Key terms
Linear advection
Upwind scheme
Lax-Wendroff
MacCormack
CFL condition
Numerical diffusion
Numerical dispersion
Finite differences
How it works
Linear advection on a periodic 1D grid: compare first-order upwind, Lax-Wendroff, and MacCormack schemes against the exact translated pulse, exposing numerical diffusion, dispersive ringing, and the CFL limit.
For positive speed, upwind replaces the derivative with a biased backward difference. Its modified equation contains an artificial diffusion term proportional to (1−ν)Δx, so discontinuities are damped and broadened rather than translated sharply.
Why do Lax–Wendroff and MacCormack overshoot near jumps?
They are second-order, less diffusive schemes. Around a discontinuity, high-frequency components acquire phase errors, producing dispersive ringing. This is the same monotonicity-vs-accuracy tension behind TVD limiters and modern high-resolution methods.
What does CFL ν mean here?
ν = cΔt/Δx is the number of grid cells information travels in one time step. For these explicit linear advection schemes the basic stability range is roughly ν ≤ 1. Above that, the numerical domain of dependence cannot keep up with the PDE.