Skip to content
6 changes: 3 additions & 3 deletions include/openmc/mgxs.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ class Mgxs {
//!
//! @param xs_id HDF5 group id for the cross section data.
//! @param temperature Temperatures to read.
//! @param num_group number of energy groups
//! @param energy_bins energy bins
//! @param num_delay number of delayed groups
Mgxs(hid_t xs_id, const vector<double>& temperature, int num_group,
int num_delay);
Mgxs(hid_t xs_id, const vector<double>& temperature,
const vector<double>& energy_bins, int num_delay);

//! \brief Constructor that initializes and populates all data to build a
//! macroscopic cross section from microscopic cross sections.
Expand Down
1 change: 1 addition & 0 deletions include/openmc/mgxs_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class MgxsInterface {
vector<double> energy_bin_avg_;
vector<double> rev_energy_bins_;
vector<vector<double>> nuc_temps_; // all available temperatures
vector<double> void_velocities_; // velocity of particles in void regions
};

namespace data {
Expand Down
3 changes: 2 additions & 1 deletion include/openmc/xsdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ class XsData {
//! the incoming particle.
//! @param n_pol Number of polar angles.
//! @param n_azi Number of azimuthal angles.
//! @param energy_bins energy bins of XsData
void from_hdf5(hid_t xsdata_grp, bool fissionable,
AngleDistributionType scatter_format,
AngleDistributionType final_scatter_format, int order_data,
bool is_isotropic, int n_pol, int n_azi);
bool is_isotropic, int n_pol, int n_azi, const vector<double>& energy_bins);

//! \brief Combines the microscopic data to a macroscopic object.
//!
Expand Down
6 changes: 3 additions & 3 deletions openmc/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def fill_cube(N, n_1, n_2, fill_1, fill_2, fill_3):

void_sigma_a = 4.0e-6
void_sigma_s = 3.0e-4
void_mat_data = openmc.XSdata('void', groups)
void_mat_data = openmc.XSdata('approx void', groups)
void_mat_data.order = 0
void_mat_data.set_total([void_sigma_a + void_sigma_s])
void_mat_data.set_absorption([void_sigma_a])
Expand Down Expand Up @@ -1097,15 +1097,15 @@ def fill_cube(N, n_1, n_2, fill_1, fill_2, fill_3):

# Instantiate some Macroscopic Data
source_data = openmc.Macroscopic('source')
void_data = openmc.Macroscopic('void')
void_data = openmc.Macroscopic('approx void')
absorber_data = openmc.Macroscopic('absorber')

# Instantiate some Materials and register the appropriate Macroscopic objects
source_mat = openmc.Material(name='source')
source_mat.set_density('macro', 1.0)
source_mat.add_macroscopic(source_data)

void_mat = openmc.Material(name='void')
void_mat = openmc.Material(name='approx void')
void_mat.set_density('macro', 1.0)
void_mat.add_macroscopic(void_data)

Expand Down
83 changes: 77 additions & 6 deletions openmc/mgxs_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import openmc.mgxs
from openmc.mgxs import SCATTER_TABULAR, SCATTER_LEGENDRE, SCATTER_HISTOGRAM
from .checkvalue import check_type, check_value, check_greater_than, \
check_iterable_type, check_less_than, check_filetype_version, PathLike
check_iterable_type, check_length, check_less_than, check_filetype_version, PathLike

ROOM_TEMPERATURE_KELVIN = 294.0

Expand Down Expand Up @@ -177,7 +177,9 @@ class XSdata:
def __init__(self, name, energy_groups, temperatures=[ROOM_TEMPERATURE_KELVIN],
representation=REPRESENTATION_ISOTROPIC, num_delayed_groups=0):

# Initialize class attributes
self._is_void = False

#Initialize class attributes
self.name = name
self.energy_groups = energy_groups
self.num_delayed_groups = num_delayed_groups
Expand Down Expand Up @@ -212,6 +214,7 @@ def __deepcopy__(self, memo):
# If this is the first time we have tried to copy this object, copy it
if existing is None:
clone = type(self).__new__(type(self))
clone._is_void = self._is_void
clone._name = self.name
clone._energy_groups = copy.deepcopy(self.energy_groups, memo)
clone._num_delayed_groups = self.num_delayed_groups
Expand Down Expand Up @@ -260,6 +263,9 @@ def name(self):
def name(self, name):

check_type('name for XSdata', name, str)
if name == 'void':
self._is_void = True

self._name = name

@property
Expand Down Expand Up @@ -322,6 +328,8 @@ def temperatures(self):

@temperatures.setter
def temperatures(self, temperatures):
if self._is_void:
check_length('temperatures', temperatures, 1, 1)

check_iterable_type('temperatures', temperatures, Real)
self._temperatures = np.array(temperatures)
Expand Down Expand Up @@ -481,6 +489,8 @@ def add_temperature(self, temperature):
Temperature (in units of Kelvin) of the provided dataset.

"""
if self._is_void:
raise TypeError('Cannot add temperatures to a void xs')

check_type('temperature', temperature, Real)

Expand Down Expand Up @@ -532,6 +542,8 @@ def set_total(self, total, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_total_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set total xs in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
Expand Down Expand Up @@ -561,6 +573,8 @@ def set_absorption(self, absorption, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_absorption_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set absorption xs in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
Expand Down Expand Up @@ -590,6 +604,8 @@ def set_fission(self, fission, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_fission_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set fission xs in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
Expand Down Expand Up @@ -621,6 +637,8 @@ def set_kappa_fission(self, kappa_fission, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_kappa_fission_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set kappa-fission xs in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
Expand Down Expand Up @@ -652,6 +670,8 @@ def set_chi(self, chi, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_chi_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set chi in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G']"]]
Expand Down Expand Up @@ -681,6 +701,8 @@ def set_chi_prompt(self, chi_prompt, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_chi_prompt_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set chi-prompt in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G']"]]
Expand Down Expand Up @@ -710,6 +732,8 @@ def set_chi_delayed(self, chi_delayed, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_chi_delayed_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set chi-delayed in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G']"], self.xs_shapes["[DG][G']"]]
Expand Down Expand Up @@ -741,6 +765,8 @@ def set_beta(self, beta, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_beta_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set beta in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[DG]"], self.xs_shapes["[DG][G]"]]
Expand Down Expand Up @@ -770,6 +796,8 @@ def set_decay_rate(self, decay_rate, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_decay_rate_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set decay rate in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[DG]"]]
Expand Down Expand Up @@ -799,6 +827,8 @@ def set_scatter_matrix(self, scatter, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_scatter_matrix_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set scatter matrix in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G][G'][Order]"]]
Expand Down Expand Up @@ -830,6 +860,8 @@ def set_multiplicity_matrix(self, multiplicity, temperature=ROOM_TEMPERATURE_KEL
openmc.mgxs_library.set_multiplicity_matrix_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set multiplicity matrix in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G][G']"]]
Expand Down Expand Up @@ -861,6 +893,8 @@ def set_nu_fission(self, nu_fission, temperature=ROOM_TEMPERATURE_KELVIN):
openmc.mgxs_library.set_nu_fission_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set nu-fission in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"], self.xs_shapes["[G][G']"]]
Expand Down Expand Up @@ -893,6 +927,8 @@ def set_prompt_nu_fission(self, prompt_nu_fission, temperature=ROOM_TEMPERATURE_
openmc.mgxs_library.set_prompt_nu_fission_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set prompt nu-fission in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"], self.xs_shapes["[G][G']"]]
Expand Down Expand Up @@ -925,6 +961,8 @@ def set_delayed_nu_fission(self, delayed_nu_fission, temperature=ROOM_TEMPERATUR
openmc.mgxs_library.set_delayed_nu_fission_mgxs()

"""
if self._is_void:
raise TypeError('Cannot set delayed nu-fission in a void')

# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[DG][G]"], self.xs_shapes["[DG][G][G']"]]
Expand Down Expand Up @@ -996,6 +1034,8 @@ def set_total_mgxs(self, total, temperature=ROOM_TEMPERATURE_KELVIN, nuclide='to
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set total xs in a void')

check_type('total', total, (openmc.mgxs.TotalXS,
openmc.mgxs.TransportXS))
Expand Down Expand Up @@ -1036,6 +1076,8 @@ def set_absorption_mgxs(self, absorption, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set absorption xs in a void')

check_type('absorption', absorption, openmc.mgxs.AbsorptionXS)
check_value('energy_groups', absorption.energy_groups,
Expand Down Expand Up @@ -1078,6 +1120,8 @@ def set_fission_mgxs(self, fission, temperature=ROOM_TEMPERATURE_KELVIN, nuclide
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set fission in a void')

check_type('fission', fission, openmc.mgxs.FissionXS)
check_value('energy_groups', fission.energy_groups,
Expand Down Expand Up @@ -1120,6 +1164,8 @@ def set_nu_fission_mgxs(self, nu_fission, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set nu-fission in a void')

check_type('nu_fission', nu_fission, (openmc.mgxs.FissionXS,
openmc.mgxs.NuFissionMatrixXS))
Expand Down Expand Up @@ -1171,6 +1217,8 @@ def set_prompt_nu_fission_mgxs(self, prompt_nu_fission, temperature=ROOM_TEMPERA
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set prompt nu-fission in a void')

check_type('prompt_nu_fission', prompt_nu_fission,
(openmc.mgxs.FissionXS, openmc.mgxs.NuFissionMatrixXS))
Expand Down Expand Up @@ -1218,6 +1266,8 @@ def set_delayed_nu_fission_mgxs(self, delayed_nu_fission, temperature=ROOM_TEMPE
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set delayed nu-fission in a void')

check_type('delayed_nu_fission', delayed_nu_fission,
(openmc.mgxs.DelayedNuFissionXS,
Expand Down Expand Up @@ -1267,6 +1317,8 @@ def set_kappa_fission_mgxs(self, k_fission, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set kappa-fission in a void')

check_type('kappa_fission', k_fission, openmc.mgxs.KappaFissionXS)
check_value('energy_groups', k_fission.energy_groups,
Expand Down Expand Up @@ -1308,6 +1360,8 @@ def set_chi_mgxs(self, chi, temperature=ROOM_TEMPERATURE_KELVIN, nuclide='total'
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set chi in a void')

check_type('chi', chi, openmc.mgxs.Chi)
check_value('energy_groups', chi.energy_groups, [self.energy_groups])
Expand Down Expand Up @@ -1346,6 +1400,8 @@ def set_chi_prompt_mgxs(self, chi_prompt, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set prompt chi in a void')

check_type('chi_prompt', chi_prompt, openmc.mgxs.Chi)
check_value('prompt', chi_prompt.prompt, [True])
Expand Down Expand Up @@ -1388,6 +1444,8 @@ def set_chi_delayed_mgxs(self, chi_delayed, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set delayed chi in a void')

check_type('chi_delayed', chi_delayed, openmc.mgxs.ChiDelayed)
check_value('energy_groups', chi_delayed.energy_groups,
Expand Down Expand Up @@ -1431,6 +1489,8 @@ def set_beta_mgxs(self, beta, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set beta in a void')

check_type('beta', beta, openmc.mgxs.Beta)
check_value('num_delayed_groups', beta.num_delayed_groups,
Expand Down Expand Up @@ -1471,6 +1531,8 @@ def set_decay_rate_mgxs(self, decay_rate, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set decay rate in a void')

check_type('decay_rate', decay_rate, openmc.mgxs.DecayRate)
check_value('num_delayed_groups', decay_rate.num_delayed_groups,
Expand Down Expand Up @@ -1516,6 +1578,8 @@ def set_scatter_matrix_mgxs(self, scatter, temperature=ROOM_TEMPERATURE_KELVIN,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set scatter matrix in a void')

check_type('scatter', scatter, openmc.mgxs.ScatterMatrixXS)
check_value('energy_groups', scatter.energy_groups,
Expand Down Expand Up @@ -1604,6 +1668,8 @@ def set_multiplicity_matrix_mgxs(self, nuscatter, scatter=None,
openmc.mgxs.Library.get_xsdata()

"""
if self._is_void:
raise TypeError('Cannot set multiplicity matrix in a void')

check_type('nuscatter', nuscatter, (openmc.mgxs.ScatterMatrixXS,
openmc.mgxs.MultiplicityMatrixXS))
Expand Down Expand Up @@ -1992,6 +2058,15 @@ def to_hdf5(self, file):

xs_grp = grp.create_group(str(int(np.round(temperature))) + "K")

# Add the kinetics data
if self._inverse_velocity[i] is not None:
xs_grp.create_dataset("inverse-velocity",
data=self._inverse_velocity[i])
elif self._is_void:
raise TypeError('Void mgxs must have inverse-velocity data.')

if self._is_void: continue

if self._total[i] is None:
raise ValueError('total data must be provided when writing '
'the HDF5 library')
Expand Down Expand Up @@ -2141,10 +2216,6 @@ def to_hdf5(self, file):
scatt_grp.create_dataset("g_min", data=g_out_bounds[:, :, :, 0])
scatt_grp.create_dataset("g_max", data=g_out_bounds[:, :, :, 1])

# Add the kinetics data
if self._inverse_velocity[i] is not None:
xs_grp.create_dataset("inverse-velocity",
data=self._inverse_velocity[i])

@classmethod
def from_hdf5(cls, group, name, energy_groups, num_delayed_groups):
Expand Down
Loading
Loading