OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SimulationOptions.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
39
40#ifndef OPENSWMM_ENGINE_SIMULATION_OPTIONS_HPP
41#define OPENSWMM_ENGINE_SIMULATION_OPTIONS_HPP
42
43#include "FilePathPair.hpp"
44#include <string>
45#include <vector>
46#include <unordered_map>
47
49#include <cstdint>
50#include <cmath>
51
52namespace openswmm {
53
54// ============================================================================
55// Enumerators matching legacy SWMM enums.h
56// ============================================================================
57
62enum class FlowUnits : int {
63 CFS = 0,
64 GPM = 1,
65 MGD = 2,
66 CMS = 3,
67 LPS = 4,
68 MLD = 5
69};
70
75enum class RoutingModel : int {
76 STEADY = 0,
77 KINWAVE = 1,
78 DYNWAVE = 2,
79 FV = 3
80};
81
85enum class QualitySolverKind : int {
86 LEGACY = 0,
103};
104
116
121enum class RunoffModel : int {
122 NONE = 0,
124};
125
143enum class NodeContinuity : int {
146};
147
148// ============================================================================
149// SimulationOptions struct
150// ============================================================================
151
167 // -----------------------------------------------------------------------
168 // Time control
169 // -----------------------------------------------------------------------
170
173 double start_date = 2453006.0; // Jan 1, 2004 OADate (days since 12/30/1899) (legacy default)
174
176 double end_date = 0.0;
177
187 double total_duration_ms = -1.0;
188
190 double report_start = 0.0;
191
193 double routing_step = 20.0;
194
196 double min_routing_step = 0.5;
197
199 double dry_step = 3600.0;
200
202 double wet_step = 300.0;
203
205 double report_step = 900.0;
206
208 double dry_days = 0.0;
209
212 double variable_step = 0.75;
213
219 double lengthening_step = 0.0;
220
222 int sweep_start = 1;
223
225 int sweep_end = 365;
226
227 // -----------------------------------------------------------------------
228 // Flow and routing
229 // -----------------------------------------------------------------------
230
233
236
250
261 double quality_step = 0.0;
262
271
281 bool lard_rwpt = false;
282
287 int rwpt_seed = 0;
288
299 bool water_age = false;
300
320
333 bool heat_transport = false;
334
349 double humidity[12] = {50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50};
350
353
358
360 std::string humidity_ts_name;
361
369 double water_density = 1000.0;
370
372 double water_specific_heat = 4184.0;
373
378 double wind_func_coeff_a = 1.505e-8;
379 double wind_func_coeff_b = 1.6e-8;
380
382 double pressure_ratio = 1.0;
383
395
398
401
402 // -----------------------------------------------------------------------
403 // Solver settings
404 // -----------------------------------------------------------------------
405
407 int max_trials = 8;
408
413
418 double tpa_celerity = 100.0;
419
424 double dps_target_celerity = 25.0;
425
431 double dps_alpha = 3.0;
432
438 double dps_decay_time = 0.5;
439
453
460
465 double uf_k3 = 0.015;
466
469
485
495 bool anderson_accel = false;
496
499 int normal_flow_ltd = 2; // BOTH (legacy default)
500
504
507 int inertial_damping = 1; // PARTIAL (legacy default)
508
511 int link_offsets = 0; // DEPTH_OFFSET (legacy default)
512
514 double min_slope = 0.0;
515
517 double min_surf_area = 0.0; // 0 = use MIN_SURFAREA constant
518
521 double head_tol = 0.005;
522
525 double sys_flow_tol = 0.05;
526
529 double lat_flow_tol = 0.05;
530
535 bool skip_steady_state = false;
536
547
548 // -----------------------------------------------------------------------
549 // System settings
550 // -----------------------------------------------------------------------
551
553 bool quality_routing = false;
554
556 bool allow_ponding = false;
557
559 bool ignore_rainfall = false;
560
562 bool ignore_snow_melt = false;
563
565 bool ignore_groundwater = false;
566
568 bool ignore_rdii = false;
569
571 bool ignore_routing = false;
572
574 bool ignore_quality = false;
575
585 bool ignore_2d = false;
586
587 // -----------------------------------------------------------------------
595 double rule_step = 0.0;
596
597 // Threading
598 // -----------------------------------------------------------------------
599
624 int num_threads = 1;
625
626 // -----------------------------------------------------------------------
627 // New in 6.0.0 — CRS (R06)
628 // -----------------------------------------------------------------------
629
646 std::string crs;
647
648 // -----------------------------------------------------------------------
649 // New in 6.0.0 — Extension options map (R05)
650 // -----------------------------------------------------------------------
651
669 std::unordered_map<std::string, std::string> ext_options;
670
671 // -----------------------------------------------------------------------
672 // Evaporation settings (from [EVAPORATION] section)
673 // -----------------------------------------------------------------------
674
676 int evap_type = 0;
677
679 double evap_values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
680
682 std::string evap_ts_name;
683
685 std::string evap_recovery_pat;
686
688 bool evap_dry_only = false;
689
691 double pan_coeff[12] = {1,1,1,1,1,1,1,1,1,1,1,1};
692
693 // -----------------------------------------------------------------------
694 // Temperature settings (from [TEMPERATURE] section)
695 // -----------------------------------------------------------------------
696
698 int temp_source = 0;
699
701 std::string temp_ts_name;
702
705
707 double temp_file_start = 0.0;
708
713 int temp_units = -1;
714
716 int wind_type = 0;
717
719 double wind_speed[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
720
722 double snow_divt = 34.0;
723
725 double snow_ati_wt = 0.5;
726
728 double snow_nrg_ratio = 0.6;
729
731 double snow_lat = 0.0;
732
738 double snow_dtlong = 0.0;
739
744 double snow_elev = 0.0;
745
747 double snow_min_melt = 0.0;
748
750 double snow_max_melt = 0.0;
751
753 double adc_imperv[10] = {1,1,1,1,1,1,1,1,1,1};
754
756 double adc_perv[10] = {1,1,1,1,1,1,1,1,1,1};
757
758 // -----------------------------------------------------------------------
759 // Report settings (from [REPORT] section)
760 // -----------------------------------------------------------------------
761
763 bool rpt_disabled = false;
764
767
769 int rpt_nodes = 1;
770
772 int rpt_links = 1;
773
775 bool rpt_input = false;
776
778 bool rpt_continuity = true;
779
781 bool rpt_flowstats = true;
782
784 bool rpt_controls = false;
785
787 bool rpt_averages = false;
788
790 std::vector<std::string> rpt_subcatch_names;
791
793 std::vector<std::string> rpt_node_names;
794
796 std::vector<std::string> rpt_link_names;
797
803 double totalDurationMs() const {
804 if (total_duration_ms >= 0.0) return total_duration_ms;
805 return std::floor((end_date - start_date) * 86400.0) * 1000.0;
806 }
807};
808
809} /* namespace openswmm */
810
811#endif /* OPENSWMM_ENGINE_SIMULATION_OPTIONS_HPP */
Carrier for an external file reference in a SWMM model.
Option struct for the explicit finite-volume 1D network solver.
@ NONE
Definition SimulationContext.hpp:180
Definition NodeCoupling.cpp:16
InfiltrationModel
Infiltration methods.
Definition SimulationOptions.hpp:109
@ MOD_GREEN_AMPT
Definition SimulationOptions.hpp:113
@ CURVE_NUMBER
Definition SimulationOptions.hpp:114
@ GREEN_AMPT
Definition SimulationOptions.hpp:112
@ HORTON
Definition SimulationOptions.hpp:110
@ MOD_HORTON
Definition SimulationOptions.hpp:111
FlowUnits
Flow unit systems.
Definition SimulationOptions.hpp:62
@ GPM
Gallons per minute.
Definition SimulationOptions.hpp:64
@ MGD
Million gallons per day.
Definition SimulationOptions.hpp:65
@ CFS
Cubic feet per second.
Definition SimulationOptions.hpp:63
@ MLD
Million liters per day.
Definition SimulationOptions.hpp:68
@ CMS
Cubic meters per second.
Definition SimulationOptions.hpp:66
@ LPS
Liters per second.
Definition SimulationOptions.hpp:67
QualitySolverKind
Water-quality engine ([OPTIONS] QUALITY_SOLVER, master plan D-UT6).
Definition SimulationOptions.hpp:85
@ EULERIAN_ARD
Eulerian ARD on the FV cell mesh (all routing models)
Definition SimulationOptions.hpp:87
@ LEGACY
Legacy-parity CSTR mixing (QualityRouting.cpp)
Definition SimulationOptions.hpp:86
@ LAGRANGIAN
Definition SimulationOptions.hpp:88
NodeContinuity
Node continuity formulation for depth update.
Definition SimulationOptions.hpp:143
@ EXPLICIT
Classic explicit two-branch (default)
Definition SimulationOptions.hpp:144
@ SEMI_IMPLICIT
Unified semi-implicit formulation.
Definition SimulationOptions.hpp:145
RunoffModel
Runoff routing methods.
Definition SimulationOptions.hpp:121
@ NL_POND
Non-linear reservoir (default)
Definition SimulationOptions.hpp:123
RoutingModel
Flow routing methods.
Definition SimulationOptions.hpp:75
@ FV
Explicit conservative finite volume (Godunov, HLL/HLLC)
Definition SimulationOptions.hpp:79
@ KINWAVE
Kinematic wave approximation.
Definition SimulationOptions.hpp:77
@ STEADY
Steady-state (no routing)
Definition SimulationOptions.hpp:76
@ DYNWAVE
Dynamic wave (full Saint-Venant, implicit Picard)
Definition SimulationOptions.hpp:78
Two-string carrier for any external file path that appears in a SWMM .inp file.
Definition FilePathPair.hpp:63
All SWMM simulation options parsed from [OPTIONS] section.
Definition SimulationOptions.hpp:166
std::string humidity_ts_name
Timeseries name for humidity (humidity_type == 2).
Definition SimulationOptions.hpp:360
double water_density
Water density, kg/m³ ([OPTIONS] WATER_DENSITY; CSH Table 4.1).
Definition SimulationOptions.hpp:369
bool ignore_groundwater
Ignore groundwater.
Definition SimulationOptions.hpp:565
double dry_step
Dry-weather runoff timestep in seconds.
Definition SimulationOptions.hpp:199
bool rpt_disabled
TRUE if all reporting is disabled.
Definition SimulationOptions.hpp:763
double adc_imperv[10]
Areal depletion curve for impervious surfaces (10 fractions).
Definition SimulationOptions.hpp:753
bool outfall_backflow_zero
[OPTIONS] OUTFALL_BACKFLOW_QUALITY LAST|ZERO — quality carried by reverse flow at outfalls (false = L...
Definition SimulationOptions.hpp:319
bool rpt_continuity
Report continuity errors (default true).
Definition SimulationOptions.hpp:778
double routing_step
Hydraulic routing timestep in seconds. Legacy default: 20.
Definition SimulationOptions.hpp:193
double humidity[12]
Monthly relative humidity, % ([TEMPERATURE] HUMIDITY).
Definition SimulationOptions.hpp:349
double variable_step
Courant factor for variable time stepping (0 = fixed step).
Definition SimulationOptions.hpp:212
bool ignore_routing
Ignore routing.
Definition SimulationOptions.hpp:571
int report_signed_heads
Report signed piezometric heads: 0 = NO (default, legacy bit-parity — NODE_HEAD is rebuilt as f32(flo...
Definition SimulationOptions.hpp:459
double snow_min_melt
Snowmelt: minimum melt coefficient.
Definition SimulationOptions.hpp:747
int rpt_links
Link reporting: 0=NONE, 1=ALL, 2=SOME. Default ALL.
Definition SimulationOptions.hpp:772
double min_routing_step
Minimum routing timestep in seconds (CFL floor).
Definition SimulationOptions.hpp:196
double end_date
Simulation end date/time (decimal days, OADate (days since 12/30/1899)).
Definition SimulationOptions.hpp:176
std::string crs
Coordinate reference system string.
Definition SimulationOptions.hpp:646
FlowUnits flow_units
Flow units system.
Definition SimulationOptions.hpp:232
int evap_type
Evaporation type: 0=CONSTANT, 1=MONTHLY, 2=TIMESERIES, 3=TEMPERATURE, 4=FILE.
Definition SimulationOptions.hpp:676
double lat_flow_tol
Lateral inflow tolerance (fraction, e.g., 0.05 = 5%).
Definition SimulationOptions.hpp:529
bool ignore_rainfall
Ignore rainfall (for hot start runs).
Definition SimulationOptions.hpp:559
double wet_step
Wet-weather runoff timestep in seconds.
Definition SimulationOptions.hpp:202
double snow_divt
Snowmelt: dividing temperature.
Definition SimulationOptions.hpp:722
std::string evap_ts_name
Timeseries name for evaporation (evap_type == 2).
Definition SimulationOptions.hpp:682
int rwpt_seed
[OPTIONS] RWPT_SEED — deterministic counter-RNG seed (D-L6). Same seed ⇒ bit-identical runs at any th...
Definition SimulationOptions.hpp:287
std::string evap_recovery_pat
Recovery pattern name for evaporation.
Definition SimulationOptions.hpp:685
int wind_type
Wind speed type: 0=MONTHLY, 1=FILE.
Definition SimulationOptions.hpp:716
RoutingModel routing_model
Routing method. Legacy default: DYNWAVE.
Definition SimulationOptions.hpp:235
bool ignore_snow_melt
Ignore snowmelt.
Definition SimulationOptions.hpp:562
std::unordered_map< std::string, std::string > ext_options
Key-value map for unknown [OPTIONS] keys.
Definition SimulationOptions.hpp:669
std::vector< std::string > rpt_link_names
Named links to report (used when rpt_links == 2).
Definition SimulationOptions.hpp:796
bool rpt_flowstats
Report flow statistics (default true).
Definition SimulationOptions.hpp:781
double snow_dtlong
Snowmelt: longitude/solar-time correction (minutes).
Definition SimulationOptions.hpp:738
int surcharge_method
Surcharge method: 0=EXTRAN, 1=SLOT, 2=DYNAMIC_SLOT (DPS).
Definition SimulationOptions.hpp:412
double dps_decay_time
DPS decay time scale (seconds).
Definition SimulationOptions.hpp:438
double pan_coeff[12]
Monthly pan coefficients (used when evap_type == 4/FILE).
Definition SimulationOptions.hpp:691
QualitySolverKind quality_solver
Water-quality engine selection ([OPTIONS] QUALITY_SOLVER).
Definition SimulationOptions.hpp:249
bool rpt_controls
Report control actions (default false).
Definition SimulationOptions.hpp:784
double head_tol
Convergence head tolerance in project length units.
Definition SimulationOptions.hpp:521
bool skip_steady_state
Skip routing when system is in steady state.
Definition SimulationOptions.hpp:535
double water_specific_heat
Water specific heat capacity, J/kg/°C (WATER_SPECIFIC_HEAT_CAPACITY).
Definition SimulationOptions.hpp:372
double snow_elev
Snowmelt: site elevation above sea level (ft, internal units).
Definition SimulationOptions.hpp:744
int rpt_nodes
Node reporting: 0=NONE, 1=ALL, 2=SOME. Default ALL.
Definition SimulationOptions.hpp:769
double tpa_celerity
TPA acoustic celerity a for SURCHARGE_METHOD TPA (PROJECT length units per second,...
Definition SimulationOptions.hpp:418
double evap_values[12]
Monthly evaporation values (used when evap_type == 0 or 1).
Definition SimulationOptions.hpp:679
double snow_nrg_ratio
Snowmelt: negative melt ratio.
Definition SimulationOptions.hpp:728
double total_duration_ms
Total simulation duration in milliseconds, or -1 if not set.
Definition SimulationOptions.hpp:187
double totalDurationMs() const
Total simulation duration in milliseconds (legacy TotalDuration).
Definition SimulationOptions.hpp:803
double dps_target_celerity
DPS target pressure celerity (m/s, converted to ft/s at init).
Definition SimulationOptions.hpp:424
int unsteady_friction
Unsteady friction model: 0=NONE (default, inert), 1=VITKOVSKY.
Definition SimulationOptions.hpp:452
double snow_max_melt
Snowmelt: maximum melt coefficient.
Definition SimulationOptions.hpp:750
RunoffModel runoff_model
Runoff routing method.
Definition SimulationOptions.hpp:400
int rpt_subcatchments
Subcatchment reporting: 0=NONE, 1=ALL, 2=SOME. Default ALL.
Definition SimulationOptions.hpp:766
int sweep_start
Street sweeping start day-of-year (1-365). 0 = not set.
Definition SimulationOptions.hpp:222
int inertial_damping
Inertial damping: 0=NONE, 1=PARTIAL, 2=FULL.
Definition SimulationOptions.hpp:507
double snow_lat
Snowmelt: latitude (degrees).
Definition SimulationOptions.hpp:731
std::string temp_ts_name
Timeseries name for temperature data.
Definition SimulationOptions.hpp:701
std::vector< std::string > rpt_node_names
Named nodes to report (used when rpt_nodes == 2).
Definition SimulationOptions.hpp:793
double wind_func_coeff_b
Definition SimulationOptions.hpp:379
int humidity_type
Humidity source: 0=CONSTANT, 1=MONTHLY, 2=TIMESERIES.
Definition SimulationOptions.hpp:352
FilePathPair temp_file
File path for temperature data. Carries {absolute, original}.
Definition SimulationOptions.hpp:704
double temp_file_start
Temperature file start date (OADate).
Definition SimulationOptions.hpp:707
double report_start
Report start date/time.
Definition SimulationOptions.hpp:190
bool ignore_quality
Ignore water quality.
Definition SimulationOptions.hpp:574
double sys_flow_tol
System flow tolerance (fraction, e.g., 0.05 = 5%).
Definition SimulationOptions.hpp:525
bool lard_rwpt
[OPTIONS] DISPERSION RWPT|OFF — LARD RWPT dispersion (X3b; strategy §5; the GUI plan's Lagrangian-gro...
Definition SimulationOptions.hpp:281
bool write_absolute_paths
Slice IO-4 opt-out: emit external-file paths verbatim absolute.
Definition SimulationOptions.hpp:546
double wind_func_coeff_a
Wind-function coefficients (WIND_FUNC_COEFF_A / _B), CSH Table 4.1 — f(w) = a + b·w,...
Definition SimulationOptions.hpp:378
int normal_flow_ltd
Normal flow limitation: 0=SLOPE, 1=FROUDE, 2=BOTH, 3=NEITHER.
Definition SimulationOptions.hpp:499
double uf_k3
Unsteady friction coefficient k3 (dimensionless).
Definition SimulationOptions.hpp:465
bool water_age
[OPTIONS] WATER_AGE ON|OFF — transported water-age tracking (water age plan §1, reserved species WATE...
Definition SimulationOptions.hpp:299
int force_main_eqn
Force main equation: 0=Hazen-Williams, 1=Darcy-Weisbach.
Definition SimulationOptions.hpp:503
NodeContinuity node_continuity
Node continuity formulation for depth update. Default: EXPLICIT (legacy).
Definition SimulationOptions.hpp:468
std::vector< std::string > rpt_subcatch_names
Named subcatchments to report (used when rpt_subcatchments == 2).
Definition SimulationOptions.hpp:790
bool rpt_averages
Report time-averaged results (default false).
Definition SimulationOptions.hpp:787
double rule_step
Control rule evaluation interval (seconds).
Definition SimulationOptions.hpp:595
int max_trials
Maximum number of flow routing iterations (dynamic wave).
Definition SimulationOptions.hpp:407
bool rpt_input
Report input summary.
Definition SimulationOptions.hpp:775
int link_offsets
Link offset mode: 0=DEPTH_OFFSET, 1=ELEV_OFFSET.
Definition SimulationOptions.hpp:511
bool evap_dry_only
If true, evaporation only occurs on dry days.
Definition SimulationOptions.hpp:688
double snow_ati_wt
Snowmelt: ATI weight (0–1).
Definition SimulationOptions.hpp:725
double start_date
Simulation start date/time (decimal days, OADate (days since 12/30/1899)).
Definition SimulationOptions.hpp:173
double adc_perv[10]
Areal depletion curve for pervious surfaces (10 fractions).
Definition SimulationOptions.hpp:756
int max_segments_per_link
[OPTIONS] MAX_SEGMENTS_PER_LINK — LARD slab capacity per link (strategy §4.1; default 100,...
Definition SimulationOptions.hpp:270
double min_surf_area
Minimum node surface area (ft²).
Definition SimulationOptions.hpp:517
double wind_speed[12]
Monthly wind speed values (12 months).
Definition SimulationOptions.hpp:719
int humidity_var
Humidity quantity: 0=RELATIVE (%), 1=DEWPOINT (deg F US / deg C SI).
Definition SimulationOptions.hpp:357
bool quality_routing
True if quality routing is enabled.
Definition SimulationOptions.hpp:553
bool allow_ponding
True if evaporation is included.
Definition SimulationOptions.hpp:556
bool anderson_accel
Enable Anderson acceleration for Picard iteration convergence.
Definition SimulationOptions.hpp:495
int virtual_junction_momentum
Virtual-junction momentum treatment. Always 0 (BASIC).
Definition SimulationOptions.hpp:484
double report_step
Reporting output interval in seconds.
Definition SimulationOptions.hpp:205
int temp_source
Temperature source: 0=NONE, 1=TIMESERIES, 2=FILE.
Definition SimulationOptions.hpp:698
InfiltrationModel infiltration
Infiltration method for subcatchments.
Definition SimulationOptions.hpp:397
double quality_step
[OPTIONS] QUALITY_STEP — transport substep, seconds (HH:MM:SS or seconds; 0 = follow ROUTING_STEP).
Definition SimulationOptions.hpp:261
bool ignore_rdii
Ignore RDII.
Definition SimulationOptions.hpp:568
bool ignore_2d
Ignore the 2D surface-routing module.
Definition SimulationOptions.hpp:585
double dry_days
Antecedent dry days.
Definition SimulationOptions.hpp:208
int temp_units
Climate-file temperature units: 0=tenths-degC (C10), 1=degC (C), 2=degF (F); -1 = unspecified (reader...
Definition SimulationOptions.hpp:713
int num_threads
Number of OpenMP threads for parallel solver loops.
Definition SimulationOptions.hpp:624
bool heat_transport
[OPTIONS] HEAT_TRANSPORT ON|OFF — transported temperature (heat plan §1, reserved species TEMPERATURE...
Definition SimulationOptions.hpp:333
fv::FvOptions fv
Knobs for FLOW_ROUTING FV, grouped rather than spread across this struct (plan §4....
Definition SimulationOptions.hpp:394
double dps_alpha
DPS surcharge shock parameter (dimensionless, >= 2).
Definition SimulationOptions.hpp:431
double min_slope
Minimum conduit slope (ft/ft).
Definition SimulationOptions.hpp:514
int sweep_end
Street sweeping end day-of-year (1-365). 0 = not set.
Definition SimulationOptions.hpp:225
double pressure_ratio
Pa/P elevation correction in the Bowen ratio (PRESSURE_RATIO).
Definition SimulationOptions.hpp:382
double lengthening_step
Conduit lengthening timestep (seconds, 0 = use routing_step).
Definition SimulationOptions.hpp:219
Knobs for FLOW_ROUTING FV.
Definition FvOptions.hpp:123