use crate::{Density, Length, PhysicsError, Pressure, Speed, Temperature};
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct MassFlowRate<R: deep_causality_algebra::RealField>(R);
impl<R: deep_causality_algebra::RealField> Default for MassFlowRate<R> {
fn default() -> Self {
Self(R::zero())
}
}
impl<R: deep_causality_algebra::RealField> MassFlowRate<R> {
pub fn new(val: R) -> Result<Self, PhysicsError> {
if !val.is_finite() {
return Err(PhysicsError::PhysicalInvariantBroken(
"Mass flow rate must be finite".into(),
));
}
if val < R::zero() {
return Err(PhysicsError::PhysicalInvariantBroken(
"Mass flow rate cannot be negative".into(),
));
}
Ok(Self(val))
}
pub fn new_unchecked(val: R) -> Self {
Self(val)
}
pub fn value(&self) -> R {
self.0
}
}
impl<R: deep_causality_algebra::RealField + Into<f64>> From<MassFlowRate<R>> for f64 {
fn from(val: MassFlowRate<R>) -> Self {
val.0.into()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FlowBranch {
Subsonic,
Supersonic,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NozzleExitState<R: deep_causality_algebra::RealField> {
mach: R,
pressure: Pressure<R>,
temperature: Temperature<R>,
density: Density<R>,
velocity: Speed<R>,
}
impl<R: deep_causality_algebra::RealField> Default for NozzleExitState<R> {
fn default() -> Self {
Self {
mach: R::zero(),
pressure: Pressure::default(),
temperature: Temperature::default(),
density: Density::default(),
velocity: Speed::default(),
}
}
}
impl<R: deep_causality_algebra::RealField> NozzleExitState<R> {
pub fn new(
mach: R,
pressure: Pressure<R>,
temperature: Temperature<R>,
density: Density<R>,
velocity: Speed<R>,
) -> Self {
Self {
mach,
pressure,
temperature,
density,
velocity,
}
}
pub fn mach(&self) -> R {
self.mach
}
pub fn pressure(&self) -> Pressure<R> {
self.pressure
}
pub fn temperature(&self) -> Temperature<R> {
self.temperature
}
pub fn density(&self) -> Density<R> {
self.density
}
pub fn velocity(&self) -> Speed<R> {
self.velocity
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct PlumeGeometry<R: deep_causality_algebra::RealField> {
max_radius: Length<R>,
penetration_length: Length<R>,
terminal_shock_standoff: Length<R>,
}
impl<R: deep_causality_algebra::RealField> Default for PlumeGeometry<R> {
fn default() -> Self {
Self {
max_radius: Length::default(),
penetration_length: Length::default(),
terminal_shock_standoff: Length::default(),
}
}
}
impl<R: deep_causality_algebra::RealField> PlumeGeometry<R> {
pub fn new(
max_radius: Length<R>,
penetration_length: Length<R>,
terminal_shock_standoff: Length<R>,
) -> Self {
Self {
max_radius,
penetration_length,
terminal_shock_standoff,
}
}
pub fn max_radius(&self) -> Length<R> {
self.max_radius
}
pub fn penetration_length(&self) -> Length<R> {
self.penetration_length
}
pub fn terminal_shock_standoff(&self) -> Length<R> {
self.terminal_shock_standoff
}
}