feat: Add additional constraint options for enforceEquilibrium - #25
Open
frankfeifan wants to merge 42 commits into
Open
frankfeifan wants to merge 42 commits into
frankfeifan wants to merge 42 commits into
Conversation
…tro and refactored secondary species calculation
…computes the reaction rate to be textbook consistent
…pts for reference solutions of the bdot
…, added a flag to run ideal solution as the initial guess to improve convergence
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
This PR adds more constraint options for each primary species in the
enforceEquilibriumsolve in addition to the originalAggregateConcentrationoption. Available constraint options includeAggregateConcentration,pX, andChargeBalance.Species changes are:
Introduced a
PrimarySpeciesConstraintTypeenum (AggregateConcentration,pX,ChargeBalance, and a placeholderMineralEquilibrium) so each row of the equilibrium solve can be closed by a different constraint.Generalized
enforceEquilibrium_AggregateintoenforceEquilibrium_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 withpXconstraint type enforcesln(a_i) + pX·ln(10) = 0, while the row withChargeBalancetype 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.3oreference run, and a charge-balance-on-Cl⁻ case that recovers the analytically implied Cl⁻ aggregate.