Repository navigation
Reject chem_params%diffusion without chemistry - #2108
Merged
sbryngelson merged 1 commit intoOct 25, 2026
Merged
sbryngelson merged 1 commit into
sbryngelson merged 1 commit into
Conversation
Motivation Diffusion without chemistry passes validation but accesses unallocated flux arrays on the first time step. Expectation Reject the unsupported combination before execution and match the allocation and deallocation guards. Change The diffusion flux arrays (flux_src_n(E) and the species slots) are allocated only when chemistry is on, but the Riemann-state zeroing and the s_compute_additional_physics_rhs loops test chem_params%diffusion alone. A non-reacting case with chem_params%diffusion = T passed validation and then segfaulted on the first time step. Prohibit the combination in check_chemistry, next to the other chemistry checks, and give the matching deallocation in s_finalize_rhs_module the chemistry guard its allocation has. Two validator unit tests cover the rejection and the accepted chemistry + diffusion case. Result Invalid non-reacting diffusion cases are rejected. Chemistry diffusion remains accepted. The precheck passes and regression reference files are unchanged. Fixes MFlowCode#1908 Co-authored-by: ruru25254649 <ruru.2525.4649@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WPhkY8p1EHhGY7jScizJmC
platelett
requested review from
danieljvickers
and removed request for
a team
October 25, 2026 09:56
|
Claude Code Review Head SHA: 26a3d39 Files changed:
Findings: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2108 +/- ##
=======================================
Coverage 61.95% 61.95%
=======================================
Files 86 86
Lines 22906 22906
Branches 3378 3378
=======================================
Hits 14192 14192
Misses 6206 6206
Partials 2508 2508 ☔ 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.
Fixes #1908.
A case that sets
chem_params%diffusion = 'T'withoutchemistry = 'T'passes./mfc.sh validate, then segfaults on the first time step. This PR rejects that case in the validator. It also adds thechemistryguard that #1908 asks for to the matching deallocation. No working case changes and no goldens move.Why it crashes
s_initialize_rhs_moduleallocates the arrays the diffusion path writes only underif (chemistry):flux_src_n;flux_src_n(E), when nothing else allocates it.Several sites test
chem_params%diffusionon its own, so they still run in a non-reacting case:m_riemann_state.fpp:if (chem_params%diffusion)zeroesflux_src_vf(E:species%end).m_rhs.fpp:s_compute_additional_physics_rhsruns onviscous .or. surface_tension .or. chem_params%diffusion .or. heat_conduction. Inside it, each direction'sif (chem_params%diffusion)block readsflux_src_n(E).For example,
examples/1D_sodshocktubewith that one line added:Change
check_chemistrygets one rule, next to the other chemistry checks:sigma is set but surface_tension is not enabled. Guarding the six-plus Fortran sites instead would spread one condition over several files.s_finalize_rhs_modulegets thechemistry .and.guard its allocation already has, as flux_src_n energy-slot deallocation lacks the chemistry guard its allocation has #1908 asks. With the new rule it is unreachable, but allocate and deallocate are now symmetric.toolchain/mfc/test_case_validator.py: one for the rejection, and one showing that diffusion with chemistry is still accepted.Side effects
chem_params%diffusion = 'T'and nochemistryis now rejected at validation. It used to crash on step 1.chem_params%diffusionalso setchemistry, so they still validate.Verification
chem_params%diffusion = 'T', master (GNU 13.4 + Open MPI, CPU)Case parameter constraint violations: 1. chem_params%diffusion requires chemistry = Tpytest toolchain/mfc/test_case_validator.py8E56ACC1,4587725Aand41AD0140(GNU 13.4 + Open MPI)./mfc.sh precheck, which validates every example caseContribution Policy
All contributions are expected to demonstrate:
If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.
Acknowledgement
This PR is from Diablo (Tsinghua University) participating in the SC26 Student Cluster Competition.