Skip to content
This repository was archived by the owner on Sep 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Added optional arguments to the constructor of `PcSaftFunctional` in Python to make it more analogous to `PcSaft`. [#34](https://github.com/feos-org/feos-pcsaft/pull/34)
- Building Pc-SAFT parameters from segments does not check anymore, whether multiple polar or associating groups are present. [#33](https://github.com/feos-org/feos-pcsaft/pull/33)

## [0.1.0] - 2022-01-12
### Added
Expand Down
52 changes: 25 additions & 27 deletions src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,31 @@ impl FromSegments for PcSaftRecord {
epsilon_k += s.m * s.epsilon_k * *n;
});

// We do not allow more than a single segment for q, mu, kappa_ab, epsilon_k_ab
let q: Vec<f64> = segments.iter().filter_map(|s| s.0.q).collect();
let q = match q.len() {
0 => None,
1 => Some(q[0]),
_ => panic!("More than one segment with quadrupole moment."),
};
let mu: Vec<f64> = segments.iter().filter_map(|s| s.0.mu).collect();
let mu = match mu.len() {
0 => None,
1 => Some(mu[0]),
_ => panic!("More than one segment with dipole moment."),
};
let kappa_ab: Vec<f64> = segments.iter().filter_map(|s| s.0.kappa_ab).collect();
let kappa_ab = match kappa_ab.len() {
0 => None,
1 => Some(kappa_ab[0]),
_ => panic!("More than one segment with association site."),
};
let epsilon_k_ab: Vec<f64> = segments.iter().filter_map(|s| s.0.epsilon_k_ab).collect();
let epsilon_k_ab = match epsilon_k_ab.len() {
0 => None,
1 => Some(epsilon_k_ab[0]),
_ => panic!("More than one segment with association site"),
};
let na = Some(1.0);
let nb = Some(1.0);
let q = segments
.iter()
.filter_map(|(s, n)| s.q.map(|q| q * *n))
.reduce(|a, b| a + b);
let mu = segments
.iter()
.filter_map(|(s, n)| s.mu.map(|mu| mu * *n))
.reduce(|a, b| a + b);
let kappa_ab = segments
.iter()
.filter_map(|(s, n)| s.kappa_ab.map(|k| k * *n))
.reduce(|a, b| a + b);
let epsilon_k_ab = segments
.iter()
.filter_map(|(s, n)| s.epsilon_k_ab.map(|e| e * *n))
.reduce(|a, b| a + b);
let na = segments
.iter()
.filter_map(|(s, n)| s.na.map(|na| na * *n))
.reduce(|a, b| a + b);
let nb = segments
.iter()
.filter_map(|(s, n)| s.nb.map(|nb| nb * *n))
.reduce(|a, b| a + b);

Self {
m,
sigma: (sigma3 / m).cbrt(),
Expand Down