Skip to content

Approximate arctangent introduces jumps in screening free energies #2095

Description

@zingale

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_f0 uses fast_atan.
  • screening/screen.H:553: chabrier1998_helmholtz_F uses fast_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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions