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

#include <ReactionData.hpp>

Collaboration diagram for openswmm::ReactionData:

Classes

struct  LidLaw
 
struct  LidState
 
struct  MsxRoutingLedger
 
struct  ParameterOverride
 
struct  Source
 
struct  SourcePattern
 
struct  SubsurfaceLaw
 
struct  SurfaceLaw
 
struct  WallArea
 

Public Member Functions

bool lid_enabled (int control) const
 Test whether a LID control key occurs in the configured reaction list.
 
const double * coefficients (bool link, int element, std::vector< double > &scratch) const
 Borrow global coefficients or gather element-specific parameter overrides.
 
bool wet_enabled (int sc) const noexcept
 Test whether wet surface reactions can apply to one subcatchment.
 
bool has_subcatch_reactions () const noexcept
 Test whether any global or sparse wet subcatchment reaction is configured.
 
int n_species () const noexcept
 Count authored reaction species.
 
int find_species (std::string_view n) const
 Find the first exact-case species name.
 
int find_coef (std::string_view n) const
 Find the first exact-case coefficient name.
 
int find_term (std::string_view n) const
 Find the first exact-case term name.
 
void clear ()
 Reset reaction configuration/runtime state while preserving authored surface rows.
 

Public Attributes

ReactionSolverKind solver = ReactionSolverKind::RK5
 Default integrator.
 
ReactionCoupling coupling = ReactionCoupling::NONE
 
ReactionRateUnits rate_units = ReactionRateUnits::HR
 
ReactionAreaUnits area_units = ReactionAreaUnits::FT2
 
bool wall_geometry = false
 WALL densities use a fixed reference contact area.
 
double timestep = 0.0
 0 ⇒ follow QUALITY_STEP
 
double atol = 1.0e-6
 
double rtol = 1.0e-4
 
double default_temp_c = 20.0
 
int registry_base = -1
 first MSX index in the registry
 
std::vector< std::string > species_name
 cold
 
std::vector< uint8_t > species_is_wall
 0 = BULK, 1 = WALL
 
std::vector< std::string > species_units
 cold
 
std::vector< double > species_atol
 hot (0 ⇒ global)
 
std::vector< double > species_rtol
 hot (0 ⇒ global)
 
std::vector< std::string > coef_name
 cold
 
std::vector< uint8_t > coef_is_param
 1 = PARAMETER (overridable), 0 = CONSTANT
 
std::vector< double > coef_value
 
std::vector< ParameterOverride > parameter_overrides
 
std::vector< WallArea > wall_areas
 
std::vector< int > lid_controls
 
std::vector< LidLaw > lid_laws
 
struct openswmm::ReactionData::LidState lid
 
std::vector< double > booster_mass
 
double pattern_timestep = 3600.0
 seconds, independent of RATE_UNITS
 
std::vector< SourcePattern > source_patterns
 
std::vector< Source > sources
 
std::vector< uint8_t > report_enabled
 
std::vector< int > reported_species
 
std::vector< std::string > term_name
 cold
 
std::vector< std::string > term_expr_src
 cold (compiled in R2)
 
std::vector< SubsurfaceLaw > subsurface_laws
 
std::vector< ReactionExprForm > pipe_form
 size n_species
 
std::vector< std::string > pipe_expr_src
 size n_species (cold)
 
std::vector< ReactionExprForm > tank_form
 
std::vector< std::string > tank_expr_src
 
std::vector< SurfaceLaw > wet_laws
 
std::vector< SurfaceLaw > buildup_laws
 
std::vector< ReactionExprForm > subcatch_form
 
std::vector< std::string > subcatch_expr_src
 
std::vector< RxExprSpan > subcatch_expr
 
std::vector< double > init_global
 
std::vector< double > rain_conc
 
std::vector< uint8_t > init_elem_is_link
 0 = NODE row, 1 = LINK row
 
std::vector< int > init_elem_idx
 resolved node/link index
 
std::vector< int > init_elem_species
 0..n_species()-1
 
std::vector< double > init_elem_value
 
std::vector< RxToken > token_pool
 hot: one contiguous pool
 
std::vector< RxExprSpan > term_expr
 per term, in-order evaluation
 
