Advanced forcing#
Note
Engine: OpenSWMM 6 — refactored.
The Forcing view reached via solver.forcing overrides
runtime state across node, link, subcatchment, and gage domains. It is
the long-form alternative to the per-object setters
(Node.lateral_inflow = ...) and adds two important knobs:
mode (
ForcingMode) —REPLACEoverwrites the engine-computed value;ADDadds to it.persist —
False(default) means one-shot for the next step;Truekeeps the forcing active every step until cleared.
Reference: openswmm_forcing.h.
Quickstart#
from openswmm.engine import Solver, ForcingMode, ForcingTarget
with Solver("model.inp") as s:
# One-shot — overwritten by the engine on the next step.
s.forcing.node_lat_inflow("J1", 0.5)
# Sticky add — survives every step until cleared.
s.forcing.node_lat_inflow(
"J1", 0.1,
mode=ForcingMode.ADD,
persist=True,
)
for _ in s.steps():
pass
# Clear one forcing or everything.
s.forcing.clear(ForcingTarget.NODE, "J1")
s.forcing.clear_all()
Methods#
Every method accepts an object selector (int | str), the new value,
plus keyword-only mode (defaulting to ForcingMode.REPLACE) and
persist (defaulting to False).
Method |
Forces … |
|---|---|
|
Lateral inflow at a node. |
|
Head boundary at a node. |
|
Quality mass-flux at a node. |
|
Flow through a link. |
|
Control setting on a link. |
|
Rainfall on a subcatchment. |
|
Evaporation on a subcatchment. |
|
Rainfall on a gage. |
Clearing#
Method |
What it does |
|---|---|
|
Clear forcing on one object. |
|
Clear every forcing on the engine. |
See also#
Nodes, Links, Subcatchments, Rain gages — the per-object setters are equivalent to
mode=REPLACE, persist=Falseforcing.Control rules — rule-based overrides.