Skip to main content

ControlVolume

Struct ControlVolume 

Source
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>

Source

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.

Source

pub fn from_constrained( volume: Constrained<Volume, StrictlyPositive>, state: State<Fluid>, ) -> Self

Creates a new ControlVolume from a pre-validated positive volume and state.

Source

pub fn net_mass_flow<'a, I>(flows: I) -> MassRate
where 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.

Source

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 = ()>,

Source

pub fn state_derivative<Model>( &self, flows: &[BoundaryFlow<Fluid>], model: &Model, ) -> Result<StateDerivative<Fluid>, PropertyError>
where Model: ThermoModel<Fluid = Fluid> + HasCv + HasEnthalpy + HasInternalEnergy,

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>

Source§

fn clone(&self) -> ControlVolume<Fluid>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Fluid: Copy> Copy for ControlVolume<Fluid>

Source§

impl<Fluid: Debug> Debug for ControlVolume<Fluid>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Fluid: PartialEq> PartialEq for ControlVolume<Fluid>

Source§

fn eq(&self, other: &ControlVolume<Fluid>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Fluid: PartialEq> StructuralPartialEq for ControlVolume<Fluid>

Auto Trait Implementations§

§

impl<Fluid> Freeze for ControlVolume<Fluid>
where Fluid: Freeze,

§

impl<Fluid> RefUnwindSafe for ControlVolume<Fluid>
where Fluid: RefUnwindSafe,

§

impl<Fluid> Send for ControlVolume<Fluid>
where Fluid: Send,

§

impl<Fluid> Sync for ControlVolume<Fluid>
where Fluid: Sync,

§

impl<Fluid> Unpin for ControlVolume<Fluid>
where Fluid: Unpin,

§

impl<Fluid> UnsafeUnpin for ControlVolume<Fluid>
where Fluid: UnsafeUnpin,

§

impl<Fluid> UnwindSafe for ControlVolume<Fluid>
where Fluid: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.