std::vector< RxExprSpan > pipe_expr
 per species (len 0 ⇒ none)
 
std::vector< RxExprSpan > tank_expr
 per species
 
bool compiled = false
 R2 compile pass succeeded.
 
bool warned_react_failure = false
 
bool warned_negative_clamp = false
 review A2: once-per-run note
 
std::vector< double > msx_node_conc
 
std::vector< double > msx_link_conc
 
std::vector< double > msx_ext_mass_in
 
std::vector< double > msx_coupling_queue
 
MsxRoutingLedger msx_ledger
 
MsxSurfaceData surface
 
bool configured = false
 a reactions component applied
 

Member Function Documentation

◆ clear()

void openswmm::ReactionData::clear ( )
inline

Reset reaction configuration/runtime state while preserving authored surface rows.

Moves surface aside, restores default ReactionData fields and moves surface back. Releases compiled pools, species/coefficient/expression lists and runtime concentrations/ledgers. The preserved .inp-authored surface rows require later msxsurf resolution when reapplying a component. Invalidates borrowed references to all replaced storage.

Here is the caller graph for this function:

◆ coefficients()

const double * openswmm::ReactionData::coefficients ( bool link,
int element,
std::vector< double > & scratch ) const
inline

Borrow global coefficients or gather element-specific parameter overrides.

Every matching override is applied in row order, so later duplicates win. Caller validates coefficient indices; this helper does not enforce PARAMETER kind. Pointer remains valid until its owning vector changes/dies; scratch copy can allocate/throw.

Parameters
[in]linkTrue selects link overrides, false node overrides.
[in]elementElement key; negative values return global coefficients directly.
[out]scratchCaller-owned vector overwritten with global coefficients only when overrides exist and element>=0; otherwise preserved.
Returns
Pointer to coef_value or scratch data; length coef_value.size(), and an empty vector may return NULL.

◆ find_coef()

int openswmm::ReactionData::find_coef ( std::string_view n) const
inline

Find the first exact-case coefficient name.

Parameters
[in]nBorrowed untrimmed name; comparison is byte-exact, including embedded NULs.
Returns
First matching zero-based index, or -1; linear scan.
Here is the caller graph for this function:

◆ find_species()

int openswmm::ReactionData::find_species ( std::string_view n) const
inline

Find the first exact-case species name.

Parameters
[in]nBorrowed untrimmed name; comparison is byte-exact, including embedded NULs.
Returns
First matching zero-based index, or -1; linear scan.
Here is the caller graph for this function:

◆ find_term()

int openswmm::ReactionData::find_term ( std::string_view n) const
inline

Find the first exact-case term name.

Parameters
[in]nBorrowed untrimmed name; comparison is byte-exact, including embedded NULs.
Returns
First matching zero-based index, or -1; linear scan.
Here is the caller graph for this function:

◆ has_subcatch_reactions()

bool openswmm::ReactionData::has_subcatch_reactions ( ) const
inlinenoexcept

Test whether any global or sparse wet subcatchment reaction is configured.

Returns
True for a non-NONE global form or any wet_laws row; does not inspect sparse row forms or compiled status.
Here is the caller graph for this function:

◆ lid_enabled()

bool openswmm::ReactionData::lid_enabled ( int control) const
inline

Test whether a LID control key occurs in the configured reaction list.

Parameters
[in]controlStored LID-control index; no bounds or control-type validation.
Returns
True on the first equal key, false otherwise; linear scan.
Here is the caller graph for this function:

◆ n_species()

int openswmm::ReactionData::n_species ( ) const
inlinenoexcept

Count authored reaction species.

Returns
species_name.size() converted to int; alignment and registry_base are not checked.
Here is the caller graph for this function:

◆ wet_enabled()

bool openswmm::ReactionData::wet_enabled ( int sc) const
inlinenoexcept

Test whether wet surface reactions can apply to one subcatchment.

Sparse form is not checked here; presence of even a NONE law returns true.

Parameters
[in]scSubcatchment key compared to sparse wet_laws; no model-range validation.
Returns
True if any global subcatch_form is non-NONE or any sparse wet law names sc.
Here is the caller graph for this function:

Member Data Documentation

◆ area_units

