Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3e45571
multigroup inverse-speed data for void regions
GuySten Feb 3, 2026
1d19ba0
wip
GuySten Feb 3, 2026
6c51c14
add another warning
GuySten Feb 3, 2026
51dfb76
wip
GuySten Feb 4, 2026
3d22ce7
fix typo and import
GuySten Feb 4, 2026
a1b09c2
fix typo
GuySten Feb 4, 2026
7ac31b3
fix typo
GuySten Feb 4, 2026
6e358d1
fix typo
GuySten Feb 4, 2026
ba43542
move around code
GuySten Feb 4, 2026
59c0b50
rename void to approx void in random ray example
GuySten Feb 4, 2026
6568952
update inputs
GuySten Feb 4, 2026
fb469c6
more fixes
GuySten Feb 4, 2026
5672eac
use default velocity approx when imberse velocity data is missing
GuySten Feb 7, 2026
9ef5648
wip
GuySten Feb 7, 2026
05abd9c
wip
GuySten Feb 7, 2026
957d098
wip
GuySten Feb 7, 2026
59b4c00
revert warning
GuySten Feb 7, 2026
a954f5d
Merge branch 'develop' into check-xs-vacuum
GuySten Feb 8, 2026
a78f7d6
simplify code
GuySten Feb 8, 2026
a394950
off by one
GuySten Feb 9, 2026
68822cf
fix xt code
GuySten Feb 9, 2026
aa1703f
fix typo
GuySten Feb 9, 2026
4998e8a
simplify code
GuySten Feb 9, 2026
28c044f
ran clang format
GuySten Feb 9, 2026
58c0090
ensure minimum neutron energy
GuySten Feb 9, 2026
26e6c6d
ensure minimum neutron energy in tests
GuySten Feb 9, 2026
4571f8d
dos2unix
GuySten Feb 9, 2026
2c98286
fix missing file
GuySten Feb 9, 2026
c4f149f
simplify code
GuySten Feb 10, 2026
0c057df
Remove group edge validation checks
GuySten Feb 10, 2026
db2c48c
simplify code
GuySten Feb 10, 2026
1f653f7
close hdf5 groups
GuySten Feb 11, 2026
e56b6ed
update test results
GuySten Feb 11, 2026
0854ff5
Merge branch 'develop' into check-xs-vacuum
GuySten Mar 6, 2026
d5af24c
update
GuySten Mar 6, 2026
1861ab1
fix some errors
GuySten Mar 6, 2026
fe7e5a3
another simplification
GuySten Mar 6, 2026
d4f7c34
Revert "another simplification"
GuySten Mar 6, 2026
f9a7e38
rafactor mass method
GuySten Mar 7, 2026
ab6c770
further simplification
GuySten Mar 7, 2026
3d91c0d
fix some errors
GuySten Mar 7, 2026
c017a90
revert test
GuySten Mar 7, 2026
f8da4ff
decrease number of particles
GuySten Mar 7, 2026
f7b0fd4
try further simplification
GuySten Mar 7, 2026
efa9250
Revert "try further simplification"
GuySten Mar 7, 2026
d16f89a
added docs
GuySten Mar 10, 2026
03af12d
Update cross_sections.rst
nelsonag Mar 10, 2026
2226113
improved docs according to reviewer suggestions
GuySten Mar 11, 2026
76edf35
Fix documentation
paulromano Mar 13, 2026
33b021b
Merge branch 'develop' into pr/GuySten/3766
paulromano Mar 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
82 changes: 76 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 @@ -260,6 +262,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 +327,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 +488,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 +541,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 +572,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 +603,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 +636,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 +669,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 +700,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 +731,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 +764,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 +795,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 +826,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 +859,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 +892,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 +926,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 +960,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 +1033,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 +1075,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 +1119,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 +1163,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 +1216,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 +1265,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 +1316,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 +1359,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 +1399,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 +1443,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 +1488,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 +1530,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 +1577,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 +1667,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 +2057,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 +2215,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
5 changes: 5 additions & 0 deletions src/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "openmc/hdf5_interface.h"
#include "openmc/lattice.h"
#include "openmc/material.h"
#include "openmc/mgxs_interface.h"
#include "openmc/nuclide.h"
#include "openmc/settings.h"
#include "openmc/xml_interface.h"
Expand Down Expand Up @@ -397,6 +398,10 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
for (std::string mat : mats) {
if (mat.compare("void") == 0) {
material_.push_back(MATERIAL_VOID);
if (!settings::run_CE && data::mg.void_velocities_.empty())
warning("Void inverse-velocity data is not available in the "
"multi-group nuclear data library. "
"Time related calculation results might be wrong!");
} else {
material_.push_back(std::stoi(mat));
}
Expand Down
Loading
Loading