AMReX-Astro / AMReX-Astro/Microphysics
RHS Jacobian filter includes intermediate reactions
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 43
- Forks
- 46
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Jacobian sparsity filter in networks/rhs.H does not exclude intermediate reactions as intended
Summary
RHS::is_jacobian_term_used() attempts to exclude intermediate reactions (those with any __extra__ species index > NumSpec) when deciding if a Jacobian entry is needed. The implementation uses || across <= NumSpec tests, which is almost always true, so intermediate reactions are not filtered out.
Severity
Medium (primarily correctness-of-pruning/performance; can increase unnecessary Jacobian work and obscure intended sparsity behavior)
Affected Code
networks/rhs.H- around lines 235-240 and 256-260
Why This Is a Bug
The comments state that reactions with extra species should be excluded. That requires all participating species IDs to be within NumSpec (&& logic). The current || logic admits any reaction with at least one in-network species, including intermediate reactions.
Proposed Patch
--- a/networks/rhs.H
+++ b/networks/rhs.H
@@
- if (data.species_A <= NumSpec ||
- data.species_B <= NumSpec ||
- data.species_C <= NumSpec ||
- data.species_D <= NumSpec ||
- data.species_E <= NumSpec ||
- data.species_F <= NumSpec) {
+ if (data.species_A <= NumSpec &&
+ data.species_B <= NumSpec &&
+ data.species_C <= NumSpec &&
+ data.species_D <= NumSpec &&
+ data.species_E <= NumSpec &&
+ data.species_F <= NumSpec) {
is_spec_1_used = 1;
}
@@
- if (data.species_A <= NumSpec ||
- data.species_B <= NumSpec ||
- data.species_C <= NumSpec ||
- data.species_D <= NumSpec ||
- data.species_E <= NumSpec ||
- data.species_F <= NumSpec) {
+ if (data.species_A <= NumSpec &&
+ data.species_B <= NumSpec &&
+ data.species_C <= NumSpec &&
+ data.species_D <= NumSpec &&
+ data.species_E <= NumSpec &&
+ data.species_F <= NumSpec) {
is_spec_2_used = 1;
}
Validation
- Compare Jacobian nonzero pattern before/after for a network with intermediate reactions.
- Confirm species evolution and energy RHS/Jacobian numerics are unchanged (only pruning logic should change).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in networks/rhs.H at RHS::is_jacobian_term_used(), focusing on the two species-use checks around lines 235-240 and 256-260. Review the existing comments and compare the Jacobian nonzero pattern before and after on a network with intermediate reactions; done means intermediate reactions are excluded while species evolution, energy RHS, and Jacobian numerics remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100