Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions feos-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Added new functions `isenthalpic_compressibility`, `thermal_expansivity` and `grueneisen_parameter` to `State`. [#154](https://github.com/feos-org/feos/pull/154)
- Readded `PhaseEquilibrium::new_npt` to the public interface in Rust and Python. [#164](https://github.com/feos-org/feos/pull/164)

### Changed
- Changed constructors of `Parameter` trait to return `Result`s. [#161](https://github.com/feos-org/feos/pull/161)
Expand Down
8 changes: 7 additions & 1 deletion feos-core/src/phase_equilibria/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ impl<E: EquationOfState> PhaseEquilibrium<E, 2> {
Self([vapor, liquid])
}

pub(super) fn new_npt(
/// Creates a new PhaseEquilibrium that contains two states at the
/// specified temperature, pressure and moles.
///
/// The constructor can be used in custom phase equilibrium solvers or,
/// e.g., to generate initial guesses for an actual VLE solver.
/// In general, the two states generated are NOT in an equilibrium.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this even more visible, we could add a header, i.e.

/// # Note
///
/// In general, the two states generated are NOT in an equilibrium.

pub fn new_npt(
eos: &Arc<E>,
temperature: SINumber,
pressure: SINumber,
Expand Down
40 changes: 40 additions & 0 deletions feos-core/src/python/phase_equilibria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,46 @@ macro_rules! impl_phase_equilibrium {
)?))
}

/// Creates a new PhaseEquilibrium that contains two states at the
/// specified temperature, pressure and moles.
///
/// The constructor can be used in custom phase equilibrium solvers or,
/// e.g., to generate initial guesses for an actual VLE solver.
/// In general, the two states generated are NOT in an equilibrium.
///
/// Parameters
/// ----------
/// eos : EquationOfState
/// The equation of state.
/// temperature : SINumber
/// The system temperature.
/// pressure : SINumber
/// The system pressure.
/// vapor_moles : SIArray1
/// Amount of substance of the vapor phase.
/// liquid_moles : SIArray1
/// Amount of substance of the liquid phase.
///
/// Returns
/// -------
/// PhaseEquilibrium
#[staticmethod]
pub fn new_npt(
eos: $py_eos,
temperature: PySINumber,
pressure: PySINumber,
vapor_moles: &PySIArray1,
liquid_moles: &PySIArray1
) -> PyResult<Self> {
Ok(Self(PhaseEquilibrium::new_npt(
&eos.0,
temperature.into(),
pressure.into(),
vapor_moles,
liquid_moles
)?))
}

#[getter]
fn get_vapor(&self) -> PyState {
PyState(self.0.vapor().clone())
Expand Down