diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index 5dcd07331d6..5aea2dbfc78 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -2752,6 +2752,10 @@ void score_pulse_height_tally(Particle& p, const vector& 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. diff --git a/tests/regression_tests/pulse_height/results_true.dat b/tests/regression_tests/pulse_height/results_true.dat index c57e8ff1c83..ec8e2032a13 100644 --- a/tests/regression_tests/pulse_height/results_true.dat +++ b/tests/regression_tests/pulse_height/results_true.dat @@ -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 diff --git a/tests/unit_tests/test_pulse_height.py b/tests/unit_tests/test_pulse_height.py new file mode 100644 index 00000000000..1206458c9b2 --- /dev/null +++ b/tests/unit_tests/test_pulse_height.py @@ -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"