RDII objects
The RDII API exposes both EPA SWMM RTK unit hydrographs and the
swmmrs Antecedent Moisture Model (AMM) extension.
RTK uses Simulation.unit_hydrographs and Simulation.rdii_assignments; AMM
uses Simulation.amm_models and Simulation.amm_assignments. Python can edit
existing models and replace assignment lists, but it cannot create or delete
top-level RTK or AMM models.
Model views stay connected to one project generation. Their parameter and
assignment objects are detached, so editing one is only the first half of the
job. Assign the complete parameter or assignment sequence back to apply it.
Edits are allowed while a simulation is Open or Ended, not while it is Running.
The next Simulation.start() validates and prepares the changed configuration.
RTK unit hydrographs
RTK models come from [HYDROGRAPHS]. UnitHydrograph.rain_gage and
monthly_responses are writable individually or together through update().
The returned tuple contains January through December. Each
UnitHydrographMonth exposes named short, medium, and long responses.
from swmmrs import Simulation
with Simulation("model.inp", "model.rpt") as simulation:
unit_hydrograph = simulation.unit_hydrographs["UH1"]
responses = unit_hydrograph.monthly_responses
january_short = responses[0].short
january_short.rainfall_fraction = 0.15
january_short.time_to_peak_hours = 0.75
january_short.recession_ratio = 2.0
unit_hydrograph.update(
rain_gage=simulation.rain_gages["GAGE"],
monthly_responses=responses,
)
| Python field | SWMM parameter | Units |
|---|---|---|
rainfall_fraction |
R | Fraction |
time_to_peak_hours |
T | Hours |
recession_ratio |
K | Ratio |
maximum_initial_abstraction |
IAmax | Project rain-depth units |
initial_abstraction_recovery_rate |
IArec | Project rain-depth units per day |
initial_abstraction_at_start |
IAinit | Project rain-depth units |
Every month must provide short, medium, and long responses. Monthly rainfall must be nonnegative and sum to no more than 1.01.
Replace RTK node assignments
Simulation.rdii_assignments represents [RDII] rows and returns detached
RdiiAssignment values in node order. Each node can have at most one RTK
assignment.
from swmmrs import Simulation
from swmmrs.objects import RdiiAssignment
with Simulation("model.inp", "model.rpt") as simulation:
simulation.rdii_assignments = [
RdiiAssignment(
node=simulation.nodes["J1"],
unit_hydrograph=simulation.unit_hydrographs["UH1"],
area=3.5,
)
]
Antecedent Moisture Model
AMM models come from [AMM_MODELS] and [AMM_COMPONENTS]. AmmModel.update()
changes the rain gage, temperature bounds, and complete component list
atomically.
from swmmrs import Simulation
from swmmrs.objects import AmmStandardComponent
with Simulation("model.inp", "model.rpt") as simulation:
model = simulation.amm_models["SAN1"]
print(model.rain_gage.id, model.cold_temperature, model.hot_temperature)
components = list(model.components)
standard = next(
component
for component in components
if isinstance(component, AmmStandardComponent)
)
standard.hot_shcf = 0.06
model.update(
cold_temperature=25.0,
hot_temperature=75.0,
components=components,
)
Temperatures use the project's temperature units. Component averaging windows and half-lives use hours. See the AMM input reference for every AMM parameter's meaning and units.
Replace AMM node assignments
Simulation.amm_assignments represents [AMM_RDII] rows. Unlike RTK, multiple
AMM assignments may target one node.
from swmmrs import Simulation
from swmmrs.objects import AmmAssignment
with Simulation("model.inp", "model.rpt") as simulation:
assignments = list(simulation.amm_assignments)
assignments.append(
AmmAssignment(
node=simulation.nodes["J2"],
model=simulation.amm_models["SAN1"],
area=3.5,
)
)
simulation.amm_assignments = assignments
RTK and AMM assignment areas use acres in US projects and hectares in SI projects.
Typed, generation-bound views over configured SWMM project objects.
All view instances retain the simulation and project generation that created them. They validate that identity before accessing native state, so retained views cannot silently address a subsequently reopened project.
| CLASS | DESCRIPTION |
|---|---|
UnitHydrograph |
Expose a generation-bound editable RTK unit-hydrograph group. |
UnitHydrographMonth |
Store one month's detached short, medium, and long RTK responses. |
UnitHydrographResponse |
Store one detached short-, medium-, or long-response RTK parameter set. |
RdiiAssignment |
Store one detached RTK RDII node assignment in project units. |
AmmModel |
Expose a generation-bound editable AMM model. |
AmmStandardComponent |
Store one detached standard AMM component in project units. |
AmmBaseflowComponent |
Store one detached baseflow AMM component in project units. |
AmmAssignment |
Store one detached AMM node assignment in project units. |
UnitHydrograph
flowchart TD
swmmrs.objects.UnitHydrograph[UnitHydrograph]
swmmrs.objects._base._LiveView[_LiveView]
swmmrs.objects._base._LiveView --> swmmrs.objects.UnitHydrograph
click swmmrs.objects.UnitHydrograph href "" "swmmrs.objects.UnitHydrograph"
click swmmrs.objects._base._LiveView href "" "swmmrs.objects._base._LiveView"
Expose a generation-bound editable RTK unit-hydrograph group.
| METHOD | DESCRIPTION |
|---|---|
update |
Atomically update supplied RTK fields in project units. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
monthly_responses |
Return January-through-December named response groups.
TYPE:
|
rain_gage |
Return the unit hydrograph's rain gage.
TYPE:
|
monthly_responses
property
writable
monthly_responses: tuple[UnitHydrographMonth, ...]
Return January-through-December named response groups.
UnitHydrographMonth
flowchart TD
swmmrs.objects.UnitHydrographMonth[UnitHydrographMonth]
click swmmrs.objects.UnitHydrographMonth href "" "swmmrs.objects.UnitHydrographMonth"
Store one month's detached short, medium, and long RTK responses.
UnitHydrographResponse
Store one detached short-, medium-, or long-response RTK parameter set.
RdiiAssignment
Store one detached RTK RDII node assignment in project units.
AmmModel
flowchart TD
swmmrs.objects.AmmModel[AmmModel]
swmmrs.objects._base._LiveView[_LiveView]
swmmrs.objects._base._LiveView --> swmmrs.objects.AmmModel
click swmmrs.objects.AmmModel href "" "swmmrs.objects.AmmModel"
click swmmrs.objects._base._LiveView href "" "swmmrs.objects._base._LiveView"
Expose a generation-bound editable AMM model.
| METHOD | DESCRIPTION |
|---|---|
update |
Atomically update supplied AMM model fields in project units. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
cold_temperature |
Return the cold reference temperature in project units.
TYPE:
|
components |
Return detached component definitions in configured order.
TYPE:
|
hot_temperature |
Return the hot reference temperature in project units.
TYPE:
|
rain_gage |
Return the model's rain gage.
TYPE:
|
cold_temperature
property
writable
cold_temperature: float
Return the cold reference temperature in project units.
components
property
writable
components: tuple[AmmComponent, ...]
Return detached component definitions in configured order.
hot_temperature
property
writable
hot_temperature: float
Return the hot reference temperature in project units.
update
update(**changes: object) -> None
Atomically update supplied AMM model fields in project units.
AmmStandardComponent
Store one detached standard AMM component in project units.
AmmBaseflowComponent
Store one detached baseflow AMM component in project units.
AmmAssignment
Store one detached AMM node assignment in project units.