Lay of the Land
All methods

Dynamic analysis with SWMM

Where steady calculations run out, a design goes to EPA SWMM 5, a widely used public model that solves the full dynamic wave equations. It's also an independent check on the steady engine, since nothing here is shared with it.

The model

swmmInput in packages/hydraulics writes SWMM's input file from a design at its steady design flow.

  • Laterals are lumped into inflows where they join. What's modeled is the mains and submains, which is what backwater and surcharge are about, and it keeps thousands of short laterals from making it unstable. A lateral's water comes in where it reaches a trunk, even if it goes through other laterals first.
  • A trunk's own land comes in at its upstream end, which reads slightly high for that pipe alone, and evens out by the next one.
  • Pipes under 30 m merge into the next one down, since they'd otherwise need a time step too small to run. A merged pipe has no result of its own, and what arrived partway along it goes in at the lower end. They don't merge across a place where trunks come together, or into an outlet.
  • Nodes sit at the lowest invert touching them, with offsets for pipes coming in higher, and go up to the ground, so that water coming out of the ground shows up as flooding.
  • An outlet is a free outfall, or a fixed stage where a design tailwater's been recorded.

It's a constant inflow for 12 hours, which settles from empty on any field-sized network. Rainfall and storms aren't part of this.

Running it

hydraulics.simulate is a job for the GIS worker, which runs SWMM 5.2.4 through swmm-toolkit. The model comes whole from the job, and is written in TypeScript. conda-forge has no build of swmm-toolkit for both of the worker's platforms, so that one comes from PyPI, pinned by hash in services/gis-worker/requirements.txt.

The model arrives from a browser, so the worker runs only what swmmInput could have written: the thirteen sections and nineteen options it uses, each spelled the way it writes them. SWMM itself reads loosely. It takes [FILE] or [FILESX] as its [FILES] section, which names files to read and write, and a line past 1,023 characters as two lines, so a check for the dangerous names alone was got round. A FILE in a time series, rain gage, evaporation or temperature line is refused as well, should one of those sections ever be allowed. SWMM runs in a child process that's stopped at a deadline, in a folder that's thrown away afterwards. tests/fixtures/swmm/sections.json is the list, and a test on each side holds the builder and the worker to it, so a section or option added to the builder has to be added there and in simulate.py.

"Simulate" in the panel sends the design as it stands. What comes back is from the end of the run, when a constant inflow has settled, and says which design it was of, so the panel can say if it's changed since.

How it compares with the steady engine

swmm-cross-check.test.ts writes out models of known cases along with what the steady engine says about them, and test_swmm.py runs them in real SWMM. So a change to either side has to keep the two agreeing.

Case SWMM's continuity error Worst difference in head Worst difference in flow
One pipe, mild, free outfall -0.24% +1.7 cm -0.02%
One pipe, mild, low tailwater -0.03% +0.9 cm -0.02%
One pipe, mild, high tailwater -0.01% 0.0 cm -0.02%
One short pipe, backed up all along it -0.01% -0.5 cm 0.00%
One pipe, steep, free outfall -0.14% 0.0 cm -0.02%
One pipe under pressure from its tailwater +0.01% 0.0 cm -0.02%
One pipe under pressure from too much flow +0.01% 0.0 cm 0.00%
A main gathering flow, free outfall -0.11% +1.2 cm 0.00%
A main gathering flow, backed up +0.02% -0.6 cm 0.00%

The two share no code and reach this by different methods: the steady engine by the gradually varied flow equation, and SWMM by solving the dynamic wave equations until they settle. These are clean cases on a single size of pipe with no losses at junctions. Real designs add those, which the steady engine leaves out and SWMM doesn't take much account of here either, so differences there can be larger, and the panel shows them for each design.

Across the benchmarks

