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

Create a new StateBuilder for the given equation of state.

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 molar enthalpy for the new state.

Provide the molar entropy for the new state.

Provide the molar internal energy for the new state.

Specify a vapor state.

Specify a liquid state.

Provide an initial density used in density iterations.

Provide an initial temperature used in the Newton solver.

Try to build the state with the given inputs.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.