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 = Arc::new(PengRobinson::new(Arc::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(&(arr1(&[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 = Arc::new(PengRobinson::new(Arc::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 = Arc::new(PengRobinson::new(
Arc::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(&(arr1(&[0.2, 0.6]) * MOL / METER.powi::<P3>()))
.build()?;
assert_relative_eq!(state.molefracs, arr1(&[0.25, 0.75]));
assert_relative_eq!(state.density, 0.8 * MOL / METER.powi::<P3>());
Implementations§
Source§impl<E: Residual> StateBuilder<'_, E, false>
impl<E: Residual> StateBuilder<'_, 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<Array1<f64>>) -> Self
pub fn partial_density(self, partial_density: &'a Density<Array1<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 molefracs(self, molefracs: &'a Array1<f64>) -> Self
pub fn molefracs(self, molefracs: &'a Array1<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: Residual + IdealGas, const IG: bool> StateBuilder<'a, E, IG>
impl<'a, E: Residual + IdealGas, 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>
Trait Implementations§
Auto 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>
impl<'a, E, const IG: bool> Sync for StateBuilder<'a, E, IG>
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<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
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, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.
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<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.