Control rules#
Note
Engine: OpenSWMM 6 — refactored.
solver.controls is a MutableSequence of ControlRule
records over the [CONTROLS] block, plus runtime link-override
helpers.
Reference: openswmm_controls.h.
Quickstart#
from openswmm.engine import Solver
with Solver("model.inp") as s:
# Append a rule.
s.controls.append(\"\"\"
RULE r1
IF NODE J1 DEPTH > 1.0
THEN ORIFICE OR1 SETTING = 0.5
\"\"\")
# Iterate / inspect.
for rule in s.controls:
print(rule.id, rule.text)
# Direct runtime actions on a link.
s.controls.set_link_setting("OR1", 0.25)
s.controls.set_link_status("OR1", closed=False)
Controls — MutableSequence#
Operation |
What it does |
|---|---|
|
Container protocol over |
|
Append a rule. Accepts a raw string, a |
|
Insert in the middle. Emulated by clear + rebuild. |
|
Remove entries. |
Direct runtime actions#
Method |
What it does |
|---|---|
|
Set the link’s control setting. |
|
Open / close the link. |
See also#
Links —
Link.control_settingandLink.target_setting.Advanced forcing — for non-rule-based overrides.