1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//! Flow regimes and where a component supports them.
use super::BoundaryKind;
/// Flow regime.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Regime {
/// Wet flow with Froude number below one.
WetSubcritical,
/// Flow with Froude number above one.
Supercritical,
/// Flow at Froude number one.
Critical,
/// Dry cells or sections.
Dry,
/// Moving front between wet and dry.
WetDryFront,
/// Flow that reverses direction within one branch.
ReversalInBranch,
/// Weir flow with only the upstream side above the crest.
FreeWeirFlow,
/// Weir flow with both sides above the crest, including equal heads.
SubmergedWeirFlow,
/// Both sides of a weir at or below the crest, with no flow.
BelowCrest,
/// Orifice flow with both sides above the crown.
SubmergedOrificeFlow,
/// Gate flow with the downstream side at or below the sill.
FreeGateAperture,
/// Gate flow with the downstream side between the sill and the opening top.
MixedGateAperture,
/// Gate flow with both sides above the opening top.
SubmergedGateAperture,
/// Gate at zero opening, with no flow.
GateClosed,
/// Running pump on its curve, with positive flow.
PumpCurve,
/// Running pump at a lift where its curve gives zero flow.
PumpShutoff,
/// Stopped pump that isolates its two sides, with no flow.
PumpIsolated,
/// Culvert flow whose inlet-control headwater governs.
CulvertInletControl,
/// Culvert flow whose outlet-control headwater governs.
CulvertOutletControl,
}
impl Regime {
/// Returns the stable kebab-case id. Persisted decisions store it, so it never changes.
pub fn id(&self) -> &'static str {
match self {
Self::WetSubcritical => "wet-subcritical",
Self::Supercritical => "supercritical",
Self::Critical => "critical",
Self::Dry => "dry",
Self::WetDryFront => "wet-dry-front",
Self::ReversalInBranch => "reversal-in-branch",
Self::FreeWeirFlow => "free-weir-flow",
Self::SubmergedWeirFlow => "submerged-weir-flow",
Self::BelowCrest => "below-crest",
Self::SubmergedOrificeFlow => "submerged-orifice-flow",
Self::FreeGateAperture => "free-gate-aperture",
Self::MixedGateAperture => "mixed-gate-aperture",
Self::SubmergedGateAperture => "submerged-gate-aperture",
Self::GateClosed => "gate-closed",
Self::PumpCurve => "pump-curve",
Self::PumpShutoff => "pump-shutoff",
Self::PumpIsolated => "pump-isolated",
Self::CulvertInletControl => "culvert-inlet-control",
Self::CulvertOutletControl => "culvert-outlet-control",
}
}
}
/// Part of a component where a regime claim holds.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum RegimeScope {
/// At boundaries of this kind.
Boundary(BoundaryKind),
/// In the interior, away from boundaries.
Interior,
}
impl RegimeScope {
/// Returns the stable kebab-case id of the scope kind. Persisted decisions store it, so it
/// never changes. A `Boundary` id omits the boundary kind, which has its own id.
pub fn id(&self) -> &'static str {
match self {
Self::Boundary(_) => "boundary",
Self::Interior => "interior",
}
}
}
/// Regime that a component supports within one scope.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct RegimeSupport {
/// Where the claim holds.
pub scope: RegimeScope,
/// Supported regime.
pub regime: Regime,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::capability::id_check::assert_ids;
#[test]
fn regime_ids_are_unique_kebab_case() {
let all = [
Regime::WetSubcritical,
Regime::Supercritical,
Regime::Critical,
Regime::Dry,
Regime::WetDryFront,
Regime::ReversalInBranch,
Regime::FreeWeirFlow,
Regime::SubmergedWeirFlow,
Regime::BelowCrest,
Regime::SubmergedOrificeFlow,
Regime::FreeGateAperture,
Regime::MixedGateAperture,
Regime::SubmergedGateAperture,
Regime::GateClosed,
Regime::PumpCurve,
Regime::PumpShutoff,
Regime::PumpIsolated,
Regime::CulvertInletControl,
Regime::CulvertOutletControl,
];
assert_ids(&all.map(|r| r.id()));
}
#[test]
fn structure_regime_ids_are_frozen() {
for (regime, id) in [
(Regime::SubmergedOrificeFlow, "submerged-orifice-flow"),
(Regime::FreeGateAperture, "free-gate-aperture"),
(Regime::MixedGateAperture, "mixed-gate-aperture"),
(Regime::SubmergedGateAperture, "submerged-gate-aperture"),
(Regime::GateClosed, "gate-closed"),
(Regime::PumpCurve, "pump-curve"),
(Regime::PumpShutoff, "pump-shutoff"),
(Regime::PumpIsolated, "pump-isolated"),
(Regime::CulvertInletControl, "culvert-inlet-control"),
(Regime::CulvertOutletControl, "culvert-outlet-control"),
] {
assert_eq!(regime.id(), id);
}
}
#[test]
fn scope_ids_are_unique_kebab_case() {
let all = [
RegimeScope::Boundary(BoundaryKind::Wall),
RegimeScope::Interior,
];
assert_ids(&all.map(|s| s.id()));
}
}