From 230db28d39ae1e3011e3ad85cb8b5090693fe862 Mon Sep 17 00:00:00 2001 From: John Tramm Date: Tue, 28 Oct 2025 03:22:37 -0500 Subject: [PATCH] FW-CADIS Disregard Max Realizations Setting (#3616) --- docs/source/usersguide/variance_reduction.rst | 3 +-- src/simulation.cpp | 7 ++----- src/weight_windows.cpp | 15 +++++++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/source/usersguide/variance_reduction.rst b/docs/source/usersguide/variance_reduction.rst index 369e33e2d..5c2485158 100644 --- a/docs/source/usersguide/variance_reduction.rst +++ b/docs/source/usersguide/variance_reduction.rst @@ -133,8 +133,7 @@ random ray mode can be found in the :ref:`Random Ray User Guide `. # we used for source region decomposition wwg = openmc.WeightWindowGenerator( method='fw_cadis', - mesh=mesh, - max_realizations=settings.batches + mesh=mesh ) # Add generator to openmc.settings object diff --git a/src/simulation.cpp b/src/simulation.cpp index f55546c4c..05d554526 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -400,11 +400,8 @@ void finalize_batch() simulation::time_tallies.stop(); // update weight windows if needed - if (settings::solver_type != SolverType::RANDOM_RAY || - simulation::current_batch == settings::n_batches) { - for (const auto& wwg : variance_reduction::weight_windows_generators) { - wwg->update(); - } + for (const auto& wwg : variance_reduction::weight_windows_generators) { + wwg->update(); } // Reset global tally results diff --git a/src/weight_windows.cpp b/src/weight_windows.cpp index 0d648d333..674fae49c 100644 --- a/src/weight_windows.cpp +++ b/src/weight_windows.cpp @@ -26,6 +26,7 @@ #include "openmc/random_ray/flat_source_domain.h" #include "openmc/search.h" #include "openmc/settings.h" +#include "openmc/simulation.h" #include "openmc/tallies/filter_energy.h" #include "openmc/tallies/filter_mesh.h" #include "openmc/tallies/filter_particle.h" @@ -966,11 +967,17 @@ void WeightWindowsGenerator::update() const Tally* tally = model::tallies[tally_idx_].get(); - // if we're beyond the number of max realizations or not at the corrrect - // update interval, skip the update - if (max_realizations_ < tally->n_realizations_ || - tally->n_realizations_ % update_interval_ != 0) + // If in random ray mode, only update on the last batch + if (settings::solver_type == SolverType::RANDOM_RAY) { + if (simulation::current_batch != settings::n_batches) { + return; + } + // If in Monte Carlo mode and beyond the number of max realizations or + // not at the correct update interval, skip the update + } else if (max_realizations_ < tally->n_realizations_ || + tally->n_realizations_ % update_interval_ != 0) { return; + } wws->update_weights(tally, tally_value_, threshold_, ratio_, method_);