Skip to content

Pulsed Height Tally in mixed neutron-gamma fields#3937

Open
kosbor-personal wants to merge 1 commit into
openmc-dev:developfrom
kosbor-personal:fix-pht-neutron-photons
Open

Pulsed Height Tally in mixed neutron-gamma fields#3937
kosbor-personal wants to merge 1 commit into
openmc-dev:developfrom
kosbor-personal:fix-pht-neutron-photons

Conversation

@kosbor-personal
Copy link
Copy Markdown

@kosbor-personal kosbor-personal commented May 12, 2026

Intro

Hi everyone!

Long time listener, first time caller. This is my first Pull Request, so I would appreciate any feedback on how I can improve this contribution and also potential future ones.

All the best,
Bor Kos

Problem Description

We’ve been working on verifying and validating OpenMC for well-logging applications. In this pull request, I wanted to address an issue we encountered when we started analysing so‑called pulsed‑neutron applications, where we are interested in gamma spectra from capture reactions from 14 MeV neutrons thermalized within a rock formation.

Long story short, these have been our observations regarding pulse height tallies (PHT) in gamma-only and coupled neutron–gamma fields:

  • Correct behaviour for gamma‑only PHT cases (i.e. perfect match with MCNP and experimental results)
  • Excellent agreement between OpenMC and MCNP for gamma spectra in coupled neutron–gamma simulations
  • Significant deviations in pulse height tallies for coupled neutron–gamma simulations

This issue was shared on the forum:
https://openmc.discourse.group/t/pulse-height-tally-in-mixed-neutron-gamma-fields/6229

This led me to believe that there is an issue in how neutron‑generated photons are treated within the pulse height accounting logic.

Looking at the code, I believe photons produced by neutrons were incorrectly having their energy subtracted from pht_storage, leading to systematic undercounting in PHT results.

In pht_secondary_particles(), OpenMC subtracts energy from pht_storage for all secondary photons, assuming their parent’s energy had previously been added to the PHT. This assumption is valid for photon/electron/positron parents but invalid for neutron reactions, because:

  • Neutron energy is never added to pht_storage
  • Neutron‑generated photons therefore had energy subtracted without ever being added

This results in a net loss of recorded pulse height.

Fix

The fix ensures that energy is only subtracted for secondary particles whose parent particle is either a photon, electron, or positron. This is achieved by tracking the parent particle type for each secondary particle and only applying the energy subtraction when the parent is a photon/electron/positron.

Code Changes

  1. include/openmc/particle_data.h

    • Added parent_particle to SourceSite
    • Added corresponding member variable and accessors to ParticleData
  2. src/particle.cpp

    • Set parent_particle in create_secondary()
    • Propagate via from_source()
    • Apply whitelist logic in pht_secondary_particles()
  3. openmc/lib/core.py

    • Added parent_particle to the Python _SourceSite ctypes structure

Testing / Validation

  • Pytest suite

    • Failed tests matched failures in unmodified openmc-dev.
    • Suspected cause is compiler settings.
    • None of the failed tests are related to pulse height tallies.
  • Gamma‑only PHT

    • Results remain unchanged.
    • Plots attached for two different sources:
      • Potassium (left)
      • Thorium (right)
image
  • Coupled neutron–gamma simulations
    • Pulsed‑neutron tools tested in two environments:
      • Dolomite
      • Brine
    • Results match MCNP.
    • Lesser effect observed in brine, most likely due to high chlorine absorption.
image

In coupled neutron–photon simulations, photons produced by neutron reactions
incorrectly subtracted energy from pulse-height storage. Track the parent
particle type for secondary particles and restrict PHT energy subtraction
to photons, electrons and positrons only.

This restores correct PHT behavior in mixed n–γ fields while preserving
gamma-only results.
@kosbor-personal kosbor-personal marked this pull request as ready for review May 12, 2026 14:11
Comment thread src/particle.cpp
bank.u = u;
bank.E = settings::run_CE ? E : g();
bank.time = time();
bank_second_E() += bank.E;
Copy link
Copy Markdown
Contributor

@GuySten GuySten May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can add a guard in this line (skip it for neutrons) instead of adding another bank attribute.
This should significantly simplify this PR.

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.

2 participants