Skip to content

feat: Add additional constraint options for enforceEquilibrium - #25

Open
frankfeifan wants to merge 42 commits into
mainfrom
feat/frankfei/EQEnforceConstraints
Open

frankfeifan wants to merge 42 commits into
mainfrom
feat/frankfei/EQEnforceConstraints

Conversation

@frankfeifan

Copy link
Copy Markdown
Collaborator

This PR adds more constraint options for each primary species in the enforceEquilibrium solve in addition to the original AggregateConcentration option. Available constraint options include AggregateConcentration, pX, and ChargeBalance.

Species changes are:

  • Introduced a PrimarySpeciesConstraintType enum (AggregateConcentration, pX, ChargeBalance, and a placeholder MineralEquilibrium) so each row of the equilibrium solve can be closed by a different constraint.

  • Generalized enforceEquilibrium_Aggregate into enforceEquilibrium_PrimaryConcentrations, which takes a per-species constraint type and value array and now also returns the converged aggregate (total) concentrations.

  • Implemented the new residual/Jacobian rows in computeResidualAndJacobianPrimaryConcentrations — a row with pX constraint type enforces ln(a_i) + pX·ln(10) = 0, while the row with ChargeBalance type ensures charge electroneutrality over the mobile aggregate concentrations.

  • Added EQ3NR-verified tests for the new constraints: a pH-constrained carbonate case that recovers the withheld total H⁺ (3.76e-1) from the same carbonate.3o reference run, and a charge-balance-on-Cl⁻ case that recovers the analytically implied Cl⁻ aggregate.

rrsettgast and others added 30 commits November 26, 2025 17:17
…tro and refactored secondary species calculation
…computes the reaction rate to be textbook consistent
@frankfeifan frankfeifan self-assigned this Sep 15, 2026
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.87995% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.92%. Comparing base (7423e3e) to head (be4f3b8).

Files with missing lines Patch % Lines
...EquilibriumReactionsPrimaryConcentrations_impl.hpp 98.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main      #25      +/-   ##
===========================================
- Coverage   100.00%   99.92%   -0.08%     
===========================================
  Files           25       35      +10     
  Lines          830     1387     +557     
===========================================
+ Hits           830     1386     +556     
- Misses           0        1       +1     

☔ View full report in Codecov by Harness.
📢 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.

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.

2 participants