Stormwater Management Model (SWMM)
repository·develop·Indexed 43 days ago
https://github.com/usepa/stormwater-management-modelA professional-grade hydrology-hydraulic simulation solver for modeling runoff quantity and quality in urban areas. Implemented in C, SWMM supports single-event and continuous long-term simulations. Version 5.2 introduces HEC-22 inlet analysis, conical and pyramidal storage units, Type5 variable speed pumps, and advanced control rules with named variables and arithmetic expressions.
What's inside SWMM
- The Stormwater Management Model (SWMM) is a dynamic hydrology-hydraulic water quality simulation model. It is designed for both single-event and long-term (continuous) simulations of runoff quantity and quality, primarily in urban environments. The solver is implemented in the C programming language and is released in the Public Domain.
Implement HEC-22 Inlet Analysis
developSWMM 5.2+ supports HEC-22 methodology to model surface runoff captured by street inlets and sent to a below-ground drainage system. This requires three specific input sections:
[STREETS]for cross-section geometry,[INLETS]for inlet designs, and[INLET_USAGE]to link inlets to conduits and sewer nodes.Key Implementation Details:
- Curb & Gutter inlets: Must be used with street conduits.
- Drop inlets: Must be used with trapezoidal channels.
- Routing Compatibility: Works with all routing procedures. For Kinematic Wave and Steady Flow, it is recommended to use storage nodes at the end of inlet conduits that converge at sag points to prevent non-captured flow from exiting the system.
- Flow Dynamics: Captured flow is limited by the capacity of the receiving sewer node to prevent flooding. If the sewer node is at capacity, excess flow is sent back through the inlet onto the street.
- Reporting: A new 'Street Flow' table in the Status Report provides peak flow, roadway spread/depth, capture efficiency, and backflow frequency.
Windows build dependencies for SWMM
developThe following dependencies must be installed on your Windows system before attempting to build SWMM:
- Build Tools for Visual Studio 2017
- CMake 3.13
Build the SWMM 5.2 engine on Linux or MacOS
developTo build the SWMM 5.2 engine shared object library (
libswmm5.so) and the command line executable (runswmm) on Linux or MacOS, use CMake to generate and run the build.Steps:
- Create and enter a build directory:
mkdir build cd build - Generate the build system:
cmake .. - Compile the project:
cmake --build .
Outputs: The files
libswmm5.soandrunswmmwill be located in thebuilddirectory.mkdir build cd build cmake .. cmake --build .- Create and enter a build directory:
Build SWMM locally on Windows
developTo build the Stormwater Management Model (SWMM) on a Windows environment, ensure you have the required build tools installed and then execute the provided build script from the project root.
cd swmm tools\make.cmdVerify CMake installation
developThe SWMM 5.2 build process requires CMake version 3.5 or higher. You can verify your installed version by running the following command in your console:
cmake --versionBuild the SWMM 5.2 engine on Windows
developTo build the SWMM 5.2 engine library (
swmm5.dll) and the command line executable (runswmm.exe) on Windows, you must use CMake and a Microsoft Visual Studio C compiler.Prerequisites:
- CMake version 3.5 or higher.
- Microsoft Visual Studio C compiler.
Steps:
- Open a console and navigate to the project root directory.
- Create and enter a build directory:
mkdir build cd build - Generate the build system using CMake. Replace
<compiler>with your specific Visual Studio version (e.g.,"Visual Studio 16 2019") and<platform>withWin32orx64:cmake -G <compiler> .. -A <platform> - Compile the project in Release mode:
cmake --build . --config Release
Outputs: The files
swmm5.dllandrunswmm.exewill be located in thebuild\Releasedirectory.mkdir build cd build cmake -G "Visual Studio 16 2019" .. -A x64 cmake --build . --config ReleaseUse Named Variables and Arithmetic in Control Rules
developSWMM 5.2 allows for more complex control logic using Named Variables and Arithmetic Expressions.
Named Variables
Variables act as aliases for object attributes. They are defined using the format:
VARIABLE name = object type name attributeExample:
[RULES] VARIABLE Dabc = NODE abc DEPTH VARIABLE Defg = NODE efg DEPTH VARIABLE P45 = PUMP 45 STATUS RULE 1 IF Dabc > Defg AND P45 = OFF THEN PUMP 45 STATUS = ONArithmetic Expressions
You can define mathematical expressions using named variables. They are defined using the format:
EXPRESSION name = f(variable1, variable2, ...)Example:
[RULES] VARIABLE Q1 = LINK 1 FLOW VARIABLE Q2 = LINK 2 FLOW VARIABLE Q3 = LINK 3 FLOW EXPRESSION Net_Inflow = (Q1 + Q2)/2 - Q3 RULE 1 IF Net_Inflow > 0.1 THEN ORIFICE 3 SETTING = 1 ELSE ORIFICE 3 SETTING = 0.5[RULES] VARIABLE Dabc = NODE abc DEPTH VARIABLE Defg = NODE efg DEPTH VARIABLE P45 = PUMP 45 STATUS RULE 1 IF Dabc > Defg AND P45 = OFF THEN PUMP 45 STATUS = ONConfigure the [INLET_USAGE] section
developThe
[INLET_USAGE]section assigns specific inlet designs to street conduits.Format:
Link Inlet Node (Number %Clogged Qmax aLocal wLocal Placement)Parameter Description Linkname of street conduit containing the inlet Inletname of inlet structure to place in street Nodename of sewer node receiving flow intercepted by inlet Numbernumber of inlets placed on each side of street (default: 1) %Cloggeddegree to which inlet capacity is reduced due to clogging (%) (default: 0) Qmaxmaximum flow that inlet can intercept (0 = no restriction) aLocalheight of local gutter depression (in or mm) wLocalwidth of local gutter depression (ft or m) PlacementAUTOMATIC,ON_GRADE, orON_SAG(default:AUTOMATIC)Notes:
AUTOMATICplacement lets SWMM decide based on topography.- Local gutter depression (
aLocal,wLocal) applies only over the length of the inlet.
Link Inlet Node (Number %Clogged Qmax aLocal wLocal Placement)Configure the [STREETS] section
developThe
[STREETS]section defines the dimensions of street cross-sections used in the project. Each unique cross-section requires one line.Format:
Name Tcrown Hcurb Sx nRoad a W Sides Tback Sback nBackParameter Description NameID name assigned to street cross section Tcrowndistance from curb to street crown (ft or m) Hcurbcurb height (ft or m) Sxstreet cross slope (%) nRoadManning's n of street surface agutter depression height (in or mm) Wgutter width (ft or m) Sides1 for single sided street or 2 for two-sided street Tbackstreet backing width (ft or m) Sbackstreet backing slope (%) nBackstreet backing Manning's n Usage Notes:
- If
a(gutter depression) is 0, the gutter widthWis ignored. - If there is no backing, the three backing parameters (
Tback,Sback,nBack) can be omitted. - To apply a street section to a conduit, add a line to the
[XSECTIONS]section using the format:ConduitID STREET StreetSectionName.
Name Tcrown Hcurb Sx nRoad a W Sides Tback Sback nBack- If
Define Conical and Pyramidal Storage Units
developSWMM 5.2 introduces two new functional shapes for surface area vs. depth curves in the
[STORAGE]section.1. Conical (truncated elliptical cone): Uses the equation:
Area = PI * (L*W/4 + W*Z*Depth + (W/L)*(Z*Depth)^2)2. Pyramidal (truncated rectangular pyramid): Uses the equation:
Area = L*W + (L+W)*Z*Depth + (2*Z*Depth)^2Input Format:
node elev maxDepth initDepth SHAPE L W Z 0 fEvap (infil)Parameter Description nodename of a storage node elevelevation of the node's invert maxDepthmaximum height of stored water initDepthinitial height of stored water Llength of the longer side of the base Wwidth of the shorter side of the base Zside slope (run/rise) fEvapfraction of potential evaporation realized infiloptional infiltration parameters Example:
[STORAGE] node1 10.0 5.0 0.0 CONICAL 10 5 0.5 0 0.1 node2 12.0 3.0 1.0 PYRAMIDAL 8 4 0.3 0 0.05[STORAGE] node elev maxDepth initDepth CONICAL L W Z 0 fEvap (infil) node elev maxDepth initDepth PYRAMIDAL L W Z 0 fEvap (infil)Configure the [INLETS] section
developThe
[INLETS]section defines the design of inlet structures. Different types of inlets use different formats.Formats:
- GRATE:
Name GRATE Length Width Type (Aopen Vsplash) - CURB:
Name CURB Length Height Throat - SLOTTED:
Name SLOTTED Length Width - CUSTOM:
Name CUSTOM GradeCurve (SagCurve)
Grate Types:
P_BAR-50,P_BAR-50x100,P_BAR-30,CURVED_VANE,TILT_BAR-45,TILT_BAR-30,RETICULINE,GENERIC.- For
GENERICgrates, you must provideAopen(fraction of area open) andVsplash(splash over velocity).
Other Parameters:
Throat: For CURB inlets (HORIZONTAL,INCLINED, orVERTICAL).GradeCurve: For CUSTOM on-grade inlets (Diversion-type curve).SagCurve: For CUSTOM on-sag inlets (Rating-type curve).
Examples:
; A 2-ft x 2-ft parallel bar grate InletType1 GRATE 2 2 P-BAR-30 ; A combination inlet (use same ID for both lines) InletType2 GRATE 2 2 CURVED_VANE InletType2 CURB 4 0.5 HORIZONTAL ; A custom inlet using Curve1 as its capture curve InletType3 CUSTOM Curve1; A 2-ft x 2-ft parallel bar grate InletType1 GRATE 2 2 P-BAR-30 ; A combination inlet InletType2 GRATE 2 2 CURVED_VANE InletType2 CURB 4 0.5 HORIZONTAL ; A custom inlet using Curve1 as its capture curve InletType3 CUSTOM Curve1- GRATE: