IMO Test 4 — Exit flow rate¶

Definition¶

One hundred occupants evacuate through a 1 m exit. The exit flow should not exceed 1.33 persons/s.

The project enables the exit throughput limiter at 1.33 persons/s and applies its existing numerical tolerance. Unthrottled flow is reported for comparison but is not an acceptance criterion.

The exit is represented by a 1 × 1 m absorbing square inside the room rather than a wall opening.

Source: IMO MSC.1/Circ.1533, Annex 3, Test 4.

In [1]:
from datetime import datetime, timezone

print(datetime.now(timezone.utc).isoformat())
2026-12-01T15:30:05.381113+00:00
In [2]:
import sys
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from shapely import wkt
from shapely.geometry import Polygon

repository = Path.cwd().parents[1]
sys.path.insert(0, str(repository / "tests" / "vv"))
sys.path.insert(0, str(repository / "standards" / "rimea"))
sys.path.insert(0, str(repository / "standards"))

from vv_helpers import (
    run_vv_scenario,
    agents_outside_polygon,
    specific_exit_flow,
    with_flow_limiter,
    MAX_SPECIFIC_FLOW,
    FLOW_CAP_TOLERANCE,
)

from imo.scenario_builders.imo04_exit_flow import build_scenario
In [3]:
plt.rcParams.update({
    "figure.facecolor": "white",
    "axes.facecolor": "#f7f7f5",
    "axes.spines.top": False,
    "axes.spines.right": False,
    "font.size": 11,
    "figure.dpi": 120,
})

Scenario¶

The geometry, exit and population distribution are loaded from the same scenario definition used by pytest.

In [4]:
scenario = build_scenario()

geometry = wkt.loads(scenario["walkable_area_wkt"])

distribution = next(
    iter(scenario["distributions"].values())
)

exit_definition = next(
    iter(scenario["exits"].values())
)

parameters = distribution["parameters"]

print(f"Population: {parameters['number']}")
print(f"Desired speed: {parameters['v0']} m/s")
print(f"Agent radius: {parameters['radius']} m")
Population: 100
Desired speed: 1.2 m/s
Agent radius: 0.15 m
In [5]:
def draw_geometry(ax):
    x, y = geometry.exterior.xy
    ax.plot(x, y, color="black", linewidth=1.5)

    for interior in geometry.interiors:
        x, y = interior.xy
        ax.plot(x, y, color="black")

    ax.set(
        xlabel="x [m]",
        ylabel="y [m]",
        aspect="equal",
    )

fig, ax = plt.subplots(figsize=(10, 5))
draw_geometry(ax)

for definition, color, label in [
    (distribution, "tab:blue", "Starting region"),
    (exit_definition, "tab:green", "Exit"),
]:
    polygon = Polygon(definition["coordinates"])
    x, y = polygon.exterior.xy

    ax.fill(x, y, color=color, alpha=0.25, label=label)

ax.set_title("Scenario geometry")
ax.legend()
plt.tight_layout()
plt.show()
No description has been provided for this image

Simulation¶

The simulation uses the existing verification runner and the original pytest simulation settings.

In [6]:
results = {}
trajectories = {}
flows = {}

for limiter_on in (False, True):
    settings = build_scenario()

    settings["exits"] = with_flow_limiter(
        settings["exits"],
        limiter_on,
        MAX_SPECIFIC_FLOW,
    )

    metrics, trajectory = run_vv_scenario(
        **settings,
        max_simulation_time=300.0,
    )

    results[limiter_on] = metrics
    trajectories[limiter_on] = trajectory

    flows[limiter_on] = specific_exit_flow(
        trajectory.data,
        trajectory.frame_rate,
    )

    print(
        f"Limiter {limiter_on}: "
        f"{flows[limiter_on]:.3f} persons/s"
    )
Limiter False: 5.789 persons/s
Limiter True: 1.316 persons/s

Results¶

Exit flow is compared with and without throughput throttling. Only the throttled case is subject to the flow-cap acceptance criterion.

In [7]:
cap = MAX_SPECIFIC_FLOW * (1 + FLOW_CAP_TOLERANCE)

fig, axes = plt.subplots(1, 2, figsize=(12, 4))

for limiter_on in (False, True):
    trajectory = trajectories[limiter_on]

    exit_frames = (
        trajectory.data.groupby("id")["frame"]
        .max()
        .sort_values()
        .to_numpy()
    )

    exit_times = exit_frames / trajectory.frame_rate

    axes[0].step(
        exit_times,
        np.arange(1, len(exit_times) + 1),
        where="post",
        label=f"Limiter {'on' if limiter_on else 'off'}",
    )

axes[0].set(
    xlabel="Time [s]",
    ylabel="Cumulative completed trajectories",
    title="Evacuation progress",
)

axes[0].legend()

axes[1].bar(
    ["Limiter off", "Limiter on"],
    [flows[False], flows[True]],
)

axes[1].axhline(
    MAX_SPECIFIC_FLOW,
    color="black", linestyle="--",
    label="Nominal flow cap",
)

axes[1].axhline(
    cap,
    color="tab:red", linestyle=":",
    label="Acceptance limit",
)

axes[1].set(
    ylabel="Flow [persons/s]",
    title="Exit flow comparison",
)

axes[1].legend()
plt.tight_layout()
plt.show()
No description has been provided for this image

Acceptance criteria¶

  • The unthrottled scenario contains 100 occupants.
  • All occupants evacuate in both configurations.
  • The throttled flow does not exceed the nominal cap plus the existing project tolerance.
  • Unthrottled flow is informational only.
In [8]:
assert results[False]["total_agents"] == 100

for metrics in results.values():
    assert metrics["agents_remaining"] == 0

print(f"Nominal cap: {MAX_SPECIFIC_FLOW:.3f} persons/s")
print(f"Acceptance limit: {cap:.3f} persons/s")
print(f"Measured throttled flow: {flows[True]:.3f} persons/s")

assert flows[True] <= cap

print("All acceptance criteria passed.")
Nominal cap: 1.330 persons/s
Acceptance limit: 1.343 persons/s
Measured throttled flow: 1.316 persons/s
All acceptance criteria passed.