OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::SimulationContext::MassBalance Struct Reference

#include <SimulationContext.hpp>

Collaboration diagram for openswmm::SimulationContext::MassBalance:

Public Member Functions

void resize_quality (int n_pollutants)
 Resize and zero all pollutant continuity arrays.
 
void reset ()
 Reset continuity totals while retaining pollutant array sizes and initial buildup.
 
double runoff_error () const
 Runoff continuity error (fraction).
 
double routing_error () const
 Routing continuity error (fraction).
 
double gw_error () const
 Groundwater continuity error (fraction). Gap #72.
 

Public Attributes

double runoff_rainfall = 0.0
 Total rainfall volume (ft3)
 
double runoff_runon = 0.0
 Outfall-routed runon volume (ft3), legacy RUNOFF_RUNON.
 
double runoff_evap = 0.0
 Total evaporation volume (ft3)
 
double runoff_infil = 0.0
 Total infiltration volume (ft3)
 
double runoff_runoff = 0.0
 Total surface runoff volume (ft3)
 
double runoff_lid_drain
 LID drain-to-node outflow (ft3), legacy RUNOFF_DRAINS / VlidDrain.
 
double runoff_snowremov = 0.0
 Total snow removal volume (ft3)
 
double runoff_init_store = 0.0
 Initial surface storage (ft3)
 
double runoff_final_store = 0.0
 
double runoff_init_snow = 0.0
 
double runoff_final_snow = 0.0
 
double rdii_rainfall = 0.0
 
double rdii_produced = 0.0
 
double routing_dry_weather = 0.0
 
double routing_wet_weather = 0.0
 
double routing_gw_inflow = 0.0
 
double routing_link_gw_inflow = 0.0
 
double routing_rdii = 0.0
 
double routing_external = 0.0
 
double routing_flooding = 0.0
 
double routing_coupling_out = 0.0
 
double routing_outflow = 0.0
 
double routing_evap_loss = 0.0
 
double routing_seep_loss = 0.0
 
double routing_init_storage = 0.0
 
double routing_final_storage = 0.0
 
std::array< double, 11 > routing_report {}
 
double routing_forcing_inflow = 0.0
 Cumulative user-forced lateral inflow (ft3)
 
std::vector< double > routing_forcing_qual_inflow
 Per-pollutant cumulative user-forced quality mass.
 
double gw_infil = 0.0
 Cumulative infiltration to GW (ft)
 
double gw_upper_evap = 0.0
 Cumulative upper zone evaporation (ft)
 
double gw_lower_evap = 0.0
 Cumulative lower zone evaporation (ft)
 
double gw_lower_perc = 0.0
 Cumulative deep percolation (ft)
 
double gw_lateral_flow = 0.0
 Cumulative lateral GW flow (ft)
 
double gw_init_storage = 0.0
 Initial GW storage (ft)
 
double gw_final_storage = 0.0
 
double gw_infil_2d_recharge = 0.0
 
double step_flooding = 0.0
 
double step_outflow = 0.0
 
double step_dw_inflow = 0.0
 
double step_gw_inflow = 0.0
 
double step_rdii_inflow = 0.0
 
double step_ext_inflow = 0.0
 
double last_step_flow_error = 0.0
 
double step_ext_withdrawal = 0.0
 
std::vector< double > qual_init_buildup
 Initial buildup mass.
 
std::vector< double > qual_final_buildup
 Final buildup mass.
 
std::vector< double > qual_ponded_lost
 Ponded mass written off when a surface dried (legacy FINAL_LOAD)
 
std::vector< double > qual_surface_buildup
 Accumulated buildup during sim.
 
std::vector< double > qual_wet_deposition
 Wet deposition mass.
 
std::vector< double > qual_sweeping
 Mass removed by sweeping.
 
std::vector< double > qual_bmp_removal
 BMP treatment removal.
 
std::vector< double > qual_infil_loss
 Mass lost to infiltration.
 
std::vector< double > qual_runoff_load
 Mass load in surface runoff.
 
std::vector< double > qual_routing_wet
 Wet weather quality inflow to routing.
 
std::vector< double > qual_routing_outflow
 Quality mass leaving at outfalls.
 
std::vector< double > qual_routing_flood
 Quality mass lost to flooding.
 
std::vector< double > qual_routing_init
 Initial stored quality mass.
 
std::vector< double > qual_routing_final
 Final stored quality mass.
 
std::vector< double > qual_routing_reacted
 Quality mass lost to decay.
 
