Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
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
Added functions to python interface
  • Loading branch information
g-bauer committed Apr 6, 2022
commit 0f8ae0216797377d23dba2b8e68387ba2a61ffd0
23 changes: 23 additions & 0 deletions src/python/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,29 @@ macro_rules! impl_state {
self.0.ln_phi().view().to_pyarray(py)
}

/// Return logarithmic pure substance fugacity coefficient.
///
/// For each component, the hypothetical liquid fugacity coefficient
/// at mixture temperature and pressure is computed.
///
/// Returns
/// -------
/// numpy.ndarray
#[pyo3(text_signature = "($self)")]
fn ln_phi_pure<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<f64>> {
Ok(self.0.ln_phi_pure()?.view().to_pyarray(py))
}

/// Return logarithmic symmetric activity coefficient.
///
/// Returns
/// -------
/// numpy.ndarray
#[pyo3(text_signature = "($self)")]
fn ln_symmetric_activity_coefficient<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<f64>> {
Ok(self.0.ln_symmetric_activity_coefficient()?.view().to_pyarray(py))
}

/// Return derivative of logarithmic fugacity coefficient w.r.t. temperature.
///
/// Returns
Expand Down
15 changes: 9 additions & 6 deletions src/state/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,19 @@ impl<U: EosUnit, E: EquationOfState> State<U, E> {
&(arr1(&[1.0]) * U::reference_moles()),
crate::DensityInitialization::Liquid,
)?;
state.ln_phi()[0]
Ok(state.ln_phi()[0])
})
.collect()
}

/// Activity coefficient $\ln \gamma_i = \ln \varphi_i(T, p, \mathbf{N}) - \ln \varphi_i(T, p)$
pub fn ln_symmetric_activity_coefficient(&self) -> EosResult<Array1<f64>> {
match self.eos.components() {
1 => Ok(arr1(&[0.0])),
_ => Ok(self.ln_phi() - &self.ln_phi_pure()?),
}
}

/// Partial derivative of the logarithm of the fugacity coefficient w.r.t. temperature: $\left(\frac{\partial\ln\varphi_i}{\partial T}\right)_{p,N_i}$
pub fn dln_phi_dt(&self) -> QuantityArray1<U> {
let func = |s: &Self, evaluate: Evaluate| {
Expand Down Expand Up @@ -490,11 +498,6 @@ impl<U: EosUnit, E: EquationOfState> State<U, E> {
.unwrap()
}

/// Activity coefficient $\ln \gamma_i = \ln \varphi_i(T, p, \mathbf{N}) - \ln \varphi_i(T, p)$
pub fn ln_symmetric_activity_coefficient(&self) -> Array1<f64> {
self.ln_phi() - self.ln_phi_pure()
}

/// Helmholtz energy $A$ evaluated for each contribution of the equation of state.
pub fn helmholtz_energy_contributions(&self) -> Vec<(String, QuantityScalar<U>)> {
let new_state = self.derive0();
Expand Down