AMReX-Astro / AMReX-Astro/Microphysics

The default energy inversion does not report iteration exhaustion

Open
#2,071 1 comment 0 reactions 1 assignee View on GitHub

@zhichen3 is already working on this.

Since Sep 7, 2026.

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

Description

Suggested priority: Medium
Reviewed commit: 3ac0bda4f00da3eed0446beadfc1cd5c51b99a40

Affected code: nse_solver.H:449–452, nse_solver.H:507–516, nse_solver.H:539–561.

nse_T_from_e() stops after 100 iterations but returns void without checking converged after the loop. In the default nse.solve_nse_e_mode = 1, its caller proceeds to compute the NSE composition at the last temperature and returns it. It copies the requested energy into the result without verifying that the EOS energy at the returned temperature and composition matches it.

Impact: If the outer temperature solve exhausts its iterations while the inner composition solves succeed, the interface returns an unconverged thermodynamic state without an error indication.

Validation limit: Confirmed by control-flow inspection; the standard input converged, and no physical input reaching this exhaustion path was reproduced.

Suggested fix: Propagate a convergence status or raise the established solver error on exhaustion. Validate the final energy residual and add an exhaustion-path regression test.

Validation and regression coverage

This finding is based on inspection of the iteration limit, loop exit, and caller behavior at the reviewed commit. No executable reproduction of iteration exhaustion is claimed.

The existing unit_test/nse_net_cell test was built with ccache disabled and run with inputs_ase. It completed successfully and recovered the requested perturbed energy in both energy modes; it does not exercise this failure path. See captured cell-test output.

Validation used GNU C++20, double precision, CPU, no MPI/OpenMP, simplified SDC, the ase network, Helmholtz EOS, and Chabrier screening. AMReX revision: 3c3bbaa34cd3.

A regression test should force the outer temperature iteration to exhaust its budget while allowing the inner composition solves to succeed, then verify that the caller receives failure instead of a thermodynamic state reported as solved.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.