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

Commit 0f8ae02

Browse files
committed
Added functions to python interface
1 parent aa42396 commit 0f8ae02

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
@@ -525,6 +525,29 @@ macro_rules! impl_state {
525525
self.0.ln_phi().view().to_pyarray(py)
526526
}
527527

528+
/// Return logarithmic pure substance fugacity coefficient.
529+
///
530+
/// For each component, the hypothetical liquid fugacity coefficient
531+
/// at mixture temperature and pressure is computed.
532+
///
533+
/// Returns
534+
/// -------
535+
/// numpy.ndarray
536+
#[pyo3(text_signature = "($self)")]
537+
fn ln_phi_pure<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<f64>> {
538+
Ok(self.0.ln_phi_pure()?.view().to_pyarray(py))
539+
}
540+
541+
/// Return logarithmic symmetric activity coefficient.
542+
///
543+
/// Returns
544+
/// -------
545+
/// numpy.ndarray
546+
#[pyo3(text_signature = "($self)")]
547+
fn ln_symmetric_activity_coefficient<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<f64>> {
548+
Ok(self.0.ln_symmetric_activity_coefficient()?.view().to_pyarray(py))
549+
}
550+
528551
/// Return derivative of logarithmic fugacity coefficient w.r.t. temperature.
529552
///
530553
/// Returns

src/state/properties.rs

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

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

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

0 commit comments

Comments
 (0)