← All tools

Collective dynamics Interactive tool

Phantom Traffic Jam

One small brake can stop a whole highway. Seed a disturbance on a circular road and explore how reaction time turns it into a travelling traffic jam.

A traffic simulation. Use the brake control and read the flow and speed indicators below.
Live highway / 30 driversFREE FLOWAvg speed — m/s

Tap to seed a wave. Hold to stop your car. Focus this sandbox to brake with Space.

Free flowSlowingStopped

Getting started

Thirty drivers share a circular highway. Cars travel clockwise; the cyan outline and YOU label identify the car you control. Green cars are moving quickly, amber cars are slowing, and red cars are nearly stopped. The two rear lights glow pink when a driver brakes.

  1. Tap HOLD / TAP BRAKE to apply at least 0.3 simulation seconds of braking. Watch the following drivers react in turn.
  2. Hold the brake for several seconds to stop your car and build a queue. Release to accelerate again. You can also focus the sandbox or brake button and hold Space. Space retains its normal function on the slider and other buttons.
  3. Move Driver alertness towards Distracted to increase reaction lag up to 1.8 seconds. Delayed corrections can amplify a disturbance into a persistent stop-and-go wave.
  4. Move towards Hyper-focused to reduce the lag to zero. Disturbances then dissipate as drivers restore their spacing. Recovery can take several laps.
  5. Use Pause to inspect the road and Reset traffic to restore uniform spacing and equilibrium speeds. Reset preserves your reaction-lag setting and playback state.

Try the same five-second brake at 0.10 s and 1.60 s reaction lag, resetting between experiments. Compare how long the queue survives after you release. The cars move forward while the region of congestion passes backwards through the population.

The flow indicator reads SHOCKWAVE ACTIVE whenever at least one car travels below 2 m/s. This is a simple congestion indicator: a single stopped car also triggers it. Average speed is the mean speed of all thirty cars. Devices requesting reduced motion start paused; select Play to begin.

The mathematics

The sandbox uses a delayed Intelligent Driver Model (IDM). Positions θi\theta_i are angles around a ring of radius R=200R=200 model metres. With leader L=(i+1) mod 30L=(i+1)\bmod 30, the bumper-to-bumper gap and relative speed are

si=R[(θL−θi) mod 2π]−ℓ,Δvi=vi−vL.s_i=R\big[(\theta_L-\theta_i)\bmod 2\pi\big]-\ell, \qquad \Delta v_i=v_i-v_L.

The desired gap and acceleration are

si∗=s0+max⁡(0, viT+viΔvi2ab),v˙i=a[1−(viv0)4−(si∗si)2],θ˙i=viR.\begin{aligned} s_i^*&=s_0+\max\left(0,\,v_iT+\frac{v_i\Delta v_i}{2\sqrt{ab}}\right),\\ \dot v_i&=a\left[1-\left(\frac{v_i}{v_0}\right)^4-\left(\frac{s_i^*}{s_i}\right)^2\right], \qquad \dot\theta_i=\frac{v_i}{R}. \end{aligned}

Here s0=12s_0=12 m, T=1.2T=1.2 s, a=1.5a=1.5 m/s², b=2.0b=2.0 m/s², car length ℓ=8\ell=8 m and desired free-road speed v0=10v_0=10 m/s. This speed puts the low-lag population in a stable regime while allowing large delays to amplify a disturbance. The nonnegative dynamic-gap term prevents a rapidly receding leader from producing a negative desired gap. All quantities on the right-hand side are perceived at time t−τt-\tau, where τ\tau is the slider’s reaction lag.

On a crowded ring, the equilibrium speed is lower than the desired free-road speed. Initialisation solves the uniform-spacing IDM equation for that equilibrium, so the initial traffic has no artificial acceleration transient.

How it is computed

Physics advances in fixed 0.016 s steps, independently of rendering. Playback runs at 6× speed: one real second advances three simulation seconds. Reaction lags, braking durations and the speed readout use simulation time. A bounded circular history buffer stores positions and speeds; the reaction lag selects the nearest historical step. Changing alertness takes effect on the next step without resetting traffic.

Each step computes all new speeds from the same snapshot, then advances the positions using those speeds. Speeds stay between zero and 10 m/s; ordinary model acceleration is limited to the range −9 to +1.5 m/s². Your brake requests −4.5 m/s², or stronger braking if the following model already requires it. A short press lasts at least 0.3 simulation seconds; a hold continues until release. Brake lights illuminate below −0.2 m/s² or whenever your brake is active.

A final geometric safety guard limits each car’s travel to its current available gap, preserving a minimum 0.5 m clearance. This prevents overlap under extreme delays, though it can impose sharper braking than the ordinary acceleration limit. Frame catch-up is capped at 0.1 seconds; returning from a hidden tab does not fast-forward the simulation.

The road is drawn at a logical radius of 200 pixels and scaled to the available screen size. Display pixels and model metres are separate: the car silhouettes are enlarged for readability. The average-speed readout refreshes five times per simulation second.

What the model assumes

All drivers have the same vehicle, desired speed and reaction lag. There are no lane changes, overtaking, intersections, random disturbances or inflows. Congestion comes from delayed car following after your braking input. The ring keeps the density fixed and allows a wave to circulate repeatedly.

This is an educational delayed-IDM sandbox. Its reaction delay and collision guard are modelling choices, and the sharp transition between smooth flow and stop-and-go motion depends on the density and parameters. The display illustrates collective behaviour; it does not predict the capacity or safety of a particular road.

← Explore more tools