mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Move remaining functions in mgxs_data.F90
This commit is contained in:
parent
06751d5373
commit
eb576a6fd2
6 changed files with 57 additions and 147 deletions
|
|
@ -3,7 +3,9 @@
|
|||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/cross_sections.h"
|
||||
#include "openmc/container_util.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/file_utils.h"
|
||||
#include "openmc/geometry_aux.h"
|
||||
|
|
@ -84,7 +86,7 @@ void read_mgxs()
|
|||
std::string& name = nuclide_names[i_nuc];
|
||||
|
||||
if (already_read.find(name) == already_read.end()) {
|
||||
add_mgxs_c(file_id, name, nuc_temps[i_nuc]);
|
||||
add_mgxs(file_id, name, nuc_temps[i_nuc]);
|
||||
already_read.insert(name);
|
||||
}
|
||||
|
||||
|
|
@ -97,8 +99,10 @@ void read_mgxs()
|
|||
file_close(file_id);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
add_mgxs_c(hid_t file_id, const std::string& name,
|
||||
add_mgxs(hid_t file_id, const std::string& name,
|
||||
const std::vector<double>& temperature)
|
||||
{
|
||||
write_message("Loading " + std::string(name) + " data...", 6);
|
||||
|
|
@ -118,43 +122,64 @@ add_mgxs_c(hid_t file_id, const std::string& name,
|
|||
|
||||
//==============================================================================
|
||||
|
||||
bool
|
||||
query_fissionable_c(int n_nuclides, const int i_nuclides[])
|
||||
void create_macro_xs()
|
||||
{
|
||||
bool result = false;
|
||||
for (int n = 0; n < n_nuclides; n++) {
|
||||
if (data::nuclides_MG[i_nuclides[n] - 1].fissionable) result = true;
|
||||
// Get temperatures to read for each material
|
||||
auto kTs = get_mat_kTs();
|
||||
|
||||
// Force all nuclides in a material to be the same representation.
|
||||
// Therefore type(nuclides[mat->nuclide_[0]]) dictates type(macroxs).
|
||||
// At the same time, we will find the scattering type, as that will dictate
|
||||
// how we allocate the scatter object within macroxs.
|
||||
for (int i = 0; i < model::materials.size(); ++i) {
|
||||
if (kTs[i].size() > 0) {
|
||||
// Convert atom_densities to a vector
|
||||
Material* mat = model::materials[i];
|
||||
std::vector<double> atom_densities(mat->atom_density_.begin(),
|
||||
mat->atom_density_.end());
|
||||
|
||||
// Build array of pointers to nuclides_MG's Mgxs objects needed for this
|
||||
// material
|
||||
std::vector<Mgxs*> mgxs_ptr;
|
||||
for (int i_nuclide : mat->nuclide_) {
|
||||
mgxs_ptr.push_back(&data::nuclides_MG[i_nuclide]);
|
||||
}
|
||||
|
||||
data::macro_xs.emplace_back(mat->name_, kTs[i], mgxs_ptr, atom_densities);
|
||||
} else {
|
||||
// Preserve the ordering of materials by including a blank entry
|
||||
data::macro_xs.emplace_back();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
create_macro_xs_c(const char* mat_name, int n_nuclides, const int i_nuclides[],
|
||||
int n_temps, const double temps[], const double atom_densities[],
|
||||
double tolerance, int& method)
|
||||
std::vector<std::vector<double>> get_mat_kTs()
|
||||
{
|
||||
if (n_temps > 0) {
|
||||
// // Convert temps to a vector
|
||||
std::vector<double> temperature(temps, temps + n_temps);
|
||||
std::vector<std::vector<double>> kTs(model::materials.size());
|
||||
|
||||
// Convert atom_densities to a vector
|
||||
std::vector<double> atom_densities_vec(atom_densities,
|
||||
atom_densities + n_nuclides);
|
||||
for (const auto& cell : model::cells) {
|
||||
// Skip non-material cells
|
||||
if (cell->fill_ != C_NONE) continue;
|
||||
|
||||
// Build array of pointers to nuclides_MG's Mgxs objects needed for this
|
||||
// material
|
||||
std::vector<Mgxs*> mgxs_ptr(n_nuclides);
|
||||
for (int n = 0; n < n_nuclides; n++) {
|
||||
mgxs_ptr[n] = &data::nuclides_MG[i_nuclides[n] - 1];
|
||||
for (int j = 0; j < cell->material_.size(); ++j) {
|
||||
// Skip void materials
|
||||
int i_material = cell->material_[j];
|
||||
if (i_material == MATERIAL_VOID) continue;
|
||||
|
||||
// Get temperature of cell (rounding to nearest integer)
|
||||
double sqrtkT = cell->sqrtkT_.size() == 1 ?
|
||||
cell->sqrtkT_[j] : cell->sqrtkT_[0];
|
||||
double kT = sqrtkT * sqrtkT;
|
||||
|
||||
// Add temperature if it hasn't already been added
|
||||
if (!contains(kTs[i_material], kT)) {
|
||||
kTs[i_material].push_back(kT);
|
||||
}
|
||||
}
|
||||
|
||||
data::macro_xs.emplace_back(mat_name, temperature, mgxs_ptr, atom_densities_vec);
|
||||
} else {
|
||||
// Preserve the ordering of materials by including a blank entry
|
||||
data::macro_xs.emplace_back();
|
||||
}
|
||||
return kTs;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue