Engine check: EPA SWMM 5.2.4
Summary. Rillwork runs EPA SWMM 5.2.4, compiled to WebAssembly from EPA's own C source with no changes. All 73 example and regression models in EPA's test suite give the same results as a native build of the same source. Against EPA's own Windows build, the only differences are tiny rounding differences in the maths library.
The engine
- Source: EPA's Storm Water Management Model, tag v5.2.4, from EPA's official repository (github.com/USEPA/Stormwater-Management-Model). It is a US Government work and public domain.
- Unmodified: Rillwork does not change EPA's code. The small wrapper around it only stages your files for the engine (for example converting Windows line endings, as EPA's Windows program does).
- Stated in every report: the drainage report names the engine and its version.
What we compared
Every model in EPA's test suite (73 models: EPA's examples and the extran, routing, swc, update and user regression sets) was run in four builds of the same source:
| Build | Compiler and maths library | Role |
|---|---|---|
| WebAssembly | Emscripten (clang), musl maths library | What Rillwork runs |
| Native, same maths library | clang for x86-64 Windows, musl maths library | Isolates the CPU target from everything else |
| EPA release settings | Microsoft C compiler, EPA's own CMake release build (fast floating point) | EPA's Windows build |
| Strict floating point | Microsoft C compiler, strict IEEE floating point | Shows how much EPA's own builds differ from each other |
For each model we compared the binary results file (.out), value by value, and the text report (.rpt), ignoring only the three wall-clock lines (analysis begun, ended, elapsed time).
Results
| Comparison | Result |
|---|---|
| WebAssembly vs native build with the same maths library | 73 of 73 models: bit-identical results files. Reports identical, apart from one extra warning line explained below. |
| WebAssembly vs EPA's Windows release build | Most models bit-identical; the rest differ by last-digit rounding. Typical largest difference: under 0.001 % of a series' peak. Largest: a few rounding-sensitive models (for example EPA's user5, user1 and Example1). |
| EPA's release build vs EPA's strict build (same compiler) | Differences of the same order on the same models: this is the spread EPA's own Windows program already has. |
| WebAssembly in the browser vs WebAssembly in Node | 73 of 73 identical results files and reports. |
One EPA model (ncdc_format.inp) stops with an input error in every build, EPA's included; that counts as the same result.
The differences, explained
- Maths-library rounding. Functions such as
pow,expandlogcan round the last bit differently in Microsoft's C runtime and in musl. A native build that uses musl's maths functions is bit-identical to the WebAssembly build on every model, so nothing else differs. How much a model's results move depends on how sensitive that model is to rounding; EPA's fast and strict Windows builds already differ by the same amount. - An extra "WARNING 09" on some models. For rain time series with a single point, EPA's code converts a very large number to an integer, which C leaves undefined. On x86-64 it gives no warning; in WebAssembly the report adds "time series interval greater than recording interval". The results files are bit-identical. Fixing it would mean changing EPA's code, which we do not do.
- Line endings and file paths. EPA's Windows program reads text files with Windows line endings and Windows paths. The wrapper converts line endings and stages data files under the names the model uses, so the engine sees the same input it would on Windows.
What this does not cover
The check shows that Rillwork runs EPA's engine faithfully. It does not show that a model is right for a project: the inputs, the method and the engineering judgement remain the responsibility of the engineer using the software.
Source of this summary: the project's engine-gate report (docs/ENGINE-GATE.md in the Rillwork source), generated by its native-vs-WebAssembly comparison scripts, and the browser gate (docs/BROWSER-GATE.md).