Struct feos_core::StateBuilder
source · [−]pub struct StateBuilder<'a, U: EosUnit, E: EquationOfState> { /* 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 = Rc::new(PengRobinson::new(Rc::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(3))
.moles(&(arr1(&[2.5]) * MOL))
.build()?;
assert_eq!(state.density, 0.2 * MOL / METER.powi(3));
// For a pure component, the composition does not need to be specified.
let eos = Rc::new(PengRobinson::new(Rc::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(3))
.total_moles(2.5 * MOL)
.build()?;
assert_eq!(state.density, 0.2 * MOL / METER.powi(3));
// The state can be constructed without providing any extensive property.
let eos = Rc::new(PengRobinson::new(
Rc::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(3)))
.build()?;
assert_relative_eq!(state.molefracs, arr1(&[0.25, 0.75]));
assert_relative_eq!(state.density, 0.8 * MOL / METER.powi(3));
Implementations
sourceimpl<'a, U: EosUnit, E: EquationOfState> StateBuilder<'a, U, E>
impl<'a, U: EosUnit, E: EquationOfState> StateBuilder<'a, U, E>
sourcepub fn temperature(self, temperature: QuantityScalar<U>) -> Self
pub fn temperature(self, temperature: QuantityScalar<U>) -> Self
Provide the temperature for the new state.
sourcepub fn volume(self, volume: QuantityScalar<U>) -> Self
pub fn volume(self, volume: QuantityScalar<U>) -> Self
Provide the volume for the new state.
sourcepub fn density(self, density: QuantityScalar<U>) -> Self
pub fn density(self, density: QuantityScalar<U>) -> Self
Provide the density for the new state.
sourcepub fn partial_density(self, partial_density: &'a QuantityArray1<U>) -> Self
pub fn partial_density(self, partial_density: &'a QuantityArray1<U>) -> Self
Provide partial densities for the new state.
sourcepub fn total_moles(self, total_moles: QuantityScalar<U>) -> Self
pub fn total_moles(self, total_moles: QuantityScalar<U>) -> Self
Provide the total moles for the new state.
sourcepub fn moles(self, moles: &'a QuantityArray1<U>) -> Self
pub fn moles(self, moles: &'a QuantityArray1<U>) -> Self
Provide the 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 pressure(self, pressure: QuantityScalar<U>) -> Self
pub fn pressure(self, pressure: QuantityScalar<U>) -> Self
Provide the pressure for the new state.
sourcepub fn molar_enthalpy(self, molar_enthalpy: QuantityScalar<U>) -> Self
pub fn molar_enthalpy(self, molar_enthalpy: QuantityScalar<U>) -> Self
Provide the molar enthalpy for the new state.
sourcepub fn molar_entropy(self, molar_entropy: QuantityScalar<U>) -> Self
pub fn molar_entropy(self, molar_entropy: QuantityScalar<U>) -> Self
Provide the molar entropy for the new state.
sourcepub fn molar_internal_energy(
self,
molar_internal_energy: QuantityScalar<U>
) -> Self
pub fn molar_internal_energy(
self,
molar_internal_energy: QuantityScalar<U>
) -> Self
Provide the molar internal energy for the new state.
sourcepub fn initial_density(self, initial_density: QuantityScalar<U>) -> Self
pub fn initial_density(self, initial_density: QuantityScalar<U>) -> Self
Provide an initial density used in density iterations.
sourcepub fn initial_temperature(self, initial_temperature: QuantityScalar<U>) -> Self
pub fn initial_temperature(self, initial_temperature: QuantityScalar<U>) -> Self
Provide an initial temperature used in the Newton solver.
Trait Implementations
sourceimpl<'a, U: EosUnit, E: EquationOfState> Clone for StateBuilder<'a, U, E>
impl<'a, U: EosUnit, E: EquationOfState> Clone for StateBuilder<'a, U, E>
Auto Trait Implementations
impl<'a, U, E> RefUnwindSafe for StateBuilder<'a, U, E> where
E: RefUnwindSafe,
U: RefUnwindSafe,
impl<'a, U, E> !Send for StateBuilder<'a, U, E>
impl<'a, U, E> !Sync for StateBuilder<'a, U, E>
impl<'a, U, E> Unpin for StateBuilder<'a, U, E> where
U: Unpin,
impl<'a, U, E> UnwindSafe for StateBuilder<'a, U, E> where
E: RefUnwindSafe,
U: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more