8000 Reject pH plans only for phases that form at feed conditions (#78) by rafatahmed · Pull Request #82 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

Reject pH plans only for phases that form at feed conditions (#78) - #82

Merged
rafatahmed merged 1 commit into
mainfrom
fix/saturation-gate
Oct 22, 2026
Merged

rafatahmed merged 1 commit into
mainfrom
fix/saturation-gate

Conversation

@rafatahmed
Copy link
Copy Markdown
Owner

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_policy classifies positive indices (owner decision on #78):

Phase Class Reason (sources in code and docs)
Hydroxylapatite review forms via ACP/OCP/brushite precursors, Mg-inhibited (Nancollas et al. 1976)
Goethite review slow from ferrihydrite (Schwertmann & Murad 1983)
MnHPO4 review log K −25.4 traces only to 1976 WATEQF data; not reported to form at 25 °C or in dilute feeds (Ball & Nordstrom 1991; Pedas et al. 2011)
Vivianite review Fe(II) phosphate of reducing environments; fixed-oxidation-state artifact (Metz et al. 2024; Rothe et al. 2016)
Fe(II) supplied advisory oxidizes to amorphous Fe(III) phosphate (Stumm & Lee 1961; Voegelin et al. 2010)
Brushite, monetite, gypsum, struvite, calcite, ferrihydrite, all others; any allocated solid block unchanged

The coupled pH plan, acid selection, equilibrium delivery warnings and the validated transition all use the same policy. Review-only plans are requires_review with the cited reasons; accepted candidates still rank first. The MnHPO4 database constant is not changed.

Result (26 formulas, RO water, pH 5.8)

  • Usable pH plan: 21/26 (was 0); 12 of them also meet every nutrient target.
  • Still rejected: 5, each with monetite (CaHPO4) or brushite supersaturated.

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 OK
  • python tools/verify_distribution.py — PASS
  • sphinx -W --keep-going — clean

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.
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 Flahax | 🛠️ Build #35320886 | 📁 Comparing 4d5c593 against latest (d3a0456)

  🔍 Preview build  

3 files changed
± changelog.html
± api/reference.html
± guide/water-to-delivery.html

@rafatahmed
rafatahmed merged commit 5c325b1 into main Oct 22, 2026
6 checks passed
@rafatahmed
rafatahmed deleted the fix/saturation-gate branch October 22, 2026 09:40
@rafatahmed rafatahmed self-assigned this Oct 23, 2026
rafatahmed added a commit that referenced this pull request Nov 7, 2026
Reject pH plans only for phases that form at feed conditions (#78)
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.

Positive SI of slow-forming phases (hydroxylapatite, MnHPO4) blocks every acid plan

1 participant

0