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 all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 20 additions & 5 deletions src/equation_of_state.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -295,11 +295,26 @@ pub trait EquationOfState {
}

/// Reference values and residual entropy correlations for entropy scaling.
pub trait EntropyScaling<U: EosUnit, E: EquationOfState> {
fn viscosity_reference(&self, state: &State<U, E>) -> EosResult<QuantityScalar<U>>;
pub trait EntropyScaling<U: EosUnit> {
fn viscosity_reference(
&self,
temperature: QuantityScalar<U>,
volume: QuantityScalar<U>,
moles: &QuantityArray1<U>,
) -> EosResult<QuantityScalar<U>>;
fn viscosity_correlation(&self, s_res: f64, x: &Array1<f64>) -> EosResult<f64>;
fn diffusion_reference(&self, state: &State<U, E>) -> EosResult<QuantityScalar<U>>;
fn diffusion_reference(
&self,
temperature: QuantityScalar<U>,
volume: QuantityScalar<U>,
moles: &QuantityArray1<U>,
) -> EosResult<QuantityScalar<U>>;
fn diffusion_correlation(&self, s_res: f64, x: &Array1<f64>) -> EosResult<f64>;
fn thermal_conductivity_reference(&self, state: &State<U, E>) -> EosResult<QuantityScalar<U>>;
fn thermal_conductivity_reference(
&self,
temperature: QuantityScalar<U>,
volume: QuantityScalar<U>,
moles: &QuantityArray1<U>,
) -> EosResult<QuantityScalar<U>>;
fn thermal_conductivity_correlation(&self, s_res: f64, x: &Array1<f64>) -> EosResult<f64>;
}
23 changes: 16 additions & 7 deletions src/state/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,15 @@ impl<U: EosUnit, E: EquationOfState> State<U, E> {
///
/// These properties are available for equations of state
/// that implement the [EntropyScaling] trait.
impl<U: EosUnit, E: EquationOfState + EntropyScaling<U, E>> State<U, E> {
impl<U: EosUnit, E: EquationOfState + EntropyScaling<U>> State<U, E> {
/// Return the viscosity via entropy scaling.
pub fn viscosity(&self) -> EosResult<QuantityScalar<U>> {
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())
}

Expand All @@ -638,15 +640,18 @@ impl<U: EosUnit, E: EquationOfState + EntropyScaling<U, E>> State<U, E> {

/// Return the viscosity reference as used in entropy scaling.
pub fn viscosity_reference(&self) -> EosResult<QuantityScalar<U>> {
self.eos.viscosity_reference(self)
self.eos
.viscosity_reference(self.temperature, self.volume, &self.moles)
}

/// Return the diffusion via entropy scaling.
pub fn diffusion(&self) -> EosResult<QuantityScalar<U>> {
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())
}

Expand All @@ -663,15 +668,18 @@ impl<U: EosUnit, E: EquationOfState + EntropyScaling<U, E>> State<U, E> {

/// Return the diffusion reference as used in entropy scaling.
pub fn diffusion_reference(&self) -> EosResult<QuantityScalar<U>> {
self.eos.diffusion_reference(self)
self.eos
.diffusion_reference(self.temperature, self.volume, &self.moles)
}

/// Return the thermal conductivity via entropy scaling.
pub fn thermal_conductivity(&self) -> EosResult<QuantityScalar<U>> {
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)?
Expand All @@ -692,6 +700,7 @@ impl<U: EosUnit, E: EquationOfState + EntropyScaling<U, E>> State<U, E> {

/// Return the thermal conductivity reference as used in entropy scaling.
pub fn thermal_conductivity_reference(&self) -> EosResult<QuantityScalar<U>> {
self.eos.thermal_conductivity_reference(self)
self.eos
.thermal_conductivity_reference(self.temperature, self.volume, &self.moles)
}
}