Skip to main content

hydr_structures/structures/pump/
parameters.rs

1//! Immutable pump curve, suction bound, speed policy, free outlet, and physical applicability.
2
3use super::{PumpApplicability, PumpCurve, PumpFreeOutlet, PumpSpeedPolicy};
4use crate::structures::{StructureError, StructureInputErrorKind};
5
6/// Explicit reference-curve proposal model without evolving pump or storage state.
7#[derive(Clone, Debug, PartialEq)]
8pub struct PumpParameters {
9    curve: PumpCurve,
10    minimum_suction_stage_m: f64,
11    speed_policy: PumpSpeedPolicy,
12    applicability: PumpApplicability,
13    free_outlet: Option<PumpFreeOutlet>,
14}
15impl PumpParameters {
16    /// Check explicit suction bound, supported speed policy, and complete physical evidence.
17    ///
18    /// The pump has no free outlet. Add one with [`Self::with_free_outlet`].
19    pub fn new(
20        curve: PumpCurve,
21        minimum_suction_stage_m: f64,
22        speed_policy: PumpSpeedPolicy,
23        applicability: PumpApplicability,
24    ) -> Result<Self, StructureError> {
25        if !minimum_suction_stage_m.is_finite() {
26            return Err(StructureError::input(
27                StructureInputErrorKind::Definition,
28                format!(
29                    "minimum_suction_stage_m={minimum_suction_stage_m}: supply a finite common-datum suction bound"
30                ),
31            ));
32        }
33        speed_policy.check()?;
34        applicability.check()?;
35        Ok(Self {
36            curve,
37            minimum_suction_stage_m,
38            speed_policy,
39            applicability,
40            free_outlet: None,
41        })
42    }
43    /// Check and attach a free delivery outlet, replacing any earlier one.
44    ///
45    /// Lift becomes `max(receiving stage, outlet) - donor stage`. A dry receiver whose bed lies at
46    /// or below the outlet takes delivery.
47    pub fn with_free_outlet(mut self, outlet: PumpFreeOutlet) -> Result<Self, StructureError> {
48        outlet.check()?;
49        self.free_outlet = Some(outlet);
50        Ok(self)
51    }
52    /// Complete closed reference-speed curve.
53    pub fn curve(&self) -> &PumpCurve {
54        &self.curve
55    }
56    /// Running donor stage must lie strictly above this common-datum bound.
57    pub fn minimum_suction_stage_m(&self) -> f64 {
58        self.minimum_suction_stage_m
59    }
60    /// Immutable reference-only or explicitly declared affinity policy.
61    pub fn speed_policy(&self) -> &PumpSpeedPolicy {
62        &self.speed_policy
63    }
64    /// Complete physical stage-head, loss, isolation, and operating-envelope evidence.
65    pub fn applicability(&self) -> &PumpApplicability {
66        &self.applicability
67    }
68    /// Declared free delivery outlet. Without one, a running pump needs a wet receiver.
69    pub fn free_outlet(&self) -> Option<&PumpFreeOutlet> {
70        self.free_outlet.as_ref()
71    }
72}