From 5ff8dca3727786cdbc7ec287c8c6505902a7e5a4 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 17 Jun 2020 22:41:27 -0500 Subject: [PATCH] Change i_nuclide_/i_element_ to index_ --- include/openmc/nuclide.h | 3 ++- include/openmc/photon.h | 3 ++- src/nuclide.cpp | 20 ++++++++++---------- src/photon.cpp | 6 +++--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/openmc/nuclide.h b/include/openmc/nuclide.h index 71973dc1b..60bac81d2 100644 --- a/include/openmc/nuclide.h +++ b/include/openmc/nuclide.h @@ -9,6 +9,7 @@ #include #include +#include #include #include "openmc/constants.h" @@ -63,7 +64,7 @@ public: int A_; //!< Mass number int metastable_; //!< Metastable state double awr_; //!< Atomic weight ratio - int i_nuclide_; //!< Index in the nuclides array + gsl::index index_; //!< Index in the nuclides array // Temperature dependent cross section data std::vector kTs_; //!< temperatures in eV (k*T) diff --git a/include/openmc/photon.h b/include/openmc/photon.h index 0e56ed83a..e6e39893f 100644 --- a/include/openmc/photon.h +++ b/include/openmc/photon.h @@ -4,6 +4,7 @@ #include "openmc/endf.h" #include "openmc/particle.h" +#include #include #include "xtensor/xtensor.hpp" @@ -58,7 +59,7 @@ public: // Data members std::string name_; //!< Name of element, e.g. "Zr" int Z_; //!< Atomic number - int i_element_; //!< Index in global elements vector + gsl::index index_; //!< Index in global elements vector // Microscopic cross sections xt::xtensor energy_; diff --git a/src/nuclide.cpp b/src/nuclide.cpp index 0f1d02fe4..604cba0b5 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -49,11 +49,11 @@ int Nuclide::XS_PHOTON_PROD {4}; Nuclide::Nuclide(hid_t group, const std::vector& temperature) { // Set index of nuclide in global vector - i_nuclide_ = data::nuclides.size(); + index_ = data::nuclides.size(); // Get name of nuclide from group, removing leading '/' name_ = object_name(group).substr(1); - data::nuclide_map[name_] = i_nuclide_; + data::nuclide_map[name_] = index_; read_attribute(group, "Z", Z_); read_attribute(group, "A", A_); @@ -497,7 +497,7 @@ double Nuclide::nu(double E, EmissionMode mode, int group) const void Nuclide::calculate_elastic_xs(Particle& p) const { // Get temperature index, grid index, and interpolation factor - auto& micro {p.neutron_xs_[i_nuclide_]}; + auto& micro {p.neutron_xs_[index_]}; int i_temp = micro.index_temp; int i_grid = micro.index_grid; double f = micro.interp_factor; @@ -533,7 +533,7 @@ double Nuclide::elastic_xs_0K(double E) const void Nuclide::calculate_xs(int i_sab, int i_log_union, double sab_frac, Particle& p) { - auto& micro {p.neutron_xs_[i_nuclide_]}; + auto& micro {p.neutron_xs_[index_]}; // Initialize cached cross sections to zero micro.elastic = CACHE_INVALID; @@ -740,7 +740,7 @@ void Nuclide::calculate_xs(int i_sab, int i_log_union, double sab_frac, Particle void Nuclide::calculate_sab_xs(int i_sab, double sab_frac, Particle& p) { - auto& micro {p.neutron_xs_[i_nuclide_]}; + auto& micro {p.neutron_xs_[index_]}; // Set flag that S(a,b) treatment should be used for scattering micro.index_sab = i_sab; @@ -769,7 +769,7 @@ void Nuclide::calculate_sab_xs(int i_sab, double sab_frac, Particle& p) void Nuclide::calculate_urr_xs(int i_temp, Particle& p) const { - auto& micro = p.neutron_xs_[i_nuclide_]; + auto& micro = p.neutron_xs_[index_]; micro.use_ptable = true; // Create a shorthand for the URR data @@ -787,8 +787,8 @@ void Nuclide::calculate_urr_xs(int i_temp, Particle& p) const // therefore preserving correlation of temperature in probability tables. p.stream_ = STREAM_URR_PTABLE; //TODO: to maintain the same random number stream as the Fortran code this - //replaces, the seed is set with i_nuclide_ + 1 instead of i_nuclide_ - double r = future_prn(static_cast(i_nuclide_ + 1), *p.current_seed()); + //replaces, the seed is set with index_ + 1 instead of index_ + double r = future_prn(static_cast(index_ + 1), *p.current_seed()); p.stream_ = STREAM_TRACKING; int i_low = 0; @@ -956,8 +956,8 @@ extern "C" int openmc_load_nuclide(const char* name, const double* temps, int n) file_close(file_id); // Read multipole file into the appropriate entry on the nuclides array - const auto& nuc = data::nuclides.back(); - if (settings::temperature_multipole) read_multipole_data(nuc->i_nuclide_); + int i_nuclide = data::nuclide_map.at(name); + if (settings::temperature_multipole) read_multipole_data(i_nuclide); // Read elemental data, if necessary if (settings::photon_transport) { diff --git a/src/photon.cpp b/src/photon.cpp index 2b40a1966..2be3f0e7d 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -39,11 +39,11 @@ std::unordered_map element_map; PhotonInteraction::PhotonInteraction(hid_t group) { // Set index of element in global vector - i_element_ = data::elements.size(); + index_ = data::elements.size(); // Get name of nuclide from group, removing leading '/' name_ = object_name(group).substr(1); - data::element_map[name_] = i_element_; + data::element_map[name_] = index_; // Get atomic number read_attribute(group, "Z", Z_); @@ -472,7 +472,7 @@ void PhotonInteraction::calculate_xs(Particle& p) const // calculate interpolation factor double f = (log_E - energy_(i_grid)) / (energy_(i_grid+1) - energy_(i_grid)); - auto& xs {p.photon_xs_[i_element_]}; + auto& xs {p.photon_xs_[index_]}; xs.index_grid = i_grid; xs.interp_factor = f;