pub struct ControlVolume<Fluid> { /* private fields */ }Expand description
A finite control volume representing a well-mixed region of fluid.
The internal fluid state is assumed to be spatially uniform, and any mass leaving the volume is at the current internal state. Changes in kinetic and potential energy are neglected.
Implementations§
Source§impl<Fluid> ControlVolume<Fluid>
impl<Fluid> ControlVolume<Fluid>
Sourcepub fn new(volume: Volume, state: State<Fluid>) -> Result<Self, ConstraintError>
pub fn new(volume: Volume, state: State<Fluid>) -> Result<Self, ConstraintError>
Creates a new ControlVolume from a volume and initial state.
§Errors
Returns a ConstraintError if volume is not strictly positive.
Sourcepub fn from_constrained(
volume: Constrained<Volume, StrictlyPositive>,
state: State<Fluid>,
) -> Self
pub fn from_constrained( volume: Constrained<Volume, StrictlyPositive>, state: State<Fluid>, ) -> Self
Creates a new ControlVolume from a pre-validated positive volume and state.
Sourcepub fn net_mass_flow<'a, I>(flows: I) -> MassRatewhere
I: IntoIterator<Item = &'a BoundaryFlow<Fluid>>,
Fluid: 'a,
pub fn net_mass_flow<'a, I>(flows: I) -> MassRatewhere
I: IntoIterator<Item = &'a BoundaryFlow<Fluid>>,
Fluid: 'a,
Returns the net mass flow rate into the control volume.
Inflow contributions are positive. Outflow contributions are negative.
Only BoundaryFlow::Mass entries affect the result.
Sourcepub fn net_energy_flow<'a, I, Model>(
&self,
flows: I,
model: &Model,
) -> Result<Power, PropertyError>where
Model: ThermoModel<Fluid = Fluid> + HasEnthalpy,
I: IntoIterator<Item = &'a BoundaryFlow<Fluid>>,
Fluid: 'a,
pub fn net_energy_flow<'a, I, Model>(
&self,
flows: I,
model: &Model,
) -> Result<Power, PropertyError>where
Model: ThermoModel<Fluid = Fluid> + HasEnthalpy,
I: IntoIterator<Item = &'a BoundaryFlow<Fluid>>,
Fluid: 'a,
Returns the net energy flow rate into the control volume.
Inflow contributions are positive. Outflow contributions are negative.
§Parameters
flows: Iterator over boundary flows.model: Model used to compute thermodynamic properties.
§Errors
Returns a PropertyError if any required enthalpy cannot be computed.
Source§impl<Fluid> ControlVolume<Fluid>where
Fluid: TimeIntegrable<Derivative = ()>,
impl<Fluid> ControlVolume<Fluid>where
Fluid: TimeIntegrable<Derivative = ()>,
Sourcepub fn state_derivative<Model>(
&self,
flows: &[BoundaryFlow<Fluid>],
model: &Model,
) -> Result<StateDerivative<Fluid>, PropertyError>
pub fn state_derivative<Model>( &self, flows: &[BoundaryFlow<Fluid>], model: &Model, ) -> Result<StateDerivative<Fluid>, PropertyError>
Returns the time derivative of the control volume’s internal state.
The model applies transient mass and energy balances to a fixed-volume, well-mixed control volume with negligible kinetic and potential energy changes.
§Mass and Energy Balances
Conservation of mass and energy yield the following, using a positive-into-the-system sign convention for both heat and work:
dM/dt = V · dρ/dt = ∑ṁ_in − ∑ṁ_out
dU/dt = Q̇_net + Ẇ_net + ∑(ṁ_in · h_in) − ∑(ṁ_out · h_out)The total time derivative of internal energy in the fixed volume is:
dU/dt = V · (ρ · du/dt + u · dρ/dt)
= V · (ρ · cv · dT/dt + u · dρ/dt)Substituting and solving for dρ/dt and dT/dt:
dρ/dt = (∑ṁ_in − ∑ṁ_out) / V
dT/dt = (Q̇_net + Ẇ_net + ∑(ṁ_in · h_in) − ∑(ṁ_out · h_out) − u · V · dρ/dt)
/ (ρ · V · cv)Where:
dρ/dt= rate of change of fluid density (kg/m³·s)dT/dt= rate of change of fluid temperature (K/s)dU/dt= rate of change of total internal energy in the volume (W)ṁ_in= mass inflow rate (kg/s)ṁ_out= mass outflow rate (kg/s)h_in= specific enthalpy of the inflow (J/kg)h_out= specific enthalpy of the outflow (J/kg)Q̇_net= net heat transfer rate into the system (W)Ẇ_net= net work rate into the system (W)u= specific internal energy of the fluid (J/kg)ρ= fluid density (kg/m³)cv= specific heat at constant volume (J/kg·K)V= volume of the control region (m³)
Note that SI units are shown for clarity.
All computations use unit-safe types via the uom system,
which enforces dimensional consistency at compile time.
§Parameters
flows: Boundary flows affecting the control volume.model: Model used to compute thermodynamic properties.
§Errors
Returns a PropertyError if any required property cannot be computed.
Trait Implementations§
Source§impl<Fluid: Clone> Clone for ControlVolume<Fluid>
impl<Fluid: Clone> Clone for ControlVolume<Fluid>
Source§fn clone(&self) -> ControlVolume<Fluid>
fn clone(&self) -> ControlVolume<Fluid>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<Fluid: Copy> Copy for ControlVolume<Fluid>
Source§impl<Fluid: Debug> Debug for ControlVolume<Fluid>
impl<Fluid: Debug> Debug for ControlVolume<Fluid>
Source§impl<Fluid: PartialEq> PartialEq for ControlVolume<Fluid>
impl<Fluid: PartialEq> PartialEq for ControlVolume<Fluid>
Source§fn eq(&self, other: &ControlVolume<Fluid>) -> bool
fn eq(&self, other: &ControlVolume<Fluid>) -> bool
self and other values to be equal, and is used by ==.