ReactionAreaUnits openswmm::ReactionData::area_units = ReactionAreaUnits::FT2

◆ atol

double openswmm::ReactionData::atol = 1.0e-6

◆ booster_mass

std::vector<double> openswmm::ReactionData::booster_mass

◆ buildup_laws

std::vector<SurfaceLaw> openswmm::ReactionData::buildup_laws

◆ coef_is_param

std::vector<uint8_t> openswmm::ReactionData::coef_is_param

1 = PARAMETER (overridable), 0 = CONSTANT

◆ coef_name

std::vector<std::string> openswmm::ReactionData::coef_name

cold

◆ coef_value

std::vector<double> openswmm::ReactionData::coef_value

hot (global values; per-element overrides use parameter_overrides below)

◆ compiled

bool openswmm::ReactionData::compiled = false

R2 compile pass succeeded.

◆ configured

bool openswmm::ReactionData::configured = false

a reactions component applied

◆ coupling

ReactionCoupling openswmm::ReactionData::coupling = ReactionCoupling::NONE

◆ default_temp_c

double openswmm::ReactionData::default_temp_c = 20.0

TEMP's value when no heat-transport temperature exists for the element (HEAT_TRANSPORT off, or state not yet seeded). 20 degC is the standard water-quality reference temperature.

◆ init_elem_idx

std::vector<int> openswmm::ReactionData::init_elem_idx

resolved node/link index

◆ init_elem_is_link

std::vector<uint8_t> openswmm::ReactionData::init_elem_is_link

0 = NODE row, 1 = LINK row

◆ init_elem_species

std::vector<int> openswmm::ReactionData::init_elem_species

◆ init_elem_value

std::vector<double> openswmm::ReactionData::init_elem_value

◆ init_global

std::vector<double> openswmm::ReactionData::init_global

size n_species

◆ lid

struct openswmm::ReactionData::LidState openswmm::ReactionData::lid

◆ lid_controls

std::vector<int> openswmm::ReactionData::lid_controls

◆ lid_laws

std::vector<LidLaw> openswmm::ReactionData::lid_laws

◆ msx_coupling_queue

std::vector<double> openswmm::ReactionData::msx_coupling_queue

Review D1/F21 (2026-10-15): species MASS (conc-units × ft³) handed to a node by the 2D surface drain and the aquifer bed, [node * ns + m]. Drained into msx_ext_mass_in every routing step by the same remaining-span rule as NodeData::coupling_qual_queue (transport::drainMsxCouplingQueue). Empty until a seam books into it.

◆ msx_ext_mass_in

std::vector<double> openswmm::ReactionData::msx_ext_mass_in

◆ msx_ledger

MsxRoutingLedger openswmm::ReactionData::msx_ledger

◆ msx_link_conc

std::vector<double> openswmm::ReactionData::msx_link_conc

◆ msx_node_conc

std::vector<double> openswmm::ReactionData::msx_node_conc

◆ parameter_overrides

std::vector<ParameterOverride> openswmm::ReactionData::parameter_overrides

◆ pattern_timestep

double openswmm::ReactionData::pattern_timestep = 3600.0

seconds, independent of RATE_UNITS

◆ pipe_expr

std::vector<RxExprSpan> openswmm::ReactionData::pipe_expr

per species (len 0 ⇒ none)

◆ pipe_expr_src

std::vector<std::string> openswmm::ReactionData::pipe_expr_src

size n_species (cold)

◆ pipe_form

std::vector<ReactionExprForm> openswmm::ReactionData::pipe_form

size n_species

◆ rain_conc

std::vector<double> openswmm::ReactionData::rain_conc

[REACTION_RAINFALL]: concentration of each species in rainfall, in its own units (0 = rain falls clean). Size n_species. Multispecies Phase 2.

◆ rate_units

ReactionRateUnits openswmm::ReactionData::rate_units = ReactionRateUnits::HR

◆ registry_base

int openswmm::ReactionData::registry_base = -1

first MSX index in the registry

◆ report_enabled

std::vector<uint8_t> openswmm::ReactionData::report_enabled

Native result selection. Empty means all species (legacy default). Selection is retained through species edits and canonical serialization.

◆ reported_species

