Skip to content
Open
Show file tree
Hide file tree
Changes from 39 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
5 changes: 5 additions & 0 deletions include/openmc/mgxs_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class MgxsInterface {
// Get the group index corresponding to a continuous energy
int get_group_index(double E);

// Get the inverse velocity corresponding to particle p
double get_inverse_velocity(const Particle& p);

int num_energy_groups_;
int num_delayed_groups_;
vector<std::string> xs_names_; // available names in HDF5 file
Expand All @@ -61,6 +64,8 @@ class MgxsInterface {
vector<double> energy_bin_avg_;
vector<double> rev_energy_bins_;
vector<vector<double>> nuc_temps_; // all available temperatures
vector<double>
default_inverse_velocity_; // approximate default inverse-velocity data
};

namespace data {
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class Particle : public ParticleData {

double speed() const;

double mass() const;

//! create a secondary particle
//
//! stores the current phase space attributes of the particle in the
Expand Down
1 change: 1 addition & 0 deletions openmc/mgxs/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def group_edges(self):
@group_edges.setter
def group_edges(self, edges):
cv.check_type('group edges', edges, Iterable, Real)
cv.check_increasing('group edges', edges)
cv.check_greater_than('number of group edges', len(edges), 1)
self._group_edges = np.array(edges)

Expand Down
29 changes: 29 additions & 0 deletions src/mgxs_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,23 @@ int MgxsInterface::get_group_index(double E)

//==============================================================================

double MgxsInterface::get_inverse_velocity(const Particle& p)
{
auto mat = p.material();
if (mat != MATERIAL_VOID) {
auto& macro_xs = macro_xs_[mat];
int macro_t = p.mg_xs_cache().t;
int macro_a = macro_xs.get_angle_index(p.u());
double inv_v =
macro_xs.get_xs(MgxsType::INVERSE_VELOCITY, p.g(), macro_t, macro_a);
if (inv_v > 0.0)
return inv_v;
}
return default_inverse_velocity_[p.g()];
}

//==============================================================================

void MgxsInterface::read_header(const std::string& path_cross_sections)
{
// Save name of HDF5 file to be read to struct data
Expand Down Expand Up @@ -237,6 +254,18 @@ void MgxsInterface::read_header(const std::string& path_cross_sections)
"library file!");
}

// Calculate approximate default inverse velocity data
for (int i = 0; i < energy_bins_.size() - 1; ++i) {
double e_min = std::max(energy_bins_[i], 1e-5);
double e_max = energy_bins_[i + 1];
double inv_v = (std::acosh(1 + e_max / MASS_NEUTRON_EV) -
std::sqrt(1 + 2 * MASS_NEUTRON_EV / e_max) -
std::acosh(1 + e_min / MASS_NEUTRON_EV) +
std::sqrt(1 + 2 * MASS_NEUTRON_EV / e_min)) /
(C_LIGHT * std::log(e_max / e_min));
default_inverse_velocity_.push_back(inv_v);
}

// Close MGXS HDF5 file
file_close(file_id);
}
Expand Down
30 changes: 15 additions & 15 deletions src/particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ double Particle::speed() const
{
if (settings::run_CE) {
// Determine mass in eV/c^2
double mass;
switch (type().pdg_number()) {
case PDG_NEUTRON:
mass = MASS_NEUTRON_EV;
case PDG_ELECTRON:
case PDG_POSITRON:
mass = MASS_ELECTRON_EV;
default:
mass = this->type().mass() * AMU_EV;
}
double mass = this->mass();

// Equivalent to C * sqrt(1-(m/(m+E))^2) without problem at E<<m:
return C_LIGHT * std::sqrt(this->E() * (this->E() + 2 * mass)) /
(this->E() + mass);
} else {
auto& macro_xs = data::mg.macro_xs_[this->material()];
int macro_t = this->mg_xs_cache().t;
int macro_a = macro_xs.get_angle_index(this->u());
return 1.0 / macro_xs.get_xs(MgxsType::INVERSE_VELOCITY, this->g(), nullptr,
nullptr, nullptr, macro_t, macro_a);
return 1.0 / data::mg.get_inverse_velocity(*this);
}
}

double Particle::mass() const
{
switch (type().pdg_number()) {
case PDG_NEUTRON:
return MASS_NEUTRON_EV;
case PDG_ELECTRON:
case PDG_POSITRON:
return MASS_ELECTRON_EV;
default:
return this->type().mass() * AMU_EV;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/mg_basic_delayed/results_true.dat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
k-combined:
1.017078E+00 1.181139E-02
1.012441E+00 7.095889E-03
Loading