Added test of volume calc from MG mode, then corrected 2 issues: the first led to #1698, the second led to the test failing as volume calcs need atom densities but they existed in a different location in MG mode. To fix the former, if blocks were placed to point to the MG nuclide data as necessary, and the latter by calling Material.finalize() at the appropriate spot in the MG code

This commit is contained in:
agnelson 2021-10-05 14:12:31 -05:00
parent adc935b99d
commit 75fd0a7f78
4 changed files with 29 additions and 18 deletions

View file

@ -349,24 +349,26 @@ Material::~Material()
void Material::finalize()
{
// Set fissionable if any nuclide is fissionable
for (const auto& i_nuc : nuclide_) {
if (data::nuclides[i_nuc]->fissionable_) {
fissionable_ = true;
break;
if (settings::run_CE) {
for (const auto& i_nuc : nuclide_) {
if (data::nuclides[i_nuc]->fissionable_) {
fissionable_ = true;
break;
}
}
// Generate material bremsstrahlung data for electrons and positrons
if (settings::photon_transport &&
settings::electron_treatment == ElectronTreatment::TTB) {
this->init_bremsstrahlung();
}
// Assign thermal scattering tables
this->init_thermal();
}
// Generate material bremsstrahlung data for electrons and positrons
if (settings::photon_transport &&
settings::electron_treatment == ElectronTreatment::TTB) {
this->init_bremsstrahlung();
}
// Assign thermal scattering tables
this->init_thermal();
// Normalize density
this->normalize_density();
// Normalize density
this->normalize_density();
}
void Material::normalize_density()

View file

@ -123,10 +123,14 @@ void MgxsInterface::create_macro_xs()
// 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) {
// First we have to normalize the densities as it has not been called yet
// for MG mode
auto& mat {model::materials[i]};
mat->finalize();
if (kTs[i].size() > 0) {
// Convert atom_densities to a vector
auto& mat {model::materials[i]};
vector<double> atom_densities(
mat->atom_density_.begin(), mat->atom_density_.end());

View file

@ -8,6 +8,7 @@
#include "openmc/hdf5_interface.h"
#include "openmc/material.h"
#include "openmc/message_passing.h"
#include "openmc/mgxs_interface.h"
#include "openmc/nuclide.h"
#include "openmc/output.h"
#include "openmc/random_lcg.h"
@ -237,7 +238,8 @@ vector<VolumeCalculation::Result> VolumeCalculation::execute() const
// Create 2D array to store atoms/uncertainty for each nuclide. Later this
// is compressed into vectors storing only those nuclides that are
// non-zero
auto n_nuc = data::nuclides.size();
auto n_nuc = settings::run_CE ? data::nuclides.size()
: data::mg.nuclides_.size();
xt::xtensor<double, 2> atoms({n_nuc, 2}, 0.0);
#ifdef OPENMC_MPI
@ -442,7 +444,8 @@ void VolumeCalculation::to_hdf5(
vector<std::string> nucnames;
for (int i_nuc : result.nuclides) {
nucnames.push_back(data::nuclides[i_nuc]->name_);
nucnames.push_back(settings::run_CE ? data::nuclides[i_nuc]->name_
: data::mg.nuclides_[i_nuc].name);
}
// Create array of total # of atoms with uncertainty for each nuclide

View file

@ -100,6 +100,8 @@ class VolumeTest(PyAPITestHarness):
for iso in ['H1', 'O16', 'B10', 'Mo99', 'U235']:
mat = openmc.XSdata(iso, groups)
mat.order = 0
mat.atomic_weight_ratio = \
openmc.data.atomic_mass(iso) / openmc.data.NEUTRON_MASS
mat.set_scatter_matrix(scatter)
if iso == 'U235':
mat.set_nu_fission(np.multiply(nu, fiss))