Skip to content

Conversation

@vineetbansal
Copy link
Collaborator

Summary

Major changes:

Added some currently failing tests for PHREEQC's solid-liquid equilibrium calculations. The None values in all the newly-introduced tests (with the #TODO: fill-in marker) need to be filled in before I can add a commit that adds the desired functionality.

This PR builds on top of PR #285 so that we don't get flagged on failing CI tests that have nothing to do with the changes proposed here. I'm happy to rebase this PR based on suggestions to PR #285 (if any).

Todos

If this is work in progress, what else needs to be done?

  • Fill in the real desired values instead of the Nones, preferably by running these cases through a standalone PhreeqC workflow.
  • Once these values are filled in, a subsequent commit can make these tests pass.

Checklist

  • Google format doc strings added.
  • Code linted with ruff. (For guidance in fixing rule violates, see rule list)
  • Type annotations included. Check with mypy.
  • Tests added for new features/fixes.
  • I have run the tests locally and they passed. (expected to fail)

Tip: Install pre-commit hooks to auto-check types and linting before every commit:

pip install -U pre-commit
pre-commit install

@vineetbansal
Copy link
Collaborator Author

All newly introduced tests here translate to the IPhreeqc string:

SOLUTION 0
  temp 25.0
  units mol/kgw
  pH 7.0
  pe 8.5
  redox pe
  water 1.9940960639434773
  Cu(2) 4.011842831773806
SAVE SOLUTION 0
END

I'm hoping that someone (@SuixiongTay ?) can fill in the correct values for these tests by running the above script in IPhreeqc along with the correct variation (should be different for each case) on the EQUILIBRIUM PHASES block:

USE SOLUTION 0
EQUILIBRIUM PHASES 1 
Calcite 1 0
SAVE SOLUTION 0
END

I've chosen CuO simply because ChatGPT tells me that its a compound likely to equilibrate to different Cu concentrations depending on conc. of atmosphere gases. If some other compound should better illustrate the differences, please feel free to change!

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.08%. Comparing base (2dc42fc) to head (deb8aaf).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/pyEQL/functions.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #286      +/-   ##
==========================================
+ Coverage   84.89%   85.08%   +0.19%     
==========================================
  Files           9       10       +1     
  Lines        1476     1495      +19     
  Branches      257      261       +4     
==========================================
+ Hits         1253     1272      +19     
  Misses        193      193              
  Partials       30       30              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vineetbansal
Copy link
Collaborator Author

For reference, we plan to define atmosphere as {"CO2": -3.5, "O2": -0.6778}

@rkingsbury
Copy link
Member

For reference, we plan to define atmosphere as {"CO2": -3.5, "O2": -0.6778}

I think this will be fine. The only other non-trivial components of the atmosphere are N2 and Argon, and I'm fairly certain that neither of those partitions into water to any meaningful degree.

I found a compilation of Henry's law constants, which shows that the Kh values for Ar and N2 actually appear to be on a similar order of magnitude to those of O2.

@SuixiongTay - when you're running test simulations, can you include a case where N2 and Ar are included in EQUILIBRIUM_PHASES and see what that does to the speciation?

I think in the end we will probably just stick with O2 and CO2, but it'll be good to double check.

assert np.isclose(s6_Ca.charge_balance, 0, atol=1e-8)


def test_equilibrate_vacuum():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this test test_equilibrate_liquid b/c technically it represents a closed container (no contact with gas/solid/vacuum)

Comment on lines 260 to 297


def test_equilibrate_vacuum():
solution = Solution([["Cu+2", "4 mol/L"], ["O-2", "4 mol/L"]], volume="2 L", engine="phreeqc")
solution.equilibrate()
assert solution.get_total_amount("Cu", "mol").magnitude == pytest.approx(None) # TODO: fill-in


def test_equilibrate_with_atm():
solution = Solution([["Cu+2", "4 mol/L"], ["O-2", "4 mol/L"]], volume="2 L", engine="phreeqc")
solution.equilibrate(atmosphere=True)
assert solution.get_total_amount("Cu", "mol").magnitude == pytest.approx(None) # TODO: fill-in


