Skip to main content

ThermoSystem

Struct ThermoSystem 

Source
pub struct ThermoSystem { /* private fields */ }
Expand description

An owned mixture + model selection that answers equilibrium questions.

vle_thermo::flash::SystemSpec borrows all its data, so this struct owns the components and parameter matrices and assembles a fresh (cheap, Copy) spec per call. Construct once per column problem, reuse for every evaluation.

Implementations§

Source§

impl ThermoSystem

Source

pub fn peng_robinson(names: &[&str]) -> Result<Self>

A φ-φ system: Peng–Robinson (1976) for both phases, classical mixing, all kij = 0. Components are loaded from vle-thermo’s built-in database by (case-insensitive) name.

This is the right default for near-ideal hydrocarbon pairs like benzene–toluene.

§Errors

StagesError::Thermo if any name is not in the database.

Source

pub fn van_laar(names: &[&str; 2], a12: f64, a21: f64) -> Result<Self>

A γ-φ system: van Laar activity coefficients for the liquid, ideal-gas vapor. Components are loaded from vle-thermo’s built-in database by (case-insensitive) name.

§Arguments
  • a12, a21 — the dimensionless van Laar parameters, in the component order given by names (a12 multiplies the first component’s infinite-dilution log-γ: ln γ₁^∞ = A₁₂).

For methanol(1)–water(2), vle Chapter IV (Orbey & Sandler Table 4.5) regressed A₁₂ = 0.5853, A₂₁ = 0.3458.

§Errors

StagesError::Thermo if any name is not in the database.

Source

pub fn nrtl(names: &[&str; 2], a12: f64, a21: f64, alpha12: f64) -> Result<Self>

A γ-φ system: NRTL activity coefficients (Renon & Prausnitz, AIChE J. 1968, 14, 135) for the liquid, ideal-gas vapor. Components are loaded from vle-thermo’s built-in database by (case-insensitive) name.

NRTL is the general aqueous-organic infrastructure the ladder needs from M2 on (Ponchon–Savarit’s ammonia–water showcase, and the later extractive/azeotropic ternaries). Its binary form has three parameters: two interaction energies plus one shared non-randomness factor.

§Arguments
  • a12, a21 — the NRTL interaction energies gᵢⱼ − gⱼⱼ in kJ/kmol, in the component order given by names. vle-thermo forms τᵢⱼ = aᵢⱼ / (R·T) internally (R = 8.31451 kJ/(kmol·K)), so these are the energy parameters, not the dimensionless τ.
  • alpha12 — the (symmetric) non-randomness parameter α₁₂ = α₂₁, dimensionless, typically 0.2–0.47.
§Errors

StagesError::Thermo if any name is not in the database.

Source

pub fn t_ref(&self) -> f64

The enthalpy-datum temperature in K ([T_REF]).

Source

pub fn p_ref(&self) -> f64

The enthalpy-datum pressure in kPa ([P_REF]).

Source

pub fn n_components(&self) -> usize

Number of components in the mixture.

Source

pub fn component_names(&self) -> Vec<String>

Component names, in the order compositions are indexed.

Source

pub fn bubble_temperature(&self, p: f64, x: &[f64]) -> Result<BubblePoint>

Bubble temperature of a liquid of composition x at pressure p.

§Arguments
  • p — pressure in kPa (absolute)
  • x — liquid mole fractions (must sum to 1)
§Returns

BubblePoint with value = bubble temperature in K.

Source

pub fn bubble_pressure(&self, t: f64, x: &[f64]) -> Result<BubblePoint>

Bubble pressure of a liquid of composition x at temperature t.

§Arguments
  • t — temperature in K
  • x — liquid mole fractions (must sum to 1)
§Returns

BubblePoint with value = bubble pressure in kPa (absolute).

Source

pub fn phase_enthalpy( &self, t: f64, p: f64, comp: &[f64], phase: Phase, ) -> Result<f64>

Molar enthalpy of comp in the given phase at (t, p).

This is the energy quantity Ponchon–Savarit needs: the H–x–y diagram is saturated-liquid and saturated-vapor enthalpy versus composition. The call routes to vle-thermo’s phase_enthalpy_entropy, which for the γ-φ liquid assembles ideal-gas terms minus the per-component Clausius–Clapeyron condensation enthalpy plus the excess enthalpy Hᴱ — the γ-φ enthalpy route (see the M2 lesson in docs/theory/ponchon-savarit.md). Entropy is computed alongside but deliberately discarded — P–S never uses it; widen the return to a pair only when a later milestone needs S.

§Arguments
  • t — temperature in K
  • p — pressure in kPa (absolute)
  • comp — phase mole fractions (must sum to 1, length = n components)
  • phasePhase::Liquid or Phase::Vapor
§Returns

Molar enthalpy in kJ/kmol, relative to the system’s t_ref/p_ref datum with per-component reference enthalpy zero (P–S uses differences).

§Errors

StagesError::Dimension on a length mismatch; StagesError::Thermo if the property evaluation fails.

Trait Implementations§

Source§

impl Clone for ThermoSystem

Source§

fn clone(&self) -> ThermoSystem

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 Debug for ThermoSystem

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.