From 959bec57aee8eb04de3102784fb81aee84e7a07a Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Fri, 23 Apr 2021 10:30:07 -0400 Subject: [PATCH] ensure we allocate differential tally space up front in event mode --- src/particle_data.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/particle_data.cpp b/src/particle_data.cpp index 8f4db5a8a9..7f1f9f4564 100644 --- a/src/particle_data.cpp +++ b/src/particle_data.cpp @@ -3,6 +3,7 @@ #include "openmc/geometry.h" #include "openmc/nuclide.h" #include "openmc/photon.h" +#include "openmc/settings.h" #include "openmc/tallies/derivative.h" #include "openmc/tallies/filter.h" #include "openmc/tallies/tally.h" @@ -18,8 +19,10 @@ ParticleData::ParticleData() zero_delayed_bank(); - // Every particle starts with no accumulated flux derivative. - if (!model::active_tallies.empty()) { + // Every particle starts with no accumulated flux derivative. Note that in + // event mode, we construct the particle once up front, so have to run this + // even if the current batch is inactive. + if (!model::active_tallies.empty() || settings::event_based) { flux_derivs_.resize(model::tally_derivs.size()); zero_flux_derivs(); }