def test_equilibrate_with_co2_pp():
# Specify partial pressure of equilibrium gas(es) directly, as log10_<partial_pressure> values.
solution = Solution([["Cu+2", "4 mol/L"], ["O-2", "4 mol/L"]], volume="2 L", engine="phreeqc")
solution.equilibrate(gases={"CO2": -2})
assert solution.get_total_amount("Cu", "mol").magnitude == pytest.approx(None) # TODO: fill-in


def test_equilibrate_with_co2_pp_atm():
# Specify partial pressure of equilibrium gas(es) directly, but in some recognizable units.
solution = Solution([["Cu+2", "4 mol/L"], ["O-2", "4 mol/L"]], volume="2 L", engine="phreeqc")
solution.equilibrate(gases={"CO2": "0.01 atm"})
assert solution.get_total_amount("Cu", "mol").magnitude == pytest.approx(None) # TODO: fill-in


def test_equilibrate_with_calcite():
solution = Solution([["Cu+2", "4 mol/L"], ["O-2", "4 mol/L"]], volume="2 L", engine="phreeqc")
solution.equilibrate(solids=["Calcite"])
assert solution.get_total_amount("Cu", "mol").magnitude == pytest.approx(None) # TODO: fill-in


def test_equilibrate_with_calcite_and_atm():
solution = Solution([["Cu+2", "4 mol/L"], ["O-2", "4 mol/L"]], volume="2 L", engine="phreeqc")
solution.equilibrate(atmosphere=True, solids=["Calcite"])
assert solution.get_total_amount("Cu", "mol").magnitude == pytest.approx(None) # TODO: fill-in
Copy link
Member

@rkingsbury rkingsbury Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set of tests look great (pending adding the right values)

One more we should add - we'll want to handle collisions between atmosphere=True and gases={<something>} kwargs. If a user specifies both, we could either

  1. Combine the contents of the atmosphere dict with whatever the user supplied, overwriting any duplicated keys (e.g., atmosphere=True, gases={"CO2": "0.01 atm"} should overwrite {"CO2": -3.5} in the call to IPHREEQC). If a key gets overwritten, a warning or INFO message should be logged.

  2. Ignore the atmosphere kwarg and use only what the user specified, while logging a WARNING

I'm in favor of option 1 b/c I can imagine many users might want to simulate "the atmosphere plus some trace impurity gas", and option 1 would make that easy to do. But I could be convinced for option 2 as well. @SuixiongTay @YitongPan1 what do y'all think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me - I've implemented the "atmosphere plus some trace impurity gas.." approach in the upcoming PR.

@rkingsbury rkingsbury mentioned this pull request Nov 4, 2025
5 tasks
@SuixiongTay
Copy link
Collaborator

SuixiongTay commented Nov 4, 2025

Hi @vineetbansal , below are the ion species distribution after equilibrium from PHREEQC

1.CuO test case

PHREEQC input:

SOLUTION 0
  temp 25.0
  units mol/kgw
  pH 7.0
  pe 8.5
  redox pe
  water 1.9940960639434773
  Cu(2) 4.011842831773806
SAVE SOLUTION 0
END

USE SOLUTION 0
EQUILIBRIUM PHASES 1 
 Calcite 1 0
SAVE SOLUTION 0
END

PHREEQC output:

                                               Log       Log       Log    mole V
   Species          Molality    Activity  Molality  Activity     Gamma    cm³/mol

   OH-             2.011e-07   9.705e-08    -6.697    -7.013    -0.316      2.99
   H+              1.410e-07   1.000e-07    -6.851    -7.000    -0.149      0.00
   H2O             5.551e+01   9.588e-01     1.744    -0.018     0.000     18.07
Cu(1)         2.213e-08
   Cu+             2.213e-08   8.865e-09    -7.655    -8.052    -0.397     (0)  
Cu(2)         4.012e+00
   Cu2(OH)2+2      1.591e+00   4.631e+01     0.202     1.666     1.464     (0)  
   Cu+2            7.394e-01   1.073e-01    -0.131    -0.969    -0.838    -23.59
   Cu(OH)2         7.030e-02   2.061e-01    -1.153    -0.686     0.467     (0)  
   CuOH+           1.993e-02   1.029e-02    -1.701    -1.988    -0.287     (0)  
   Cu(OH)3-        5.127e-08   1.191e-07    -7.290    -6.924     0.366     (0)  
   Cu(OH)4-2       7.826e-15   2.278e-13   -14.106   -12.642     1.464     (0)  
