The Lighthill-Whitham-Richards (LWR) model treats traffic as a compressible fluid on a 1D road. Vehicle conservation gives the hyperbolic PDE: ∂ρ/∂t + ∂F(ρ)/∂x = 0. With the Greenshields speed-density relation, nonlinear wave phenomena emerge spontaneously.
v(ρ) = v_max·(1 − ρ/ρ_max)F(ρ) = ρ·v(ρ) — parabolic fundamental diagram.G = min(D(ρ_L), S(ρ_R)) where demand D = F on free-flow branch, supply S = F on congested branch.ρ_i^{n+1} = ρ_i^n − (Δt/Δx)·(G_{i+1/2} − G_{i-1/2})Δt = 0.45·Δx / v_max for stability.v(ρ) = v_max · (1 − ρ/ρ_max) [Greenshields]
F(ρ) = ρ · v(ρ) [flux / fundamental diagram]
c(ρ) = dF/dρ = v_max·(1−2ρ/ρ_max) [kinematic wave speed]
w = (F_R − F_L)/(ρ_R − ρ_L) [Rankine-Hugoniot shock speed]
The LWR model was proposed independently by Lighthill & Whitham (1955) and Richards (1956). Despite being nearly 70 years old, it remains the foundation of motorway traffic management systems worldwide — including the UK's Motorway Incident Detection and Automatic Signalling (MIDAS) network.
The LWR model, developed by Lighthill, Whitham, and Richards in the 1950s–60s, describes macroscopic traffic as a continuous fluid governed by a conservation-of-vehicles PDE: ∂ρ/∂t + ∂F(ρ)/∂x = 0, where ρ is vehicle density and F(ρ) = ρ·v(ρ) is the traffic flux.
Greenshields (1935) proposed a linear speed-density relation: v(ρ) = v_max·(1 − ρ/ρ_max). This yields a parabolic flow-density (fundamental) diagram with maximum flow at ρ = ρ_max/2. It is the simplest closed-form model still widely used for theoretical analysis.
Kinematic waves are density disturbances that propagate through the traffic stream at speed c = dF/dρ = v_max·(1 − 2ρ/ρ_max). At low densities c > 0 (waves travel forward); at high densities c < 0 (waves travel backward against the flow), explaining why congestion propagates upstream.
A shockwave forms where two regions of different density meet, creating a sharp discontinuity. The Rankine-Hugoniot condition gives the shock speed: w = (F_R − F_L)/(ρ_R − ρ_L), where subscripts L/R denote left/right states. Shockwaves often propagate backward at 10–20 km/h even as vehicles move forward.
The Godunov scheme is a conservative finite-volume method for hyperbolic PDEs. At each time step it solves Riemann problems at cell interfaces to compute numerical fluxes, then updates cell averages. For LWR with a concave flux, the Godunov flux equals the supply-demand formulation: G = min(D(ρ_L), S(ρ_R)).
In congested traffic, the wave speed c = dF/dρ is negative (the fundamental diagram slope is negative on the right branch). A density perturbation — say caused by a sudden brake — therefore moves upstream, creating a stop-and-go wave that drivers encounter before they reach the original incident location.
A Hovmöller diagram plots a scalar field — here traffic density ρ — as a 2D colour map with space on the horizontal axis and time on the vertical axis. Diagonal lines in the diagram reveal wave propagation: forward-leaning lines show downstream-moving features; backward-leaning lines show upstream-moving (backward) shockwaves.
The Courant–Friedrichs–Lewy (CFL) condition requires Δt ≤ Δx / max|c| to keep the explicit scheme numerically stable. Violating it causes the simulation to diverge with growing oscillations. In this simulation Δt is automatically chosen to satisfy CFL with a safety factor of 0.45.
The 'Add Incident' button injects a localised density spike into a short segment of the ring road, simulating a lane reduction or accident. The resulting downstream rarefaction fan and upstream shockwave are immediately visible in the space-time diagram as diverging coloured stripes.
The LWR model underpins variable speed-limit systems, ramp metering control, traffic state estimation from probe vehicles, and motorway incident detection. Extensions such as Payne-Whitham (second-order) and multi-class LWR add inertia and vehicle heterogeneity for higher fidelity.
This simulation solves the Lighthill-Whitham-Richards (LWR) continuum traffic model on a periodic ring road: the conservation law ∂ρ/∂t + ∂F(ρ)/∂x = 0 tracks vehicle density ρ as a compressible fluid. Speed follows the Greenshields relation v(ρ) = v_max·(1 − ρ/ρ_max), giving a parabolic flow-density fundamental diagram, and each cell interface is updated with a Godunov finite-volume scheme using a supply-demand flux G = min(D(ρ_L), S(ρ_R)). The result is a real-time space-time (Hovmöller) diagram showing kinematic waves and shockwaves emerging spontaneously from noise or an injected incident.
A 1 km ring road discretised into 200 cells, coloured by density from free-flow (blue) to jammed (red). The Hovmöller panel stacks each time-step's density profile so diagonal stripes reveal whether waves drift forward (low density) or backward (high density) relative to traffic, while a small fundamental-diagram plot tracks the current operating point on the ρ–Q curve.
Drag v_max (10–60 m/s) to set free-flow speed, ρ_max (40–200 veh/km) to set jam density, and Initial ρ (5–110 veh/km) to seed the starting traffic state. Sim speed (0.25×–8×) scales playback rate. Pause/Reset control the run, and Add Incident injects a localised density spike near one-third of the road to trigger a visible backward-propagating shockwave.
The stop-and-go "phantom traffic jams" you hit on a clear motorway with no crash or junction are a real prediction of this model: once density crosses the critical value ρ_max/2, the wave speed turns negative and any small braking perturbation grows into a jam that crawls backward through the traffic even as every driver keeps inching forward.
It treats traffic as a continuous fluid rather than individual cars, governed by the conservation law ∂ρ/∂t + ∂F(ρ)/∂x = 0, where ρ is vehicle density and F(ρ) = ρ·v(ρ) is the flux (flow rate). This macroscopic view, developed by Lighthill, Whitham and Richards in the 1950s, predicts congestion patterns without tracking every vehicle.
Greenshields' 1935 formula sets speed as v(ρ) = v_max·(1 − ρ/ρ_max), linearly decreasing from free-flow speed at zero density to zero at jam density. Multiplying by ρ gives a parabolic flux curve peaking at ρ_max/2, which is exactly the fundamental-diagram plot shown in the simulation's corner panel.
The kinematic wave speed is c = dF/dρ = v_max·(1 − 2ρ/ρ_max). Below half the jam density this is positive (waves drift forward with traffic); above it, c turns negative, so a density disturbance propagates upstream against the direction cars are travelling — visible as backward-leaning stripes in the Hovmöller diagram.
Each cell boundary flux is computed as G = min(D(ρ_L), S(ρ_R)), the smaller of the left cell's demand and the right cell's supply, which correctly resolves shocks and rarefactions without oscillation. The time step is automatically capped by the CFL condition (Δt ≈ 0.45·Δx/v_max) so the scheme never advances faster than information can physically travel between cells.
It injects a density spike into a short segment about one-third of the way around the ring, mimicking a lane closure or crash. Downstream of the spike density drops (a rarefaction fan), while upstream a sharp shockwave forms and crawls backward — the same Rankine-Hugoniot shock behaviour that causes real motorway tailbacks to appear well before the actual obstruction.