Closed tjlaboss closed 16 hours ago
Triggers unsatisfied, max unc./thresh. is 1.0000000000000002 for (n,p) in tally 3
~Wonder if this is floating point issue or a data library difference vs. the ENDF and JEFF libraries I tested on. Marking as draft...~
...reproduced this using the NNDC data. Added more particles, and now the triggers are satisfied early as expected.
This makes sense to me. I'll rename the parameter to ignore_zeros
, revert 29b07827f8d48c4e8eb5385f58c777a1f8441787, make a note in the documentation, and add more particles to the test case.
Thanks @tjlaboss! Please ping me when the PR is ready for another look
@paulromano, thanks for the review. The requested changes have been made and the CI tests have passed.
Resolve https://github.com/openmc-dev/openmc/issues/2899
Description
Add the ability to ignore tally bins with zero scores when evaluating tally triggers.
allow_zero
option forTrigger
class and tallies.xml. (default: False)Checklist
Questions and Discussion
OpenMC's tally trigger behavior
After OpenMC completes inactive batches, it runs a few active batches to begin gathering tally statistics. Then, tally triggers are evaluated.
This can present a problem with the new 'allow_zero' option. When triggers are evaluated this early, tally bins may not yet have any scores. Normally, this sets the error metric to infinity, but when
allow_zero == True
, the trigger can "fire" prematurely if none of the tally bins have any hits yet. This can happen for rare events, such as shielding problems and small-xs reactions.Currently, this check is performed immediately after those initial active batches are performed, regardless of the user's tally trigger 'trigger_batch_interval' setting; let's call this "interval 0". In commit 29b07827f8d48c4e8eb5385f58c777a1f8441787,
check_triggers()
is changed to skip "interval 0", so that the check is only performed after each full interval. This way, users can ensure a minimum number of active batches and avoid false positives when zero-score bins are allowed.This does change the default tally trigger behavior. Since the default 'trigger_batch_interval' is 1, this will add 1 additional batch before checking tally triggers even if they do not enable
allow_zero
on any tallies. I think this is the best balance between straightforwardly addressing the problem and being unobtrusive to existing tally trigger users, but let's discuss.Alternatives
allow_zero
is used on any tallies, and only skip the 0th interval if it is. The advantage is that this would then have no impact on existing workflows. The disadvantage is that the trigger checking behavior with and without the option would be inconsistent.Testing
Is the single unit test sufficient, or is a regression test necessary as well?
Bool
How do we want to handle Booleans in the XML, without using
eval
(unsafe) ordistutils
(deprecated)? Here, I just check if a lowercase string is in ("true", "1"), or ("false", "0"), and otherwise crash. This is similar to how bools are handled in settings.py, but with the inconsistency that an unrecognized string (e.g., "rtue" or "yes") won't default toFalse
.