diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c03b4bb8..24f824759 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Export `EosVariant` and `FunctionalVariant` directly in the crate root instead of their own modules. [#62](https://github.com/feos-org/feos/pull/62) - Changed constructors `VaporPressure::new` and `DataSet.vapor_pressure` (Python) to take a new optional argument `critical_temperature`. [#86](https://github.com/feos-org/feos/pull/86) +- The limitations of the homo gc method for PC-SAFT are enforced more strictly. [#88](https://github.com/feos-org/feos/pull/88) ## [0.3.0] - 2022-09-14 - Major restructuring of the entire `feos` project. All individual models are reunited in the `feos` crate. `feos-core` and `feos-dft` still live as individual crates within the `feos` workspace. diff --git a/src/pcsaft/parameters.rs b/src/pcsaft/parameters.rs index ccdb2e72b..f7e2b980c 100644 --- a/src/pcsaft/parameters.rs +++ b/src/pcsaft/parameters.rs @@ -151,25 +151,15 @@ impl FromSegments for PcSaftRecord { impl FromSegments for PcSaftRecord { fn from_segments(segments: &[(Self, usize)]) -> Result { // We do not allow more than a single segment for q, mu, kappa_ab, epsilon_k_ab - let quadpole_comps = segments.iter().filter_map(|(s, _)| s.q).count(); - if quadpole_comps > 1 { - return Err(ParameterError::IncompatibleParameters(format!( - "{quadpole_comps} segments with quadrupole moment." - ))); - }; - let dipole_comps = segments.iter().filter_map(|(s, _)| s.mu).count(); - if dipole_comps > 1 { - return Err(ParameterError::IncompatibleParameters(format!( - "{dipole_comps} segment with dipole moment." - ))); - }; - let assoc_comps = segments + let quadpole_segments: usize = segments.iter().filter_map(|(s, n)| s.q.map(|_| n)).sum(); + let dipole_segments: usize = segments.iter().filter_map(|(s, n)| s.mu.map(|_| n)).sum(); + let assoc_segments: usize = segments .iter() - .filter_map(|(s, _)| s.association_record.as_ref()) - .count(); - if assoc_comps > 1 { + .filter_map(|(s, n)| s.association_record.map(|_| n)) + .sum(); + if quadpole_segments + dipole_segments + assoc_segments > 1 { return Err(ParameterError::IncompatibleParameters(format!( - "{assoc_comps} segments with association sites." + "Too many polar/associating segments (dipolar: {dipole_segments}, quadrupolar {quadpole_segments}, associating: {assoc_segments})." ))); } let segments: Vec<_> = segments