H(0)          1.197e-37
   H2              5.986e-38   1.755e-37   -37.223   -36.756     0.467     28.61
O(0)          8.491e-20
   O2              4.246e-20   1.245e-19   -19.372   -18.905     0.467     30.40

2.Calcite test case

A simpler test case would be by equilibrating water with calcite (pKsp= 8.48) and CO2 at pH 8.4:

PHREEQC input:

SOLUTION 1 
 pH 8.4
EQUILIBRIUM_PHASES 1
 Calcite 0.0 10.0 
 CO2(g) -3.5 
END 

With the ion species distribution after equilibrium below:

PHREEQC output:

                                               Log       Log       Log    mole V
   Species          Molality    Activity  Molality  Activity     Gamma    cm³/mol

   OH-             2.011e-06   1.927e-06    -5.697    -5.715    -0.019     -4.10
   H+              5.470e-09   5.254e-09    -8.262    -8.280    -0.018      0.00
   H2O             5.551e+01   1.000e+00     1.744    -0.000     0.000     18.07
C(-4)         3.927e-29
   CH4             3.927e-29   3.928e-29   -28.406   -28.406     0.000     35.46
C(4)          9.810e-04
   HCO3-           9.501e-04   9.110e-04    -3.022    -3.040    -0.018     24.69
   CO2             1.076e-05   1.076e-05    -4.968    -4.968     0.000     34.43
   CO3-2           9.621e-06   8.132e-06    -5.017    -5.090    -0.073     -5.25
   CaCO3           5.561e-06   5.563e-06    -5.255    -5.255     0.000    -14.60
   CaHCO3+         4.935e-06   4.733e-06    -5.307    -5.325    -0.018      9.68
   (CO2)2          2.125e-12   2.125e-12   -11.673   -11.673     0.000     68.87
Ca            4.924e-04
   Ca+2            4.819e-04   4.072e-04    -3.317    -3.390    -0.073    -18.12
   CaCO3           5.561e-06   5.563e-06    -5.255    -5.255     0.000    -14.60
   CaHCO3+         4.935e-06   4.733e-06    -5.307    -5.325    -0.018      9.68
   CaOH+           1.343e-08   1.286e-08    -7.872    -7.891    -0.019     (0)  
H(0)          1.563e-15
   H2              7.814e-16   7.816e-16   -15.107   -15.107     0.000     28.61
O(0)          0.000e+00
   O2              0.000e+00   0.000e+00   -62.166   -62.166     0.000     30.40

@SuixiongTay
Copy link
Collaborator

I think in the end we will probably just stick with O2 and CO2, but it'll be good to double check.

Hi @rkingsbury , here are the outputs after including N2 for equilibration. The current PHREEQC database does not include aqueous complexes for Ar.

I believe including O2, N2, and CO2 should be sufficient for the PHREEQC wrapper

PHREEQC input:

SOLUTION 0
  temp 25.0
  units mol/kgw
  pH 7.0
  pe 8.5
  redox pe
  water 1.9940960639434773
  Cu(2) 4.011842831773806
SAVE SOLUTION 0
END

USE SOLUTION 0
EQUILIBRIUM PHASES 1 
 Calcite 1 0
 N2(g) -0.1079
SAVE SOLUTION 0
END

PHREEQC output:

                                               Log       Log       Log    mole V
   Species          Molality    Activity  Molality  Activity     Gamma    cm³/mol

   OH-             2.011e-07   9.705e-08    -6.697    -7.013    -0.316      2.99
   H+              1.410e-07   1.000e-07    -6.851    -7.000    -0.149      0.00
   H2O             5.551e+01   9.588e-01     1.744    -0.018     0.000     18.07
Cu(1)         1.496e-08
   Cu+             1.496e-08   5.994e-09    -7.825    -8.222    -0.397     (0)  
Cu(2)         4.012e+00
   Cu2(OH)2+2      1.591e+00   4.631e+01     0.202     1.666     1.464     (0)  
   Cu+2            7.394e-01   1.073e-01    -0.131    -0.969    -0.838    -23.59
   Cu(OH)2         7.030e-02   2.061e-01    -1.153    -0.686     0.467     (0)  
   CuOH+           1.993e-02   1.029e-02    -1.701    -1.988    -0.287     (0)  
   Cu(OH)3-        5.127e-08   1.191e-07    -7.290    -6.924     0.366     (0)  
   Cu(OH)4-2       7.826e-15   2.278e-13   -14.106   -12.642     1.464     (0)  
