Skip to content

Commit

Permalink
Fix check for trigger score name
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Oct 2, 2024
1 parent 1645e3b commit 496d32c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tallies/tally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void Tally::init_triggers(pugi::xml_node node)
} else {
int i_score = 0;
for (; i_score < this->scores_.size(); ++i_score) {
if (reaction_name(this->scores_[i_score]) == score_str)
if (this->scores_[i_score] == reaction_type(score_str))
break;
}
if (i_score == this->scores_.size()) {
Expand Down
31 changes: 31 additions & 0 deletions tests/unit_tests/test_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,34 @@ def test_tally_trigger_zero_ignored(run_in_tmpdir):
total_batches = sp.n_realizations + sp.n_inactive
assert total_batches < pincell.settings.trigger_max_batches



def test_trigger_he3_production(run_in_tmpdir):
li6 = openmc.Material()
li6.set_density('g/cm3', 1.0)
li6.add_nuclide('Li6', 1.0)

sph = openmc.Sphere(r=20, boundary_type='vacuum')
outer_cell = openmc.Cell(fill=li6, region=-sph)
model = openmc.Model()
model.geometry = openmc.Geometry([outer_cell])
model.settings.source = openmc.IndependentSource(
energy=openmc.stats.delta_function(14.1e6)
)
model.settings.batches = 10
model.settings.particles = 100
model.settings.run_mode = 'fixed source'
model.settings.trigger_active = True
model.settings.trigger_batch_interval = 10
model.settings.trigger_max_batches = 30

# Define tally with trigger
trigger = openmc.Trigger(trigger_type='rel_err', threshold=0.0001)
trigger.scores = ['He3-production']
he3_production_tally = openmc.Tally()
he3_production_tally.scores = ['He3-production']
he3_production_tally.triggers = [trigger]
model.tallies = openmc.Tallies([he3_production_tally])

# Run model to verify that trigger works
model.run()

0 comments on commit 496d32c

Please sign in to comment.