mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
Fix check for trigger score name (#3155)
This commit is contained in:
parent
1645e3bb87
commit
b54de4d761
2 changed files with 32 additions and 1 deletions
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue