AMReX-Astro / AMReX-Astro/Castro

SDC2 conducts heat when diffuse_temp is disabled

Open
#3,392 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

Location: Source/hydro/Castro_mol_hydro.cpp:547-559.

Finding

The second-order MOL branch calls fill_temp_cond and mol_diffusive_flux
whenever DIFFUSION is compiled in. Unlike both fourth-order diffusion calls, it
does not test the runtime flag castro.diffuse_temp.

A diffusion-capable executable therefore conducts heat with diffuse_temp=0
when using SDC2. The runtime-disabled case can also lose its diffusion timestep
restriction while retaining the explicit diffusive update.

Evidence

The call is guarded only by #ifdef DIFFUSION.
Source/diffusion/diffusion_util.cpp:13-63 computes conductivity without
checking diffuse_temp, and Source/hydro/Castro_mol.cpp:317-350 adds the
resulting energy flux without checking it either. The fourth-order branch
explicitly tests diffuse_temp == 1.

A fresh 1-D debug executable also reproduced the ignored switch. With hydro
enabled to avoid report 02 and a fixed dt=1e-8, diffuse_temp=0 and
diffuse_temp=1 gave identical final printed diagnostics. Maximum temperature was
1.940592276 in both runs. Keeping diffuse_temp=0 but setting
diffuse_cond_scale_fac=0 changed that maximum to 1.940595995. README.md records
the inputs and commands.

Proposed fix

Wrap conductivity evaluation and mol_diffusive_flux in if (diffuse_temp).
Keep this independent of do_hydro, so diffusion-only runs remain supported.
The out-of-bounds zeroing in report 02 must also be fixed for that case.

Validation after fixing

Use the diffusion problem with a nonuniform temperature and zero velocity. With
hydro disabled, diffuse_temp=0 must leave energy unchanged, while
diffuse_temp=1 must diffuse. Test SDC2 and SDC4 using the same executable and
a small fixed timestep.

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 at Source/hydro/Castro_mol_hydro.cpp:547-559 and compare the SDC2 path with the fourth-order diffusion calls. Read Source/diffusion/diffusion_util.cpp:13-63, Source/hydro/Castro_mol.cpp:317-350, and the README.md inputs and commands. Validate the diffusion problem with SDC2 and SDC4: diffuse_temp=0 must leave energy unchanged, while diffuse_temp=1 must diffuse, including hydro-disabled runs and report 02.

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
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.