AMReX-Astro / AMReX-Astro/Microphysics

NSE derivatives remain nonzero outside the clamped table domain

Open
#2,075 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

reproduce.cpp
reproduction-output.txt

Reviewed commit: 3ac0bda4f00da3eed0446beadfc1cd5c51b99a40

Suggested priority: Medium

Affected code: nse_tabular/nse_table.H:402-418, nse_tabular/nse_table.H:496-539, nse_tabular/nse_table.H:549-592.

Description

nse_interp() clamps temperature and density to the table bounds. Outside a bound, the returned composition is constant with respect to that coordinate. The derivative routines also clamp their interpolation coordinates, but return the boundary polynomial slope divided by the original temperature or density instead of zero. This creates an inconsistent EOS Jacobian even with default cubic interpolation.

Reproduction

Using the shipped table, cubic interpolation, and Ye=0.472:

State Reported derivative Centered finite difference
T=3e10, rho=1.23e9 dabar/dT=-1.456288624132152e-13 0
T=5.18e9, rho=2e10 dabar/drho=1.942508832455048e-11 0

Both finite-difference samples remain outside the relevant bound. Temperature and density units are K and g/cm³.

Expected behavior / suggested fix

Return zero for differentiation along a strictly out-of-range coordinate when values use constant extension. Specify the derivative
convention exactly on the boundary. Alternatively, reject out-of-domain evaluations consistently across value and derivative APIs.

Impact and validation: Newton iterations can visit outside the table, where these artificial composition slopes affect their co
rrections. The derivative mismatch is reproduced in output; no convergence failure is attributed specifically to this defect.

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 nse_tabular/nse_table.H at the listed ranges around nse_interp() and the temperature and density derivative routines. Run reproduce.cpp with the shipped table and compare the reported derivatives with reproduction-output.txt and the centered finite differences. Done means out-of-range derivatives match the constant extension and boundary behavior is specified and validated.

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
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.