Skip to content

Commit bc1efb2

Browse files
committed
Revive phi in hetero gc PC-SAFT (#157)
1 parent d4064cf commit bc1efb2

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Changed
99
- Changed the internal implementation of the association contribution to accomodate more general association schemes. [#150](https://github.com/feos-org/feos/pull/150)
1010
- To comply with the new association implementation, the default values of `na` and `nb` are now `0` rather than `1`. Parameter files have been adapted accordingly. [#150](https://github.com/feos-org/feos/pull/150)
11+
- Added the possibility to specify a pure component correction parameter `phi` for the heterosegmented gc PC-SAFT equation of state. [#157](https://github.com/feos-org/feos/pull/157)
1112

1213
### Changed
1314
- Adjusted all models' implementation of the `Parameter` trait which now requires `Result`s in some methods. [#161](https://github.com/feos-org/feos/pull/161)

src/gc_pcsaft/eos/parameter.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ pub struct GcPcSaftChemicalRecord {
1919
pub identifier: Identifier,
2020
pub segments: HashMap<String, f64>,
2121
pub bonds: HashMap<[String; 2], f64>,
22+
phi: f64,
2223
}
2324

2425
impl GcPcSaftChemicalRecord {
2526
pub fn new(
2627
identifier: Identifier,
2728
segments: HashMap<String, f64>,
2829
bonds: HashMap<[String; 2], f64>,
30+
phi: f64,
2931
) -> Self {
3032
Self {
3133
identifier,
3234
segments,
3335
bonds,
36+
phi,
3437
}
3538
}
3639
}
@@ -53,11 +56,13 @@ impl From<ChemicalRecord> for GcPcSaftChemicalRecord {
5356
chemical_record.identifier.clone(),
5457
chemical_record.segment_count(),
5558
chemical_record.bond_count(),
59+
1.0,
5660
)
5761
}
5862
}
5963

6064
/// Parameter set required for the gc-PC-SAFT equation of state.
65+
#[derive(Clone)]
6166
pub struct GcPcSaftEosParameters {
6267
pub molarweight: Array1<f64>,
6368
pub component_index: Array1<usize>,
@@ -116,11 +121,14 @@ impl ParameterHetero for GcPcSaftEosParameters {
116121
let mut sigma_mix = Vec::new();
117122
let mut epsilon_k_mix = Vec::new();
118123

124+
let mut phi = Vec::new();
125+
119126
let mut joback_records = Vec::new();
120127

121128
for (i, chemical_record) in chemical_records.iter().cloned().enumerate() {
122129
let mut segment_indices = IndexMap::with_capacity(segment_records.len());
123130
let segment_map = chemical_record.segment_map(&segment_records)?;
131+
phi.push(chemical_record.phi);
124132

125133
let mut m_i = 0.0;
126134
let mut sigma_i = 0.0;
@@ -214,7 +222,7 @@ impl ParameterHetero for GcPcSaftEosParameters {
214222
let sigma_ij =
215223
Array2::from_shape_fn([sigma.len(); 2], |(i, j)| 0.5 * (sigma[i] + sigma[j]));
216224
let epsilon_k_ij = Array2::from_shape_fn([epsilon_k.len(); 2], |(i, j)| {
217-
(epsilon_k[i] * epsilon_k[j]).sqrt()
225+
(epsilon_k[i] * phi[component_index[i]] * epsilon_k[j] * phi[component_index[j]]).sqrt()
218226
}) * (1.0 - &k_ij);
219227

220228
// Combining rules polar
@@ -271,6 +279,14 @@ impl ParameterHetero for GcPcSaftEosParameters {
271279
}
272280
}
273281

282+
impl GcPcSaftEosParameters {
283+
pub fn phi(self, phi: &[f64]) -> Result<Self, ParameterError> {
284+
let mut cr = self.chemical_records;
285+
cr.iter_mut().zip(phi.iter()).for_each(|(c, &p)| c.phi = p);
286+
Self::from_segments(cr, self.segment_records, self.binary_segment_records)
287+
}
288+
}
289+
274290
impl HardSphereProperties for GcPcSaftEosParameters {
275291
fn monomer_shape<N: DualNum<f64>>(&self, _: N) -> MonomerShape<N> {
276292
let m = self.m.mapv(N::from);

src/gc_pcsaft/python/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ impl_parameter_from_segments!(GcPcSaftEosParameters, PyGcPcSaftEosParameters);
9595

9696
#[pymethods]
9797
impl PyGcPcSaftEosParameters {
98+
fn phi(&self, phi: Vec<f64>) -> PyResult<Self> {
99+
Ok(Self(Arc::new((*self.0).clone().phi(&phi)?)))
100+
}
101+
98102
fn _repr_markdown_(&self) -> String {
99103
self.0.to_markdown()
100104
}

0 commit comments

Comments
 (0)