External inflows#
Note
Engine: OpenSWMM 6 — refactored. Documents
openswmm.engine.Inflows.
The Inflows class registers static external inflows on nodes
at configure time:
External inflows — time-series flow with optional scale/baseline.
Dry-Weather Flow (DWF) — average flow with up to 4 multiplicative patterns (monthly / weekly / daily / hourly).
Rainfall-Dependent Inflow & Infiltration (RDII) — driven by a unit hydrograph attached to a sewershed area.
For overrides applied during a running simulation (per-step
lateral inflows), see Nodes.set_lateral_inflow (one-shot)
or Forcing.node_lat_inflow (persistent).
Reference: openswmm_inflows.h.
Class signature#
class Inflows:
def __init__(self, solver: Solver) -> None: ...
Key methods#
External inflows (time-series)#
Method |
Action / returns |
|---|---|
|
Attach a time-series-driven inflow to a node. |
|
Number of registered external inflows. |
type— pollutant index, or-1for hydraulic flow.mfactor— units conversion multiplier.sfactor— scaling factor.baseline— baseline flow added on top of the time series.basepat_idx— optional pattern index multiplying the baseline.
Dry-Weather Flow#
Method |
Action / returns |
|---|---|
|
Attach DWF with up to 4 patterns. |
|
Number of registered DWF entries. |
type— pollutant index, or-1for hydraulic flow.base_value— average dry-weather flow.pattern_idxs— list of up to 4Patternindices (monthly, daily, hourly, weekend-hourly). Use-1to skip a slot.
RDII#
Method |
Action / returns |
|---|---|
|
Attach RDII at a node, driven by a named unit hydrograph and a sewershed area. |
|
Number of registered RDII entries. |
End-to-end example#
from openswmm.engine import Solver, Inflows, Nodes, Tables
with Solver("site_drainage.inp", "site_drainage.rpt", "site_drainage.out") as s:
nodes = Nodes(s)
tables = Tables(s)
inflows = Inflows(s)
ts_idx = tables.get_index("WET_WEATHER_TS")
node_idx = nodes.get_index("J1")
# Attach a flow time series to J1 (during model edit phase, before initialize)
s.open()
inflows.add_external(
node_idx=node_idx,
ts_idx=ts_idx,
type=-1, # hydraulic flow
mfactor=1.0, # no unit conversion
sfactor=1.0, # no scaling
baseline=0.05, # cfs baseline
basepat_idx=-1, # no pattern on baseline
)
s.initialize()
s.start()
while s.step():
pass
s.end()
print(f"External inflows registered: {inflows.ext_inflow_count()}")
Common recipes#
Add Dry-Weather Flow with monthly + hourly patterns#
monthly_idx = tables.get_index("MONTHLY_PATTERN")
daily_idx = tables.get_index("DAILY_PATTERN")
hourly_idx = tables.get_index("HOURLY_PATTERN")
inflows.add_dwf(
node_idx=nodes.get_index("J1"),
type=-1,
base_value=0.5, # average DWF
pattern_idxs=[monthly_idx, daily_idx, hourly_idx, -1],
)
Add RDII to a node#
inflows.add_rdii(
node_idx=nodes.get_index("J1"),
uh_name="UH1", # unit hydrograph defined in [HYDROGRAPHS]
area=12.5, # sewershed area
)
Combine baseline + scaling for unit conversion#
# Time series in m³/s, model in CFS:
inflows.add_external(
node_idx=nodes.get_index("J1"),
ts_idx=tables.get_index("INFLOW_M3S"),
type=-1,
mfactor=35.3147, # m³/s → cfs
sfactor=1.0,
baseline=0.0,
basepat_idx=-1,
)
Bulk arrays#
The Inflows class is a registration surface, not a per-step
data accessor. For per-step inflow values, use
Nodes.get_lateral_inflow() (per-node) or OutputReader
post-run (Output reader (binary .out file)).
EngineState requirements & exceptions#
Method group |
Required state |
Notes |
|---|---|---|
registration setters ( |
|
Must be done before |
count accessors |
|
n/a |
Common EngineError codes:
INVALID_INDEX— node, table, or pattern index out of range.INVALID_TYPE— pollutant index given for a non-quality model.
See also#
Advanced forcing — runtime overrides that bypass the registered inflows.
Tables (time series, curves, patterns) — define the time series and patterns that drive inflows.
Nodes — observe the inflow state during the run.