Repository navigation
Reject pH plans only for phases that form at feed conditions (#78) - #82
Merged
Merged
Conversation
FlahaX and live PHREEQC 3.8.6 agree on every saturation-index sign at the coupled target states, so the indices were right; the gate rejected any positive index, including phases that do not form in a feed. saturation_policy.py classifies them, with reasons and sources: hydroxylapatite (precursor pathway, Mg-inhibited; Nancollas et al. 1976), goethite (slow from ferrihydrite; Schwertmann & Murad 1983), anhydrous MnHPO4 (log K -25.4 traces only to 1976 WATEQF program data; not reported to form at 25 C or in dilute feeds) and vivianite (Fe(II) phosphate of reducing environments, a fixed-oxidation-state artifact) make a plan requires_review; iron(II) feeds carry an Fe(III)-phosphate advisory. Brushite, monetite, gypsum, struvite, calcite, ferrihydrite and all other phases, and any allocated solid, still reject. The coupled pH plan, acid selection, equilibrium delivery and plan validation share the policy; coupled plans with review-only findings are selectable after accepted ones. 26-formula RO-water audit at pH 5.8: 21 formulas now get a usable pH plan (12 also meet every target), against none before; the 5 still rejected have monetite or brushite supersaturated. Owner decision and cited research summary on #78.
rafatahmed
added a commit
that referenced
this pull request
Nov 7, 2026
Reject pH plans only for phases that form at feed conditions (#78)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #78.
Problem
After #81 every coupled pH plan was dosed exactly to target, but the saturation gate rejected all 62 candidates across the 26 library formulas: hydroxylapatite and MnHPO4 are supersaturated in every phosphate feed. The indices themselves are right — live PHREEQC 3.8.6 agrees with FlahaX on every SI sign at 12 coupled target states (max |diff| 0.171). The gate treated every positive index as a precipitation risk.
Change
New
flahax.saturation_policyclassifies positive indices (owner decision on #78):The coupled pH plan, acid selection, equilibrium delivery warnings and the
validatedtransition all use the same policy. Review-only plans arerequires_reviewwith the cited reasons; accepted candidates still rank first. The MnHPO4 database constant is not changed.Result (26 formulas, RO water, pH 5.8)
Open question
In 10 of the 13 monetite rejections brushite is not supersaturated. Monetite usually nucleates slowly at 25 °C relative to brushite, so it may deserve review class too — left as a hard gate until there is evidence (see #78).
Validation
FLAHAX_REQUIRE_PHREEQC=1 python -m unittest— 396 tests OKpython tools/verify_distribution.py— PASSsphinx -W --keep-going— clean