Global Weight Window Generation via CAPI (#2359)

Co-authored-by: Jonathan Shimwell <drshimwell@gmail.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Patrick Shriwise 2023-06-09 10:47:27 -05:00 committed by GitHub
parent c123ce0fa0
commit 610a5d8c34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 2789 additions and 171 deletions

View file

@ -24,6 +24,7 @@
#include "openmc/tallies/trigger.h"
#include "openmc/timer.h"
#include "openmc/track_output.h"
#include "openmc/weight_windows.h"
#ifdef _OPENMP
#include <omp.h>
@ -137,6 +138,11 @@ int openmc_simulation_init()
}
}
// load weight windows from file
if (!settings::weight_windows_file.empty()) {
openmc_weight_windows_import(settings::weight_windows_file.c_str());
}
// Set flag indicating initialization is done
simulation::initialized = true;
return 0;
@ -175,6 +181,12 @@ int openmc_simulation_finalize()
if (settings::output_tallies && mpi::master)
write_tallies();
// If weight window generators are present in this simulation,
// write a weight windows file
if (variance_reduction::weight_windows_generators.size() > 0) {
openmc_weight_windows_export();
}
// Deactivate all tallies
for (auto& t : model::tallies) {
t->active_ = false;
@ -356,6 +368,11 @@ void finalize_batch()
accumulate_tallies();
simulation::time_tallies.stop();
// update weight windows if needed
for (const auto& wwg : variance_reduction::weight_windows_generators) {
wwg->update();
}
// Reset global tally results
if (simulation::current_batch <= settings::n_inactive) {
xt::view(simulation::global_tallies, xt::all()) = 0.0;