OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
Constants.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
38
39#ifndef OPENSWMM_CONSTANTS_HPP
40#define OPENSWMM_CONSTANTS_HPP
41
42namespace openswmm {
43
44// ============================================================================
45// Physical constants
46// ============================================================================
47
48namespace constants {
49
52constexpr double GRAVITY = 32.2;
53
55constexpr double SQRT_GRAVITY = 5.67450438786; // sqrt(32.2)
56
58constexpr double INV_SQRT_GRAVITY = 0.17622692584; // 1.0 / sqrt(32.2)
59
61constexpr double PI = 3.141592654;
62
66constexpr double PHI = 1.486;
67
70constexpr double MEXP = 5.0 / 3.0;
71
73constexpr double VISCOS = 1.1e-5;
74
76constexpr double SEC_PER_DAY = 86400.0;
77
79constexpr double FT_PER_IN = 1.0 / 12.0;
80
82constexpr double IN_PER_FT = 12.0;
83
84// ============================================================================
85// Numerical thresholds and tolerances
86// ============================================================================
87
91constexpr double FUDGE = 0.0001;
92
95constexpr double MIN_SURFAREA = 12.566; // 4*pi
96
102constexpr double FLOW_TOL = 0.00001;
103
105constexpr double MIN_DELTA_Z = 0.001;
106
109constexpr double XTOL = 0.001;
110
112constexpr double TINY = 1.0e-6;
113
116static constexpr double MISSING = -1.0e10;
117
118// ============================================================================
119// Dynamic wave solver constants
120// ============================================================================
121
124constexpr double OMEGA = 0.5;
125
128constexpr double DEFAULT_HEAD_TOL = 0.005;
129
132constexpr int DEFAULT_MAX_TRIALS = 8;
133
136constexpr double MAX_VELOCITY = 50.0;
137
140constexpr double MIN_TIMESTEP = 0.001;
141
144constexpr double EXTRAN_CROWN_CUTOFF = 0.96;
145
147constexpr double SLOT_CROWN_CUTOFF = 0.985257;
148
150constexpr double SLOT_WIDTH_FACTOR = 0.001;
151
152// ============================================================================
153// ODE solver constants (RK45 Cash-Karp)
154// ============================================================================
155
156namespace ode {
157
159constexpr int MAX_STEPS = 10000;
160
162constexpr double ODE_TINY = 1.0e-30;
163
165constexpr double SAFETY = 0.9;
166
168constexpr double PGROW = -0.2;
169
171constexpr double PSHRNK = -0.25;
172
174constexpr double ERRCON = 1.89e-4;
175
178constexpr double GWTOL = 0.0001;
179
181constexpr double ODETOL = 0.0001;
182
183} // namespace ode
184
185// ============================================================================
186// Hydraulic structure constants
187// ============================================================================
188
190constexpr double MIN_LINK_FLOW = 0.001;
191
192// ============================================================================
193// Cross-section constants
194// ============================================================================
195
197constexpr double RECT_ALFMAX = 0.97;
198
200constexpr double TRAP_ALFMAX = 0.98;
201
203constexpr int N_TRANSECT_TBL = 51;
204
206constexpr int MAX_SHAPES = 26;
207
208// ============================================================================
209// Data structure constants
210// ============================================================================
211
213constexpr int N_FLOW_CLASSES = 7;
214
216constexpr int MAX_PAST_RAIN = 48;
217
219constexpr int N_TIME_BINS = 5;
220
225constexpr int DATE_DELTA = 693594;
226
227} // namespace constants
228} // namespace openswmm
229
230#endif // OPENSWMM_CONSTANTS_HPP
Definition Constants.hpp:156
constexpr double PGROW
Exponent for step increase.
Definition Constants.hpp:168
constexpr double ODETOL
Runoff ODE tolerance.
Definition Constants.hpp:181
constexpr double GWTOL
Definition Constants.hpp:178
constexpr double ERRCON
Error control threshold = (5/SAFETY)^(1/PGROW).
Definition Constants.hpp:174
constexpr int MAX_STEPS
Maximum number of integration steps.
Definition Constants.hpp:159
constexpr double PSHRNK
Exponent for step decrease.
Definition Constants.hpp:171
constexpr double ODE_TINY
Underflow protection for scaling.
Definition Constants.hpp:162
constexpr double SAFETY
Safety factor for step size adjustment.
Definition Constants.hpp:165
Definition Constants.hpp:48
constexpr int DATE_DELTA
Definition Constants.hpp:225
constexpr double MIN_SURFAREA
Definition Constants.hpp:95
constexpr double DEFAULT_HEAD_TOL
Definition Constants.hpp:128
constexpr int MAX_PAST_RAIN
Maximum past rain hours tracked per gage.
Definition Constants.hpp:216
constexpr double FUDGE
Definition Constants.hpp:91
constexpr double IN_PER_FT
Inches per foot.
Definition Constants.hpp:82
constexpr double FLOW_TOL
Definition Constants.hpp:102
constexpr double MEXP
Definition Constants.hpp:70
constexpr double GRAVITY
Definition Constants.hpp:52
constexpr int MAX_SHAPES
Maximum number of cross-section shape types.
Definition Constants.hpp:206
constexpr double PHI
Definition Constants.hpp:66
constexpr double SQRT_GRAVITY
sqrt(GRAVITY) — precomputed to avoid per-element std::sqrt in Froude calc.
Definition Constants.hpp:55
constexpr double EXTRAN_CROWN_CUTOFF
Definition Constants.hpp:144
constexpr double MAX_VELOCITY
Definition Constants.hpp:136
constexpr double SLOT_WIDTH_FACTOR
Preissmann slot width factor (slot_width = y_full * this factor).
Definition Constants.hpp:150
constexpr int N_TIME_BINS
Number of time step histogram bins.
Definition Constants.hpp:219
constexpr double OMEGA
Definition Constants.hpp:124
constexpr double MIN_DELTA_Z
Minimum elevation drop for conduit slope computation (ft).
Definition Constants.hpp:105
constexpr double TINY
Small positive number for underflow protection.
Definition Constants.hpp:112
constexpr int DEFAULT_MAX_TRIALS
Definition Constants.hpp:132
constexpr double MIN_TIMESTEP
Definition Constants.hpp:140
constexpr int N_FLOW_CLASSES
Number of flow classification bins.
Definition Constants.hpp:213
constexpr double FT_PER_IN
Feet per inch.
Definition Constants.hpp:79
constexpr double PI
Pi.
Definition Constants.hpp:61
constexpr double SLOT_CROWN_CUTOFF
Preissmann slot crown cutoff fraction.
Definition Constants.hpp:147
constexpr double TRAP_ALFMAX
Maximum alpha fraction for trapezoidal shapes.
Definition Constants.hpp:200
constexpr double SEC_PER_DAY
Seconds per day.
Definition Constants.hpp:76
constexpr double INV_SQRT_GRAVITY
1.0 / sqrt(GRAVITY) — multiply instead of divide in Froude computation.
Definition Constants.hpp:58
constexpr double XTOL
Definition Constants.hpp:109
constexpr double VISCOS
Kinematic viscosity of water at 20°C (ft²/sec).
Definition Constants.hpp:73
constexpr double RECT_ALFMAX
Maximum alpha fraction for rectangular shapes.
Definition Constants.hpp:197
constexpr int N_TRANSECT_TBL
Transect discretization table size.
Definition Constants.hpp:203
constexpr double MIN_LINK_FLOW
Minimum orifice/weir flow threshold.
Definition Constants.hpp:190
Definition ExchangeLaw.hpp:60