Skip to main content

hydr_structures/structures/culvert/outlet/
row.rs

1//! One outlet-control row: barrel, length, roughness, entrance loss, slope, gravity and the
2//! entrance face blockage.
3
4use crate::structures::{BlockageFraction, CulvertBarrel, StructureError};
5
6/// Barrel, length, Manning `n`, entrance loss, slope, gravity and entrance face blockage of one
7/// outlet-control row.
8#[derive(Clone, Copy, Debug, PartialEq)]
9pub struct CulvertOutletRow {
10    /// Barrel the flow runs through. A barrel with a floor runs its profile on the open section,
11    /// with depths, tailwater and headwater above the bed.
12    pub barrel: CulvertBarrel,
13    /// Barrel length `L` in metres.
14    pub length_m: f64,
15    /// Manning roughness `n` in `s/m^(1/3)`. Above a floor it is the wall `n`, and friction
16    /// takes the weighted perimeter `P_n = P_w + rho^(3/2) b`.
17    pub manning_n: f64,
18    /// Entrance loss coefficient `ke` of the inlet that the flow enters.
19    pub entrance_loss: f64,
20    /// Signed barrel slope `S` in metres per metre, positive when the barrel falls from the inlet
21    /// to the outlet. The inlet invert sits `S L` above the outlet invert.
22    pub slope: f64,
23    /// Gravity in metres per second squared.
24    pub gravity_m_per_s2: f64,
25    /// Blocked share `f` of the entrance face. The entrance loss becomes
26    /// `ke / (1 - f)^2 + (f / (1 - f))^2`: the entrance loss at the face velocity `V / (1 - f)`
27    /// plus the expansion back to `V`. This rule is a hydr definition.
28    pub face_blockage: BlockageFraction,
29}
30
31impl CulvertOutletRow {
32    /// Rejects a nonfinite or nonpositive length, roughness or gravity, a nonfinite or negative
33    /// entrance loss, a nonfinite slope, and an adverse barrel whose outlet sits more than `D/2`
34    /// above its inlet, with `D'` above a floor.
35    pub(crate) fn check(&self) -> Result<(), StructureError> {
36        let fields = format!(
37            "length_m={:?},manning_n={:?},entrance_loss={:?},slope={:?},gravity_m_per_s2={:?}",
38            self.length_m, self.manning_n, self.entrance_loss, self.slope, self.gravity_m_per_s2
39        );
40        let positive = [
41            (self.length_m, "barrel length in metres"),
42            (self.manning_n, "Manning n in s/m^(1/3)"),
43            (
44                self.gravity_m_per_s2,
45                "gravity in metres per second squared",
46            ),
47        ];
48        for (value, what) in positive {
49            if !(value.is_finite() && value > 0.0) {
50                return Err(StructureError::definition(format!(
51                    "{fields}: supply a finite positive {what}"
52                )));
53            }
54        }
55        if !(self.entrance_loss.is_finite() && self.entrance_loss >= 0.0) {
56            return Err(StructureError::definition(format!(
57                "{fields}: supply a finite nonnegative entrance loss coefficient"
58            )));
59        }
60        if !self.slope.is_finite() {
61            return Err(StructureError::definition(format!(
62                "{fields}: supply a finite barrel slope in metres per metre"
63            )));
64        }
65        let rise = self.barrel.open_rise_m();
66        if self.slope * self.length_m < -0.5 * rise {
67            let bed = match self.barrel.floor() {
68                Some(floor) => format!(",sediment_depth_m={:?}", floor.sediment_depth_m),
69                None => String::new(),
70            };
71            return Err(StructureError::definition(format!(
72                "{fields},rise_m={rise:?}{bed}: the outlet invert sits more than half the rise above the inlet invert. Supply an adverse fall of at most rise/2"
73            )));
74        }
75        Ok(())
76    }
77}