Skip to content

True SDC O4 normalizes species before enforcing positive cell-centered density #3385

Description

@zingale

Summary

In the 4th-order true SDC path, Castro converts cell averages to cell centers and immediately normalizes species on the centered state before enforcing a positive density. Near sharp gradients, the average-to-center conversion can produce negative or very small centered densities, so the species normalization step can generate invalid partial densities or NaNs before the later burn guards run.

Affected code

Problem

normalize_species_sdc() assumes u(i,j,k,URHO) is valid and positive. It clamps each rho X_k against small_x * rho and then rescales by rho / sum(rho X_k).

That is unsafe immediately after make_cell_center(...), because Castro already recognizes elsewhere that the average-to-center conversion can make rho < 0 near steep gradients. The main computeTemp() path explicitly enforces minimum density after the same conversion before continuing thermodynamics work, but the SDC path does not.

Why this matters

  • Negative centered density can make the clamp bounds nonsensical.
  • Very small or negative rho_xn_sum can lead to large rescaling or NaNs.
  • This happens before okay_to_burn() gets a chance to reject the zone, so the state can already be corrupted.

Likely impact

  • Corrupted species in the O4 true SDC reaction update.
  • Spurious failures or NaNs in difficult zones near discontinuities.
  • Potentially non-reproducible behavior because this depends on local reconstructed centered states.

Suggested fix

Before calling normalize_species_sdc() on a centered state, enforce a positive density first, or fold a density floor into normalize_species_sdc() itself.

At minimum, the following two paths should be protected:

  • The O4 update path after make_cell_center(...) on Sborder
  • construct_old_react_source() when sdc_order == 4 && input_is_average

Possible acceptance criteria

  • Add a regression test or problem setup with a steep interface that exercises the O4 true SDC path.
  • Verify no NaNs appear in the centered state after normalization.
  • Verify species remain bounded and sum to density after the fix.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions