Open gridley opened 1 year ago
Nice -- thanks for finding this and putting in the fix! Just do double check, as we are now doing +=
instead of =
, do we need to zero these values at the start of each batch (or was this already being done?)
Yes, total_weight
gets zeroed out at the start of initialize_batch
, which is precisely the desired behavior. The total weight should increase over the generations and reflect the total in the batch.
On the other hand, the other variables indeed are zeroed out in finalize_generation
. So we maybe don't need to use an increment here. Might make more sense to remove the unnecessary zeroing in the other code and use assignment instead here; and this is something to also change up in the main OpenMC repo, too.
It would be so nice to have all these global parameters grouped into a struct to better keep track of them. It seems that total_weight
is only used for eigenvalue estimation, and not in tallies themselves (they have their own total weight counter).
The total weight per batch was accidentally being reset after each generation; the correct behavior is to sum between generations rather than assign from the previous generation's total weight. Now it is reset to zero only after each batch.
The bug is easy to show. Turn up the generations per batch on any eigenvalue problem.