AMReX-Astro / AMReX-Astro/Castro

True SDC ignores castro.do_react

Open
#3,391 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-code-audit sdc
Dominant language
C++
Stars
340
Forks
105
Avg merge
3d 8h
Merged PRs (30d)
8

Description

Locations: Source/sdc/sdc_react_util.H:11-45,
Source/sdc/Castro_sdc_util.H:134-236, and
Source/driver/Castro_advance_sdc.cpp:182-198,241-249.

Finding

In a build with REACTIONS, true SDC always constructs reactive sources and
invokes its reaction update. Both overloads of okay_to_burn check temperature,
density, and shock suppression, but neither checks castro.do_react. There is
no reference to do_react anywhere in Source/sdc or the true-SDC advance
driver.

Consequently, setting castro.do_react=0 does not disable burning. This changes
the physics of a supposedly nonreacting control run. The timestep estimator does
honor do_react, so nuclear timestep restrictions can also be disabled while
burning remains active.

Evidence

Static call-path verification: sdc_update_o2 and sdc_update_centers_o4 reach
sdc_solve through okay_to_burn; instantaneous_react uses the same gate.
single_zone_react_source then calls actual_rhs unconditionally. Compare the
explicit guard in Source/reactions/Castro_react.cpp:152 and the timestep guard
in Source/driver/Castro.cpp:1712.

No fresh reacting simulation was run for this finding.

Proposed fix

Add an early if (!castro::do_react) { return false; } to both okay_to_burn
overloads, preferably via a shared helper. This disables both implicit burning
and stored instantaneous rates while preserving advection and the correction
sweeps. Do not bypass the complete SDC update, since it also evolves nonreactive
terms.

Validation after fixing

Use a uniform hot periodic state in reacting_convergence. For both SDC orders,
run once with do_react=0 and once with do_react=1. With no advection or
other sources, the disabled run must preserve species and energy and report zero
reaction rates. The enabled run must burn. Repeat with each solver option.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the two okay_to_burn overloads in Source/sdc/sdc_react_util.H and trace their callers in Source/sdc/Castro_sdc_util.H and Source/driver/Castro_advance_sdc.cpp. Compare the do_react guards in Source/reactions/Castro_react.cpp and Source/driver/Castro.cpp. Validate both SDC orders and solver options in reacting_convergence with do_react=0 and 1; the disabled run should preserve species and energy with zero reaction rates, while the enabled run burns.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.