From 96a66789b11ca3e96b72ed7631939f2c198294ce Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 24 Aug 2020 13:48:21 -0500 Subject: [PATCH] Activate need_depletion_rx for reaction rate-based depletion only --- include/openmc/tallies/tally.h | 2 -- openmc/deplete/helpers.py | 3 +++ openmc/lib/settings.py | 5 +++-- src/finalize.cpp | 1 + src/simulation.cpp | 2 -- src/tallies/tally.cpp | 13 ------------- 6 files changed, 7 insertions(+), 19 deletions(-) diff --git a/include/openmc/tallies/tally.h b/include/openmc/tallies/tally.h index c19ceb2af..a87946bf7 100644 --- a/include/openmc/tallies/tally.h +++ b/include/openmc/tallies/tally.h @@ -119,8 +119,6 @@ public: int energyout_filter_ {C_NONE}; int delayedgroup_filter_ {C_NONE}; - bool depletion_rx_ {false}; //!< Has depletion reactions (e.g. (n,2n)) - std::vector triggers_; int deriv_ {C_NONE}; //!< Index of a TallyDerivative object for diff tallies. diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index c2ddb0e9e..fd3f8d3b0 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -48,6 +48,9 @@ class DirectReactionRateHelper(ReactionRateHelper): super().__init__(n_nuc, n_react) self._rate_tally = None + # Automatically pre-calculate reaction rates for depletion + openmc.lib.settings.need_depletion_rx = True + @ReactionRateHelper.nuclides.setter def nuclides(self, nuclides): ReactionRateHelper.nuclides.fset(self, nuclides) diff --git a/openmc/lib/settings.py b/openmc/lib/settings.py index 573303857..1eab4aa8a 100644 --- a/openmc/lib/settings.py +++ b/openmc/lib/settings.py @@ -27,12 +27,13 @@ class _Settings: generations_per_batch = _DLLGlobal(c_int32, 'gen_per_batch') inactive = _DLLGlobal(c_int32, 'n_inactive') max_lost_particles = _DLLGlobal(c_int32, 'max_lost_particles') - rel_max_lost_particles = _DLLGlobal(c_double, 'rel_max_lost_particles') + need_depletion_rx = _DLLGlobal(c_bool, 'need_depletion_rx') + output_summary = _DLLGlobal(c_bool, 'output_summary') particles = _DLLGlobal(c_int64, 'n_particles') + rel_max_lost_particles = _DLLGlobal(c_double, 'rel_max_lost_particles') restart_run = _DLLGlobal(c_bool, 'restart_run') run_CE = _DLLGlobal(c_bool, 'run_CE') verbosity = _DLLGlobal(c_int, 'verbosity') - output_summary = _DLLGlobal(c_bool, 'output_summary') @property def run_mode(self): diff --git a/src/finalize.cpp b/src/finalize.cpp index bf9b437e8..fc0775ded 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -119,6 +119,7 @@ int openmc_finalize() simulation::keff = 1.0; simulation::n_lost_particles = 0; + simulation::need_depletion_rx = false; simulation::satisfy_triggers = false; simulation::total_gen = 0; diff --git a/src/simulation.cpp b/src/simulation.cpp index c8115ae37..c95c0386c 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -107,7 +107,6 @@ int openmc_simulation_init() simulation::current_batch = 0; simulation::k_generation.clear(); simulation::entropy.clear(); - simulation::need_depletion_rx = false; openmc_reset(); // If this is a restart run, load the state point data and binary source @@ -190,7 +189,6 @@ int openmc_simulation_finalize() if (settings::check_overlaps) print_overlap_check(); // Reset flags - simulation::need_depletion_rx = false; simulation::initialized = false; return 0; } diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 0131592f8..a4e10ebb7 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -377,7 +377,6 @@ Tally::set_scores(const std::vector& scores) { // Reset state and prepare for the new scores. scores_.clear(); - depletion_rx_ = false; scores_.reserve(scores.size()); // Check for the presence of certain restrictive filters. @@ -449,15 +448,6 @@ Tally::set_scores(const std::vector& scores) } break; - case N_2N: - case N_3N: - case N_4N: - case N_GAMMA: - case N_P: - case N_A: - depletion_rx_ = true; - break; - case SCORE_CURRENT: // Check which type of current is desired: mesh or surface currents. if (surface_present || cell_present || cellfrom_present) { @@ -859,9 +849,6 @@ setup_active_tallies() case TallyType::SURFACE: model::active_surface_tallies.push_back(i); } - - // Check if tally contains depletion reactions and if so, set flag - if (tally.depletion_rx_) simulation::need_depletion_rx = true; } } }