Skip to content

Commit 39da759

Browse files
authored
Merge pull request #277 from ugognw/fix-salt-dict-non-h-o-heteroatom
Fix salt dict non-h/o-heteroatom
2 parents e1c7cf6 + 813e1d6 commit 39da759

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.1] - 2025-08-18
9+
10+
### Fixed
11+
12+
- `Solution.get_salt_dict()`: In solutions containing polyatomic ions with a heteroatom (an atom other than `H` or `O`)
13+
having a stoichiometric coefficient greater than 1 mol per mol salt , such as Fe(CN)6[-3], the method would
14+
return incorrect results, possibly impacting activity coefficient calculations. This has now been fixed. (#277, @ugognw)
15+
816
## [1.3.0] - 2025-08-08
917

1018
### Fixed

src/pyEQL/solution.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,11 @@ def get_salt_dict(self, cutoff: float = 1e-6, use_totals: bool = True) -> dict[s
15711571
# # use only the predominant species for each element
15721572
components = {}
15731573
for el, lst in self.get_components_by_element().items():
1574-
components[lst[0]] = self.get_total_amount(el, "mol").magnitude
1574+
component = lst[0]
1575+
ion = Ion.from_formula(component)
1576+
el_no_oxi_state = el.split("(")[0]
1577+
nu_el = ion.get_el_amt_dict()[el_no_oxi_state]
1578+
components[component] = self.get_total_amount(el, "mol").magnitude / nu_el
15751579
# add H+ and OH-, which would otherwise be excluded
15761580
for k in ["H[+1]", "OH[-1]"]:
15771581
if self.components.get(k):

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from pyEQL.engines import EOS
88
from pyEQL.salt_ion_match import Salt
99

10-
_CATIONS = ["Na[+1]", "Ca[+2]", "Fe[+3]", "K[+1]", "Li[+1]", "Cu[+2]", "Ba[+2]"]
11-
_ANIONS = ["Cl[-1]", "SO4[-2]", "PO4[-3]", "ClO[-1]", "NO3[-1]", "CO3[-2]", "MnO4[-2]"]
10+
_CATIONS = ["Na[+1]", "Ca[+2]", "Fe[+3]", "K[+1]", "Li[+1]", "Cu[+2]", "Ba[+2]", "NH4[+1]"]
11+
_ANIONS = ["Fe(CN)6[-3]", "Cl[-1]", "SO4[-2]", "PO4[-3]", "ClO[-1]", "NO3[-1]", "CO3[-2]", "MnO4[-2]"]
1212
_SALTS = list(product(_CATIONS[:3], _ANIONS[:3]))
1313
_ACIDS = [("H[+1]", anion) for anion in _ANIONS[:3]]
1414
_BASES = [(cation, "OH[-1]") for cation in _CATIONS[:3]]

0 commit comments

Comments
 (0)