AMReX-Astro / AMReX-Astro/Microphysics
Approximate arctangent introduces jumps in screening free energies
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 43
- Forks
- 46
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Summary
chabrier1998 and chugunov2009 use fast_atan in their free energies.
Its two polynomial branches do not meet at abs(x) = 0.378. This makes
the free energies discontinuous at Gamma = 0.378^2, and can introduce
finite jumps in reaction screening as temperature or density varies.
Suggested priority: medium. The jump is small in the enhancement factor,
but it violates the smoothness needed by derivative-based solvers.
No full reaction integration failure was reproduced in this review.
Affected code
screening/screen.H:461:chugunov2009_f0usesfast_atan.screening/screen.H:553:chabrier1998_helmholtz_Fusesfast_atan.util/approx_math/approx_math.H:57-63: unmatched polynomial branches.
Reviewed commit: e4b401b7637894a3db5ffa1e4b401509a332a1d6.
Related approximation changes: PR #1583 and PR #1611 (24fc8547).
Reproduction
Run the harness described in README.md. It calls the production headers
with double precision, CPU execution, and Debye-Huckel skipping disabled.
It also evaluates fast_atan immediately on either side of 0.378.
For pure hydrogen at rho = 100 g/cm^3, with a proton-proton screening
pair, choose T0 = 23459845.13964622 K. This puts the compound-nucleus
coupling parameter at 0.378^2 in the Chabrier free energy.
The resulting actual_log_screen values are:
T = T0 * (1 - 1.e-9): h = 0.01856207303271599
T = T0 * (1 + 1.e-9): h = 0.01871818296030522
A relative temperature change of only 2.e-9 causes a jump in h of
approximately 1.5611e-4, or about 0.84% of h. The multiplicative
enhancement exp(h) jumps by approximately 0.0156%.
The same polynomial defect affects chugunov2009_f0; its reaction-level
transition occurs at a different temperature because that method passes
Gamma / t_12 to the free-energy function. The Chabrier transition
temperature above is not a Chugunov transition temperature.
Proposed fix
Use admath::atan in both screening free-energy functions. It provides a
smooth value and a consistent automatic derivative. This also addresses
the separate derivative issue in 03-screening-temperature-derivative.md.
If the approximation is needed for performance, replace it with a fit
whose values and first derivatives match at every branch boundary,
including the reciprocal transformations. Benchmark the replacement and
measure errors in the complete screening expression, where cancellation
can amplify approximation errors.
Validation
Probe both free-energy functions on both sides of every approximation
boundary. Verify the value difference tends to zero with the probe
spacing. Repeat at the reaction level with skipping disabled and compare
with an atan reference across weak and strong coupling.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with util/approx_math/approx_math.H:57-63 and the callers at screening/screen.H:461 and screening/screen.H:553. Run the README.md harness, probe both sides of every approximation boundary, and compare the reaction-level results with an atan reference across weak and strong coupling. Done means the free-energy values and derivatives are continuous and the reported screening transition no longer jumps.
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
- 66/100