Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/tallies/tally_scoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2752,6 +2752,10 @@ void score_pulse_height_tally(Particle& p, const vector<int>& tallies)
// Temporarily change energy of particle to pulse-height value
p.E_last() = p.pht_storage()[index];

// Skip pulses with zero energy
if (p.E_last() == 0.0)
continue;

// Initialize an iterator over valid filter bin combinations. If
// there are no valid combinations, use a continue statement to ensure
// we skip the assume_separate break below.
Expand Down
4 changes: 2 additions & 2 deletions tests/regression_tests/pulse_height/results_true.dat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tally 1:
4.140000E+00
3.443000E+00
3.000000E-02
3.000000E-04
1.000000E-02
1.000000E-04
1.000000E-02
Expand Down
24 changes: 24 additions & 0 deletions tests/unit_tests/test_pulse_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import openmc


def test_zero_energy_pulse_heights(run_in_tmpdir):
surf = openmc.Sphere(r=10.0, boundary_type='vacuum')
cell = openmc.Cell(region=-surf)
model = openmc.Model()
model.geometry = openmc.Geometry([cell])
model.settings.run_mode = 'fixed source'
model.settings.source = openmc.IndependentSource(
space=openmc.stats.Point(),
energy=openmc.stats.Discrete([5.0e6], [1.0]),
particle='photon',
)
model.settings.particles = 100
model.settings.batches = 1
model.settings.electron_treatment = 'led'

tally = openmc.Tally()
tally.scores = ['pulse-height']
model.tallies = openmc.Tallies([tally])
model.run(apply_tally_results=True)

assert (tally.mean == 0.0).all(), "Zero energy pulses should not be counted"
Loading