Skip to content

Commit

Permalink
standardize_formula: add ammonium sulfate
Browse files Browse the repository at this point in the history
  • Loading branch information
rkingsbury committed Sep 2, 2024
1 parent 284d8c6 commit 8bb933a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `gibbs_mix`: A new keyword argument `activity_correction` was added to `gibbs_mix`. It defaults
to `True` (no change from prior behavior), but can be set to `False` in order to calculate the
ideal mixing energy, which is equivalent to only considering entropic effects. (#178, @Jaebeom-P)
- `standardize_formula`: Improve formatting of ammonium sulfate salts. Aqueous ammonium sulfate previously
standardized to `H8S(NO2)2(aq)`, now it will display as `(NH4)2SO4(aq)`.

### Changed

Expand Down
6 changes: 6 additions & 0 deletions src/pyEQL/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def standardize_formula(formula: str):
elif sform == "C2I2ClO2[-1]":
sform = "CI2ClCOO[-1]"

# ammonium sulfate salts
elif sform == "H8S(NO2)2(aq)":
sform = "(NH4)2SO4(aq)"
elif sform == "H4SNO4[-1]":
sform = "NH4SO4[-1]"

# TODO - consider adding recognition of special formulas like MeOH for methanol or Cit for citrate
return sform

Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def test_standardize_formula():
# Cl+Br
assert standardize_formula("CBrCl2COO-") == "CBrCl2COO[-1]"
assert standardize_formula("CBr2ClCOO-") == "CBr2ClCOO[-1]"
assert standardize_formula("(NH4)2SO4") == "(NH4)2SO4(aq)"
assert standardize_formula("NH4SO4-") == "NH4SO4[-1]"


def test_formula_dict():
Expand Down

0 comments on commit 8bb933a

Please sign in to comment.