Skip to content

Return discrete lines exactly in lin-lin tabular energy sampling - #4069

Open
dallonby wants to merge 1 commit into
openmc-dev:developfrom
dallonby:fix-discrete-line-linlin
Open

Return discrete lines exactly in lin-lin tabular energy sampling#4069
dallonby wants to merge 1 commit into
openmc-dev:developfrom
dallonby:fix-discrete-line-linlin

Conversation

@dallonby

Copy link
Copy Markdown

Description

Fixes #4068.

ContinuousTabular, KalbachMann, and CorrelatedAngleEnergy guard their histogram interpolation branch with k >= n_discrete (a sampled discrete line is returned at exactly its tabulated energy), but not the lin-lin branch — a discrete hit leaves the CDF walk with r1 < c_k, so the lin-lin inversion runs with a negative (r1 - c_k) and shifts the sampled energy below the line.

This PR mirrors the histogram guard in all three samplers. For Kalbach-Mann, the discrete branch takes r[k]/a[k] directly — identical to what the parameter interpolation reduces to at E_out = E_l_k, so no behavior change beyond the energy fix.

Impact (measured against the official ENDF/B-VIII.0 HDF5 library; details in #4068): the discrete-lines-with-lin-lin combination appears in 19,913 secondary-photon tables (discrete gammas of (n,2n)/(n,3n)/(n,n′)-continuum reactions across ~half the nuclides) and in zero neutron-product tables — so coupled neutron–photon runs currently sample smeared gamma lines, while neutron-only results are unaffected by this change.

Found while porting the transport engine to Apple Silicon GPUs (dallonby/openmc-metal).

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (not applicable)
  • I have made corresponding changes to the documentation (not applicable — behavior now matches the documented tabular sampling)
  • I have added tests that prove my fix is effective (none added — happy to add a unit test sampling a synthetic discrete+lin-lin table on request)

🤖 Generated with Claude Code

ContinuousTabular, KalbachMann, and CorrelatedAngleEnergy all guard the
histogram interpolation branch with k >= n_discrete, returning a sampled
discrete line's energy exactly — but none of them guard the lin-lin
branch. A discrete hit leaves the walk with r1 < c_k, so the lin-lin
inversion runs with a negative (r1 - c_k) and shifts the sampled energy
below the line (bounded by the max(0, ...) clamp at E_l_k - p_l_k/frac).

In ENDF/B-VIII.0 the discrete-lines-with-lin-lin combination appears in
19,913 incident-energy tables — all secondary-photon distributions
(discrete gammas from (n,2n), (n,3n), (n,n') continuum and similar), so
coupled neutron-photon transport samples smeared gamma lines. No
neutron-product table in the library uses the combination, so
neutron-only results are unaffected.

The fix mirrors the existing histogram guard in all three samplers; for
Kalbach-Mann the r/a parameters use the line's tabulated values, which
is what the interpolation reduces to at E_out = E_l_k.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dallonby added a commit to dallonby/openmc that referenced this pull request Aug 21, 2026
CHI_DELAYED -> PR openmc-dev#4067; discrete-line lin-lin sampling (with the
ENDF/B-VIII.0 photon-table census) -> issue openmc-dev#4068 + PR openmc-dev#4069;
MG density_mult tally asymmetry -> issue openmc-dev#4070.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discrete lines in lin-lin tabular energy distributions are sampled off-line (affects secondary-photon spectra)

1 participant