diff --git a/CHANGELOG.md b/CHANGELOG.md index 683c443..e22425c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Changed +- Removed `State` from `EntropyScaling` trait and adjusted associated methods to use temperature, volume and moles instead of state. [#36](https://github.com/feos-org/feos-core/pull/36) + ## [0.1.5] - 2022-02-21 ### Fixed - Fixed bug in `predict` of `Estimator`. [#30](https://github.com/feos-org/feos-core/pull/30) diff --git a/src/equation_of_state.rs b/src/equation_of_state.rs index d84d5eb..8590ba5 100644 --- a/src/equation_of_state.rs +++ b/src/equation_of_state.rs @@ -1,5 +1,5 @@ use crate::errors::{EosError, EosResult}; -use crate::state::{State, StateHD}; +use crate::state::StateHD; use crate::EosUnit; use ndarray::prelude::*; use num_dual::{Dual3, Dual3_64, Dual64, DualNum, HyperDual, HyperDual64}; @@ -295,11 +295,26 @@ pub trait EquationOfState { } /// Reference values and residual entropy correlations for entropy scaling. -pub trait EntropyScaling { - fn viscosity_reference(&self, state: &State) -> EosResult>; +pub trait EntropyScaling { + fn viscosity_reference( + &self, + temperature: QuantityScalar, + volume: QuantityScalar, + moles: &QuantityArray1, + ) -> EosResult>; fn viscosity_correlation(&self, s_res: f64, x: &Array1) -> EosResult; - fn diffusion_reference(&self, state: &State) -> EosResult>; + fn diffusion_reference( + &self, + temperature: QuantityScalar, + volume: QuantityScalar, + moles: &QuantityArray1, + ) -> EosResult>; fn diffusion_correlation(&self, s_res: f64, x: &Array1) -> EosResult; - fn thermal_conductivity_reference(&self, state: &State) -> EosResult>; + fn thermal_conductivity_reference( + &self, + temperature: QuantityScalar, + volume: QuantityScalar, + moles: &QuantityArray1, + ) -> EosResult>; fn thermal_conductivity_correlation(&self, s_res: f64, x: &Array1) -> EosResult; } diff --git a/src/state/properties.rs b/src/state/properties.rs index 7bd9bef..e853f12 100644 --- a/src/state/properties.rs +++ b/src/state/properties.rs @@ -615,13 +615,15 @@ impl State { /// /// These properties are available for equations of state /// that implement the [EntropyScaling] trait. -impl> State { +impl> State { /// Return the viscosity via entropy scaling. pub fn viscosity(&self) -> EosResult> { let s = self .molar_entropy(Contributions::Residual) .to_reduced(U::reference_molar_entropy())?; - Ok(self.eos.viscosity_reference(self)? + Ok(self + .eos + .viscosity_reference(self.temperature, self.volume, &self.moles)? * self.eos.viscosity_correlation(s, &self.molefracs)?.exp()) } @@ -638,7 +640,8 @@ impl> State { /// Return the viscosity reference as used in entropy scaling. pub fn viscosity_reference(&self) -> EosResult> { - self.eos.viscosity_reference(self) + self.eos + .viscosity_reference(self.temperature, self.volume, &self.moles) } /// Return the diffusion via entropy scaling. @@ -646,7 +649,9 @@ impl> State { let s = self .molar_entropy(Contributions::Residual) .to_reduced(U::reference_molar_entropy())?; - Ok(self.eos.diffusion_reference(self)? + Ok(self + .eos + .diffusion_reference(self.temperature, self.volume, &self.moles)? * self.eos.diffusion_correlation(s, &self.molefracs)?.exp()) } @@ -663,7 +668,8 @@ impl> State { /// Return the diffusion reference as used in entropy scaling. pub fn diffusion_reference(&self) -> EosResult> { - self.eos.diffusion_reference(self) + self.eos + .diffusion_reference(self.temperature, self.volume, &self.moles) } /// Return the thermal conductivity via entropy scaling. @@ -671,7 +677,9 @@ impl> State { let s = self .molar_entropy(Contributions::Residual) .to_reduced(U::reference_molar_entropy())?; - Ok(self.eos.thermal_conductivity_reference(self)? + Ok(self + .eos + .thermal_conductivity_reference(self.temperature, self.volume, &self.moles)? * self .eos .thermal_conductivity_correlation(s, &self.molefracs)? @@ -692,6 +700,7 @@ impl> State { /// Return the thermal conductivity reference as used in entropy scaling. pub fn thermal_conductivity_reference(&self) -> EosResult> { - self.eos.thermal_conductivity_reference(self) + self.eos + .thermal_conductivity_reference(self.temperature, self.volume, &self.moles) } }