Fix check for trigger score name (#3155)

This commit is contained in:
Paul Romano 2024-10-02 12:12:44 -05:00 committed by GitHub
parent 1645e3bb87
commit b54de4d761
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 1 deletions

View file

@ -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()) {

View file

@ -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()