Skip to content
Open
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
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
25 changes: 9 additions & 16 deletions include/openmc/ifp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,12 @@
#include "openmc/particle.h"
#include "openmc/particle_data.h"
#include "openmc/settings.h"
#include "openmc/simulation.h"

#include <algorithm> // for copy

namespace openmc {

//! Check the value of the IFP parameter for beta effective or both.
//!
//! \return true if "BetaEffective" or "Both", false otherwise.
bool is_beta_effective_or_both();

//! Check the value of the IFP parameter for generation time or both.
//!
//! \return true if "GenerationTime" or "Both", false otherwise.
bool is_generation_time_or_both();

//! Resize IFP vectors
//!
//! \param[in,out] delayed_groups List of delayed group numbers
Expand All @@ -28,10 +19,10 @@ bool is_generation_time_or_both();
template<typename T, typename U>
void resize_ifp_data(vector<T>& delayed_groups, vector<U>& lifetimes, int64_t n)
{
if (is_beta_effective_or_both()) {
if (simulation::ifp_delayed_on) {
delayed_groups.resize(n);
}
if (is_generation_time_or_both()) {
if (simulation::ifp_lifetime_on) {
lifetimes.resize(n);
}
}
Expand Down Expand Up @@ -85,10 +76,12 @@ void resize_simulation_ifp_banks();
//! Retrieve IFP data from the IFP fission banks.
//!
//! \param[in] i_bank Index in the fission banks
//! \param[in,out] delayed_groups Delayed group numbers
//! \param[in,out] lifetimes Lifetimes lists
void copy_ifp_data_from_fission_banks(
int i_bank, vector<int>& delayed_groups, vector<double>& lifetimes);
//! \param[in] j_bank Index in the ifp banks
//! \param[in,out] delayed_groups_bank Delayed group numbers
//! \param[in,out] lifetimes_bank Lifetimes lists
void copy_ifp_data_from_fission_banks(int i_bank, int j_bank,
vector<vector<int>>& delayed_groups_bank,
vector<vector<double>>& lifetimes_bank);

#ifdef OPENMC_MPI

Expand Down
13 changes: 1 addition & 12 deletions include/openmc/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ enum class SSWCellType {
To,
};

// Type of IFP parameters
enum class IFPParameter {
None,
Both,
BetaEffective,
GenerationTime,
};

struct CollisionTrackConfig {
bool mcpl_write {false}; //!< Write collision tracks using MCPL?
std::unordered_set<int>
Expand Down Expand Up @@ -69,8 +61,7 @@ extern bool
delayed_photon_scaling; //!< Scale fission photon yield to include delayed
extern "C" bool entropy_on; //!< calculate Shannon entropy?
extern "C" bool
event_based; //!< use event-based mode (instead of history-based)
extern bool ifp_on; //!< Use IFP for kinetics parameters?
event_based; //!< use event-based mode (instead of history-based)
extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular?
extern bool material_cell_offsets; //!< create material cells offsets?
extern "C" bool output_summary; //!< write summary.h5?
Expand Down Expand Up @@ -142,8 +133,6 @@ extern array<double, 4>
time_cutoff; //!< Time cutoff in [s] for each particle type
extern int
ifp_n_generation; //!< Number of generation for Iterated Fission Probability
extern IFPParameter
ifp_parameter; //!< Parameter to calculate for Iterated Fission Probability
extern int
legendre_to_tabular_points; //!< number of points to convert Legendres
extern int max_order; //!< Maximum Legendre order for multigroup data
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace simulation {
extern int ct_current_file; //!< current collision track file index
extern "C" int current_batch; //!< current batch
extern "C" int current_gen; //!< current fission generation
extern bool ifp_delayed_on; //!< Store delayed group IFP data?
extern bool ifp_lifetime_on; //!< Store lifetime IFP data?
extern "C" bool initialized; //!< has simulation been initialized?
extern "C" double keff; //!< average k over batches
extern "C" double keff_std; //!< standard deviation of average k
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
18 changes: 6 additions & 12 deletions src/bank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ void sort_fission_bank()
sorted_bank = &simulation::fission_bank[simulation::fission_bank.size()];
}

if (settings::ifp_on) {
allocate_temporary_vector_ifp(
sorted_ifp_delayed_group_bank, sorted_ifp_lifetime_bank);
}
allocate_temporary_vector_ifp(
sorted_ifp_delayed_group_bank, sorted_ifp_lifetime_bank);

// Use parent and progeny indices to sort fission bank
for (int64_t i = 0; i < simulation::fission_bank.size(); i++) {
Expand All @@ -118,19 +116,15 @@ void sort_fission_bank()
"shared fission bank size.");
}
sorted_bank[idx] = site;
if (settings::ifp_on) {
copy_ifp_data_from_fission_banks(
i, sorted_ifp_delayed_group_bank[idx], sorted_ifp_lifetime_bank[idx]);
}
copy_ifp_data_from_fission_banks(
i, idx, sorted_ifp_delayed_group_bank, sorted_ifp_lifetime_bank);
}

// Copy sorted bank into the fission bank
std::copy(sorted_bank, sorted_bank + simulation::fission_bank.size(),
simulation::fission_bank.data());
if (settings::ifp_on) {
copy_ifp_data_to_fission_banks(
sorted_ifp_delayed_group_bank.data(), sorted_ifp_lifetime_bank.data());
}
copy_ifp_data_to_fission_banks(
sorted_ifp_delayed_group_bank.data(), sorted_ifp_lifetime_bank.data());
}

//==============================================================================
Expand Down
76 changes: 29 additions & 47 deletions src/eigenvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ void synchronize_bank()
// Temporary banks for IFP
vector<vector<int>> temp_delayed_groups;
vector<vector<double>> temp_lifetimes;
if (settings::ifp_on) {
resize_ifp_data(
temp_delayed_groups, temp_lifetimes, 3 * simulation::work_per_rank);
}
resize_ifp_data(
temp_delayed_groups, temp_lifetimes, 3 * simulation::work_per_rank);

// ==========================================================================
// SAMPLE N_PARTICLES FROM FISSION BANK AND PLACE IN TEMP_SITES
Expand All @@ -167,10 +165,8 @@ void synchronize_bank()
for (int64_t i = tooth_start; i < tooth_end; i++) {
int64_t idx = std::floor(tooth) - start;
temp_sites[index_temp] = simulation::fission_bank[idx];
if (settings::ifp_on) {
copy_ifp_data_from_fission_banks(
idx, temp_delayed_groups[index_temp], temp_lifetimes[index_temp]);
}
copy_ifp_data_from_fission_banks(
idx, index_temp, temp_delayed_groups, temp_lifetimes);
++index_temp;

// Next tooth
Expand Down Expand Up @@ -209,10 +205,8 @@ void synchronize_bank()

// IFP number of generation
int ifp_n_generation;
if (settings::ifp_on) {
broadcast_ifp_n_generation(
ifp_n_generation, temp_delayed_groups, temp_lifetimes);
}
broadcast_ifp_n_generation(
ifp_n_generation, temp_delayed_groups, temp_lifetimes);

int64_t index_local = 0;
vector<MPI_Request> requests;
Expand All @@ -228,7 +222,7 @@ void synchronize_bank()
simulation::work_index.begin(), simulation::work_index.end(), start);

// Resize IFP send buffers
if (settings::ifp_on && mpi::n_procs > 1) {
if (mpi::n_procs > 1) {
resize_ifp_data(send_delayed_groups, send_lifetimes,
ifp_n_generation * 3 * simulation::work_per_rank);
}
Expand All @@ -246,15 +240,12 @@ void synchronize_bank()
mpi::source_site, neighbor, mpi::rank, mpi::intracomm,
&requests.back());

if (settings::ifp_on) {
// Send IFP data
if (is_beta_effective_or_both())
send_ifp_info(index_local, n, ifp_n_generation, neighbor, requests,
temp_delayed_groups, send_delayed_groups);
if (is_generation_time_or_both())
send_ifp_info(index_local, n, ifp_n_generation, neighbor, requests,
temp_lifetimes, send_lifetimes);
}
if (simulation::ifp_delayed_on)
send_ifp_info(index_local, n, ifp_n_generation, neighbor, requests,
temp_delayed_groups, send_delayed_groups);
if (simulation::ifp_lifetime_on)
send_ifp_info(index_local, n, ifp_n_generation, neighbor, requests,
temp_lifetimes, send_lifetimes);
}

