From 0e80b57e771ddb90bf8da9016b3aad70a333ab12 Mon Sep 17 00:00:00 2001
From: Philipp Rehner <69816385+prehner@users.noreply.github.com>
Date: Fri, 28 Jun 2024 11:01:53 +0200
Subject: [PATCH] Fix bug for mixtures using GcPcSaft (#4)
---
src/property/gc_pcsaft.rs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/property/gc_pcsaft.rs b/src/property/gc_pcsaft.rs
index 60e9509..3321440 100644
--- a/src/property/gc_pcsaft.rs
+++ b/src/property/gc_pcsaft.rs
@@ -28,6 +28,7 @@ impl GcPcSaftPropertyModel {
file_ideal_gas: P,
file_binary: Option
,
) -> Result {
+ let mut i = 0;
let (groups, bonds) = molecules
.iter()
.map(|molecule| {
@@ -38,14 +39,14 @@ impl GcPcSaftPropertyModel {
molecule
.feature_variables(&index_structure_vars)
.into_keys()
- .enumerate()
- .for_each(|(i, s)| {
+ .for_each(|s| {
if let Some(index) = s.find('-') {
let (g1, g2) = s.split_at(index);
bonds.push(([g1.to_string(), g2[1..].to_string()], i));
} else {
groups.push((s, i))
}
+ i += 1;
});
(groups, bonds)
})
@@ -96,11 +97,13 @@ impl PropertyModel for GcPcSaftPropertyModel {
.iter()
.cloned()
.map(|(s, i)| (s, parameters[i]))
+ .filter(|(_, n)| *n > 0.0)
.collect();
let bonds = bonds
.iter()
.cloned()
.map(|(s, i)| (s, parameters[i]))
+ .filter(|(_, n)| *n > 0.0)
.collect();
GcPcSaftChemicalRecord::new(Identifier::default(), segments, bonds, 1.0)
})