Market Bar Flow 2D

Plan view of the market hall: hover a visitor, switch on the density map, and compare the queue with Erlang-C theory.

Presets

Playback

What to try
  • Press Lunch rush, then Narrow exit: watch the queue at the bar saturate (utilisation above 100 %) and, separately, the crowd compress in front of a 1 m door.
  • Set the exit to 10 m and ordering to 0 %: the stream flows freely at the desired speed and the trip time equals the free-walk time.
  • Change only the number of serving stations at a fixed load and compare the simulated wait with the Erlang-C value.
  • Switch on the density map: the hot spots appear at the bar queues and in front of the door.
  • Raise social repulsion A: people keep more distance, the density at the door falls and the flow per metre drops a little.

Hall, crowd and bar

Options

Time

Layers

Model check

The science

A crowd as a fluid made of people

Seen from far away a stream of walkers behaves like a compressible fluid. With density ρ (persons per m²) and mean velocity v, conservation of people is the continuity equation ∂ρ/∂t + ∇·(ρ v) = 0, and the flow through a cross-section of width W is J = ρ v W (persons per second). Unlike water, people choose their speed: the walking speed falls as the density rises, which is why a door has a capacity. Near a bar, a counter and a queue also act like a partly blocked pipe.

The social force model (Helbing and Molnár, 1995; Helbing, Farkas and Vicsek, 2000)

Every visitor i is a disc of radius ri (0.23–0.28 m) and mass mi (60–95 kg) that obeys Newton's law with three kinds of force:

m dv/dt = m (v0 e − v)/τ + Σj [A e(rij − dij)/B w(φ) + k g(rij − dij)] nij + κ g(rij − dij) Δvt tij + (same terms for walls, columns, stalls and the counter)

  • Driving force m (v0 e − v)/τ: the person wants to walk at speed v0 (mean 1.34 m/s, with a 9 % spread) towards the next target e and relaxes to it in the reaction time τ (default 0.5 s). A single walker therefore accelerates as v(t) = v0(1 − e−t/τ).
  • Social repulsion A e(rij − dij)/B with A = 2000 N (slider) and range B = 0.08 m: people keep a personal distance. The factor w(φ) = λ + (1 − λ)(1 + cos φ)/2 (λ = 0.75) weakens the force from people behind, who cannot be seen.
  • Body force and friction act only when two discs overlap (g(x) = x for x > 0, otherwise 0): a stiff push-apart k = 1.2×105 N/m and sliding friction κ = 2.4×105 kg/(m s) on the tangential velocity difference. They create the jamming and the slow-down in a dense crowd.

Equations are integrated with a semi-implicit Euler step of 8 ms (4 ms in the numerical checks); neighbours are found with a uniform 1.2 m grid, so 260 visitors cost well under a millisecond per step.

How the visitors behave

Arrivals form a Poisson process with the chosen rate (exponential gaps). A visitor decides at the entrance whether to order a drink (probability = the slider). Those who do join the shortest of the station queues at 4.8 m from the counter (ties go to the nearest), stand 0.58 m apart in a line perpendicular to the counter, are served for S = Ts (0.7 to 1.3) seconds once they reach the front, and leave towards the exit with a mug. If every queue already holds 8 people the visitor gives up and walks on. All others walk straight for the exit door; columns, stalls and the queues of other people split the stream into lanes by themselves.

Fundamental diagram and the door

The scatter plot samples 2 × 2 m cells of the hall each second: density ρ = n/4 m² against the mean speed of the moving people inside. The dashed curve is the empirical fit of Weidmann (1993), v(ρ) = v0 [1 − exp(−1.913 (1/ρ − 1/ρmax))] with ρmax = 5.4 persons/m². Because J = ρ v W this curve has a maximum: flow first grows with density and then collapses in a jam. At the exit the flow per metre of width saturates; field and laboratory measurements give roughly 1.3 persons per second per metre as a design value and up to about 1.9 in the best cases. The dashed yellow line in the first graph is the 1.9 p/(m s) estimate for the chosen door width; the model gives 1.5 to 2.2 once the crowd is saturated.

The bar as a queueing system

With c serving stations, ordering rate λo = λ · (share ordering) and mean service time Ts, the offered load is a = λo Ts and the utilisation ρ = a/c. For Poisson arrivals and exponential service (M/M/c) the mean waiting time is given by the Erlang-C formula Wq = C(c, a) / (c/Ts − λo), C(c,a) = [ac/c! · 1/(1 − ρ)] / [Σk<c ak/k! + ac/c! · 1/(1 − ρ)]. When ρ ≥ 1 the queue grows without limit (here it is cut at 8 people per station). The page shows this value next to the simulated wait. They differ because service times are less variable than exponential (shorter real waits), the join-shortest-queue rule is better than random choice, and stepping up to the counter takes a second or two.

The three numerical checks

(1) Relaxation: one walker alone must follow v(t) = v0(1 − e−t/τ). (2) Wall standoff: a walker pushing with its full desired force against a wall stops where repulsion balances the driving force, A e(r − d)/B = m v0/τ, i.e. d = r − B ln(m v0/(τ A)) (about 43 cm for the defaults). (3) Flow conservation: in a steady corridor the flux counted as head crossings of a line must equal the Eulerian estimate q = Σ vx Δt / (L T) over a 2 m strip (Edie's definition), and no person may be created or lost. Checks use the current τ and A.

Honest simplifications

Visitors are round discs with one shared radius range, not two-dimensional bodies with arms and bags; there are no groups, families, children, wheelchairs or purchases of produce, and nobody looks at the stalls. Walking and standing are the only behaviours (no sitting, no overtaking-by-choice or counter-flow). The simple social-force model lets very hurried crowds squeeze through a door more easily than real people do, so the “faster is slower” effect is not reproduced here and the speed slider is limited to 2 m/s. Hall dimensions (30 × 10 m, stalls 0.9 m deep, bar 12 m long) are an illustrative layout, not a measured building. Use the figures to compare cases, not to certify a real venue for safety.

Throughput and people inside
Fundamental diagram: speed vs density
Customers waiting at the bar
Trip time distribution
Made with 🟠 Blender · Three.js