import {knob, seg, action, pauser, panel, row} from "../assets/controls.js"
// the copyright notice for figure licence lines in live figures; the years come from _copyright.yml (via the
// trgy-copyright-years tag that assets/figure-license.lua adds to every page)
trgyCopy = "© " + (document.querySelector('meta[name="trgy-copyright-years"]')?.content || "2026") + " Wuping Xin"
// The two fundamental diagrams of the course: Greenshields (teal) and the course triangle (violet). One lane.
lwr = {
const VF = 100, KJG = 150, W = 20, KJT = 120, KCT = 20;
return {
"Greenshields": {Q: k => VF * k * (1 - k / KJG), V: k => VF * (1 - k / KJG), c: k => VF * (1 - 2 * k / KJG),
kc: KJG / 2, kj: KJG, colour: "#2a9d8f"},
"Course triangle": {Q: k => Math.min(VF * k, W * (KJT - k)), V: k => k <= KCT ? VF : W * (KJT - k) / k,
c: k => (k < KCT ? VF : -W), kc: KCT, kj: KJT, colour: "#57068c"}
};
}
onScreen = id => { const el = document.getElementById(id); if (!el) return true; const r = el.getBoundingClientRect(); return r.width > 0 && r.bottom > 0 && r.top < innerHeight; }
// .split-box puts the controls on top in one row and the figure below, at the card's full width (user, 2026-10-11):
// splitW is that width. pairFit: two plots side by side only when each stays at least about 340 px wide;
// otherwise they stack, each at the full width (never two half-width plots wrapped one under the other)
slidePortrait = !!document.querySelector(".reveal") && window.innerHeight > window.innerWidth
splitW = !!document.querySelector(".reveal") ? fullW - 50 : Math.max(240, fullW - 40)
pairFit = splitW >= 70016 · A Bump of Slow Traffic: Which Way Does a Jam Move?
Put a patch of dense traffic on a ring road and watch it drive forward, run backward or stand still
On a busy road you often meet a short stretch where the cars are packed closer and drive slower, and then the traffic opens up again. That stretch is the bump: a patch of denser, slower traffic. Where does it go? Here is the experiment, run by the traffic model of Lecture 4:
- The road: one lane, 10 km long, closed into a ring like a test track, with no ramps. No car gets on or off, so the number of cars never changes. (A ring has no ends, so nothing at the edges disturbs what you watch.)
- The traffic: cars evenly spaced all round the ring, at the background density you set. 25 veh/km is one car every 40 m.
- The bump: on one 2 km stretch, centred at km 3, the cars start closer together, with up to the extra density you set at its middle. At the default, 10 veh/km more: one car every 29 m instead of 40 m.
- The drivers: each one drives at the speed that the flow–density curve gives for the density around them (Greenshields’ curve or the course triangle). The closer the cars, the slower they drive.
- What you watch: six minutes of driving. The strip on top shows the road unrolled, with the cars on it.
NoteBefore you play: predict
Does the bump move forward with the cars, backward against them, or stay put? Answer twice, on the default Greenshields curve: for light traffic around it (25 veh/km), and for heavy traffic (100 veh/km). Does it keep its shape?
Live: a bump of slow traffic
Predict at 25 veh/km, does the bump drive as fast as the cars?
NoteHow to read it
- The road, unrolled (top): the ring cut open at km 0 and laid flat. Each dot stands for the same number of cars (given above the strip), coloured by their speed. In the bump the dots crowd together; watch the crowd move while every dot drives on.
- Density along the ring (left, or on top on a phone): at the time on the slider; the dashed line is the bump at the start. Its colour is the diagram’s: Greenshields teal, the course triangle violet.
- The time–space diagram (right, or below on a phone): time across, position up. The colour is the speed of traffic, from red, the slowest in this run, to green, the fastest (the line under the plots gives both). Each thin line is one car, 12 of them spread so the same number of vehicles lies between each pair. The dashed line is the time on the slider.
- The bump moves: the speed of the centre of the bump’s extra cars, measured between minute 1 and minute 4.
- Small-bump prediction: the slope of the flow–density curve, c = dQ/dk, at the background density: the speed of a very small bump.
- The cars drive at: the speed of the cars in the background traffic.
- Extra cars in the bump: the vehicles above the background. It stays the same while the bump changes shape: cars are neither made nor lost.
- Diagram: two curves of flow against density, for one lane (all densities here are per lane). Greenshields is a smooth parabola: 100 km/h on an empty road, jammed at 150 veh/km. The course triangle is free flow at 100 km/h up to 20 veh/km, then congestion down to a jam at 120 veh/km, so its default 25 veh/km is already congested. The background density stops just short of the jam, so that the bump still fits under it.
What it shows
The bump is not a group of cars. Every car drives through it: on the road strip the dots crowd together as they reach it and spread out again after it; in the time–space diagram the thin lines climb across the slow patch and leave it again. What moves is a pattern of density, and it has its own speed.
- Light traffic: the bump moves forward, but slower than the cars. At 25 veh/km on Greenshields’ curve it drives at about +62 km/h, while the cars do 83.
- Heavy traffic: the bump moves backward, against the cars: about −38 km/h at 100 veh/km. This is how a jam spreads upstream.
- The top of the curve: somewhere near the top of Greenshields’ curve the bump stands still. What to try asks you where.
- Its shape: on Greenshields the back steepens until it is a jump, and the front spreads out, because denser traffic carries slower waves. On the course triangle every free-flow wave has the same speed, so a free-flow bump keeps its shape.
The speed of a small bump is the slope of the flow–density curve, dQ/dk: positive below capacity, zero at the top, negative above it. Lighthill and Whitham (1955) and Richards (1956) derived it from one law, that cars are neither made nor lost, and one curve, the flow as a function of density. The steepened back is a shock: the back of a queue. Lecture 4 of the course derives all of this; Lecture 7 builds the simulation.
What to try
- Find where it stands still. On Greenshields, slide the background density until the bump neither drives nor runs back. Is that exactly at the top of the curve, 75 veh/km?
- Make it bigger. Raise the extra density to 30 veh/km in light traffic. Does it move faster or slower than the small-bump prediction?
- Count the cars. Watch Extra cars in the bump while the bump steepens. Why does it never change?
- Switch the curve. Set the extra density back to 10 veh/km. On the course triangle at 10 veh/km it drives with the cars and keeps its shape. Now try 60 veh/km. Which way does it go, and how fast?
References. Lighthill, M. J. and Whitham, G. B. (1955). On kinematic waves II: a theory of traffic flow on long crowded roads. Proceedings of the Royal Society A 229, 317–345. https://doi.org/10.1098/rspa.1955.0089. Richards, P. I. (1956). Shock waves on the highway. Operations Research 4, 42–51. https://doi.org/10.1287/opre.4.1.42