// Increment all indices
Expand Down Expand Up @@ -293,7 +284,7 @@ void synchronize_bank()
}

// Resize IFP receive buffers
if (settings::ifp_on && mpi::n_procs > 1) {
if (mpi::n_procs > 1) {
resize_ifp_data(recv_delayed_groups, recv_lifetimes,
ifp_n_generation * simulation::work_per_rank);
}
Expand All @@ -317,15 +308,12 @@ void synchronize_bank()
MPI_Irecv(&simulation::source_bank[index_local], static_cast<int>(n),
mpi::source_site, neighbor, neighbor, mpi::intracomm, &requests.back());

if (settings::ifp_on) {
// Receive IFP data
if (is_beta_effective_or_both())
receive_ifp_data(index_local, n, ifp_n_generation, neighbor, requests,
recv_delayed_groups, deserialization_info);
if (is_generation_time_or_both())
receive_ifp_data(index_local, n, ifp_n_generation, neighbor, requests,
recv_lifetimes, deserialization_info);
}
if (simulation::ifp_delayed_on)
receive_ifp_data(index_local, n, ifp_n_generation, neighbor, requests,
recv_delayed_groups, deserialization_info);
if (simulation::ifp_lifetime_on)
receive_ifp_data(index_local, n, ifp_n_generation, neighbor, requests,
recv_lifetimes, deserialization_info);

} else {
// If the source sites are on this processor, we can simply copy them
Expand All @@ -335,10 +323,8 @@ void synchronize_bank()
std::copy(&temp_sites[index_temp], &temp_sites[index_temp + n],
&simulation::source_bank[index_local]);

if (settings::ifp_on) {
copy_partial_ifp_data_to_source_banks(
index_temp, n, index_local, temp_delayed_groups, temp_lifetimes);
}
copy_partial_ifp_data_to_source_banks(
index_temp, n, index_local, temp_delayed_groups, temp_lifetimes);
}

