Skip to main content

hydr_structures/structures/culvert/
law_capabilities.rs

1//! Capability declaration of the culvert structure law.
2
3use hydr_core::capability::{
4    ArithmeticRequirement, ComponentCapabilities, ComponentId, Limit, Precision, RuntimeKind,
5    RuntimeStatus, RuntimeSupport, Summary, Unsupported, UnsupportedReason,
6};
7
8/// Path of the guide that defines the law, its inversion, direction rules and limits.
9const CULVERT_DOC: &str = "docs/structures.md";
10
11const fn unsupported(
12    id: &'static str,
13    reason: UnsupportedReason,
14    summary: &'static str,
15) -> Unsupported {
16    Unsupported {
17        id,
18        reason,
19        summary,
20        doc: CULVERT_DOC,
21    }
22}
23
24const fn limit(id: &'static str, summary: &'static str) -> Limit {
25    Limit {
26        id,
27        summary,
28        doc: CULVERT_DOC,
29    }
30}
31
32static CULVERT: ComponentCapabilities = ComponentCapabilities {
33    component: ComponentId::Culvert,
34    contract: None,
35    snapshot_schema: None,
36    precision: &[Precision::F64],
37    arithmetic: &[
38        ArithmeticRequirement::F64Ieee754Basic,
39        ArithmeticRequirement::NearestEvenGradualUnderflow,
40        ArithmeticRequirement::RoundToNearestSqrt,
41        ArithmeticRequirement::FusedMulAdd,
42        ArithmeticRequirement::CorrectlyRoundedElementary,
43    ],
44    runtimes: &[
45        RuntimeSupport {
46            runtime: RuntimeKind::Cpu,
47            status: RuntimeStatus::Reference,
48            evidence: "culvert_lanes_return_single_lane_bits_at_every_layout_width",
49        },
50        RuntimeSupport {
51            runtime: RuntimeKind::Cuda,
52            status: RuntimeStatus::Executed,
53            evidence: "selected_cuda_client_matches_culvert_laws_bit_for_bit",
54        },
55        RuntimeSupport {
56            runtime: RuntimeKind::Wgpu,
57            status: RuntimeStatus::RejectedLacksF64,
58            evidence: "selected_wgpu_rejects_culvert_law_f64_without_fallback",
59        },
60    ],
61    endpoints: &[],
62    regimes: &[],
63    sources: &[],
64    options: &[],
65    nested: &[ComponentId::CulvertInlet, ComponentId::CulvertOutlet],
66    attachable_to: &[ComponentId::SurfaceChannels, ComponentId::CoupledLevelPools],
67    unsupported: &[
68        unsupported(
69            "invalid-culvert-definition",
70            UnsupportedReason::RejectedByAdmission,
71            "A nonfinite invert, a zero barrel count, no culvert end, a negative entrance loss, or an end whose inlet or outlet row the queries reject, rejects.",
72        ),
73        unsupported(
74            "culvert-end-mismatch",
75            UnsupportedReason::RejectedByAdmission,
76            "A culvert must declare an end for each direction its policy admits and no other.",
77        ),
78        unsupported(
79            "culvert-falling-transition",
80            UnsupportedReason::RejectedByAdmission,
81            "An end whose inlet headwater does not certifiably rise across its transition rejects, naming the element.",
82        ),
83        unsupported(
84            "culvert-without-certified-client",
85            UnsupportedReason::RejectedByAdmission,
86            "StructureBatch::new rejects a culvert. StructureBatch::with_culverts admits it on a client with certified roots and quadrature.",
87        ),
88        unsupported(
89            "buried-dry-end",
90            UnsupportedReason::RejectedByAdmission,
91            "A known dry end whose bed lies above its culvert bed elevation rejects.",
92        ),
93        unsupported(
94            "culvert-exit-face-blockage",
95            UnsupportedReason::RejectedByAdmission,
96            "A face blockage on an end that a declared direction uses as its exit rejects, including any face blockage on a bidirectional culvert.",
97        ),
98    ],
99    limits: &[
100        limit(
101            "culvert-barrel-storage",
102            "The law holds no water. Barrel storage is not represented, and proposals keep no state.",
103        ),
104        limit(
105            "culvert-composite-roughness",
106            "Floor and sediment friction use HDS-5 eq. 3.8 equal-velocity composite roughness with constant Manning n per material and exponent 2/3, applied through the weighted perimeter P_n.",
107        ),
108        limit(
109            "culvert-uniform-sediment",
110            "Sediment fills every barrel to one uniform depth along the whole barrel length. A local deposit at one end is not modelled.",
111        ),
112        limit(
113            "culvert-buried-inlet-coefficients",
114            "Declared inlet coefficients act on the reduced open section above the bed. Their applicability is caller evidence. NCHRP Tables A.5 and A.6 are not admitted as codes.",
115        ),
116        limit(
117            "culvert-face-loss",
118            "Entrance face blockage scales inlet-control discharge by the open share (1 - f) and sets outlet-control entrance loss to ke / (1 - f)^2 + (f / (1 - f))^2. Both are hydr definitions.",
119        ),
120        limit(
121            "culvert-metre-products",
122            "Discharges, their squares and powers of the area are formed in metres. A barrel whose discharge at X = 3.5 lies below the normal F64 range rejects at admission. Where the outlet products leave F64, as at a rise near 2^300 m, the proposal rejects as Numerical.",
123        ),
124        limit(
125            "culvert-level-zero",
126            "A lane whose outlet still level max(TW - S L, 0) is not certified below the headwater carries exact zero under EqualHeads.",
127        ),
128        limit(
129            "culvert-zero-headwater",
130            "A headwater at or below HW_i(0) = D Ks S, or below a certified still level, gives exact zero discharge.",
131        ),
132        limit(
133            "culvert-bidirectional-fall",
134            "Each admitted direction keeps its adverse fall within half the rise, so a two-way culvert keeps its inverts within D/2.",
135        ),
136        limit(
137            "culvert-unresolved-outlet",
138            "Where the outlet march leaves its headwater unresolved near the inlet discharge, the proposal rejects as Numerical. With critical depth below the crown, a start friction equal to the slope or a full-barrel head equal to the crown at the inlet within rounding has no certified outcome or bounded hull. Critical depth below 2^-30 D and a start within 2^-34 of a normal-depth pole also stay unresolved.",
139        ),
140        limit(
141            "culvert-sensitivity-cap",
142            "Head sensitivity is capped at 2^256 per metre. An outlet lane whose march row is open, a tie or unresolved, or whose divisors are not certified positive, takes the cap.",
143        ),
144        limit(
145            "culvert-outlet-cost",
146            "Every flowing lane runs one outlet march. Each lane the inlet does not certainly govern adds one certified bisection with one outlet march per round. An outlet-controlled lane that is not a drowned full barrel adds one coarse march for its head sensitivity.",
147        ),
148    ],
149    summary: Summary {
150        equations: "HDS-5: discharge is min(Q_i, Q_o) across open barrels, inverting the larger of inlet and outlet control headwaters above the bed with optional floor roughness, sediment, entrance face blockage, closed barrels, or Closed zero discharge",
151        method: "closed-form inlet inverses per band and one certified bisection in the form-1 critical-depth fraction; a drowned full barrel in closed form and otherwise one certified bisection over the certified outlet march",
152        assessment: "independent 100-digit inlet and outlet corpus rows return their discharge within the frozen round-trip tolerance on unblocked, open-floor, sedimented, and face-blocked barrels",
153    },
154};
155
156/// Returns the culvert structure law's declared scope, independent of application eligibility.
157pub fn culvert_capabilities() -> &'static ComponentCapabilities {
158    &CULVERT
159}