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.
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()assumesu(i,j,k,URHO)is valid and positive. It clamps eachrho X_kagainstsmall_x * rhoand then rescales byrho / sum(rho X_k).That is unsafe immediately after
make_cell_center(...), because Castro already recognizes elsewhere that the average-to-center conversion can makerho < 0near steep gradients. The maincomputeTemp()path explicitly enforces minimum density after the same conversion before continuing thermodynamics work, but the SDC path does not.Why this matters
rho_xn_sumcan lead to large rescaling or NaNs.okay_to_burn()gets a chance to reject the zone, so the state can already be corrupted.Likely impact
Suggested fix
Before calling
normalize_species_sdc()on a centered state, enforce a positive density first, or fold a density floor intonormalize_species_sdc()itself.At minimum, the following two paths should be protected:
make_cell_center(...)onSborderconstruct_old_react_source()whensdc_order == 4 && input_is_averagePossible acceptance criteria