Pulsed Height Tally in mixed neutron-gamma fields#3937
Open
kosbor-personal wants to merge 1 commit into
Open
Conversation
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.
GuySten
reviewed
May 12, 2026
| bank.u = u; | ||
| bank.E = settings::run_CE ? E : g(); | ||
| bank.time = time(); | ||
| bank_second_E() += bank.E; |
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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 frompht_storagefor 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:pht_storageThis 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
include/openmc/particle_data.hparent_particletoSourceSiteParticleDatasrc/particle.cppparent_particleincreate_secondary()from_source()pht_secondary_particles()openmc/lib/core.pyparent_particleto the Python_SourceSitectypes structureTesting / Validation
Pytest suite
openmc-dev.Gamma‑only PHT