H(0)          5.473e-38
   H2              2.736e-38   8.022e-38   -37.563   -37.096     0.467     28.61
N(-3)         0.000e+00
   NH4+            0.000e+00   0.000e+00   -43.626   -44.023    -0.397     19.13
   NH3             0.000e+00   0.000e+00   -46.735   -46.268     0.467     24.42
N(0)          3.549e-04
   N2              1.775e-04   5.203e-04    -3.751    -3.284     0.467     29.29
N(3)          4.192e-19
   NO2-            4.192e-19   1.863e-19   -18.378   -18.730    -0.352     26.98
N(5)          9.547e-14
   NO3-            9.547e-14   4.243e-14   -13.020   -13.372    -0.352     31.91
O(0)          4.064e-19
   O2              2.032e-19   5.956e-19   -18.692   -18.225     0.467     30.40

@rkingsbury
Copy link
Member

I believe including O2, N2, and CO2 should be sufficient for the PHREEQC wrapper

Sounds good to me! Thanks for checking. Yeah, I see that aqueous N2 is present at about 1e-4 mol/kg, which is a high enough concentration to be relevant.

@vineetbansal
Copy link
Collaborator Author

@rkingsbury, @SuixiongTay - I've filled in the values in the tests by confirming that the Phreeqc strings generated in all cases "make intuitive sense", and added the test about aqueous N2 as mentioned in the thread above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looked to me like the natural place to put the newly introduced constants. This makes it a submodule of pyEQL along with other data files.

@YitongPan1
Copy link
Collaborator

YitongPan1 commented Nov 10, 2025

Hi all, here are some additional test cases :)

def test_equilibrate_water_pH7():
    solution = Solution([], pH = 7.00, temperature = '25 degC', volume="1 L", engine="phreeqc")
    solution.equilibrate()
    assert solution.get_total_amount("H+", "mol").magnitude == pytest.approx(1.01e-07)
    assert solution.get_total_amount("OH-", "mol").magnitude == pytest.approx(9.98e-08)
    assert solution.get_total_amount("H2", "mol").magnitude == pytest.approx(7.058e-26)

def test_equilibrate_morewater_with_calcite():
    solution = Solution([], pH = 8.4, volume="5 L", engine="phreeqc")
    solution.equilibrate(gases={"CO2": "3.162e-04 atm"}, solids=["Calcite"])
    assert solution.get_total_amount("Ca+2", "mol").magnitude == pytest.approx(5*4.819e-04*0.997)
    assert solution.get_total_amount("(CO2)2", "mol").magnitude == pytest.approx(5*2.125e-12*0.997)
    assert solution.get_total_amount("HCO3-", "mol").magnitude == pytest.approx(5*9.501e-04*0.997)

def test_equilibrate_water_with_calcite():
    solution = Solution([], pH = 8.4, volume="1 L", engine="phreeqc")
    solution.equilibrate(gases={"CO2": -3.5}, solids=["Calcite"])
    assert solution.get_total_amount("Na+1", "mol").magnitude == pytest.approx(None)
    assert solution.get_total_amount("CaHCO3+", "mol").magnitude == pytest.approx(4.935e-06*0.997)
    assert solution.get_total_amount("OH-", "mol").magnitude == pytest.approx(2.011e-06*0.997)

def test_equilibrate_sophisticated():
    solution = Solution([["Ca+2", "3 mmol/kg"], ["Na+", "1 mmol/kg"], ["CO3-2", "1.9 mmol/kg"], ["SO4-2", "1 mmol/kg"], ["NO3-", "0.2 mmol/kg"], ["Cl-", "1.0 mmol/kg"]], pH = 7.00, pE = 4.0, temperature = '25 degC', volume="1 L", engine="phreeqc")
    solution.equilibrate()
    assert solution.get_total_amount("H+", "mol").magnitude == pytest.approx(1.092e-07)
    assert solution.get_total_amount("NaCO3-", "mol").magnitude == pytest.approx(2.906e-08)
    assert solution.get_total_amount("CaOH+", "mol").magnitude == pytest.approx(3.358e-09)

