pub struct StateBuilder<'a, E, const IG: bool> { /* private fields */ }Expand description
A simple tool to construct States with arbitrary input parameters.
§Examples
// Create a state for given T,V,N
let eos = &PengRobinson::new(PengRobinsonParameters::new_simple(&[369.8], &[41.9 * 1e5], &[0.15], &[15.0])?);
let state = StateBuilder::new(&eos)
.temperature(300.0 * KELVIN)
.volume(12.5 * METER.powi::<P3>())
.moles(&(dvector![2.5] * MOL))
.build()?;
assert_eq!(state.density, 0.2 * MOL / METER.powi::<P3>());
// For a pure component, the composition does not need to be specified.
let eos = &PengRobinson::new(PengRobinsonParameters::new_simple(&[369.8], &[41.9 * 1e5], &[0.15], &[15.0])?);
let state = StateBuilder::new(&eos)
.temperature(300.0 * KELVIN)
.volume(12.5 * METER.powi::<P3>())
.total_moles(2.5 * MOL)
.build()?;
assert_eq!(state.density, 0.2 * MOL / METER.powi::<P3>());
// The state can be constructed without providing any extensive property.
let eos = &PengRobinson::new(
PengRobinsonParameters::new_simple(
&[369.8, 305.4],
&[41.9 * 1e5, 48.2 * 1e5],
&[0.15, 0.10],
&[15.0, 30.0]
)?
);
let state = StateBuilder::new(&eos)
.temperature(300.0 * KELVIN)
.partial_density(&(dvector![0.2, 0.6] * MOL / METER.powi::<P3>()))
.build()?;
assert_relative_eq!(state.molefracs, dvector![0.25, 0.75]);
assert_relative_eq!(state.density, 0.8 * MOL / METER.powi::<P3>());Implementations§
Source§impl<'a, E: Residual> StateBuilder<'a, E, false>
impl<'a, E: Residual> StateBuilder<'a, E, false>
Source§impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG>
impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG>
Sourcepub fn temperature(self, temperature: Temperature) -> Self
pub fn temperature(self, temperature: Temperature) -> Self
Provide the temperature for the new state.
Sourcepub fn partial_density(self, partial_density: &'a Density<DVector<f64>>) -> Self
pub fn partial_density(self, partial_density: &'a Density<DVector<f64>>) -> Self
Provide partial densities for the new state.
Sourcepub fn total_moles(self, total_moles: Moles) -> Self
pub fn total_moles(self, total_moles: Moles) -> Self
Provide the total moles for the new state.
Sourcepub fn moles(self, moles: &'a Moles<DVector<f64>>) -> Self
pub fn moles(self, moles: &'a Moles<DVector<f64>>) -> Self
Provide the moles for the new state.
Sourcepub fn molefracs(self, molefracs: &'a DVector<f64>) -> Self
pub fn molefracs(self, molefracs: &'a DVector<f64>) -> Self
Provide the molefracs for the new state.
Sourcepub fn initial_density(self, initial_density: Density) -> Self
pub fn initial_density(self, initial_density: Density) -> Self
Provide an initial density used in density iterations.
Source§impl<'a, E: Total, const IG: bool> StateBuilder<'a, E, IG>
impl<'a, E: Total, const IG: bool> StateBuilder<'a, E, IG>
Sourcepub fn molar_enthalpy(
self,
molar_enthalpy: MolarEnergy,
) -> StateBuilder<'a, E, true>
pub fn molar_enthalpy( self, molar_enthalpy: MolarEnergy, ) -> StateBuilder<'a, E, true>
Provide the molar enthalpy for the new state.
Sourcepub fn molar_entropy(
self,
molar_entropy: MolarEntropy,
) -> StateBuilder<'a, E, true>
pub fn molar_entropy( self, molar_entropy: MolarEntropy, ) -> StateBuilder<'a, E, true>
Provide the molar entropy for the new state.
Sourcepub fn molar_internal_energy(
self,
molar_internal_energy: MolarEnergy,
) -> StateBuilder<'a, E, true>
pub fn molar_internal_energy( self, molar_internal_energy: MolarEnergy, ) -> StateBuilder<'a, E, true>
Provide the molar internal energy for the new state.
Sourcepub fn initial_temperature(
self,
initial_temperature: Temperature,
) -> StateBuilder<'a, E, true>
pub fn initial_temperature( self, initial_temperature: Temperature, ) -> StateBuilder<'a, E, true>
Provide an initial temperature used in the Newton solver.
Source§impl<E: Residual> StateBuilder<'_, E, false>
impl<E: Residual> StateBuilder<'_, E, false>
Sourcepub fn build(self) -> FeosResult<State<E>>
pub fn build(self) -> FeosResult<State<E>>
Try to build the state with the given inputs.
Source§impl<E: Total> StateBuilder<'_, E, true>
impl<E: Total> StateBuilder<'_, E, true>
Sourcepub fn build(self) -> FeosResult<State<E>>
pub fn build(self) -> FeosResult<State<E>>
Try to build the state with the given inputs.
Trait Implementations§
Source§impl<'a, E: Clone, const IG: bool> Clone for StateBuilder<'a, E, IG>
impl<'a, E: Clone, const IG: bool> Clone for StateBuilder<'a, E, IG>
Source§fn clone(&self) -> StateBuilder<'a, E, IG>
fn clone(&self) -> StateBuilder<'a, E, IG>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a, E, const IG: bool> Freeze for StateBuilder<'a, E, IG>
impl<'a, E, const IG: bool> RefUnwindSafe for StateBuilder<'a, E, IG>where
E: RefUnwindSafe,
impl<'a, E, const IG: bool> Send for StateBuilder<'a, E, IG>where
E: Sync,
impl<'a, E, const IG: bool> Sync for StateBuilder<'a, E, IG>where
E: Sync,
impl<'a, E, const IG: bool> Unpin for StateBuilder<'a, E, IG>
impl<'a, E, const IG: bool> UnwindSafe for StateBuilder<'a, E, IG>where
E: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PropertiesAD for T
impl<T> PropertiesAD for T
fn vapor_pressure<const P: usize>( &self, temperature: Temperature, ) -> FeosResult<Pressure<DualSVec<f64, f64, P>>>
fn equilibrium_liquid_density<const P: usize>( &self, temperature: Temperature, ) -> FeosResult<(Pressure<DualSVec<f64, f64, P>>, Density<DualSVec<f64, f64, P>>)>
fn liquid_density<const P: usize>( &self, temperature: Temperature, pressure: Pressure, ) -> FeosResult<Density<DualSVec<f64, f64, P>>>
fn vapor_pressure_parallel<const P: usize>(
parameter_names: [String; P],
parameters: ArrayView2<'_, f64>,
input: ArrayView2<'_, f64>,
) -> (Array1<f64>, Array2<f64>, Array1<bool>)where
Self: ParametersAD<1>,
fn liquid_density_parallel<const P: usize>(
parameter_names: [String; P],
parameters: ArrayView2<'_, f64>,
input: ArrayView2<'_, f64>,
) -> (Array1<f64>, Array2<f64>, Array1<bool>)where
Self: ParametersAD<1>,
fn equilibrium_liquid_density_parallel<const P: usize>(
parameter_names: [String; P],
parameters: ArrayView2<'_, f64>,
input: ArrayView2<'_, f64>,
) -> (Array1<f64>, Array2<f64>, Array1<bool>)where
Self: ParametersAD<1>,
fn bubble_point_pressure<const P: usize>( &self, temperature: Temperature, pressure: Option<Pressure>, liquid_molefracs: SVector<f64, 2>, ) -> FeosResult<Pressure<DualSVec<f64, f64, P>>>
fn dew_point_pressure<const P: usize>( &self, temperature: Temperature, pressure: Option<Pressure>, vapor_molefracs: SVector<f64, 2>, ) -> FeosResult<Pressure<DualSVec<f64, f64, P>>>
fn bubble_point_pressure_parallel<const P: usize>(
parameter_names: [String; P],
parameters: ArrayView2<'_, f64>,
input: ArrayView2<'_, f64>,
) -> (Array1<f64>, Array2<f64>, Array1<bool>)where
Self: ParametersAD<2>,
fn dew_point_pressure_parallel<const P: usize>(
parameter_names: [String; P],
parameters: ArrayView2<'_, f64>,
input: ArrayView2<'_, f64>,
) -> (Array1<f64>, Array2<f64>, Array1<bool>)where
Self: ParametersAD<2>,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.