Skip to content

engines.py: NativeEOS inherits from PhreeqcEOS; eliminate redundant code#353

Merged
rkingsbury merged 4 commits intomainfrom
rk/eqmissing
Feb 14, 2026
Merged

engines.py: NativeEOS inherits from PhreeqcEOS; eliminate redundant code#353
rkingsbury merged 4 commits intomainfrom
rk/eqmissing

Conversation

@rkingsbury
Copy link
Member

@rkingsbury rkingsbury commented Feb 14, 2026

Summary

This PR reorganizes engines.py (following up #351 ) to eliminate an additional ~90 lines of duplicated code. Specifically, it changes the inheritance so that NativeEOS inherits from PhreeqcEOS, with the intention to change the inheritance to Phreeqc2026EOS in a future release. Phreeqc2026EOS inherits directly from the abstract base EOS.

This change allows the equilibrate method, which contains logic specific to the respective wrappers, to live within the Phreeqc2026EOS class. It also allows PHREEQC-specific methods _setup_ppsol and _destroy_ppsol to do the same.

After all this code has been moved around and duplicate functions removed, NativeEOS only has to implement custom get_activity_coefficient, get_osmotic_coefficient, and get_solute_volume, which communicates more clearly to future developers what is different between NativeEOS and the underlying PHREEQC-based EOS.

Note that a separate __init__ is still needed for NativeEOS because it uses a different default database (llnl.dat).

So to summarize, the new inheritance structure is:

  • EOS (abstract base)
  • IdealEOS(EOS)
  • Phreeqc2026EOS(EOS)
  • PhreeqcEOS(Phreeqc2026EOS)
  • NativeEOS(PhreeqcEOS) <= to be changed to inherit from Phreeqc2026 in a future release

@rkingsbury
Copy link
Member Author

(Apologies that the diff is difficult to read; in retrospect I should have done one commit after just moving NativeEOS to the end of the file, then subsequent commits for other changes)

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 89.31624% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.27%. Comparing base (12fa836) to head (32c3aaa).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/pyEQL/engines.py 89.31% 18 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #353      +/-   ##
==========================================
+ Coverage   85.53%   86.27%   +0.73%     
==========================================
  Files          14       14              
  Lines        1860     1821      -39     
  Branches      323      313      -10     
==========================================
- Hits         1591     1571      -20     
+ Misses        224      207      -17     
+ Partials       45       43       -2     

☔ 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.

@rkingsbury rkingsbury merged commit c344f17 into main Feb 14, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant