AMReX-Astro / AMReX-Astro/Microphysics

NSE EOS Jacobians use cubic derivatives when linear interpolation is selected

Open
#2,074 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Reviewed commit: 3ac0bda4f00da3eed0446beadfc1cd5c51b99a40

Suggested priority: Medium

Affected code: nse_tabular/nse_table.H:429-440, nse_tabular/nse_table.H:496-539, nse_tabular/nse_table.H:549-592; callers in nse_tabular/nse_eos.H.

Description

nse_interp() honors network.nse_table_interp_linear, but nse_interp_dT() and nse_interp_drho() always differentiate the cubic interpolant. The EOS inversion routines therefore use derivatives of a different composition function from the one used to evaluate their residuals.

Reproduction

Set linear interpolation and use T=5.18e9 K, rho=1.23e9 g/cm^3, Ye=0.472. Compare the returned abar derivatives to centered finite differences of nse_interp() with relative perturbation 1e-5:

Derivative Reported Finite difference
dabar/dT -1.072562604210832e-9 -1.097834698172967e-9
dabar/drho 3.987522835638749e-10 4.095838820409504e-10

The discrepancies are approximately 2.3% and 2.6%. With cubic interpolation selected, the same check agrees closely.

Expected behavior / suggested fix

Differentiate the selected interpolant, or explicitly select matching value/derivative routines within the inversions. Add finite-difference checks in both modes, away from cell boundaries.

Impact and validation: An inconsistent Newton Jacobian can impair convergence. The derivative mismatch is reproduced; a linear-mode inversion failure is not claimed. See reproduction-output.txt

reproduction-output.txt

.

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 in nse_tabular/nse_table.H at the affected ranges 429-440, 496-539, and 549-592, then trace the callers in nse_tabular/nse_eos.H. Reproduce the reported derivatives at the supplied T, rho, and Ye with linear interpolation, and verify finite-difference checks in both linear and cubic modes away from cell boundaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.