std::vector<int> openswmm::ReactionData::reported_species

◆ rtol

double openswmm::ReactionData::rtol = 1.0e-4

◆ solver

ReactionSolverKind openswmm::ReactionData::solver = ReactionSolverKind::RK5

Default integrator.

RK5, not an implicit solver. Measured substeps for one routing step, at the shipping tolerances below and at 1e-10/1e-8:

case RK5 ROS2 BDF2
first-order decay, default 5 134 197
stiff (λ ratio 1e6), default 2682 281 408
stiff, atol 1e-10 2744 26938 39693

RK5 wins the common case by ~27x. It loses the stiff case at loose tolerance by ~10x but still COMPLETES, with the slow mode exact. At tight tolerance it beats both implicit solvers on the stiff problem, because RK5's step is STABILITY-limited (nearly flat in tolerance) while the Rosenbrock/BDF pairs are ACCURACY-limited and scale as sqrt(tol).

The cliff: RK5 costs about lambda_fast*dt/3.3 substeps, so past lambda_fast*dt ~ 3e5 it hits kMaxSubsteps and fails. That failure is loud and names ROS2/BDF2 as the remedy (ReactionIntegrator's substep-cap message) — a slow default that fails legibly beats an implicit default that is slower everywhere except the stiff-and-loose corner.

◆ source_patterns

std::vector<SourcePattern> openswmm::ReactionData::source_patterns

◆ sources

std::vector<Source> openswmm::ReactionData::sources

◆ species_atol

std::vector<double> openswmm::ReactionData::species_atol

hot (0 ⇒ global)

◆ species_is_wall

std::vector<uint8_t> openswmm::ReactionData::species_is_wall

0 = BULK, 1 = WALL

◆ species_name

std::vector<std::string> openswmm::ReactionData::species_name

cold

◆ species_rtol

std::vector<double> openswmm::ReactionData::species_rtol

hot (0 ⇒ global)

◆ species_units

std::vector<std::string> openswmm::ReactionData::species_units

cold

◆ subcatch_expr

std::vector<RxExprSpan> openswmm::ReactionData::subcatch_expr

◆ subcatch_expr_src

std::vector<std::string> openswmm::ReactionData::subcatch_expr_src

◆ subcatch_form

std::vector<ReactionExprForm> openswmm::ReactionData::subcatch_form

◆ subsurface_laws

std::vector<SubsurfaceLaw> openswmm::ReactionData::subsurface_laws

◆ surface

MsxSurfaceData openswmm::ReactionData::surface

BW-MSX (2026-09-19): surface buildup / washoff / sweeping of MSX species — rows parked by name at parse, resolved after this component is applied, stepped beside the pollutant surface-quality step, and delivered into msx_ext_mass_in each routing step. See quality/MsxSurfaceQuality.hpp.

◆ tank_expr

std::vector<RxExprSpan> openswmm::ReactionData::tank_expr

per species

◆ tank_expr_src

std::vector<std::string> openswmm::ReactionData::tank_expr_src

◆ tank_form

std::vector<ReactionExprForm> openswmm::ReactionData::tank_form

◆ term_expr

std::vector<RxExprSpan> openswmm::ReactionData::term_expr

per term, in-order evaluation

◆ term_expr_src

std::vector<std::string> openswmm::ReactionData::term_expr_src

cold (compiled in R2)

◆ term_name

std::vector<std::string> openswmm::ReactionData::term_name

cold

◆ timestep

double openswmm::ReactionData::timestep = 0.0

0 ⇒ follow QUALITY_STEP

◆ token_pool

std::vector<RxToken> openswmm::ReactionData::token_pool

hot: one contiguous pool

◆ wall_areas

std::vector<WallArea> openswmm::ReactionData::wall_areas

◆ wall_geometry

bool openswmm::ReactionData::wall_geometry = false

WALL densities use a fixed reference contact area.

◆ warned_negative_clamp

bool openswmm::ReactionData::warned_negative_clamp = false

review A2: once-per-run note

◆ warned_react_failure

bool openswmm::ReactionData::warned_react_failure = false

◆ wet_laws

std::vector<SurfaceLaw> openswmm::ReactionData::wet_laws

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