std::vector< double > qual_routing_ii_in
 RDII quality mass inflow.
 
std::vector< double > qual_routing_dw_in
 Dry weather quality mass inflow.
 
std::vector< double > qual_routing_gw_in
 Groundwater quality mass inflow.
 
std::vector< double > qual_routing_ex_in
 External (interface file) quality mass inflow.
 
std::vector< double > qual_routing_seep
 Quality mass lost to seepage.
 
std::vector< double > qual_routing_evap
 
std::vector< double > qual_routing_final_dry
 

Member Function Documentation

◆ gw_error()

double openswmm::SimulationContext::MassBalance::gw_error ( ) const
inline

Groundwater continuity error (fraction). Gap #72.

◆ reset()

void openswmm::SimulationContext::MassBalance::reset ( )
inline

Reset continuity totals while retaining pollutant array sizes and initial buildup.

Restores default scalar values, preserves qual_init_buildup values, and zeroes every other pollutant continuity array. Owned vector storage is moved aside and restored rather than resized; initial buildup is computed once by quality initialization.

◆ resize_quality()

void openswmm::SimulationContext::MassBalance::resize_quality ( int n_pollutants)
inline

Resize and zero all pollutant continuity arrays.

Replaces all prior pollutant totals, including initial buildup and runtime forcing loads; scalar totals are unchanged. Allocation failure can interrupt the sequence of independent assignments.

Parameters
[in]n_pollutantsNonnegative pollutant count matching the model registry; no negative guard before conversion to size_t.
Here is the call graph for this function:

◆ routing_error()

double openswmm::SimulationContext::MassBalance::routing_error ( ) const
inline

Routing continuity error (fraction).

Here is the caller graph for this function:

◆ runoff_error()

double openswmm::SimulationContext::MassBalance::runoff_error ( ) const
inline

Runoff continuity error (fraction).

Here is the caller graph for this function:

Member Data Documentation

◆ gw_final_storage

double openswmm::SimulationContext::MassBalance::gw_final_storage = 0.0

Final GW storage (ft)

◆ gw_infil

double openswmm::SimulationContext::MassBalance::gw_infil = 0.0

Cumulative infiltration to GW (ft)

◆ gw_infil_2d_recharge

double openswmm::SimulationContext::MassBalance::gw_infil_2d_recharge = 0.0

U3 (track I-b, 2026-09-07): the part of the groundwater's infiltration input that arrived from the 2D surface ([2D_OPTIONS] INFIL_DESTINATION SUBCATCH_AQUIFER), ft³ — the same unit as gw_infil (rate × area × dt). Already inside it: the recharge is added to each subcatchment's infiltration rate before GWSolver::execute books it, so this is a diagnostic split, not a second inflow. Booked at delivery, in the same loop as mass_balance_2d.infil_to_aquifer (G1-c item 1), so the two are the same volumes in two units.

◆ gw_init_storage

double openswmm::SimulationContext::MassBalance::gw_init_storage = 0.0

Initial GW storage (ft)

◆ gw_lateral_flow

double openswmm::SimulationContext::MassBalance::gw_lateral_flow = 0.0

Cumulative lateral GW flow (ft)

◆ gw_lower_evap

double openswmm::SimulationContext::MassBalance::gw_lower_evap = 0.0

Cumulative lower zone evaporation (ft)

◆ gw_lower_perc

double openswmm::SimulationContext::MassBalance::gw_lower_perc = 0.0

Cumulative deep percolation (ft)

◆ gw_upper_evap

double openswmm::SimulationContext::MassBalance::gw_upper_evap = 0.0

Cumulative upper zone evaporation (ft)

◆ last_step_flow_error

double openswmm::SimulationContext::MassBalance::last_step_flow_error = 0.0

legacy massbal_getStepFlowError() of the PREVIOUS routing step — 1 - outflow/inflow of that step's StepFlowTotals, formed at the end of updateRoutingMassBalance — which isInSteadyState compares with SysFlowTol at the start of the next step.

◆ qual_bmp_removal

std::vector<double> openswmm::SimulationContext::MassBalance::qual_bmp_removal

BMP treatment removal.

◆ qual_final_buildup

std::vector<double> openswmm::SimulationContext::MassBalance::qual_final_buildup

Final buildup mass.

◆ qual_infil_loss

std::vector<double> openswmm::SimulationContext::MassBalance::qual_infil_loss

Mass lost to infiltration.

◆ qual_init_buildup

std::vector<double> openswmm::SimulationContext::MassBalance::qual_init_buildup

