Mainline demand
Ramp demand
IDM driver parameters
View
Live readouts
Vehicles0
Avg speed0 km/h
Flow (merge)0 /h
Density0 /km
Min gap seen— m
Merges/min0
How it works

Every car obeys the Intelligent Driver Model (IDM), the standard microscopic car-following law used in real traffic engineering. Each vehicle's acceleration is

a = a_max·[ 1 − (v/v0)⁴ − (s*(v,Δv)/s)² ]

where s is the true bumper-to-bumper gap to the vehicle ahead, v0 is the desired free-flow speed, and the desired dynamic gap is

s*(v,Δv) = s0 + max(0, v·T + v·Δv / (2·√(a_max·b)))

s0 is a minimum jam spacing, T is the time headway the driver keeps, Δv is the closing speed to the leader, and b is the comfortable braking deceleration. Every car on the mainline and the ramp runs this exact equation every frame — nothing is scripted or pre-baked.

Two mainline lanes feed a short merge zone where a single ramp lane joins from the right. A ramp vehicle waits for a safe gap in the nearest mainline lane (checked against the same IDM safe-gap logic) before merging; if the gap never opens it queues, exactly like a real on-ramp backing up. Raise the ramp inflow slider and watch mainline lane 2 slow first, a shockwave propagate backward through following traffic, and eventually the queue spill onto the ramp itself — capacity drop in miniature.

Switch to the fundamental diagram view to see flow (veh/h) plotted against density (veh/km) as the simulation runs: the cloud of points traces the classic uncongested rising branch, a capacity peak near the merge's bottleneck flow, and the falling congested branch once density passes it. The space-time view plots each mainline car's position over time; congestion shows up as diagonal dark bands drifting upstream (against traffic) from the merge point — the real, characteristic signature of a traffic shockwave.

This is the flat 2D companion to the 3D signal-grid traffic simulation: instead of a city grid governed by traffic lights, this is a single uncontrolled highway bottleneck governed purely by car-following physics and ramp merging — the mechanism road engineers actually use to size on-ramps and metering rates.