Skip to content

Commit 4f98554

Browse files
authored
added derive for EntropyScaling trait for SAFT-VRQ Mie for ResidualModel (#179)
* added derive for EntropyScaling trait for SAFT-VRQ Mie for ResidualModel * check for segment number in the record constructor * fixed docstrings
1 parent 57e30d8 commit 4f98554

File tree

6 files changed

+92
-11
lines changed

6 files changed

+92
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Added `IdealGasModel` enum that collects all implementors of the `IdealGas` trait. [#158](https://github.com/feos-org/feos/pull/158)
1010
- Added `feos.ideal_gas` module in Python from which (currently) `Joback` and `JobackParameters` are available. [#158](https://github.com/feos-org/feos/pull/158)
1111
- Added binary association parameters to PC-SAFT. [#167](https://github.com/feos-org/feos/pull/167)
12+
- Added derive for `EntropyScaling` for SAFT-VRQ Mie to `ResidualModel` and adjusted parameter initialization. [#179](https://github.com/feos-org/feos/pull/179)
1213

1314
### Changed
1415
- Changed the internal implementation of the association contribution to accomodate more general association schemes. [#150](https://github.com/feos-org/feos/pull/150)

src/eos.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub enum ResidualModel {
3232
#[cfg(feature = "python")]
3333
Python(PyResidual),
3434
#[cfg(feature = "saftvrqmie")]
35+
#[implement(entropy_scaling)]
3536
SaftVRQMie(SaftVRQMie),
3637
#[cfg(feature = "pets")]
3738
Pets(Pets),

src/pcsaft/parameters.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct PcSaftRecord {
2424
/// Dipole moment in units of Debye
2525
#[serde(skip_serializing_if = "Option::is_none")]
2626
pub mu: Option<f64>,
27-
/// Quadrupole moment in units of Debye
27+
/// Quadrupole moment in units of Debye * Angstrom
2828
#[serde(skip_serializing_if = "Option::is_none")]
2929
pub q: Option<f64>,
3030
/// Association parameters

src/pcsaft/python.rs

+30-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,36 @@ use pyo3::prelude::*;
1212
use std::convert::{TryFrom, TryInto};
1313
use std::sync::Arc;
1414

15-
/// Create a new set of PC-SAFT pure component parameters.
15+
/// Pure-substance parameters for the PC-Saft equation of state.
16+
///
17+
/// Parameters
18+
/// ----------
19+
/// m : float
20+
/// Segment number
21+
/// sigma : float
22+
/// Segment diameter in units of Angstrom.
23+
/// epsilon_k : float
24+
/// Energetic parameter in units of Kelvin.
25+
/// mu : float, optional
26+
/// Dipole moment in units of Debye.
27+
/// q : float, optional
28+
/// Quadrupole moment in units of Debye * Angstrom.
29+
/// kappa_ab : float, optional
30+
/// Association volume parameter.
31+
/// epsilon_k_ab : float, optional
32+
/// Association energy parameter in units of Kelvin.
33+
/// na : float, optional
34+
/// Number of association sites of type A.
35+
/// nb : float, optional
36+
/// Number of association sites of type B.
37+
/// nc : float, optional
38+
/// Number of association sites of type C.
39+
/// viscosity : List[float], optional
40+
/// Entropy-scaling parameters for viscosity. Defaults to `None`.
41+
/// diffusion : List[float], optional
42+
/// Entropy-scaling parameters for diffusion. Defaults to `None`.
43+
/// thermal_conductivity : List[float], optional
44+
/// Entropy-scaling parameters for thermal_conductivity. Defaults to `None`.
1645
#[pyclass(name = "PcSaftRecord")]
1746
#[pyo3(
1847
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)"

src/saftvrqmie/parameters.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ impl SaftVRQMieRecord {
6666
viscosity: Option<[f64; 4]>,
6767
diffusion: Option<[f64; 5]>,
6868
thermal_conductivity: Option<[f64; 4]>,
69-
) -> SaftVRQMieRecord {
70-
SaftVRQMieRecord {
69+
) -> Result<SaftVRQMieRecord, ParameterError> {
70+
if m != 1.0 {
71+
return Err(ParameterError::IncompatibleParameters(format!(
72+
"Segment number `m` is not one. Chain-contributions are currently not supported."
73+
)));
74+
}
75+
Ok(SaftVRQMieRecord {
7176
m,
7277
sigma,
7378
epsilon_k,
@@ -77,7 +82,7 @@ impl SaftVRQMieRecord {
7782
viscosity,
7883
diffusion,
7984
thermal_conductivity,
80-
}
85+
})
8186
}
8287
}
8388

@@ -171,6 +176,16 @@ impl Parameter for SaftVRQMieParameters {
171176
for (i, record) in pure_records.iter().enumerate() {
172177
component_index.insert(record.identifier.clone(), i);
173178
let r = &record.model_record;
179+
if r.m != 1.0 {
180+
return Err(
181+
ParameterError::IncompatibleParameters(
182+
format!(
183+
"Segment number `m` for component {} is not one. Chain-contributions are currently not supported.",
184+
i
185+
)
186+
)
187+
);
188+
}
174189
m[i] = r.m;
175190
sigma[i] = r.sigma;
176191
epsilon_k[i] = r.epsilon_k;

src/saftvrqmie/python.rs

+41-6
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,35 @@ use quantity::python::PySINumber;
1515
use std::convert::{TryFrom, TryInto};
1616
use std::sync::Arc;
1717

18-
/// Create a set of Saft-VRQ Mie parameters from records.
18+
/// Pure-substance parameters for the Saft-VRQ Mie equation of state.
19+
///
20+
/// Parameters
21+
/// ----------
22+
/// m : float
23+
/// Segment number
24+
/// sigma : float
25+
/// Structure parameter of the Mie potential in units of
26+
/// Angstrom.
27+
/// epsilon_k : float
28+
/// Energetic parameter of the Mie potential in units of
29+
/// Kelvin.
30+
/// lr : float
31+
/// Repulsive exponent of the Mie potential.
32+
/// la : float
33+
/// Attractive exponent of the Mie potential.
34+
/// fh : int
35+
/// Feynman-Hibbs order. One of {0, 1, 2}.
36+
/// `fh = 0` disables quantum corrections so that effectively,
37+
/// the SAFT-VR Mie equation of state is used.
38+
/// viscosity : List[float], optional
39+
/// Entropy-scaling parameters for viscosity. Defaults to `None`.
40+
/// diffusion : List[float], optional
41+
/// Entropy-scaling parameters for diffusion. Defaults to `None`.
42+
/// thermal_conductivity : List[float], optional
43+
/// Entropy-scaling parameters for thermal_conductivity. Defaults to `None`.
1944
#[pyclass(name = "SaftVRQMieRecord")]
2045
#[pyo3(
21-
text_signature = "(m, sigma, epsilon_k, viscosity=None, diffusion=None, thermal_conductivity=None)"
46+
text_signature = "(m, sigma, epsilon_k, lr, la, fh, viscosity=None, diffusion=None, thermal_conductivity=None)"
2247
)]
2348
#[derive(Clone)]
2449
pub struct PySaftVRQMieRecord(SaftVRQMieRecord);
@@ -34,10 +59,20 @@ impl PySaftVRQMieRecord {
3459
la: f64,
3560
fh: usize,
3661
viscosity: Option<[f64; 4]>,
37-
) -> Self {
38-
Self(SaftVRQMieRecord::new(
39-
m, sigma, epsilon_k, lr, la, fh, viscosity, None, None,
40-
))
62+
diffusion: Option<[f64; 5]>,
63+
thermal_conductivity: Option<[f64; 4]>,
64+
) -> PyResult<Self> {
65+
Ok(Self(SaftVRQMieRecord::new(
66+
m,
67+
sigma,
68+
epsilon_k,
69+
lr,
70+
la,
71+
fh,
72+
viscosity,
73+
diffusion,
74+
thermal_conductivity,
75+
)?))
4176
}
4277

4378
#[getter]

0 commit comments

Comments
 (0)