AMReX-Astro / AMReX-Astro/Microphysics

cj_detonation density grid mismatch and missing Finalize

Open
#1,944 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-code-audit
Dominant language
C++
Stars
43
Forks
46
Avg merge
2d 18h
Merged PRs (30d)
15

Description

cj_detonation uses inconsistent density-grid spacing and misses amrex::Finalize()

Summary

util/cj_detonation/main.cpp computes dlogrho using npts (100) but iterates over npts_ad (150), so sampled densities overshoot intended rho_max. The same function returns without calling amrex::Finalize().

Severity

High

Affected Code

  • util/cj_detonation/main.cpp
    • grid setup around lines 41-42 and 97
    • sampling loop around lines 134-137
    • process exit around line 159

Why This Is a Bug

  • Density spacing mismatch distorts Hugoniot/adiabat sampling and can produce out-of-range physical states.
  • Missing amrex::Finalize() is inconsistent with other AMReX drivers in this repo and can skip orderly runtime teardown.

Proposed Patch

  1. Compute dlogrho from the same point count used by the loop (npts_ad).
  2. Call amrex::Finalize() before returning from main().
--- a/util/cj_detonation/main.cpp
+++ b/util/cj_detonation/main.cpp
@@
-  Real dlogrho = (std::log10(rho_max) - std::log10(rho_min)) / static_cast<Real>(npts-1);
+  Real dlogrho = (std::log10(rho_max) - std::log10(rho_min)) / static_cast<Real>(npts_ad-1);
@@
-  return 0;
+  amrex::Finalize();
+  return 0;

Validation

  • Verify first/last sampled rho in output match rho_min and rho_max (within floating-point tolerance).
  • Run executable and confirm normal completion with AMReX teardown behavior consistent with other tools.

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 util/cj_detonation/main.cpp, reading the grid setup around lines 41-42 and 97, the sampling loop around lines 134-137, and process exit near line 159. Check that the density spacing uses the loop's point count and that the program finalizes AMReX before returning. Validate the first and last sampled densities against rho_min and rho_max, then run the executable to confirm normal completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.