Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
enable using the multiparameter ideal gas models independently
  • Loading branch information
prehner committed Oct 17, 2025
commit 04e3b74b7d50ca58dec4222883608392ee5d65d1
1 change: 1 addition & 0 deletions py-feos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ all_models = [
"pets",
"saftvrqmie",
"saftvrmie",
"multiparameter"
]
21 changes: 12 additions & 9 deletions py-feos/src/eos/constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ impl PyEquationOfState {
/// Returns
/// -------
/// EquationOfState
fn python_ideal_gas(&mut self, ideal_gas: Vec<Bound<'_, PyAny>>) -> PyResult<()> {
self.add_ideal_gas(
fn python_ideal_gas<'py>(
slf: Bound<'py, Self>,
ideal_gas: Vec<Bound<'py, PyAny>>,
) -> PyResult<Bound<'py, Self>> {
slf.borrow_mut().add_ideal_gas(
ideal_gas
.into_iter()
.map(|i| Ok(IdealGasModel::Python(Arc::new(PyIdealGas::new(i)?))))
.collect::<PyResult<_>>()?,
);
Ok(())
Ok(slf)
}

/// Ideal gas model of Joback and Reid.
Expand All @@ -91,14 +94,14 @@ impl PyEquationOfState {
/// Returns
/// -------
/// EquationOfState
fn joback(&mut self, joback: PyGcParameters) -> PyResult<()> {
self.add_ideal_gas(
fn joback(slf: Bound<'_, Self>, joback: PyGcParameters) -> PyResult<Bound<'_, Self>> {
slf.borrow_mut().add_ideal_gas(
Joback::new(joback.try_convert_homosegmented()?)
.into_iter()
.map(IdealGasModel::Joback)
.collect(),
);
Ok(())
Ok(slf)
}

/// Ideal gas model based on DIPPR equations for the ideal
Expand All @@ -112,13 +115,13 @@ impl PyEquationOfState {
/// Returns
/// -------
/// EquationOfState
fn dippr(&mut self, dippr: PyParameters) -> PyResult<()> {
self.add_ideal_gas(
fn dippr(slf: Bound<'_, Self>, dippr: PyParameters) -> PyResult<Bound<'_, Self>> {
slf.borrow_mut().add_ideal_gas(
Dippr::new(dippr.try_convert()?)
.into_iter()
.map(IdealGasModel::Dippr)
.collect(),
);
Ok(())
Ok(slf)
}
}
25 changes: 24 additions & 1 deletion py-feos/src/eos/multiparameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ impl PyEquationOfState {
/// Returns
/// -------
/// EquationOfState
/// The equation of state that can be used to compute thermodynamic states.
#[staticmethod]
pub fn multiparameter(parameters: PyParameters) -> PyResult<Self> {
let eos = MultiParameter::new(parameters.try_convert()?);
Expand All @@ -31,4 +30,28 @@ impl PyEquationOfState {
.collect();
Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual))))
}

/// Ideal gas model used in multiparameter Helmholtz energy equations of state.
///
/// Parameters
/// ----------
/// parameters : Parameters
/// The parameters of the multiparameter Helmholtz equation of state.
///
/// Returns
/// -------
/// EquationOfState
pub fn multiparameter_ideal_gas(
slf: Bound<'_, Self>,
parameters: PyParameters,
) -> PyResult<Bound<'_, Self>> {
let eos = MultiParameter::new(parameters.try_convert()?);
let ideal_gas = eos
.ideal_gas
.into_iter()
.map(IdealGasModel::MultiParameter)
.collect();
slf.borrow_mut().add_ideal_gas(ideal_gas);
Ok(slf)
}
}