Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
4 changes: 1 addition & 3 deletions docs/source/usersguide/kinetics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ the ``ifp_n_generation`` settings in the Python API::

settings.ifp_n_generation = 5

``ifp_n_generation`` should be greater than 0, but should also be lower than
or equal to the number of inactive batches declared for the calculation.
The respect of these constraints is verified by OpenMC before any calculation.
``ifp_n_generation`` should be greater than 0.

OpenMC will automatically detect the type of data that needs to be stored based
on the tally scores selected by the user. This guarantees that only information
Expand Down
3 changes: 3 additions & 0 deletions include/openmc/tallies/tally.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class Tally {
//! Whether this tally is currently being updated
bool active_ {false};

//! Offset batch to activate this tally after.
int offset_ {0};

//! Number of realizations
int n_realizations_ {0};

Expand Down
8 changes: 1 addition & 7 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,8 @@ void read_settings_xml(pugi::xml_node root)
// Probability (IFP) method
if (check_for_node(root, "ifp_n_generation")) {
ifp_n_generation = std::stoi(get_node_value(root, "ifp_n_generation"));
if (ifp_n_generation <= 0) {
if (ifp_n_generation <= 0)
fatal_error("'ifp_n_generation' must be greater than 0.");
}
// Avoid tallying 0 if IFP logs are not complete when active cycles start
if (ifp_n_generation > n_inactive) {
fatal_error("'ifp_n_generation' must be lower than or equal to the "
"number of inactive cycles.");
}
}
}

Expand Down
16 changes: 15 additions & 1 deletion src/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,21 @@ void initialize_batch()
simulation::time_inactive.stop();
simulation::time_active.start();
for (auto& t : model::tallies) {
t->active_ = true;
if (t->offset_ == 0)
t->active_ = true;
}
}

// Activate tallies which have activation offset.
for (auto& t : model::tallies) {
if (t->offset_ > 0) {
if (!settings::restart_run) {
if (simulation::current_batch == settings::n_inactive + 1 + t->offset_)
t->active_ = true;
} else if (simulation::current_batch == simulation::restart_batch + 1) {
if (simulation::restart_batch >= settings::n_inactive + t->offset_)
t->active_ = true;
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/tallies/tally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ Tally::Tally(pugi::xml_node node)
"changed using the 'ifp_n_generation' settings.",
settings::ifp_n_generation));
}
if (settings::ifp_n_generation > settings::n_inactive) {
fatal_error("'ifp_n_generation' must be lower than or equal to the "
"number of inactive cycles.");
}
settings::ifp_on = true;
} else if (settings::run_mode == RunMode::FIXED_SOURCE) {
fatal_error(
Expand Down Expand Up @@ -656,6 +652,7 @@ void Tally::set_scores(const vector<std::string>& scores)
case SCORE_IFP_BETA_NUM:
case SCORE_IFP_DENOM:
estimator_ = TallyEstimator::COLLISION;
offset_ = settings::ifp_n_generation;
break;
}

Expand Down
56 changes: 20 additions & 36 deletions src/tallies/tally_scoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,9 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index,
if (settings::ifp_on) {
if ((p.type() == Type::neutron) && (p.fission())) {
if (is_generation_time_or_both()) {
const auto& lifetimes =
simulation::ifp_source_lifetime_bank[p.current_work() - 1];
if (lifetimes.size() == settings::ifp_n_generation) {
score = lifetimes[0] * p.wgt_last();
}
const auto& lifetime =
simulation::ifp_source_lifetime_bank[p.current_work() - 1][0];
score = lifetime * p.wgt_last();
}
}
}
Expand All @@ -959,20 +957,19 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index,
if (settings::ifp_on) {
if ((p.type() == Type::neutron) && (p.fission())) {
if (is_beta_effective_or_both()) {
const auto& delayed_groups =
simulation::ifp_source_delayed_group_bank[p.current_work() - 1];
if (delayed_groups.size() == settings::ifp_n_generation) {
if (delayed_groups[0] > 0) {
score = p.wgt_last();
if (tally.delayedgroup_filter_ != C_NONE) {
auto i_dg_filt = tally.filters()[tally.delayedgroup_filter_];
const DelayedGroupFilter& filt {
*dynamic_cast<DelayedGroupFilter*>(
model::tally_filters[i_dg_filt].get())};
score_fission_delayed_dg(i_tally, delayed_groups[0] - 1,
score, score_index, p.filter_matches());
continue;
}
const auto& delayed_group =
simulation::ifp_source_delayed_group_bank[p.current_work() - 1]
[0];
if (delayed_group > 0) {
score = p.wgt_last();
if (tally.delayedgroup_filter_ != C_NONE) {
auto i_dg_filt = tally.filters()[tally.delayedgroup_filter_];
const DelayedGroupFilter& filt {
*dynamic_cast<DelayedGroupFilter*>(
model::tally_filters[i_dg_filt].get())};
score_fission_delayed_dg(i_tally, delayed_group - 1, score,
score_index, p.filter_matches());
continue;
}
}
}
Expand All @@ -982,21 +979,8 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index,

case SCORE_IFP_DENOM:
if (settings::ifp_on) {
if ((p.type() == Type::neutron) && (p.fission())) {
int ifp_data_size;
if (is_beta_effective_or_both()) {
ifp_data_size = static_cast<int>(
simulation::ifp_source_delayed_group_bank[p.current_work() - 1]
.size());
} else {
ifp_data_size = static_cast<int>(
simulation::ifp_source_lifetime_bank[p.current_work() - 1]
.size());
}
if (ifp_data_size == settings::ifp_n_generation) {
score = p.wgt_last();
}
}
if ((p.type() == Type::neutron) && (p.fission()))
score = p.wgt_last();
}
break;

Expand Down Expand Up @@ -2644,7 +2628,7 @@ void score_surface_tally(Particle& p, const vector<int>& tallies)
// for a further scoring function.
double score = current * filter_weight;
for (auto score_index = 0; score_index < tally.scores_.size();
++score_index) {
++score_index) {
#pragma omp atomic
tally.results_(filter_index, score_index, TallyResult::VALUE) += score;
}
Expand Down Expand Up @@ -2719,7 +2703,7 @@ void score_pulse_height_tally(Particle& p, const vector<int>& tallies)

// Loop over scores.
for (auto score_index = 0; score_index < tally.scores_.size();
++score_index) {
++score_index) {
#pragma omp atomic
tally.results_(filter_index, score_index, TallyResult::VALUE) +=
filter_weight;
Expand Down
Loading