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) — REPLACE overwrites the engine-computed value; ADD adds to it.

  • persistFalse (default) means one-shot for the next step; True keeps 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 …

node_lat_inflow(node, value)

Lateral inflow at a node.

node_head_boundary(node, value)

Head boundary at a node.

node_quality(node, pollutant, mass_rate)

Quality mass-flux at a node.

link_flow(link, value)

Flow through a link.

link_setting(link, value)

Control setting on a link.

subcatchment_rainfall(sub, value)

Rainfall on a subcatchment.

subcatchment_evap(sub, value)

Evaporation on a subcatchment.

gage_rainfall(gage, value)

Rainfall on a gage.

Clearing#

Method

What it does

clear(target, key)

Clear forcing on one object. target is a ForcingTarget enum (NODE / LINK / SUBCATCH / GAGE).

clear_all()

Clear every forcing on the engine.


See also#