Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added derive for EntropyScaling trait for SAFT-VRQ Mie for ResidualModel #179

Merged
merged 3 commits into from
Jul 27, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `IdealGasModel` enum that collects all implementors of the `IdealGas` trait. [#158](https://github.com/feos-org/feos/pull/158)
- Added `feos.ideal_gas` module in Python from which (currently) `Joback` and `JobackParameters` are available. [#158](https://github.com/feos-org/feos/pull/158)
- Added binary association parameters to PC-SAFT. [#167](https://github.com/feos-org/feos/pull/167)
- Added derive for `EntropyScaling` for SAFT-VRQ Mie to `ResidualModel` and adjusted parameter initialization. [#179](https://github.com/feos-org/feos/pull/179)

### Changed
- Changed the internal implementation of the association contribution to accomodate more general association schemes. [#150](https://github.com/feos-org/feos/pull/150)
Expand Down
1 change: 1 addition & 0 deletions src/eos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub enum ResidualModel {
#[cfg(feature = "python")]
Python(PyResidual),
#[cfg(feature = "saftvrqmie")]
#[implement(entropy_scaling)]
SaftVRQMie(SaftVRQMie),
#[cfg(feature = "pets")]
Pets(Pets),
Expand Down
2 changes: 1 addition & 1 deletion src/pcsaft/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct PcSaftRecord {
/// Dipole moment in units of Debye
#[serde(skip_serializing_if = "Option::is_none")]
pub mu: Option<f64>,
/// Quadrupole moment in units of Debye
/// Quadrupole moment in units of Debye * Angstrom
#[serde(skip_serializing_if = "Option::is_none")]
pub q: Option<f64>,
/// Association parameters
Expand Down
31 changes: 30 additions & 1 deletion src/pcsaft/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,36 @@ use pyo3::prelude::*;
use std::convert::{TryFrom, TryInto};
use std::sync::Arc;

/// Create a new set of PC-SAFT pure component parameters.
/// Pure-substance parameters for the PC-Saft equation of state.
///
/// Parameters
/// ----------
/// m : float
/// Segment number
/// sigma : float
/// Segment diameter in units of Angstrom.
/// epsilon_k : float
/// Energetic parameter in units of Kelvin.
/// mu : float, optional
/// Dipole moment in units of Debye.
/// q : float, optional
/// Quadrupole moment in units of Debye * Angstrom.
/// kappa_ab : float, optional
/// Association volume parameter.
/// epsilon_k_ab : float, optional
/// Association energy parameter in units of Kelvin.
/// na : float, optional
/// Number of association sites of type A.
/// nb : float, optional
/// Number of association sites of type B.
/// nc : float, optional
/// Number of association sites of type C.
/// viscosity : List[float], optional
/// Entropy-scaling parameters for viscosity. Defaults to `None`.
/// diffusion : List[float], optional
/// Entropy-scaling parameters for diffusion. Defaults to `None`.
/// thermal_conductivity : List[float], optional
/// Entropy-scaling parameters for thermal_conductivity. Defaults to `None`.
#[pyclass(name = "PcSaftRecord")]
#[pyo3(
text_signature = "(m, sigma, epsilon_k, mu=None, q=None, kappa_ab=None, epsilon_k_ab=None, na=None, nb=None, viscosity=None, diffusion=None, thermal_conductivity=None)"
Expand Down
21 changes: 18 additions & 3 deletions src/saftvrqmie/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ impl SaftVRQMieRecord {
viscosity: Option<[f64; 4]>,
diffusion: Option<[f64; 5]>,
thermal_conductivity: Option<[f64; 4]>,
) -> SaftVRQMieRecord {
SaftVRQMieRecord {
) -> Result<SaftVRQMieRecord, ParameterError> {
if m != 1.0 {
return Err(ParameterError::IncompatibleParameters(format!(
"Segment number `m` is not one. Chain-contributions are currently not supported."
)));
}
Ok(SaftVRQMieRecord {
m,
sigma,
epsilon_k,
Expand All @@ -77,7 +82,7 @@ impl SaftVRQMieRecord {
viscosity,
diffusion,
thermal_conductivity,
}
})
}
}

Expand Down Expand Up @@ -171,6 +176,16 @@ impl Parameter for SaftVRQMieParameters {
for (i, record) in pure_records.iter().enumerate() {
component_index.insert(record.identifier.clone(), i);
let r = &record.model_record;
if r.m != 1.0 {
return Err(
ParameterError::IncompatibleParameters(
format!(
"Segment number `m` for component {} is not one. Chain-contributions are currently not supported.",
i
)
)
);
}
m[i] = r.m;
sigma[i] = r.sigma;
epsilon_k[i] = r.epsilon_k;
Expand Down
47 changes: 41 additions & 6 deletions src/saftvrqmie/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,35 @@ use quantity::python::PySINumber;
use std::convert::{TryFrom, TryInto};
use std::sync::Arc;

/// Create a set of Saft-VRQ Mie parameters from records.
/// Pure-substance parameters for the Saft-VRQ Mie equation of state.
///
/// Parameters
/// ----------
/// m : float
/// Segment number
/// sigma : float
/// Structure parameter of the Mie potential in units of
/// Angstrom.
/// epsilon_k : float
/// Energetic parameter of the Mie potential in units of
/// Kelvin.
/// lr : float
/// Repulsive exponent of the Mie potential.
/// la : float
/// Attractive exponent of the Mie potential.
/// fh : int
/// Feynman-Hibbs order. One of {0, 1, 2}.
/// `fh = 0` disables quantum corrections so that effectively,
/// the SAFT-VR Mie equation of state is used.
/// viscosity : List[float], optional
/// Entropy-scaling parameters for viscosity. Defaults to `None`.
/// diffusion : List[float], optional
/// Entropy-scaling parameters for diffusion. Defaults to `None`.
/// thermal_conductivity : List[float], optional
/// Entropy-scaling parameters for thermal_conductivity. Defaults to `None`.
#[pyclass(name = "SaftVRQMieRecord")]
#[pyo3(
text_signature = "(m, sigma, epsilon_k, viscosity=None, diffusion=None, thermal_conductivity=None)"
text_signature = "(m, sigma, epsilon_k, lr, la, fh, viscosity=None, diffusion=None, thermal_conductivity=None)"
)]
#[derive(Clone)]
pub struct PySaftVRQMieRecord(SaftVRQMieRecord);
Expand All @@ -34,10 +59,20 @@ impl PySaftVRQMieRecord {
la: f64,
fh: usize,
viscosity: Option<[f64; 4]>,
) -> Self {
Self(SaftVRQMieRecord::new(
m, sigma, epsilon_k, lr, la, fh, viscosity, None, None,
))
diffusion: Option<[f64; 5]>,
thermal_conductivity: Option<[f64; 4]>,
) -> PyResult<Self> {
Ok(Self(SaftVRQMieRecord::new(
m,
sigma,
epsilon_k,
lr,
la,
fh,
viscosity,
diffusion,
thermal_conductivity,
)?))
}

#[getter]
Expand Down