Reject chemistry with num_fluids > 1 in case validator#1472
Merged
Conversation
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a case-validator guard to reject unsupported chemistry configurations with more than one fluid, preventing known NaN-producing multi-fluid chemistry runs from reaching the Fortran simulation path.
Changes:
- Reads
num_fluidsinCaseValidator.check_chemistry. - Prohibits
chemistry = Twhennum_fluidsis set to a value other than1. - Adds an explanatory comment tying the guard to the single-reacting-gas chemistry assumption.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1472 +/- ##
=======================================
Coverage 61.31% 61.31%
=======================================
Files 72 72
Lines 19771 19771
Branches 2852 2852
=======================================
Hits 12123 12123
Misses 5699 5699
Partials 1949 1949 ☔ View full report in Codecov by Sentry. 🚀 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.
Description
Closes #1470.
Chemistry in MFC assumes a single reacting gas phase and is not coupled to the multi-fluid (5-equation) model. When
chemistry = Tis combined withnum_fluids > 1, the simulation silently producesNaNrather than erroring out. Two paths insrc/common/m_variables_conversion.fppare responsible:s_convert_conservative_to_primitive_variablesoverwrites all partial densities (qK_prim_vf(1:num_fluids)) with the species-summed total density — correct fornum_fluids = 1, destructive otherwise.s_compute_pressurerecovers temperature from the total internal energy via Cantera's ideal-gas EOS, ignoringpi_inf. With a second stiffened-gas fluid present (e.g. a water droplet,pi_inf ~ 4e8), the inversion diverges andNaNpropagates.Full multi-fluid + chemistry coupling is a larger, research-level effort. This PR is the short-term fix: a case-validator guard that rejects the unsupported combination with a clear message instead of leaving users to debug
NaNs. Bothchemistryandnum_fluidsare known at case-definition time, so the guard lives in Python (case_validator.py); no Fortran-side check is needed.Type of change
Scope
prohibittoCaseValidator.check_chemistry, mirroring the existingmhd and num_fluids != 1guard.How Has This Been Tested?
Validator unit-checked directly:
chemistry='T', num_fluids=2-> rejected with "chemistry is only supported for single-component flows (num_fluids = 1)"chemistry='T', num_fluids=1-> passes (no regression for existing chemistry examples, all of which usenum_fluids = 1)num_fluids=2without chemistry -> passes (unaffected)chemistry='T'withnum_fluidsunset -> passes (deferred to existing model_eqns/num_fluids check)ruff checkandruff format --checkpass on the changed file.Checklist
rufflint/format pass