@vineetbansal
Copy link
Collaborator Author

Hi @YitongPan1 - thanks for the additional tests. However, I think there are some potential problems in interpretation, which may be on my end (but I think are unrelated to this PR in any case):

    assert solution.get_total_amount("H+", "mol").magnitude == pytest.approx(1.01e-07)

I believe the correct call as per pyEQL convention should be:

solution.get_total_amount("H(+1)", "mol").magnitude

Further, for 1L of water, the amount of H2O turns out to be ~55 moles and the amount of H+ is thus ~110 moles.

I'd be interested to know why you expect 1.01e-07 moles so we can perhaps make the API/documentation more explicit.

Also, running these test cases locally against the main branch (or this branch for tests that have to do with equilibrium phases) will show these failures too. I'm happy to help you recreate these scenarios locally..

@rkingsbury
Copy link
Member

rkingsbury commented Nov 10, 2025

Hi @YitongPan1 - thanks for the additional tests. However, I think there are some potential problems in interpretation, which may be on my end (but I think are unrelated to this PR in any case):

    assert solution.get_total_amount("H+", "mol").magnitude == pytest.approx(1.01e-07)

I believe the correct call as per pyEQL convention should be:

solution.get_total_amount("H(+1)", "mol").magnitude

Actually no, @YitongPan1's version is the correct one. One way to check is to pass the formula (H+ or H(+1) through pyEQL.utils.standardize_formula. You should see

>>> standardize_formula('H+')
H[+1]
>>> standardize_formula('H(+1)')
<ValueError>

The semantic difference between H+ and H(+1) in this context is subtle (and arguably could be improved). The first one means the species H+, the second (with parentheses) implies "hydrogen in the +1 oxidation state" which is not quite the same thing.

Further, for 1L of water, the amount of H2O turns out to be ~55 moles and the amount of H+ is thus ~110 moles.

I'd be interested to know why you expect 1.01e-07 moles so we can perhaps make the API/documentation more explicit.

Yes, there's an error in @YitongPan1 's tests there - mol should be mol/L for the units. That's when you should see 1e-07 for the H+ concentration (which is equal to saying that the pH is 7)

@rkingsbury
Copy link
Member

rkingsbury commented Nov 10, 2025

Further, for 1L of water, the amount of H2O turns out to be ~55 moles and the amount of H+ is thus ~110 moles.
I'd be interested to know why you expect 1.01e-07 moles so we can perhaps make the API/documentation more explicit.

Yes, there's an error in @YitongPan1 's tests there - mol should be mol/L for the units. That's when you should see 1e-07 for the H+ concentration (which is equal to saying that the pH is 7)

Actually, nevermind, the volume is already account for by the 5 and 0.997 factors (e.g., 5*4.819e-04*0.997 which converts mol/L to mol)

@rkingsbury
Copy link
Member

the amount of H2O turns out to be ~55 moles and the amount of H+ is thus ~110 moles.

@vineetbansal the amounts of H2O and H+ are different actually. These refer, respectively, to the amount of pure water and the amount of protons (the basis for pH). I think the source of the confusion might be related to the semantic difference between H+ and H(+1) I described above.

@vineetbansal
Copy link
Collaborator Author

vineetbansal commented Nov 10, 2025

@rkingsbury - thanks for the clarification. Sure enough, from the docstrings:

get_amount => Return the amount of 'solute' in the parent solution.
get_total_amount => Return the total amount of 'element' (across all solutes) in the solution.

The following asserts work with the main branch:

    solution = Solution([], pH = 7.00, temperature = '25 degC', volume="1 L", engine="phreeqc")
    solution.equilibrate()
    assert solution.get_amount("H+", "mol").magnitude == pytest.approx(9.975711240328358e-08)
    assert solution.get_total_amount("H(+1)", "mol").magnitude == pytest.approx(110.68915207310867)

In any case, @YitongPan1's asserts would not work, either with the main branch or this one (and raise a ValueError: 'H+' is not a valid Element). If they are, then perhaps she's working off a branch where the behavior was changed?

@rkingsbury
Copy link
Member

rkingsbury commented Nov 10, 2025