benchmarks/swmm.test.ts writes out the benchmark designs (benchmarks.md) the same way, and test_swmm.py runs them too. Two soils has no terrain, so it isn't modeled. A design that's only one lateral is modeled as that one pipe, since SWMM's model is otherwise only mains and submains. Measured on 2026-11-08:

Case SWMM's continuity error Difference in head Difference in flow Out of the ground
Flat ground -1.12% +2.4 cm +0.01% None
Restricted outlet, as measured 0.00% Not compared 0.00% 1.410 × 10⁻⁴ m³/s at the top, against the outlet check's 1.410 × 10⁻⁴ excess
Restricted outlet, tailwater only 0.00% 0.0 cm +0.01% None
Several junctions -0.05% -0.5 to +0.4 cm +0.01% None
Pumped outlet 0.00% Not compared +0.01% None
  • The flows are 0.01% high because the input file gives them to six decimal places: 0.000441 for 0.000440972.
  • Flat ground's continuity error is over the 0.5% allowed elsewhere, so that case allows 1.5%. It's one 400 m conduit filling from empty at 0.9 L/s. Its settled head and flow agree, though its head is the largest difference here, against the 2.5 cm allowed.
  • Where an outlet can't take the flow, SWMM holds the pipe to what it can, 3.0 × 10⁻⁴ m³/s, and the rest comes out of the ground at the top. The steady gradeline doesn't apply the outlet's capacity, and leaves it to the outlet check, so its heads aren't comparable there. That's why the same design is also run without the ditch's capacity, where the water backed up from the tailwater agrees to a tenth of a millimeter.
  • A merged conduit carries what its first pipe does, since SWMM takes in what arrives partway along at its lower end, so that's the flow it's compared with.
  • A wet well's level is the pump's to decide, so it isn't compared.

Lift stations

A lift station is a storage node for its wet well, up to the ground so that water coming out of the ground shows as flooding. A pump link on the pump's own curve (SWMM's Pump3, head against flow) runs from it to a junction of its own at the start of the force main. Pumps running together are one link with their flows added. A station only laterals feed takes its level from where they arrive, since laterals come in as inflow rather than as conduits. Force main nodes get 300 m of surcharge depth, so pressure in the pipe doesn't count as water leaving the ground. With nobody having said what size the wet well is, it's NRCS's "circular well 8 feet or less" at 8 ft.

The pump has no start and stop levels here. At a constant inflow it would only cycle, and the final period could land anywhere in a cycle. Always on, it settles at pumping what comes in, which is what's compared. So this says nothing about cycling, which the wet well panel works out from NRCS's formula.

Force mains are SWMM's plain circular conduits with Manning's n, not its force main shape, to stay the same calculation as the steady engine.

What can be tried besides the design:

  • Power out: the pump is off and the check valve holds.
  • Power out, check valve failed: SWMM's pump link can't run backward, so a plain 30 m pipe of the force main's size stands in for the pump, and there's no flap on the force main. This is a modeling device, and its length adds a little friction.

What an outlet can take is held to in any scenario, as the most flow allowed in the one conduit reaching it (receiving_capacity), and what can't get through backs up. With several conduits reaching one outlet, nothing says how they'd share it, so it's left to the outlet check.

Checked in real SWMM 5.2.4, in test_swmm.py, against cases the engine writes out:

Case Force main, m³/s Out of the ground at the wet well, m³/s
As designed, free outfall 0.02000, the inflow 0
As designed, against a tailwater 0.02000 0
Held to 0.012 by the outlet 0.01200 0.00800, the rest
Power out, check valve holding 0 0.02000, the inflow
Power out against a high outlet, check valve holding 0 0.02000
Check valve failed, outlet low 0, as it can't run uphill 0.02000
Check valve failed, outlet high -0.02443, against -0.0244 by hand 0.04443

SWMM's continuity error is larger when water floods, at 1.7% to 3.9% in the last five of these over the 3 simulated hours, against 0.05% to 0.13% in the first two. The panel shows it with those results. The flows in the settled final period still come out as above.