Skip to content

Support direct Alkalinity-only input for fixed-pH screening#5

Open
TimBartholomew wants to merge 3 commits into
avdudchenko:mainfrom
TimBartholomew:alkalinity
Open

Support direct Alkalinity-only input for fixed-pH screening#5
TimBartholomew wants to merge 3 commits into
avdudchenko:mainfrom
TimBartholomew:alkalinity

Conversation

@TimBartholomew

Copy link
Copy Markdown
Contributor

Description

This PR fixes alkalinity handling in build_water_composition(...) for fixed-pH screening workflows.

Previously, passing alkalinity directly was broken and could fail with a NameError due to an input_formula / input_fomrula typo. In addition, alkalinity-related inputs could trigger coupled carbonate handling that caused PHREEQC to reconcile carbonate chemistry and shift the specified pH.

This change makes the direct Alkalinity path explicit:

  • Direct Alkalinity input now works without crashing.
  • When Alkalinity is passed explicitly, the generated SOLUTION block includes only an Alkalinity line.
  • The direct Alkalinity path does not auto-add C(4) or C(+4), which preserves the caller-specified pH in fixed-pH screening workflows.
  • The existing CaHCO3 helper behavior is preserved as the explicit coupled carbon + alkalinity path.

Implementation

  • Added a dedicated Alkalinity branch so direct alkalinity input no longer falls through the generic species handling.
  • Fixed the input_formula / input_fomrula typo in the same area.
  • Added focused regression tests covering:
    • direct Alkalinity input emits only Alkalinity
    • CaHCO3 still emits coupled inorganic carbon + alkalinity behavior

Validation

Ran:

  • pytest src/phreeqcinwt/tests/test_solution_build.py -k "alkalinity or cahco3" -q
  • pytest src/phreeqcinwt/tests/test_solution_build.py::TestBuildSolution -q

Results:

  • Focused alkalinity tests: 2 passed
  • TestBuildSolution: 20 passed

Behavior Summary

Case A: direct Alkalinity

  • Writes Alkalinity
  • Does not write C(4) or C(+4)
  • No crash

Case B: CaHCO3

  • Existing coupled behavior remains

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.

1 participant