Initial buildup mass.

◆ qual_ponded_lost

std::vector<double> openswmm::SimulationContext::MassBalance::qual_ponded_lost

Ponded mass written off when a surface dried (legacy FINAL_LOAD)

◆ qual_routing_dw_in

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_dw_in

Dry weather quality mass inflow.

◆ qual_routing_evap

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_evap

Quality mass lost to evaporation

◆ qual_routing_ex_in

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_ex_in

External (interface file) quality mass inflow.

◆ qual_routing_final

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_final

Final stored quality mass.

◆ qual_routing_final_dry

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_final_dry

Mass booked to final storage as a link went dry, accumulated over the run (legacy massbal_addToFinalStorage). Legacy adds the end-of-run stored mass ON TOP of this running total (massbal.c:885), so it is kept apart from qual_routing_final, which SWMMEngine recomputes from state every routing step.

◆ qual_routing_flood

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_flood

Quality mass lost to flooding.

◆ qual_routing_gw_in

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_gw_in

Groundwater quality mass inflow.

◆ qual_routing_ii_in

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_ii_in

RDII quality mass inflow.

◆ qual_routing_init

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_init

Initial stored quality mass.

◆ qual_routing_outflow

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_outflow

Quality mass leaving at outfalls.

◆ qual_routing_reacted

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_reacted

Quality mass lost to decay.

◆ qual_routing_seep

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_seep

Quality mass lost to seepage.

◆ qual_routing_wet

std::vector<double> openswmm::SimulationContext::MassBalance::qual_routing_wet

Wet weather quality inflow to routing.

◆ qual_runoff_load

std::vector<double> openswmm::SimulationContext::MassBalance::qual_runoff_load

Mass load in surface runoff.

◆ qual_surface_buildup

std::vector<double> openswmm::SimulationContext::MassBalance::qual_surface_buildup

Accumulated buildup during sim.

◆ qual_sweeping

std::vector<double> openswmm::SimulationContext::MassBalance::qual_sweeping

Mass removed by sweeping.

◆ qual_wet_deposition

std::vector<double> openswmm::SimulationContext::MassBalance::qual_wet_deposition

Wet deposition mass.

◆ rdii_produced

double openswmm::SimulationContext::MassBalance::rdii_produced = 0.0

◆ rdii_rainfall

double openswmm::SimulationContext::MassBalance::rdii_rainfall = 0.0

◆ routing_coupling_out

double openswmm::SimulationContext::MassBalance::routing_coupling_out = 0.0

C2 (2026-09-07): cumulative water the 1D→2D coupling spill removed from coupled nodes (ft³). It used to be folded into routing_flooding, which reported a coupling TRANSFER under "Flooding Loss" — the water did not flood, it went to the 2D surface, where MassBalance2D::coupling_1d_to_2d_in books it arriving. Both ledgers are individually right; only the 1D report row was misleading, and a modeller reading it saw flooding they did not have.

It remains an OUTFLOW of the 1D system, so routing_error() counts it exactly as before — this change moves a number between report rows, it does not move water.

[2D_OPTIONS] COUPLING_IN_FLOODING YES restores the old grouping for run-to-run comparison against previous versions.

◆ routing_dry_weather

double openswmm::SimulationContext::MassBalance::routing_dry_weather = 0.0

◆ routing_evap_loss

double openswmm::SimulationContext::MassBalance::routing_evap_loss = 0.0

◆ routing_external

double openswmm::SimulationContext::MassBalance::routing_external = 0.0

◆ routing_final_storage

double openswmm::SimulationContext::MassBalance::routing_final_storage = 0.0

◆ routing_flooding

double openswmm::SimulationContext::MassBalance::routing_flooding = 0.0

◆ routing_forcing_inflow

double openswmm::SimulationContext::MassBalance::routing_forcing_inflow = 0.0

Cumulative user-forced lateral inflow (ft3)

◆ routing_forcing_qual_inflow

std::vector<double> openswmm::SimulationContext::MassBalance::routing_forcing_qual_inflow

Per-pollutant cumulative user-forced quality mass.

◆ routing_gw_inflow

double openswmm::SimulationContext::MassBalance::routing_gw_inflow = 0.0

◆ routing_init_storage

double openswmm::SimulationContext::MassBalance::routing_init_storage = 0.0

◆ routing_link_gw_inflow

double openswmm::SimulationContext::MassBalance::routing_link_gw_inflow = 0.0

