Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.

Commit c05d720

Browse files
committed
Added functions to python interface
1 parent 7da5352 commit c05d720

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

src/python/state.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,29 @@ macro_rules! impl_state {
565565
self.0.ln_phi().view().to_pyarray(py)
566566
}
567567

568+
/// Return logarithmic pure substance fugacity coefficient.
569+
///
570+
/// For each component, the hypothetical liquid fugacity coefficient
571+
/// at mixture temperature and pressure is computed.
572+
///
573+
/// Returns
574+
/// -------
575+
/// numpy.ndarray
576+
#[pyo3(text_signature = "($self)")]
577+
fn ln_phi_pure<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<f64>> {
578+
Ok(self.0.ln_phi_pure()?.view().to_pyarray(py))
579+
}
580+
581+
/// Return logarithmic symmetric activity coefficient.
582+
///
583+
/// Returns
584+
/// -------
585+
/// numpy.ndarray
586+
#[pyo3(text_signature = "($self)")]
587+
fn ln_symmetric_activity_coefficient<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<f64>> {
588+
Ok(self.0.ln_symmetric_activity_coefficient()?.view().to_pyarray(py))
589+
}
590+
568591
/// Return derivative of logarithmic fugacity coefficient w.r.t. temperature.
569592
///
570593
/// Returns

src/state/properties.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,19 @@ impl<U: EosUnit, E: EquationOfState> State<U, E> {
313313
&(arr1(&[1.0]) * U::reference_moles()),
314314
crate::DensityInitialization::Liquid,
315315
)?;
316-
state.ln_phi()[0]
316+
Ok(state.ln_phi()[0])
317317
})
318318
.collect()
319319
}
320320

321+
/// Activity coefficient $\ln \gamma_i = \ln \varphi_i(T, p, \mathbf{N}) - \ln \varphi_i(T, p)$
322+
pub fn ln_symmetric_activity_coefficient(&self) -> EosResult<Array1<f64>> {
323+
match self.eos.components() {
324+
1 => Ok(arr1(&[0.0])),
325+
_ => Ok(self.ln_phi() - &self.ln_phi_pure()?),
326+
}
327+
}
328+
321329
/// 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}$
322330
pub fn dln_phi_dt(&self) -> QuantityArray1<U> {
323331
let func = |s: &Self, evaluate: Evaluate| {
@@ -489,11 +497,6 @@ impl<U: EosUnit, E: EquationOfState> State<U, E> {
489497
.unwrap()
490498
}
491499

492-
/// Activity coefficient $\ln \gamma_i = \ln \varphi_i(T, p, \mathbf{N}) - \ln \varphi_i(T, p)$
493-
pub fn ln_symmetric_activity_coefficient(&self) -> Array1<f64> {
494-
self.ln_phi() - self.ln_phi_pure()
495-
}
496-
497500
/// Helmholtz energy $A$ evaluated for each contribution of the equation of state.
498501
pub fn helmholtz_energy_contributions(&self) -> Vec<(String, QuantityScalar<U>)> {
499502
let new_state = self.derive0();

0 commit comments

Comments
 (0)