From 1999c39ab4e517cbd82b587dd9181f7a0b1d56a1 Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Thu, 11 Dec 2025 17:08:29 +0100 Subject: [PATCH] Fix in the calculation of enthalpies of adsorption for mixtures --- CHANGELOG.md | 1 + crates/feos-core/src/phase_equilibria/tp_flash.rs | 12 ++++++------ crates/feos-dft/src/adsorption/pore.rs | 6 +++--- crates/feos-dft/src/profile/properties.rs | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d921692f..f1eb78c74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed +- Fixed calculation of enthalpies of adsorption for mixtures. [#329](https://github.com/feos-org/feos/pull/329) - Updated to `ndarray` 0.17 and `num-dual`0.13 to fix a broken dependency resolution. [#327](https://github.com/feos-org/feos/pull/327) - Fixed calculation of parameter combination in entropy scaling for mixtures in `viscosity_correlation`, `diffusion_correlation`, `thermal_conductivity_correlation`. [#323](https://github.com/feos-org/feos/pull/323) diff --git a/crates/feos-core/src/phase_equilibria/tp_flash.rs b/crates/feos-core/src/phase_equilibria/tp_flash.rs index 0a5ca1c6e..1c9c3072a 100644 --- a/crates/feos-core/src/phase_equilibria/tp_flash.rs +++ b/crates/feos-core/src/phase_equilibria/tp_flash.rs @@ -90,10 +90,10 @@ impl State { log_iter!(verbosity, "{:-<77}", ""); log_iter!( verbosity, - " {:4} | | {:10.8} | {:10.8}", + " {:4} | | {:10.8?} | {:10.8?}", 0, - new_vle_state.vapor().molefracs, - new_vle_state.liquid().molefracs, + new_vle_state.vapor().molefracs.data.as_vec(), + new_vle_state.liquid().molefracs.data.as_vec(), ); let mut iter = 0; @@ -279,11 +279,11 @@ impl PhaseEquilibrium { let res = res_vec.norm(); log_iter!( verbosity, - " {:4} | {:14.8e} | {:.8} | {:.8}", + " {:4} | {:14.8e} | {:.8?} | {:.8?}", iter, res, - self.vapor().molefracs, - self.liquid().molefracs, + self.vapor().molefracs.data.as_vec(), + self.liquid().molefracs.data.as_vec(), ); if res < abs_tol { return Ok(true); diff --git a/crates/feos-dft/src/adsorption/pore.rs b/crates/feos-dft/src/adsorption/pore.rs index 64446d350..c7602b7d5 100644 --- a/crates/feos-dft/src/adsorption/pore.rs +++ b/crates/feos-dft/src/adsorption/pore.rs @@ -139,9 +139,9 @@ where } pub fn enthalpy_of_adsorption(&self) -> FeosResult { - Ok((self.partial_molar_enthalpy_of_adsorption()? - * Dimensionless::new(&self.profile.bulk.molefracs)) - .sum()) + Ok(self + .partial_molar_enthalpy_of_adsorption()? + .dot(&Dimensionless::new(self.profile.bulk.molefracs.clone()))) } fn _henry_coefficients + Copy + DctNum>(&self, temperature: N) -> DVector { diff --git a/crates/feos-dft/src/profile/properties.rs b/crates/feos-dft/src/profile/properties.rs index 5501e8c24..225967409 100644 --- a/crates/feos-dft/src/profile/properties.rs +++ b/crates/feos-dft/src/profile/properties.rs @@ -352,7 +352,7 @@ where let n = drho_dmu.shape()[0]; let mut dn_dmu = DMatrix::zeros(n, n); dn_dmu - .row_iter_mut() + .column_iter_mut() .zip(drho_dmu.outer_iter()) .for_each(|(mut dn, drho)| dn.add_assign(&self.integrate_reduced_segments(&drho))); Ok(DnDmu::from_reduced(dn_dmu))