G-X4 (2026-09-20): water the two-zone [2D_AQUIFER] handed to conduits running below the water table (ft³, ≥ 0) — a gaining reach, the inflow term legacy SWMM has no conduit source for. It is the negative half of seep_loss_rate; the positive half stays routing_seep_loss, so the two never net each other out and a deck can report both in the same run.

◆ routing_outflow

double openswmm::SimulationContext::MassBalance::routing_outflow = 0.0

◆ routing_rdii

double openswmm::SimulationContext::MassBalance::routing_rdii = 0.0

◆ routing_report

std::array<double, 11> openswmm::SimulationContext::MassBalance::routing_report {}

The eleven routing flow terms above (dry weather, wet weather, groundwater, conduit GW, RDII, external, flooding, coupling out, outflow, evaporation, seepage — in that order) for the printed Flow Routing Continuity block. FV uses accepted-window volumes; its published rates are already interval means. Other routing models retain legacy half-step integration of previous/current rates. The ledger above remains the exact cross-domain authority.

◆ routing_seep_loss

double openswmm::SimulationContext::MassBalance::routing_seep_loss = 0.0

◆ routing_wet_weather

double openswmm::SimulationContext::MassBalance::routing_wet_weather = 0.0

◆ runoff_evap

double openswmm::SimulationContext::MassBalance::runoff_evap = 0.0

Total evaporation volume (ft3)

◆ runoff_final_snow

double openswmm::SimulationContext::MassBalance::runoff_final_snow = 0.0

The same quantity at the end of the run (ft3). Legacy RunoffTotals.finalSnowCover.

These two, and runoff_snowremov, were the whole of F8. The ledger had no snow terms at all, so on any deck with a [SNOWPACKS] section the starting pack was unaccounted INPUT and the surviving pack unaccounted OUTPUT, and the printed continuity percentage was not a meaningful number. Measured on the snow parity deck: -8.193 % before, +1.419 % after.

◆ runoff_final_store

double openswmm::SimulationContext::MassBalance::runoff_final_store = 0.0

Final surface storage (ft3)

◆ runoff_infil

double openswmm::SimulationContext::MassBalance::runoff_infil = 0.0

Total infiltration volume (ft3)

◆ runoff_init_snow

double openswmm::SimulationContext::MassBalance::runoff_init_snow = 0.0

Snow water equivalent PLUS free water held in every pack at the start of the run (ft3). Legacy RunoffTotals.initSnowCover, summed from snow_getSnowCover (snow.c:587).

◆ runoff_init_store

double openswmm::SimulationContext::MassBalance::runoff_init_store = 0.0

Initial surface storage (ft3)

◆ runoff_lid_drain

double openswmm::SimulationContext::MassBalance::runoff_lid_drain
Initial value:
=
0.0

LID drain-to-node outflow (ft3), legacy RUNOFF_DRAINS / VlidDrain.

◆ runoff_rainfall

double openswmm::SimulationContext::MassBalance::runoff_rainfall = 0.0

Total rainfall volume (ft3)

◆ runoff_runoff

double openswmm::SimulationContext::MassBalance::runoff_runoff = 0.0

Total surface runoff volume (ft3)

◆ runoff_runon

double openswmm::SimulationContext::MassBalance::runoff_runon = 0.0

Outfall-routed runon volume (ft3), legacy RUNOFF_RUNON.

◆ runoff_snowremov

double openswmm::SimulationContext::MassBalance::runoff_snowremov = 0.0

Total snow removal volume (ft3)

◆ step_dw_inflow

double openswmm::SimulationContext::MassBalance::step_dw_inflow = 0.0

◆ step_ext_inflow

double openswmm::SimulationContext::MassBalance::step_ext_inflow = 0.0

◆ step_ext_withdrawal

double openswmm::SimulationContext::MassBalance::step_ext_withdrawal = 0.0

legacy addExternalInflows (routing.c): a node's NEGATIVE external flow (a withdrawal) is booked as system OUTFLOW, not as a negative external inflow; summed here per step, ahead of the outfall and flooding terms as legacy's StepFlowTotals.outflow is.

◆ step_flooding

double openswmm::SimulationContext::MassBalance::step_flooding = 0.0

◆ step_gw_inflow

double openswmm::SimulationContext::MassBalance::step_gw_inflow = 0.0

◆ step_outflow

double openswmm::SimulationContext::MassBalance::step_outflow = 0.0

◆ step_rdii_inflow

double openswmm::SimulationContext::MassBalance::step_rdii_inflow = 0.0

The documentation for this struct was generated from the following file: