diff --git a/.github/workflows/post-process.yml b/.github/workflows/post-process.yml index 60889a3..fc8a94a 100644 --- a/.github/workflows/post-process.yml +++ b/.github/workflows/post-process.yml @@ -34,7 +34,6 @@ jobs: max-parallel: 6 matrix: version: - - { python: "3.9", resolution: highest, extras: testing } - { python: "3.10", resolution: lowest-direct, extras: testing } - { python: "3.11", resolution: highest, extras: testing } - { python: "3.12", resolution: lowest-direct, extras: testing } @@ -43,10 +42,6 @@ jobs: - macos-latest - windows-latest - macos-14 - exclude: - - {version: { - python: "3.9" }, - os: macos-14 } runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d4b8c0..b602cf9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,4 +57,4 @@ jobs: tox -e clean,build - name: Upload to PyPi - uses: pypa/gh-action-pypi-publish@v1.9.0 + uses: pypa/gh-action-pypi-publish@v1.10.1 diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 0522a69..00e9a92 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -23,7 +23,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: "3.11" cache: pip - name: Run pre-commit run: | @@ -36,7 +36,7 @@ jobs: max-parallel: 6 matrix: # for most PRs, test the min and max supported python on every platform, test all python on ubuntu - python-version: ["3.9", "3.12"] + python-version: ["3.10", "3.12"] os: - ubuntu-latest - macos-latest @@ -47,10 +47,6 @@ jobs: python-version: "3.10" - os: ubuntu-latest python-version: "3.11" - # no python 3.9 on the macos-14 runner - exclude: - - os: macos-14 - python-version: "3.9" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -77,7 +73,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: "3.10" - name: Install tox run: | python -m pip install tox diff --git a/.github/workflows/upgrade_dependencies.yml b/.github/workflows/upgrade_dependencies.yml index 2180493..b49711c 100644 --- a/.github/workflows/upgrade_dependencies.yml +++ b/.github/workflows/upgrade_dependencies.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: # Allow running on-demand schedule: # Runs on the 10th day of every month at 8:00 UTC (4:00 Eastern) - - cron: '0 8 10 * *' + - cron: "0 8 10 * *" jobs: upgrade: @@ -14,9 +14,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + os: ["ubuntu-latest", "macos-latest", "windows-latest"] package: ["."] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 with: @@ -24,7 +24,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: 'pip' + cache: "pip" - name: Upgrade Python dependencies shell: bash run: | diff --git a/AUTHORS.md b/AUTHORS.md index 7de455b..4f71b8c 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -5,9 +5,12 @@ developed and maintained by the Kingsbury Lab at Princeton University. Other contributors, listed alphabetically, are: -* Kirill Pushkarev (@kirill-push) -* Dhruv Duseja (@DhruvDuseja) -* Andrew Rosen (@arosen93) -* Hernan Grecco (@hgrecco) +- Arpit Bhardwaj (@abhardwaj73) +- Dhruv Duseja (@DhruvDuseja) +- Hernan Grecco (@hgrecco) +- Jaebeom Park (@Jaebeom-P) +- Kirill Pushkarev (@kirill-push) +- Andrew Rosen (@arosen93) +- Sui Xiong Tay (@SuixiongTay) (If you think that your name belongs here, please let the maintainer know) diff --git a/CHANGELOG.md b/CHANGELOG.md index a35d2f9..b528caf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.6] - 2024-09-01 + +### Fixed + +- `Solution.get_total_amount`: Bugfix that caused an error when called on certain elements + without specifying an oxidation state. For example, `get_total_amount('N')` could raise + an exception in a solution containing `Na` (but no `N`) due to a flaw in a logical + test. +- `Solution._adjust_charge_balance`: Removed a misleading and redundant log message (#162, @SuixiongTay) + +### Added + +- `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 + +- **BREAKING** `entropy_mix` now returns the ideal mixing _entropy_ in units of J/K rather than the mixing + _energy_ in J. This was done to improve clarity with respect to the function name. An `activity_correction` + kwarg was added to `gibbs_mix` so that you can still calculate the ideal mixing energy by setting it to `False`. + (#178, @Jaebeom-P) +- Revise documentation of `gibbs_mix`, `entropy_mix`, and `donnan_eql`. (#178, @Jaebeom-P) +- CI: Improve comprehensiveness of CI dependency testing. (#163, #164, @abhardwaj73) + ## [1.1.5] - 2024-07-28 ### Fixed diff --git a/README.md b/README.md index a7a4698..5f33fdf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Read the Docs](https://img.shields.io/readthedocs/pyeql)](https://pyeql.readthedocs.io/en/latest/) [![testing](https://github.com/KingsburyLab/pyeql/workflows/testing/badge.svg)](https://github.com/KingsburyLab/pyeql/actions?query=workflow%3Atesting) [![codecov](https://codecov.io/gh/KingsburyLab/pyeql/branch/main/graph/badge.svg?token=I7RP0QML6S)](https://codecov.io/gh/KingsburyLab/pyeql) -![Supported python versions](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue) +![Supported python versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8332915.svg)](https://doi.org/10.5281/zenodo.8332915) [![PyPI version](https://badge.fury.io/py/pyEQL.svg)](https://badge.fury.io/py/pyEQL) [![status](https://joss.theoj.org/papers/bdd9e247ea9736a0fdbbd5fe12bef7a6/status.svg)](https://joss.theoj.org/papers/bdd9e247ea9736a0fdbbd5fe12bef7a6) @@ -65,7 +65,7 @@ Detailed documentation is available at [https://pyeql.readthedocs.io/](https://p ### Dependencies -- Python 3.9+. This project will attempt to adhere to NumPy's +- Python 3.10+. This project will attempt to adhere to NumPy's [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html) deprecation policy for older version of Python. - [pint](https://github.com/hgrecco/pint) - for units-aware calculations diff --git a/docs/requirements.txt b/docs/requirements.txt index 3c48c08..1e58384 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -4,7 +4,7 @@ pint>=0.19 numpy scipy -pymatgen>=2023.10.11 +pymatgen>=2024.9.10 iapws monty maggma diff --git a/pyproject.toml b/pyproject.toml index e025d12..1fddbe2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,12 +18,12 @@ classifiers=[ "Topic :: Scientific/Engineering", ] license = {file = "LICENSE"} -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "pint>=0.19", "numpy>1.26,<2", "scipy>=1.12", - "pymatgen==2024.5.1", + "pymatgen>=2024.9.10", "iapws>=1.5.3", "monty>=2024.7.29", "maggma>=0.67.0", diff --git a/requirements/macos-latest_py3.10.txt b/requirements/macos-latest_py3.10.txt index c3dd43c..2feb304 100644 --- a/requirements/macos-latest_py3.10.txt +++ b/requirements/macos-latest_py3.10.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/macos-latest_py3.10_extras.txt b/requirements/macos-latest_py3.10_extras.txt index 030c8c9..801f3a8 100644 --- a/requirements/macos-latest_py3.10_extras.txt +++ b/requirements/macos-latest_py3.10_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/macos-latest_py3.11.txt b/requirements/macos-latest_py3.11.txt index 9ca78d9..94cc90d 100644 --- a/requirements/macos-latest_py3.11.txt +++ b/requirements/macos-latest_py3.11.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/macos-latest_py3.11_extras.txt b/requirements/macos-latest_py3.11_extras.txt index 745e283..fa4388d 100644 --- a/requirements/macos-latest_py3.11_extras.txt +++ b/requirements/macos-latest_py3.11_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/macos-latest_py3.12.txt b/requirements/macos-latest_py3.12.txt index 781c52d..321320c 100644 --- a/requirements/macos-latest_py3.12.txt +++ b/requirements/macos-latest_py3.12.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/macos-latest_py3.12_extras.txt b/requirements/macos-latest_py3.12_extras.txt index f100f63..5c948c0 100644 --- a/requirements/macos-latest_py3.12_extras.txt +++ b/requirements/macos-latest_py3.12_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/macos-latest_py3.9.txt b/requirements/macos-latest_py3.9.txt index 7f9c5f9..07a8927 100644 --- a/requirements/macos-latest_py3.9.txt +++ b/requirements/macos-latest_py3.9.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/macos-latest_py3.9_extras.txt b/requirements/macos-latest_py3.9_extras.txt index 968615a..c629488 100644 --- a/requirements/macos-latest_py3.9_extras.txt +++ b/requirements/macos-latest_py3.9_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.10.txt b/requirements/ubuntu-latest_py3.10.txt index 7da22d5..bc9ff79 100644 --- a/requirements/ubuntu-latest_py3.10.txt +++ b/requirements/ubuntu-latest_py3.10.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.10_extras.txt b/requirements/ubuntu-latest_py3.10_extras.txt index a65f867..8f70f9d 100644 --- a/requirements/ubuntu-latest_py3.10_extras.txt +++ b/requirements/ubuntu-latest_py3.10_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.11.txt b/requirements/ubuntu-latest_py3.11.txt index f72b63a..6ede553 100644 --- a/requirements/ubuntu-latest_py3.11.txt +++ b/requirements/ubuntu-latest_py3.11.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.11_extras.txt b/requirements/ubuntu-latest_py3.11_extras.txt index a8947d2..4a21bc7 100644 --- a/requirements/ubuntu-latest_py3.11_extras.txt +++ b/requirements/ubuntu-latest_py3.11_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.12.txt b/requirements/ubuntu-latest_py3.12.txt index 2fbd92e..d9a9f2e 100644 --- a/requirements/ubuntu-latest_py3.12.txt +++ b/requirements/ubuntu-latest_py3.12.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.12_extras.txt b/requirements/ubuntu-latest_py3.12_extras.txt index 946a399..ce69204 100644 --- a/requirements/ubuntu-latest_py3.12_extras.txt +++ b/requirements/ubuntu-latest_py3.12_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.9.txt b/requirements/ubuntu-latest_py3.9.txt index d74bb5e..dc3f660 100644 --- a/requirements/ubuntu-latest_py3.9.txt +++ b/requirements/ubuntu-latest_py3.9.txt @@ -33,7 +33,7 @@ charset-normalizer==3.3.2 # via requests contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/ubuntu-latest_py3.9_extras.txt b/requirements/ubuntu-latest_py3.9_extras.txt index ee687ad..8e7a3c1 100644 --- a/requirements/ubuntu-latest_py3.9_extras.txt +++ b/requirements/ubuntu-latest_py3.9_extras.txt @@ -45,7 +45,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.10.txt b/requirements/windows-latest_py3.10.txt index 7cdcb1f..1bb312d 100644 --- a/requirements/windows-latest_py3.10.txt +++ b/requirements/windows-latest_py3.10.txt @@ -35,7 +35,7 @@ colorama==0.4.6 # via tqdm contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.10_extras.txt b/requirements/windows-latest_py3.10_extras.txt index 09a0ae2..f87f99f 100644 --- a/requirements/windows-latest_py3.10_extras.txt +++ b/requirements/windows-latest_py3.10_extras.txt @@ -52,7 +52,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.11.txt b/requirements/windows-latest_py3.11.txt index 57bc944..d60605b 100644 --- a/requirements/windows-latest_py3.11.txt +++ b/requirements/windows-latest_py3.11.txt @@ -35,7 +35,7 @@ colorama==0.4.6 # via tqdm contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.11_extras.txt b/requirements/windows-latest_py3.11_extras.txt index e6911b1..763ea50 100644 --- a/requirements/windows-latest_py3.11_extras.txt +++ b/requirements/windows-latest_py3.11_extras.txt @@ -52,7 +52,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.12.txt b/requirements/windows-latest_py3.12.txt index bceb7c1..37ecefa 100644 --- a/requirements/windows-latest_py3.12.txt +++ b/requirements/windows-latest_py3.12.txt @@ -35,7 +35,7 @@ colorama==0.4.6 # via tqdm contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.12_extras.txt b/requirements/windows-latest_py3.12_extras.txt index 84d0d57..7d6bf3a 100644 --- a/requirements/windows-latest_py3.12_extras.txt +++ b/requirements/windows-latest_py3.12_extras.txt @@ -52,7 +52,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.9.txt b/requirements/windows-latest_py3.9.txt index 123e6ee..3e6a4ef 100644 --- a/requirements/windows-latest_py3.9.txt +++ b/requirements/windows-latest_py3.9.txt @@ -35,7 +35,7 @@ colorama==0.4.6 # via tqdm contourpy==1.2.1 # via matplotlib -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/requirements/windows-latest_py3.9_extras.txt b/requirements/windows-latest_py3.9_extras.txt index bfaa13b..232c876 100644 --- a/requirements/windows-latest_py3.9_extras.txt +++ b/requirements/windows-latest_py3.9_extras.txt @@ -52,7 +52,7 @@ contourpy==1.2.1 # via matplotlib coverage[toml]==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via paramiko cycler==0.12.1 # via matplotlib diff --git a/src/pyEQL/solution.py b/src/pyEQL/solution.py index ee19535..eac5968 100644 --- a/src/pyEQL/solution.py +++ b/src/pyEQL/solution.py @@ -1161,7 +1161,8 @@ def get_total_amount(self, element: str, units: str) -> Quantity: :meth:`get_amount` :func:`pyEQL.utils.interpret_units` """ - TOT: Quantity = 0 + _units = interpret_units(units) + TOT: Quantity = ureg.Quantity(0, _units) # standardize the element formula and units el = str(Element(element.split("(")[0])) @@ -1178,7 +1179,7 @@ def get_total_amount(self, element: str, units: str) -> Quantity: else: species = [] for k, v in comp_by_element.items(): - if el in k: + if k.split("(")[0] == el: species.extend(v) # loop through the species of interest, adding moles of element @@ -2294,9 +2295,7 @@ def _adjust_charge_balance(self, atol=1e-8) -> None: self.logger.info("balance_charge is None, so no charge balancing will be performed.") return - self.logger.info( - f"Adjusting {self._cb_species} to compensate." - ) + self.logger.info(f"Adjusting {self._cb_species} to compensate.") if self.balance_charge == "pH": # the charge imbalance associated with the H+ / OH- system can be expressed diff --git a/src/pyEQL/utils.py b/src/pyEQL/utils.py index 7b1b973..42df7c4 100644 --- a/src/pyEQL/utils.py +++ b/src/pyEQL/utils.py @@ -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 diff --git a/tests/test_phreeqc.py b/tests/test_phreeqc.py index fcec742..e89e753 100644 --- a/tests/test_phreeqc.py +++ b/tests/test_phreeqc.py @@ -131,7 +131,7 @@ def test_conductivity(s1): # even an empty solution should have some conductivity assert s1.conductivity > 0 - for conc, cond in zip([0.001, 0.05, 0.1], [123.68, 111.01, 106.69]): + for conc, cond in zip([0.001, 0.05, 0.1], [123.68, 111.01, 106.69], strict=False): s1 = Solution({"Na+": f"{conc} mol/L", "Cl-": f"{conc} mol/L"}) assert np.isclose( s1.conductivity.to("S/m").magnitude, conc * cond / 10, atol=0.5 @@ -142,7 +142,7 @@ def test_conductivity(s1): assert np.isclose(s1.conductivity.to("mS/cm").magnitude, 145, atol=10) # MgCl2 - for conc, cond in zip([0.001, 0.05, 0.1], [124.15, 114.49, 97.05]): + for conc, cond in zip([0.001, 0.05, 0.1], [124.15, 114.49, 97.05], strict=False): s1 = Solution({"Mg+2": f"{conc} mol/L", "Cl-": f"{2*conc} mol/L"}) assert np.isclose( s1.conductivity.to("S/m").magnitude, 2 * conc * cond / 10, atol=1 @@ -232,7 +232,7 @@ def test_equilibrate(s1, s2, s5_pH, s6_Ca, caplog): set(s5_pH.components.keys()) s5_pH.equilibrate() assert np.isclose(s5_pH.get_total_amount("Ca", "mol").magnitude, 0.001) - assert np.isclose(s5_pH.get_total_amount("C(4)", "mol").magnitude, 0.001) + assert np.isclose(s5_pH.get_total_amount("C(4)", "mol").magnitude, 0.001, atol=1e-7) # due to the large pH shift, water mass and density need not be perfectly conserved assert np.isclose(s5_pH.solvent_mass.magnitude, orig_solv_mass, atol=1e-3) assert np.isclose(s5_pH.density.magnitude, orig_density, atol=1e-3) diff --git a/tests/test_solution.py b/tests/test_solution.py index 2942292..fb22416 100644 --- a/tests/test_solution.py +++ b/tests/test_solution.py @@ -476,6 +476,7 @@ def test_components_by_element(s1, s2): def test_get_total_amount(s2): assert np.isclose(s2.get_total_amount("Na(1)", "g").magnitude, 8 * 58, 44) assert np.isclose(s2.get_total_amount("Na", "mol").magnitude, 8) + assert np.isclose(s2.get_total_amount("N", "mol").magnitude, 0) assert np.isclose(s2.get_total_amount("Na", "ppm").magnitude, 4 * 23300, rtol=0.02) sox = Solution({"Fe+2": "10 mM", "Fe+3": "40 mM", "Cl-": "50 mM"}, pH=3) assert np.isclose(sox.get_total_amount("Fe(2)", "mol/L").magnitude, 0.01) diff --git a/tests/test_utils.py b/tests/test_utils.py index 2226923..b0e091a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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():