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]).unwrap())));
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]).unwrap())));
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]
).unwrap())
));
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
Provide the temperature for the new state.
Provide the volume for the new state.
Provide the density for the new state.
Provide partial densities for the new state.
Provide the total moles for the new state.
Provide the moles for the new state.
Provide the molefracs for the new state.
Provide the pressure for the new state.
Provide the enthalpy for the new state.
Provide the entropy for the new state.
Provide the internal energy for the new state.
Provide an initial density used in density iterations.
Provide an initial temperature used in the Newton solver.
Trait Implementations
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
Mutably borrows from an owned value. Read more