-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Milestone
Description
The phreeqc and phreeq2026 engines contain several bits of common code that can be refactored to eliminate redundancy, thus improving quality, robustness, and test coverage. Specifically:
- Both
PhreeqcEOSandPhreeqc2026EOScontain a_setup_ppsolmethod. The purpose of this private method is to convey thepyEQL.solutioncomposition to the underlying wrapper (phreeqpythonorIPHREEQC, respectively) in a way that those wrappers can understand. Most of the contents of_setup_ppsolrelates to reformatting thepyEQLcomposition into PHREEQC format, which is identical between both wrappers. Only a small bit of each method at the end (here and here, respectively) is different between the two. - Similarly, the
get_activity_coefficientmethod of both wrappers contains a small code block whose purpose is to reformatpyEQLsolute names such asNa[+1]intoNa+, etc. There is similar, but not identical, code in_setup_ppsol
# translate the species into keys that phreeqc will understand
k = standardize_formula(solute)
spl = k.split("[")
el = spl[0]
chg = spl[1].split("]")[0]
if chg[-1] == "1":
chg = chg[0] # just pass + or -, not +1 / -1
k = el + chg
Optimization Task
- Split
_setup_ppsolinto two or more private methods. The first (or more) are shared between both wrappers (so, implemented only inPhreeqc2026EOSand inherited byPhreeqcEOS) and handles "translating"pyEQLcompositions into PHREEQC format. The second or last private method is the wrapper-specific code - One of the private methods should replace the code block in
get_activity_coefficientwith a private method that does this translation of keys. This can likely be utilized in_setup_ppsolas well.
Reactions are currently unavailable