openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Issues using triggers with particle production scoes

Open Edgar-21 opened this issue 1 year ago • 1 comments

Bug Description

I am experiencing an issue while using triggers on particle production scores, (e.g. ‘He3-production’)

The error is as follows

ERROR: Could not find the score “He3-production” in tally 1 but it was listed in a trigger on that tally

He3-production is indeed the only score listed on that tally. These scores must be implemented differently than others, since if I omit passing a score to the trigger, the trigger then works but it looks at the ‘(n,X3He)’ score (which is equivalent) https://www.oecd-nea.org/dbdata/data/manual-endf/endf102_MT.pdf, so there is a work around.

Steps to Reproduce

Here is a quick example that reproduces the behavior

import openmc


# materials
Fe = openmc.Material()
Fe.set_density('g/cc', 10)
Fe.add_element('Fe', 1.0)

materials = openmc.Materials([Fe])

# geometry
inner_sphere = openmc.Sphere(r=10)
outer_sphere = openmc.Sphere(r=20, boundary_type='vacuum')

inner_region = -inner_sphere
outer_region = -outer_sphere &+inner_sphere

inner_cell = openmc.Cell(region=inner_region)
outer_cell = openmc.Cell(region=outer_region, fill = Fe)

geometry = openmc.Geometry([inner_cell, outer_cell])

# source
point_source = openmc.IndependentSource()
point_source.space = openmc.stats.Point((0,0,0))
point_source.angle = openmc.stats.Isotropic()
point_source.energy = openmc.stats.Discrete([14.1e6],[1])


# settings
settings = openmc.Settings()
settings.batches = 10
settings.particles = 100
settings.run_mode = 'fixed source'
settings.trigger_active = True
settings.trigger_batch_interval = 10
settings._trigger_max_batches = 30

settings.source = point_source

# tallies
outer_cell_filter = openmc.CellFilter(outer_cell)
he3_production_tally = openmc.Tally(name='he3 production tally')
he3_production_tally.filters = [outer_cell_filter]
he3_production_tally.scores = ['He3-production']
trigger = openmc.Trigger(trigger_type='rel_err', threshold=0.0001)
# this happens for He and H production scores, possibly other particle production scores as well
# other scores work as expected (e.g. flux)
trigger.scores = ['He3-production'] #commenting this out makes it run but changes the trigger to (n,X3He), which is equivalent
he3_production_tally.triggers = [trigger]

tallies = openmc.Tallies([he3_production_tally])

model = openmc.Model(materials=materials, geometry=geometry, settings=settings, tallies=tallies)

model.run()

Environment

0.14.0 installed via conda

Edgar-21 avatar Apr 25 '24 13:04 Edgar-21

Here is where it is aliased: https://github.com/openmc-dev/openmc/blob/develop/src/reaction.cpp#L357-L376

Here is where the trigger scores are parsed: https://github.com/openmc-dev/openmc/blob/develop/src/tallies/tally.cpp#L707-L728

Tally trigger scores don't seem to be making the call to reaction_type() and thus isn't able to equate it to "(n,X3He)". Fixing that would also catch invalid reaction names in tally trigger scores:

trigger.scores = ['Quadratiticalie-production']
---
Traceback (most recent call last):
  File "/ibmstor/scratch/labotrav/OpenTMP/production/he3bug.py", line 57, in <module>
    model.run(threads=3)
  File "/projects/openmc/compiled/0.14.0_sawtooth_gcc-12.3.0/python/openmc/model/model.py", line 711, in run
    openmc.run(particles, threads, geometry_debug, restart_file,
  File "/projects/openmc/compiled/0.14.0_sawtooth_gcc-12.3.0/python/openmc/executor.py", line 314, in run
    _run(args, output, cwd)
  File "/projects/openmc/compiled/0.14.0_sawtooth_gcc-12.3.0/python/openmc/executor.py", line 125, in _run
    raise RuntimeError(error_msg)
RuntimeError: Could not find the score "Quadratiticalie-production" in tally 1 but it was listed in a trigger on that tally application cal

tjlaboss avatar May 24 '24 15:05 tjlaboss

Revolved by #3155

pshriwise avatar Oct 02 '24 17:10 pshriwise