From 9c06a128d963cfb744075ed599c17e4d415d6cd0 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Sat, 2 Nov 2019 22:08:06 -0400 Subject: [PATCH] initial stab at making mgxs externally usable --- include/openmc/mgxs.h | 10 +++- include/openmc/mgxs_interface.h | 59 +++++++++++++----------- src/cross_sections.cpp | 2 +- src/initialize.cpp | 4 +- src/material.cpp | 12 ++--- src/mgxs.cpp | 24 ++++------ src/mgxs_interface.cpp | 82 ++++++++++++++++----------------- src/output.cpp | 2 +- src/particle.cpp | 2 +- src/particle_restart.cpp | 2 +- src/physics_mg.cpp | 6 +-- src/source.cpp | 6 +-- src/state_point.cpp | 2 +- src/summary.cpp | 2 +- src/tallies/filter_energy.cpp | 10 ++-- src/tallies/tally_scoring.cpp | 12 ++--- src/xsdata.cpp | 32 ++++++------- 17 files changed, 135 insertions(+), 134 deletions(-) diff --git a/include/openmc/mgxs.h b/include/openmc/mgxs.h index 1b4062da9..313677f6c 100644 --- a/include/openmc/mgxs.h +++ b/include/openmc/mgxs.h @@ -110,7 +110,10 @@ class Mgxs { //! //! @param xs_id HDF5 group id for the cross section data. //! @param temperature Temperatures to read. - Mgxs(hid_t xs_id, const std::vector& temperature); + //! @param num_group number of energy groups + //! @param num_delay number of delayed groups + Mgxs(hid_t xs_id, const std::vector& temperature, + int num_group, int num_delay); //! \brief Constructor that initializes and populates all data to build a //! macroscopic cross section from microscopic cross section. @@ -119,8 +122,11 @@ class Mgxs { //! @param mat_kTs temperatures (in units of eV) that data is needed. //! @param micros Microscopic objects to combine. //! @param atom_densities Atom densities of those microscopic quantities. + //! @param num_group number of energy groups + //! @param num_delay number of delayed groups Mgxs(const std::string& in_name, const std::vector& mat_kTs, - const std::vector& micros, const std::vector& atom_densities); + const std::vector& micros, const std::vector& atom_densities, + int num_group, int num_delay); //! \brief Provides a cross section value given certain parameters //! diff --git a/include/openmc/mgxs_interface.h b/include/openmc/mgxs_interface.h index bf72d675b..c72587be2 100644 --- a/include/openmc/mgxs_interface.h +++ b/include/openmc/mgxs_interface.h @@ -12,36 +12,41 @@ namespace openmc { //============================================================================== -// Global variables +// Global MGXS data container structure //============================================================================== +struct MgxsInterface +{ + int num_energy_groups; + int num_delayed_groups; + + std::vector nuclides_MG; + std::vector macro_xs; + + std::vector energy_bins; + std::vector energy_bin_avg; + std::vector rev_energy_bins; + + MgxsInterface() = default; + + // Construct from path to cross sections file + MgxsInterface(const std::string& path_cross_sections); + + void init(const std::string& path_cross_sections); + + void add_mgxs(hid_t file_id, const std::string& name, + const std::vector& temperature); + + void create_macro_xs(); + + std::vector> get_mat_kTs(); + + void read_mg_cross_sections_header(); +}; + namespace data { - -extern std::vector nuclides_MG; -extern std::vector macro_xs; -extern int num_energy_groups; -extern int num_delayed_groups; -extern std::vector energy_bins; -extern std::vector energy_bin_avg; -extern std::vector rev_energy_bins; - -} // namespace data - -//============================================================================== -// Mgxs data loading interface methods -//============================================================================== - -void read_mgxs(); - -void -add_mgxs(hid_t file_id, const std::string& name, - const std::vector& temperature); - -void create_macro_xs(); - -std::vector> get_mat_kTs(); - -void read_mg_cross_sections_header(); + extern MgxsInterface mgInterface; +} //============================================================================== // Mgxs tracking/transport/tallying interface methods diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index 3c29dd8e6..e5315b9fd 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -155,7 +155,7 @@ void read_cross_sections_xml() if (settings::run_CE) { read_ce_cross_sections_xml(); } else { - read_mg_cross_sections_header(); + data::mgInterface.read_mg_cross_sections_header(); } // Establish mapping between (type, material) and index in libraries diff --git a/src/initialize.cpp b/src/initialize.cpp index fd524a2de..203b5fe91 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -260,8 +260,8 @@ void read_input_xml() read_ce_cross_sections(nuc_temps, thermal_temps); } else { // Create material macroscopic data for MGXS - read_mgxs(); - create_macro_xs(); + data::mgInterface.init(settings::path_cross_sections); + data::mgInterface.create_macro_xs(); } simulation::time_read_xs.stop(); } diff --git a/src/material.cpp b/src/material.cpp index 9a1e206ac..e4579e10e 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -368,7 +368,7 @@ void Material::normalize_density() // determine atomic weight ratio int i_nuc = nuclide_[i]; double awr = settings::run_CE ? - data::nuclides[i_nuc]->awr_ : data::nuclides_MG[i_nuc].awr; + data::nuclides[i_nuc]->awr_ : data::mgInterface.nuclides_MG[i_nuc].awr; // if given weight percent, convert all values so that they are divided // by awr. thus, when a sum is done over the values, it's actually @@ -388,7 +388,7 @@ void Material::normalize_density() for (int i = 0; i < nuclide_.size(); ++i) { int i_nuc = nuclide_[i]; double awr = settings::run_CE ? - data::nuclides[i_nuc]->awr_ : data::nuclides_MG[i_nuc].awr; + data::nuclides[i_nuc]->awr_ : data::mgInterface.nuclides_MG[i_nuc].awr; sum_percent += atom_density_(i)*awr; } sum_percent = 1.0 / sum_percent; @@ -726,7 +726,7 @@ void Material::init_bremsstrahlung() void Material::init_nuclide_index() { int n = settings::run_CE ? - data::nuclides.size() : data::nuclides_MG.size(); + data::nuclides.size() : data::mgInterface.nuclides_MG.size(); mat_nuclide_index_.resize(n); std::fill(mat_nuclide_index_.begin(), mat_nuclide_index_.end(), C_NONE); for (int i = 0; i < nuclide_.size(); ++i) { @@ -994,11 +994,11 @@ void Material::to_hdf5(hid_t group) const } else { for (int i = 0; i < nuclide_.size(); ++i) { int i_nuc = nuclide_[i]; - if (data::nuclides_MG[i_nuc].awr != MACROSCOPIC_AWR) { - nuc_names.push_back(data::nuclides_MG[i_nuc].name); + if (data::mgInterface.nuclides_MG[i_nuc].awr != MACROSCOPIC_AWR) { + nuc_names.push_back(data::mgInterface.nuclides_MG[i_nuc].name); nuc_densities.push_back(atom_density_(i)); } else { - macro_names.push_back(data::nuclides_MG[i_nuc].name); + macro_names.push_back(data::mgInterface.nuclides_MG[i_nuc].name); } } } diff --git a/src/mgxs.cpp b/src/mgxs.cpp index 1fca66308..83adfd0b4 100644 --- a/src/mgxs.cpp +++ b/src/mgxs.cpp @@ -24,18 +24,6 @@ namespace openmc { -//============================================================================== -// Global variables -//============================================================================== - -namespace data { - -// Storage for the MGXS data -std::vector nuclides_MG; -std::vector macro_xs; - -} // namespace data - //============================================================================== // Mgxs base-class methods //============================================================================== @@ -53,8 +41,6 @@ Mgxs::init(const std::string& in_name, double in_awr, kTs = xt::adapt(in_kTs); fissionable = in_fissionable; scatter_format = in_scatter_format; - num_groups = data::num_energy_groups; - num_delayed_groups = data::num_delayed_groups; xs.resize(in_kTs.size()); is_isotropic = in_is_isotropic; n_pol = in_polar.size(); @@ -284,7 +270,10 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector& temperature, //============================================================================== -Mgxs::Mgxs(hid_t xs_id, const std::vector& temperature) +Mgxs::Mgxs(hid_t xs_id, const std::vector& temperature, + int num_group, int num_delay) : + num_groups(num_group), + num_delayed_groups(num_delay) { // Call generic data gathering routine (will populate the metadata) int order_data; @@ -317,7 +306,10 @@ Mgxs::Mgxs(hid_t xs_id, const std::vector& temperature) //============================================================================== Mgxs::Mgxs(const std::string& in_name, const std::vector& mat_kTs, - const std::vector& micros, const std::vector& atom_densities) + const std::vector& micros, const std::vector& atom_densities, + int num_group, int num_delay) : + num_groups(num_group), + num_delayed_groups(num_delay) { // Get the minimum data needed to initialize: // Dont need awr, but lets just initialize it anyways diff --git a/src/mgxs_interface.cpp b/src/mgxs_interface.cpp index 29e5e8b36..befa94682 100644 --- a/src/mgxs_interface.cpp +++ b/src/mgxs_interface.cpp @@ -18,30 +18,25 @@ namespace openmc { -//============================================================================== -// Global variable definitions -//============================================================================== - -namespace data { - -int num_energy_groups; -int num_delayed_groups; -std::vector energy_bins; -std::vector energy_bin_avg; -std::vector rev_energy_bins; - -} // namesapce data - //============================================================================== // Mgxs data loading interface methods //============================================================================== -void read_mgxs() +namespace data { + MgxsInterface mgInterface; +} + +MgxsInterface::MgxsInterface(const std::string& path_cross_sections) +{ + init(path_cross_sections); +} + +void MgxsInterface::init(const std::string& path_cross_sections) { // Check if MGXS Library exists - if (!file_exists(settings::path_cross_sections)) { + if (!file_exists(path_cross_sections)) { // Could not find MGXS Library file - fatal_error("Cross sections HDF5 file '" + settings::path_cross_sections + + fatal_error("Cross sections HDF5 file '" + path_cross_sections + "' does not exist."); } @@ -53,7 +48,7 @@ void read_mgxs() get_temperatures(nuc_temps, dummy); // Open file for reading - hid_t file_id = file_open(settings::path_cross_sections, 'r'); + hid_t file_id = file_open(path_cross_sections, 'r'); // Read filetype std::string type; @@ -92,7 +87,7 @@ void read_mgxs() already_read.insert(name); } - if (data::nuclides_MG[i_nuc].fissionable) { + if (nuclides_MG[i_nuc].fissionable) { mat->fissionable_ = true; } } @@ -104,7 +99,7 @@ void read_mgxs() //============================================================================== void -add_mgxs(hid_t file_id, const std::string& name, +MgxsInterface::add_mgxs(hid_t file_id, const std::string& name, const std::vector& temperature) { write_message("Loading " + std::string(name) + " data...", 6); @@ -118,13 +113,14 @@ add_mgxs(hid_t file_id, const std::string& name, + "provided MGXS Library"); } - data::nuclides_MG.emplace_back(xs_grp, temperature); + nuclides_MG.emplace_back(xs_grp, temperature, num_energy_groups, + num_delayed_groups); close_group(xs_grp); } //============================================================================== -void create_macro_xs() +void MgxsInterface::create_macro_xs() { // Get temperatures to read for each material auto kTs = get_mat_kTs(); @@ -144,20 +140,21 @@ void create_macro_xs() // material std::vector mgxs_ptr; for (int i_nuclide : mat->nuclide_) { - mgxs_ptr.push_back(&data::nuclides_MG[i_nuclide]); + mgxs_ptr.push_back(&nuclides_MG[i_nuclide]); } - data::macro_xs.emplace_back(mat->name_, kTs[i], mgxs_ptr, atom_densities); + macro_xs.emplace_back(mat->name_, kTs[i], mgxs_ptr, atom_densities, + num_energy_groups, num_delayed_groups); } else { // Preserve the ordering of materials by including a blank entry - data::macro_xs.emplace_back(); + macro_xs.emplace_back(); } } } //============================================================================== -std::vector> get_mat_kTs() +std::vector> MgxsInterface::get_mat_kTs() { std::vector> kTs(model::materials.size()); @@ -186,7 +183,7 @@ std::vector> get_mat_kTs() //============================================================================== -void read_mg_cross_sections_header() +void MgxsInterface::read_mg_cross_sections_header() { // Check if MGXS Library exists if (!file_exists(settings::path_cross_sections)) { @@ -200,24 +197,25 @@ void read_mg_cross_sections_header() hid_t file_id = file_open(settings::path_cross_sections, 'r', true); ensure_exists(file_id, "energy_groups", true); - read_attribute(file_id, "energy_groups", data::num_energy_groups); + read_attribute(file_id, "energy_groups", num_energy_groups); if (attribute_exists(file_id, "delayed_groups")) { - read_attribute(file_id, "delayed_groups", data::num_delayed_groups); + read_attribute(file_id, "delayed_groups", num_delayed_groups); } else { - data::num_delayed_groups = 0; + num_delayed_groups = 0; } ensure_exists(file_id, "group structure", true); - read_attribute(file_id, "group structure", data::rev_energy_bins); + read_attribute(file_id, "group structure", rev_energy_bins); // Reverse energy bins - std::copy(data::rev_energy_bins.crbegin(), data::rev_energy_bins.crend(), - std::back_inserter(data::energy_bins)); + std::copy(rev_energy_bins.crbegin(), rev_energy_bins.crend(), + std::back_inserter(data::mgInterface.energy_bins)); // Create average energies - for (int i = 0; i < data::energy_bins.size() - 1; ++i) { - data::energy_bin_avg.push_back(0.5*(data::energy_bins[i] + data::energy_bins[i+1])); + for (int i = 0; i < data::mgInterface.energy_bins.size() - 1; ++i) { + data::mgInterface.energy_bin_avg.push_back(0.5* + (data::mgInterface.energy_bins[i] + data::mgInterface.energy_bins[i+1])); } // Add entries into libraries for MG data @@ -236,8 +234,8 @@ void read_mg_cross_sections_header() // Get the minimum and maximum energies int neutron = static_cast(Particle::Type::neutron); - data::energy_min[neutron] = data::energy_bins.back(); - data::energy_max[neutron] = data::energy_bins.front(); + data::energy_min[neutron] = data::mgInterface.energy_bins.back(); + data::energy_max[neutron] = data::mgInterface.energy_bins.front(); // Close MGXS HDF5 file file_close(file_id); @@ -251,7 +249,7 @@ void calculate_xs_c(int i_mat, int gin, double sqrtkT, Direction u, double& total_xs, double& abs_xs, double& nu_fiss_xs) { - data::macro_xs[i_mat].calculate_xs(gin - 1, sqrtkT, u, total_xs, abs_xs, + data::mgInterface.macro_xs[i_mat].calculate_xs(gin - 1, sqrtkT, u, total_xs, abs_xs, nu_fiss_xs); } @@ -269,7 +267,7 @@ get_nuclide_xs(int index, int xstype, int gin, const int* gout, } else { gout_c_p = gout; } - return data::nuclides_MG[index].get_xs(xstype, gin - 1, gout_c_p, mu, dg); + return data::mgInterface.nuclides_MG[index].get_xs(xstype, gin - 1, gout_c_p, mu, dg); } //============================================================================== @@ -286,7 +284,7 @@ get_macro_xs(int index, int xstype, int gin, const int* gout, } else { gout_c_p = gout; } - return data::macro_xs[index].get_xs(xstype, gin - 1, gout_c_p, mu, dg); + return data::mgInterface.macro_xs[index].get_xs(xstype, gin - 1, gout_c_p, mu, dg); } //============================================================================== @@ -301,7 +299,7 @@ get_name_c(int index, int name_len, char* name) std::strcpy(name, str.c_str()); // Now get the data and copy to the C-string - str = data::nuclides_MG[index - 1].name; + str = data::mgInterface.nuclides_MG[index - 1].name; std::strcpy(name, str.c_str()); // Finally, remove the null terminator @@ -313,7 +311,7 @@ get_name_c(int index, int name_len, char* name) double get_awr_c(int index) { - return data::nuclides_MG[index - 1].awr; + return data::mgInterface.nuclides_MG[index - 1].awr; } } // namespace openmc diff --git a/src/output.cpp b/src/output.cpp index d3262cc4d..8fb628e77 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -710,7 +710,7 @@ write_tallies() << data::nuclides[i_nuclide]->name_ << "\n"; } else { tallies_out << std::string(indent+1, ' ') - << data::nuclides_MG[i_nuclide].name << "\n"; + << data::mgInterface.nuclides_MG[i_nuclide].name << "\n"; } } diff --git a/src/particle.cpp b/src/particle.cpp index bf107a741..742f1ead3 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -123,7 +123,7 @@ Particle::from_source(const Bank* src) } else { g_ = static_cast(src->E); g_last_ = static_cast(src->E); - E_ = data::energy_bin_avg[g_ - 1]; + E_ = data::mgInterface.energy_bin_avg[g_ - 1]; } E_last_ = E_; } diff --git a/src/particle_restart.cpp b/src/particle_restart.cpp index b2017bbeb..87b0093d0 100644 --- a/src/particle_restart.cpp +++ b/src/particle_restart.cpp @@ -52,7 +52,7 @@ void read_particle_restart(Particle& p, int& previous_run_mode) // Set energy group and average energy in multi-group mode if (!settings::run_CE) { p.g_ = p.E_; - p.E_ = data::energy_bin_avg[p.g_ - 1]; + p.E_ = data::mgInterface.energy_bin_avg[p.g_ - 1]; } // Set particle last attributes diff --git a/src/physics_mg.cpp b/src/physics_mg.cpp index f99d15aac..e2682792f 100644 --- a/src/physics_mg.cpp +++ b/src/physics_mg.cpp @@ -82,7 +82,7 @@ scatter(Particle* p) int gin = p->g_last_ - 1; int gout = p->g_ - 1; int i_mat = p->material_; - data::macro_xs[i_mat].sample_scatter(gin, gout, p->mu_, p->wgt_); + data::mgInterface.macro_xs[i_mat].sample_scatter(gin, gout, p->mu_, p->wgt_); // Adjust return value for fortran indexing // TODO: Remove when no longer needed @@ -92,7 +92,7 @@ scatter(Particle* p) p->u() = rotate_angle(p->u(), p->mu_, nullptr); // Update energy value for downstream compatability (in tallying) - p->E_ = data::energy_bin_avg[gout]; + p->E_ = data::mgInterface.energy_bin_avg[gout]; // Set event component p->event_ = EVENT_SCATTER; @@ -148,7 +148,7 @@ create_fission_sites(Particle* p, std::vector& bank) // the energy in the fission bank int dg; int gout; - data::macro_xs[p->material_].sample_fission_energy(p->g_ - 1, dg, gout); + data::mgInterface.macro_xs[p->material_].sample_fission_energy(p->g_ - 1, dg, gout); site.E = gout + 1; site.delayed_group = dg + 1; diff --git a/src/source.cpp b/src/source.cpp index 0baa21b17..f495d5572 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -311,9 +311,9 @@ Particle::Bank sample_external_source() // If running in MG, convert site % E to group if (!settings::run_CE) { - site.E = lower_bound_index(data::rev_energy_bins.begin(), - data::rev_energy_bins.end(), site.E); - site.E = data::num_energy_groups - site.E; + site.E = lower_bound_index(data::mgInterface.rev_energy_bins.begin(), + data::mgInterface.rev_energy_bins.end(), site.E); + site.E = data::mgInterface.num_energy_groups - site.E; } // Set the random number generator back to the tracking stream. diff --git a/src/state_point.cpp b/src/state_point.cpp index cd2c475d8..f0dcfe2b0 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -208,7 +208,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) if (settings::run_CE) { nuclides.push_back(data::nuclides[i_nuclide]->name_); } else { - nuclides.push_back(data::nuclides_MG[i_nuclide].name); + nuclides.push_back(data::mgInterface.nuclides_MG[i_nuclide].name); } } } diff --git a/src/summary.cpp b/src/summary.cpp index d2721f97e..0c6222cef 100644 --- a/src/summary.cpp +++ b/src/summary.cpp @@ -57,7 +57,7 @@ void write_nuclides(hid_t file) nuc_names.push_back(nuc->name_); awrs.push_back(nuc->awr_); } else { - const auto& nuc {data::nuclides_MG[i]}; + const auto& nuc {data::mgInterface.nuclides_MG[i]}; if (nuc.awr != MACROSCOPIC_AWR) { nuc_names.push_back(nuc.name); awrs.push_back(nuc.awr); diff --git a/src/tallies/filter_energy.cpp b/src/tallies/filter_energy.cpp index dde9b692a..d69b335b6 100644 --- a/src/tallies/filter_energy.cpp +++ b/src/tallies/filter_energy.cpp @@ -43,10 +43,10 @@ EnergyFilter::set_bins(gsl::span bins) // (after flipping for the different ordering of the library and tallying // systems). if (!settings::run_CE) { - if (n_bins_ == data::num_energy_groups) { + if (n_bins_ == data::mgInterface.num_energy_groups) { matches_transport_groups_ = true; for (gsl::index i = 0; i < n_bins_ + 1; ++i) { - if (data::rev_energy_bins[i] != bins_[i]) { + if (data::mgInterface.rev_energy_bins[i] != bins_[i]) { matches_transport_groups_ = false; break; } @@ -61,9 +61,9 @@ const { if (p->g_ != F90_NONE && matches_transport_groups_) { if (estimator == ESTIMATOR_TRACKLENGTH) { - match.bins_.push_back(data::num_energy_groups - p->g_); + match.bins_.push_back(data::mgInterface.num_energy_groups - p->g_); } else { - match.bins_.push_back(data::num_energy_groups - p->g_last_); + match.bins_.push_back(data::mgInterface.num_energy_groups - p->g_last_); } match.weights_.push_back(1.0); @@ -104,7 +104,7 @@ EnergyoutFilter::get_all_bins(const Particle* p, int estimator, FilterMatch& match) const { if (p->g_ != F90_NONE && matches_transport_groups_) { - match.bins_.push_back(data::num_energy_groups - p->g_); + match.bins_.push_back(data::mgInterface.num_energy_groups - p->g_); match.weights_.push_back(1.0); } else { diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index 37310070f..bd31960be 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -361,7 +361,7 @@ score_fission_eout(const Particle* p, int i_tally, int i_score, int score_bin) if (settings::run_CE) { E_out = bank.E; } else { - E_out = data::energy_bin_avg[static_cast(bank.E)]; + E_out = data::mgInterface.energy_bin_avg[static_cast(bank.E)]; } // Set EnergyoutFilter bin index @@ -1376,13 +1376,13 @@ score_general_mg(const Particle* p, int i_tally, int start_index, // To significantly reduce de-referencing, point matxs to the macroscopic // Mgxs for the material of interest - data::macro_xs[p->material_].set_angle_index(p_u); + data::mgInterface.macro_xs[p->material_].set_angle_index(p_u); // Do same for nucxs, point it to the microscopic nuclide data of interest if (i_nuclide >= 0) { // And since we haven't calculated this temperature index yet, do so now - data::nuclides_MG[i_nuclide].set_temperature_index(p->sqrtkT_); - data::nuclides_MG[i_nuclide].set_angle_index(p_u); + data::mgInterface.nuclides_MG[i_nuclide].set_temperature_index(p->sqrtkT_); + data::mgInterface.nuclides_MG[i_nuclide].set_angle_index(p_u); } for (auto i = 0; i < tally.scores_.size(); ++i) { @@ -1869,7 +1869,7 @@ score_general_mg(const Particle* p, int i_tally, int start_index, // delayed-nu-fission xs to the absorption xs for all delayed // groups score = 0.; - for (auto d = 0; d < data::num_delayed_groups; ++d) { + for (auto d = 0; d < data::mgInterface.num_delayed_groups; ++d) { if (i_nuclide >= 0) { score += p->wgt_absorb_ * flux * get_nuclide_xs(i_nuclide, MG_GET_XS_DECAY_RATE, @@ -1960,7 +1960,7 @@ score_general_mg(const Particle* p, int i_tally, int start_index, continue; } else { score = 0.; - for (auto d = 0; d < data::num_delayed_groups; ++d) { + for (auto d = 0; d < data::mgInterface.num_delayed_groups; ++d) { if (i_nuclide >= 0) { score += atom_density * flux * get_nuclide_xs(i_nuclide, MG_GET_XS_DECAY_RATE, diff --git a/src/xsdata.cpp b/src/xsdata.cpp index cee36a938..ab6fb52d0 100644 --- a/src/xsdata.cpp +++ b/src/xsdata.cpp @@ -27,8 +27,8 @@ namespace openmc { XsData::XsData(bool fissionable, int scatter_format, int n_pol, int n_azi) { size_t n_ang = n_pol * n_azi; - size_t n_dg = data::num_delayed_groups; - size_t n_g = data::num_energy_groups; + size_t n_dg = data::mgInterface.num_delayed_groups; + size_t n_g = data::mgInterface.num_energy_groups; // check to make sure scatter format is OK before we allocate if (scatter_format != ANGLE_HISTOGRAM && scatter_format != ANGLE_TABULAR && @@ -127,8 +127,8 @@ XsData::fission_vector_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, { // Data is provided as nu-fission and chi with a beta for delayed info - size_t n_g = data::num_energy_groups; - size_t n_dg = data::num_delayed_groups; + size_t n_g = data::mgInterface.num_energy_groups; + size_t n_dg = data::mgInterface.num_delayed_groups; // Get chi xt::xtensor temp_chi({n_ang, n_g}, 0.); @@ -182,8 +182,8 @@ XsData::fission_vector_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang) { // Data is provided separately as prompt + delayed nu-fission and chi - size_t n_g = data::num_energy_groups; - size_t n_dg = data::num_delayed_groups; + size_t n_g = data::mgInterface.num_energy_groups; + size_t n_dg = data::mgInterface.num_delayed_groups; // Get chi-prompt xt::xtensor temp_chi_p({n_ang, n_g}, 0.); @@ -218,7 +218,7 @@ XsData::fission_vector_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang) // No beta is provided and there is no prompt/delay distinction. // Therefore, the code only considers the data as prompt. - size_t n_g = data::num_energy_groups; + size_t n_g = data::mgInterface.num_energy_groups; // Get chi xt::xtensor temp_chi({n_ang, n_g}, 0.); @@ -241,8 +241,8 @@ XsData::fission_matrix_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_is { // Data is provided as nu-fission and chi with a beta for delayed info - size_t n_g = data::num_energy_groups; - size_t n_dg = data::num_delayed_groups; + size_t n_g = data::mgInterface.num_energy_groups; + size_t n_dg = data::mgInterface.num_delayed_groups; // Get nu-fission matrix xt::xtensor temp_matrix({n_ang, n_g, n_g}, 0.); @@ -319,8 +319,8 @@ XsData::fission_matrix_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang) { // Data is provided separately as prompt + delayed nu-fission and chi - size_t n_g = data::num_energy_groups; - size_t n_dg = data::num_delayed_groups; + size_t n_g = data::mgInterface.num_energy_groups; + size_t n_dg = data::mgInterface.num_delayed_groups; // Get the prompt nu-fission matrix xt::xtensor temp_matrix_p({n_ang, n_g, n_g}, 0.); @@ -353,7 +353,7 @@ XsData::fission_matrix_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang) // No beta is provided and there is no prompt/delay distinction. // Therefore, the code only considers the data as prompt. - size_t n_g = data::num_energy_groups; + size_t n_g = data::mgInterface.num_energy_groups; // Get nu-fission matrix xt::xtensor temp_matrix({n_ang, n_g, n_g}, 0.); @@ -381,7 +381,7 @@ XsData::fission_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_isotropic) // as a nu-fission matrix or a set of chi and nu-fission vectors if (object_exists(xsdata_grp, "chi") || object_exists(xsdata_grp, "chi-prompt")) { - if (data::num_delayed_groups == 0) { + if (data::mgInterface.num_delayed_groups == 0) { fission_vector_no_delayed_from_hdf5(xsdata_grp, n_ang); } else { if (object_exists(xsdata_grp, "beta")) { @@ -391,7 +391,7 @@ XsData::fission_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_isotropic) } } } else { - if (data::num_delayed_groups == 0) { + if (data::mgInterface.num_delayed_groups == 0) { fission_matrix_no_delayed_from_hdf5(xsdata_grp, n_ang); } else { if (object_exists(xsdata_grp, "beta")) { @@ -403,7 +403,7 @@ XsData::fission_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_isotropic) } // Combine prompt_nu_fission and delayed_nu_fission into nu_fission - if (data::num_delayed_groups == 0) { + if (data::mgInterface.num_delayed_groups == 0) { nu_fission = prompt_nu_fission; } else { nu_fission = prompt_nu_fission + xt::sum(delayed_nu_fission, {1}); @@ -422,7 +422,7 @@ XsData::scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, hid_t scatt_grp = open_group(xsdata_grp, "scatter_data"); // Get the outgoing group boundary indices - size_t n_g = data::num_energy_groups; + size_t n_g = data::mgInterface.num_energy_groups; xt::xtensor gmin({n_ang, n_g}, 0.); read_nd_vector(scatt_grp, "g_min", gmin, true); xt::xtensor gmax({n_ang, n_g}, 0.);