In any case, @YitongPan1's asserts would not work, either with the main branch or this one (and raise a ValueError: 'H+' is not a valid Element). If they are, then perhaps she's working off a branch where the behavior was changed?

That's strange. When I'm on an up to date main branch, it's only get_total_amount('H+') that fails, although this should fail (and is not part of Yitong's asserts )because the argument to get_total_amount should be an element or element(oxi state), not a species. Everything else works.

@vineetbansal can you post your output and @YitongPan1 can you make sure you're running these on the latest main branch (use git pull to update)?

>>> from pyEQL import Solution
>>> s1 = Solution([], pH = 7.00, temperature = '25 degC', volume="1 L", engine="phreeqc")
>>> s1.get_total_amount('H(1)', 'mol')
<Quantity(110.6891520723815, 'mole')>
>>> s1.get_total_amount('H(+1)', 'mol')
<Quantity(110.6891520723815, 'mole')>
>>> s1.get_total_amount('H', 'mol')
<Quantity(110.6891520723815, 'mole')>
>>> s1.equilibrate()
>>> s1.get_total_amount('H', 'mol')
<Quantity(110.68915207310867, 'mole')>
>>> s1.get_total_amount('H(+1)', 'mol')
<Quantity(110.68915207310867, 'mole')>
>>> s1.get_total_amount('H+', 'mol')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ryan/mambaforge/envs/feynman/code/pyEQL/src/pyEQL/solution.py", line 1239, in get_total_amount
    el = str(Element(element.split("(")[0]))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ryan/mambaforge/envs/feynman/lib/python3.12/enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ryan/mambaforge/envs/feynman/lib/python3.12/enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'H+' is not a valid Element
>>> s1.get_amount('H+', 'mol')
<Quantity(9.975711240328358e-08, 'mole')>

@vineetbansal
Copy link
Collaborator Author

@rkingsbury - your REPL snippet is expected, and what I'm getting as well.

What I meant was that the code that @YitongPan1 is using in her asserts (in her "additional test cases" blurb) is failing, (as expected after our discussion above):

>>> import pyEQL
>>> pyEQL.__version__
'1.3.2.post1.dev14+g56b71d62b'
>>> solution = pyEQL.Solution([], pH = 7.00, temperature = '25 degC', volume="1 L", engine="phreeqc")
>>> solution.equilibrate()
>>> assert solution.get_total_amount("H+", "mol").magnitude == pytest.approx(1.01e-07)
ValueError: 'H+' is not a valid Element
>>> assert solution.get_total_amount("OH-", "mol").magnitude == pytest.approx(9.98e-08)
ValueError: 'OH-' is not a valid Element
>>> assert solution.get_total_amount("H2", "mol").magnitude == pytest.approx(7.058e-26)
ValueError: 'H2' is not a valid Element

Since the syntax in her suggested tests is painstakingly correct, I was just wondering if that code is/was working in some branch, but is not working on main anymore.

@rkingsbury
Copy link
Member

@rkingsbury - your REPL snippet is expected, and what I'm getting as well.

OK good!

What I meant was that the code that @YitongPan1 is using in her asserts (in her "additional test cases" blurb) is failing, (as expected after our discussion above):

>>> import pyEQL
>>> pyEQL.__version__
'1.3.2.post1.dev14+g56b71d62b'
>>> solution = pyEQL.Solution([], pH = 7.00, temperature = '25 degC', volume="1 L", engine="phreeqc")
>>> solution.equilibrate()
>>> assert solution.get_total_amount("H+", "mol").magnitude == pytest.approx(1.01e-07)
ValueError: 'H+' is not a valid Element
>>> assert solution.get_total_amount("OH-", "mol").magnitude == pytest.approx(9.98e-08)
ValueError: 'OH-' is not a valid Element
>>> assert solution.get_total_amount("H2", "mol").magnitude == pytest.approx(7.058e-26)
ValueError: 'H2' is not a valid Element

Since the syntax in her suggested tests is painstakingly correct, I was just wondering if that code is/was working in some branch, but is not working on main anymore.

I see now - sorry I missed this before. I could have sworn the first asserts used get_amount rather than get_total_amount, but I think I got mixed up.

@vineetbansal
Copy link
Collaborator Author

Closing this in favor of PR#292. We can refer back to the discussions here if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants