Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kinetics parameters using Iterated Fission Probability #3133

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions include/openmc/bank.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ extern SharedArray<SourceSite> surf_source_bank;

extern SharedArray<SourceSite> fission_bank;

extern vector<vector<int>> ifp_source_delayed_group_bank;

extern vector<vector<double>> ifp_source_lifetime_bank;

extern vector<vector<int>> ifp_fission_delayed_group_bank;

extern vector<vector<double>> ifp_fission_lifetime_bank;

extern vector<int64_t> progeny_per_particle;

} // namespace simulation
Expand Down
5 changes: 4 additions & 1 deletion include/openmc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ enum TallyScore {
SCORE_FISS_Q_PROMPT = -14, // prompt fission Q-value
SCORE_FISS_Q_RECOV = -15, // recoverable fission Q-value
SCORE_DECAY_RATE = -16, // delayed neutron precursor decay rate
SCORE_PULSE_HEIGHT = -17 // pulse-height
SCORE_PULSE_HEIGHT = -17, // pulse-height
SCORE_IFP_TIME_NUM = -18, // IFP lifetime numerator
SCORE_IFP_BETA_NUM = -19, // IFP delayed fraction numerator
SCORE_IFP_DENOM = -20 // IFP common denominator
};

// Global tally parameters
Expand Down
10 changes: 10 additions & 0 deletions include/openmc/eigenvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ void write_eigenvalue_hdf5(hid_t group);
//! \param[in] group HDF5 group
void read_eigenvalue_hdf5(hid_t group);

//==============================================================================
// Type definitions
//==============================================================================

//! Deserialization info for IFP
struct DeserializationInfo {
int64_t index_local;
int64_t n;
};

} // namespace openmc

#endif // OPENMC_EIGENVALUE_H
7 changes: 7 additions & 0 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ class ParticleData : public GeometryState {

int cell_born_ {-1};

// Iterated Fission Probability
double lifetime_ {0.0}; //!< neutron lifetime [s]

int n_collision_ {0};

bool write_track_ {false};
Expand Down Expand Up @@ -522,6 +525,10 @@ class ParticleData : public GeometryState {
double& time_last() { return time_last_; }
const double& time_last() const { return time_last_; }

// Particle lifetime
double& lifetime() { return lifetime_; }
const double& lifetime() const { return lifetime_; }

// What event took place, described in greater detail below
TallyEvent& event() { return event_; }
const TallyEvent& event() const { return event_; }
Expand Down
15 changes: 14 additions & 1 deletion include/openmc/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ enum class SSWCellType {
To,
};

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

//==============================================================================
// Global variable declarations
//==============================================================================
Expand All @@ -42,7 +50,8 @@ 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)
event_based; //!< use event-based mode (instead of history-based)
extern bool ifp; //!< Use IFP for kinetics parameters?
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 @@ -109,6 +118,10 @@ extern array<double, 4>
energy_cutoff; //!< Energy cutoff in [eV] for each particle type
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
53 changes: 53 additions & 0 deletions openmc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class Settings:
.. versionadded:: 0.12
generations_per_batch : int
Number of generations per batch
iterated_fission_probability: dict
Dictionary indicating the Iterated Fission Probability parameters.
Acceptable keys are:

:parameter: Kinetics parameter to calculate between 'beta_effective' and
'generation_time', or 'both' (str)
:n_generation: Number of generation (int)
max_lost_particles : int
Maximum number of lost particles

Expand Down Expand Up @@ -335,6 +342,9 @@ def __init__(self, **kwargs):

self._output = None

# Iterated Fission Probability
self._iterated_fission_probability = {}

# Output options
self._statepoint = {}
self._sourcepoint = {}
Expand Down Expand Up @@ -760,6 +770,27 @@ def verbosity(self, verbosity: int):
cv.check_less_than('verbosity', verbosity, 10, True)
self._verbosity = verbosity

@property
def iterated_fission_probability(self) -> dict:
return self._iterated_fission_probability

@iterated_fission_probability.setter
def iterated_fission_probability(self, iterated_fission_probability: dict):
cv.check_type(
"Iterated Fission Probability options",
iterated_fission_probability,
Mapping,
)
for key, value in iterated_fission_probability.items():
cv.check_value("Iterated Fission Probability key", key, ["parameter", "n_generation"])
if key == "parameter":
cv.check_value("parameter", value, ["beta_effective", "generation_time", "both"])
elif key == "n_generation":
cv.check_type("number of generation", value, Integral)
cv.check_greater_than("number of generation", value, 0)

self._iterated_fission_probability = iterated_fission_probability

@property
def tabular_legendre(self) -> dict:
return self._tabular_legendre
Expand Down Expand Up @@ -1347,6 +1378,16 @@ def _create_no_reduce_subelement(self, root):
element = ET.SubElement(root, "no_reduce")
element.text = str(self._no_reduce).lower()

def _create_iterated_fission_probability_subelements(self, root):
if self.iterated_fission_probability:
element = ET.SubElement(root, "iterated_fission_probability")
if 'parameter' in self._iterated_fission_probability:
subelement = ET.SubElement(element, "parameter")
subelement.text = str(self._iterated_fission_probability['parameter'])
if 'n_generation' in self._iterated_fission_probability:
subelement = ET.SubElement(element, "n_generation")
subelement.text = str(self._iterated_fission_probability['n_generation'])

def _create_tabular_legendre_subelements(self, root):
if self.tabular_legendre:
element = ET.SubElement(root, "tabular_legendre")
Expand Down Expand Up @@ -1747,6 +1788,16 @@ def _verbosity_from_xml_element(self, root):
if text is not None:
self.verbosity = int(text)

def _iterated_fission_probability_from_xml_element(self, root):
elem = root.find('iterated_fission_probability')
if elem is not None:
text = get_text(elem, 'parameter')
if text is not None:
self.iterated_fission_probability['parameter'] = text
text = get_text(elem, 'n_generation')
if text is not None:
self.iterated_fission_probability['n_generation'] = int(text)

def _tabular_legendre_from_xml_element(self, root):
elem = root.find('tabular_legendre')
if elem is not None:
Expand Down Expand Up @@ -1946,6 +1997,7 @@ def to_xml_element(self, mesh_memo=None):
self._create_trigger_subelement(element)
self._create_no_reduce_subelement(element)
self._create_verbosity_subelement(element)
self._create_iterated_fission_probability_subelements(element)
self._create_tabular_legendre_subelements(element)
self._create_temperature_subelements(element)
self._create_trace_subelement(element)
Expand Down Expand Up @@ -2052,6 +2104,7 @@ def from_xml_element(cls, elem, meshes=None):
settings._trigger_from_xml_element(elem)
settings._no_reduce_from_xml_element(elem)
settings._verbosity_from_xml_element(elem)
settings._iterated_fission_probability_from_xml_element(elem)
settings._tabular_legendre_from_xml_element(elem)
settings._temperature_from_xml_element(elem)
settings._trace_from_xml_element(elem)
Expand Down
54 changes: 54 additions & 0 deletions src/bank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ SharedArray<SourceSite> surf_source_bank;
// function.
SharedArray<SourceSite> fission_bank;

vector<vector<int>> ifp_source_delayed_group_bank;

vector<vector<double>> ifp_source_lifetime_bank;

vector<vector<int>> ifp_fission_delayed_group_bank;

vector<vector<double>> ifp_fission_lifetime_bank;

// Each entry in this vector corresponds to the number of progeny produced
// this generation for the particle located at that index. This vector is
// used to efficiently sort the fission bank after each iteration.
Expand Down Expand Up @@ -82,6 +90,10 @@ void sort_fission_bank()
// over provisioned, so we can use that as scratch space.
SourceSite* sorted_bank;
vector<SourceSite> sorted_bank_holder;
vector<int>* sorted_ifp_delayed_group_bank;
vector<vector<int>> sorted_ifp_delayed_group_bank_holder;
vector<double>* sorted_ifp_lifetime_bank;
vector<vector<double>> sorted_ifp_lifetime_bank_holder;

// If there is not enough space, allocate a temporary vector and point to it
if (simulation::fission_bank.size() >
Expand All @@ -92,6 +104,21 @@ void sort_fission_bank()
sorted_bank = &simulation::fission_bank[simulation::fission_bank.size()];
}

if (settings::ifp) {
if (settings::ifp_parameter == IFPParameter::BetaEffective ||
settings::ifp_parameter == IFPParameter::Both) {
sorted_ifp_delayed_group_bank_holder.resize(
simulation::fission_bank.size());
sorted_ifp_delayed_group_bank =
sorted_ifp_delayed_group_bank_holder.data();
}
if (settings::ifp_parameter == IFPParameter::GenerationTime ||
settings::ifp_parameter == IFPParameter::Both) {
sorted_ifp_lifetime_bank_holder.resize(simulation::fission_bank.size());
sorted_ifp_lifetime_bank = sorted_ifp_lifetime_bank_holder.data();
}
}

// Use parent and progeny indices to sort fission bank
for (int64_t i = 0; i < simulation::fission_bank.size(); i++) {
const auto& site = simulation::fission_bank[i];
Expand All @@ -102,11 +129,38 @@ void sort_fission_bank()
"shared fission bank size.");
}
sorted_bank[idx] = site;
if (settings::ifp) {
if (settings::ifp_parameter == IFPParameter::BetaEffective ||
settings::ifp_parameter == IFPParameter::Both) {
const auto& ifp_delayed_groups =
simulation::ifp_fission_delayed_group_bank[i];
sorted_ifp_delayed_group_bank[idx] = ifp_delayed_groups;
}
if (settings::ifp_parameter == IFPParameter::GenerationTime ||
settings::ifp_parameter == IFPParameter::Both) {
const auto& ifp_lifetimes = simulation::ifp_fission_lifetime_bank[i];
sorted_ifp_lifetime_bank[idx] = ifp_lifetimes;
}
}
}

// Copy sorted bank into the fission bank
std::copy(sorted_bank, sorted_bank + simulation::fission_bank.size(),
simulation::fission_bank.data());
if (settings::ifp) {
if (settings::ifp_parameter == IFPParameter::BetaEffective ||
settings::ifp_parameter == IFPParameter::Both) {
std::copy(sorted_ifp_delayed_group_bank,
sorted_ifp_delayed_group_bank + simulation::fission_bank.size(),
simulation::ifp_fission_delayed_group_bank.data());
}
if (settings::ifp_parameter == IFPParameter::GenerationTime ||
settings::ifp_parameter == IFPParameter::Both) {
std::copy(sorted_ifp_lifetime_bank,
sorted_ifp_lifetime_bank + simulation::fission_bank.size(),
simulation::ifp_fission_lifetime_bank.data());
}
}
}

//==============================================================================
Expand Down
Loading