// Increment all indices
Expand All @@ -354,21 +340,17 @@ void synchronize_bank()
int n_request = requests.size();
MPI_Waitall(n_request, requests.data(), MPI_STATUSES_IGNORE);

if (settings::ifp_on) {
if (is_beta_effective_or_both())
deserialize_ifp_info(ifp_n_generation, recv_delayed_groups,
simulation::ifp_source_delayed_group_bank, deserialization_info);
if (is_generation_time_or_both())
deserialize_ifp_info(ifp_n_generation, recv_lifetimes,
simulation::ifp_source_lifetime_bank, deserialization_info);
}
if (simulation::ifp_delayed_on)
deserialize_ifp_info(ifp_n_generation, recv_delayed_groups,
simulation::ifp_source_delayed_group_bank, deserialization_info);
if (simulation::ifp_lifetime_on)
deserialize_ifp_info(ifp_n_generation, recv_lifetimes,
simulation::ifp_source_lifetime_bank, deserialization_info);

#else
std::copy(temp_sites.data(), temp_sites.data() + settings::n_particles,
simulation::source_bank.begin());
if (settings::ifp_on) {
copy_complete_ifp_data_to_source_banks(temp_delayed_groups, temp_lifetimes);
}
copy_complete_ifp_data_to_source_banks(temp_delayed_groups, temp_lifetimes);
#endif

simulation::time_bank_sendrecv.stop();
Expand Down
Loading
Loading