OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
RDII.hpp
Go to the documentation of this file.
1
20#ifndef OPENSWMM_RDII_HPP
21#define OPENSWMM_RDII_HPP
22
23#include <array>
24#include <vector>
25#include <string>
26#include <unordered_map>
27
28namespace openswmm {
29
30struct SimulationContext;
31
32namespace rdii {
33
35 double r[12][3] = {};
36 double tPeak[12][3] = {};
37 double tBase[12][3] = {};
38 double iaMax[12][3] = {};
39 double iaRecov[12][3] = {};
40 double iaInit[12][3] = {};
41};
42
50 bool active = false;
51 double k_dep = 0.0;
52 double k_0 = 0.0;
53 double k_T = 0.0;
54 double T_ref = 10.0;
55 double theta_rec = 0.0;
56 double T_freeze = 0.0;
57};
58
62 std::vector<double> past_rain;
63 std::vector<int> past_month;
64 int period = 0;
65 int max_periods = 0;
66 int has_past_rain = 0;
67 double ia_used = 0.0;
68 long dry_seconds = 0;
69
70 void allocate(int n) {
71 max_periods = n;
72 past_rain.assign(static_cast<std::size_t>(n), 0.0);
73 past_month.assign(static_cast<std::size_t>(n), 0);
74 period = 0;
75 has_past_rain = 0;
76 ia_used = 0.0;
77 dry_seconds = static_cast<long>(n) * 300 + 1; // start dry
78 }
79};
80
82 int count = 0;
83 std::vector<int> node_idx;
84 std::vector<int> uh_idx;
85 std::vector<int> gage_idx;
86 std::vector<double> area;
87
89 std::vector<UHResponseData> uh_data;
90
91 std::vector<int> rain_interval;
92 std::vector<double> time_accum;
93 std::vector<double> rain_at_start;
94
95 void resize(int n);
96};
97
99public:
100 void init(SimulationContext& ctx);
101
109 int addUnitHydParams(const std::string& name, const UnitHydParams& params);
110
115 int findUnitHyd(const std::string& name) const;
116
118 const std::unordered_map<std::string, int>& uhNameIndex() const { return uh_name_to_idx_; }
119
128 void computeAll(SimulationContext& ctx, int month, double dt);
129
136 void applyRdiiInflows(SimulationContext& ctx) const;
137
138 std::vector<UnitHydParams> uh_params;
139
143 std::vector<std::array<ExpDecayParams, 3>> decay_params;
144
146 static int getRainInterval(const UnitHydParams& uh, double wet_step);
147
149 static int getMaxPeriods(const UnitHydParams& uh, int response, int rainInterval);
150
151private:
152 RDIIGroupSoA groups_;
153 std::unordered_map<std::string, int> uh_name_to_idx_;
154 std::vector<double> node_rdii_flow_;
155
157 double uhOrdinate(const UnitHydParams& uh, int month, int response, double t) const;
158
160 void validateExpDecay(SimulationContext& ctx) const;
161};
162
163} // namespace rdii
164} // namespace openswmm
165
166#endif // OPENSWMM_RDII_HPP
Definition RDII.hpp:98
std::vector< std::array< ExpDecayParams, 3 > > decay_params
Definition RDII.hpp:143
static int getMaxPeriods(const UnitHydParams &uh, int response, int rainInterval)
Compute max past periods for a UH response given a rain interval.
Definition RDII.cpp:98
void applyRdiiInflows(SimulationContext &ctx) const
Apply buffered RDII inflows to node lateral flows.
Definition RDII.cpp:504
void computeAll(SimulationContext &ctx, int month, double dt)
Compute RDII inflows for all groups (buffered, not added to lat_flow).
Definition RDII.cpp:378
void init(SimulationContext &ctx)
Definition RDII.cpp:133
std::vector< UnitHydParams > uh_params
Definition RDII.hpp:138
int findUnitHyd(const std::string &name) const
Look up unit hydrograph index by name.
Definition RDII.cpp:75
static int getRainInterval(const UnitHydParams &uh, double wet_step)
Compute rain processing interval for a UH (minimum limb duration, capped by wet_step).
Definition RDII.cpp:81
int addUnitHydParams(const std::string &name, const UnitHydParams &params)
Register a unit hydrograph parameter set by name.
Definition RDII.cpp:62
const std::unordered_map< std::string, int > & uhNameIndex() const
Read-only access to the UH name → index map (for validation).
Definition RDII.hpp:118
Definition NodeCoupling.cpp:15
Central, reentrant simulation context.
Definition SimulationContext.hpp:274
Definition RDII.hpp:49
double k_dep
Depletion rate (1/project-depth) — temperature-independent.
Definition RDII.hpp:51
double T_freeze
Recovery suppressed at or below this temperature (deg C)
Definition RDII.hpp:56
double k_T
Thermal recovery rate at T_ref (1/hr)
Definition RDII.hpp:53
double k_0
Base recovery rate (1/hr)
Definition RDII.hpp:52
double T_ref
Reference temperature (deg C)
Definition RDII.hpp:54
bool active
Definition RDII.hpp:50
double theta_rec
Temperature sensitivity (1/deg C)
Definition RDII.hpp:55
Definition RDII.hpp:81
void resize(int n)
Definition RDII.cpp:21
std::vector< int > gage_idx
Rain gage index per UH group (legacy: UnitHyd[j].rainGage)
Definition RDII.hpp:85
std::vector< int > uh_idx
Unit hydrograph parameter index.
Definition RDII.hpp:84
std::vector< double > area
Contributing area (acres, project units)
Definition RDII.hpp:86
std::vector< int > node_idx
Target node index.
Definition RDII.hpp:83
std::vector< UHResponseData > uh_data
Per-response data: [group * 3 + response].
Definition RDII.hpp:89
std::vector< double > time_accum
Accumulated time (sec) within current interval.
Definition RDII.hpp:92
std::vector< int > rain_interval
Rain processing interval (sec) per group.
Definition RDII.hpp:91
int count
Definition RDII.hpp:82
std::vector< double > rain_at_start
Rainfall (in/hr) captured at start of interval.
Definition RDII.hpp:93
Definition RDII.hpp:61
int has_past_rain
true if any non-zero past rain
Definition RDII.hpp:66
long dry_seconds
seconds since last non-zero rainfall
Definition RDII.hpp:68
std::vector< int > past_month
month for each past rainfall entry
Definition RDII.hpp:63
int period
current buffer write position
Definition RDII.hpp:64
int max_periods
buffer capacity
Definition RDII.hpp:65
std::vector< double > past_rain
circular buffer of past rainfall depths
Definition RDII.hpp:62
void allocate(int n)
Definition RDII.hpp:70
double ia_used
initial abstraction used so far
Definition RDII.hpp:67
Definition RDII.hpp:34
double iaRecov[12][3]
IA recovery rate (linear model)
Definition RDII.hpp:39
double iaMax[12][3]
Initial abstraction max depth.
Definition RDII.hpp:38
double tPeak[12][3]
Time to peak (sec) per month × response.
Definition RDII.hpp:36
double tBase[12][3]
Base time (sec) per month × response.
Definition RDII.hpp:37
double r[12][3]
Rainfall fraction per month × response.
Definition RDII.hpp:35
double iaInit[12][3]
Initial IA used.
Definition RDII.hpp:40