Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/source/usersguide/variance_reduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ random ray mode can be found in the :ref:`Random Ray User Guide <random_ray>`.
# 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
Expand Down
7 changes: 2 additions & 5 deletions src/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions src/weight_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_);

Expand Down
Loading