Skip to content

Commit 953d626

Browse files
authored
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
2 parents 3a07bed + 23eab2c commit 953d626

33 files changed

Lines changed: 727 additions & 447 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ARG compile_cores=1
2424
ARG build_dagmc=off
2525
ARG build_libmesh=off
2626

27-
FROM debian:bookworm-slim AS dependencies
27+
FROM ubuntu:24.04 AS dependencies
2828

2929
ARG compile_cores
3030
ARG build_dagmc

docs/source/io_formats/settings.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ found in the :ref:`random ray user guide <random_ray>`.
487487

488488
:type:
489489
The type of the domain. Can be ``material``, ``cell``, or ``universe``.
490-
490+
491491
:diagonal_stabilization_rho:
492492
The rho factor for use with diagonal stabilization. This technique is
493493
applied when negative diagonal (in-group) elements are detected in
@@ -917,6 +917,16 @@ variable and whose sub-elements/attributes are as follows:
917917
:dist:
918918
This sub-element of a ``pair`` element provides information on the corresponding univariate distribution.
919919

920+
---------------------------------------
921+
``<source_rejection_fraction>`` Element
922+
---------------------------------------
923+
924+
The ``<source_rejection_fraction>`` element specifies the minimum fraction of
925+
external source sites that must be accepted when applying rejection sampling
926+
based on constraints.
927+
928+
*Default*: 0.05
929+
920930
-------------------------
921931
``<state_point>`` Element
922932
-------------------------

docs/source/methods/random_ray.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ terms on the right hand side.
109109
In Equation :eq:`transport`, :math:`\psi` is the angular neutron flux. This
110110
parameter represents the total distance traveled by all neutrons in a particular
111111
direction inside of a control volume per second, and is often given in units of
112-
:math:`1/(\text{cm}^{2} \text{s})`. As OpenMC does not support time dependence
113-
in the random ray solver mode, we consider the steady state equation, where the
114-
units of flux become :math:`1/\text{cm}^{2}`. The angular direction unit vector,
112+
:math:`1/(\text{cm}^{2} \text{s})`. The angular direction unit vector,
115113
:math:`\mathbf{\Omega}`, represents the direction of travel for the neutron. The
116114
spatial position vector, :math:`\mathbf{r}`, represents the location within the
117115
simulation. The neutron energy, :math:`E`, or speed in continuous space, is

include/openmc/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ extern std::unordered_set<int>
145145
statepoint_batch; //!< Batches when state should be written
146146
extern std::unordered_set<int>
147147
source_write_surf_id; //!< Surface ids where sources will be written
148+
extern double source_rejection_fraction; //!< Minimum fraction of source sites
149+
//!< that must be accepted
148150

149151
extern int
150152
max_history_splits; //!< maximum number of particle splits for weight windows

include/openmc/source.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ namespace openmc {
2121
// Constants
2222
//==============================================================================
2323

24-
// Maximum number of external source spatial resamples to encounter before an
25-
// error is thrown.
24+
// Minimum number of external source sites rejected before checking againts the
25+
// source_rejection_fraction
2626
constexpr int EXTSRC_REJECT_THRESHOLD {10000};
27-
constexpr double EXTSRC_REJECT_FRACTION {0.05};
2827

2928
//==============================================================================
3029
// Global variables

openmc/data/njoy.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@
201201
_THERMAL_TEMPLATE_THERMR = """
202202
thermr / %%%%%%%%%%%%%%%% Add thermal scattering data (free gas) %%%%%%%%%%%%%%%
203203
0 {nthermr1_in} {nthermr1}
204-
0 {mat} 12 {num_temp} 1 0 {iform} 1 221 1/
204+
0 {mat} {nbin} {num_temp} 1 0 {iform} 1 221 1/
205205
{temps}
206206
{error} {energy_max}
207207
thermr / %%%%%%%%%%%%%%%% Add thermal scattering data (bound) %%%%%%%%%%%%%%%%%%
208208
{nthermal_endf} {nthermr2_in} {nthermr2}
209-
{mat_thermal} {mat} 16 {num_temp} {inelastic} {elastic} {iform} {natom} 222 1/
209+
{mat_thermal} {mat} {nbin} {num_temp} {inelastic} {elastic} {iform} {natom} 222 1/
210210
{temps}
211211
{error} {energy_max}
212212
"""
@@ -495,7 +495,7 @@ def make_ace(filename, temperatures=None, acer=True, xsdir=None,
495495
def make_ace_thermal(filename, filename_thermal, temperatures=None,
496496
ace=None, xsdir=None, output_dir=None, error=0.001,
497497
iwt=2, evaluation=None, evaluation_thermal=None,
498-
table_name=None, zaids=None, nmix=None, **kwargs):
498+
table_name=None, zaids=None, nmix=None, nbin=16, **kwargs):
499499
"""Generate thermal scattering ACE file from ENDF files
500500
501501
Parameters
@@ -532,6 +532,8 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None,
532532
ZAIDs that the thermal scattering data applies to
533533
nmix : int, optional
534534
Number of atom types in mixed moderator
535+
nbin : int, optional
536+
Number of equi-probable angles
535537
**kwargs
536538
Keyword arguments passed to :func:`openmc.data.njoy.run`
537539

openmc/deplete/abc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from openmc.utility_funcs import change_directory
2525
from openmc import Material
2626
from .stepresult import StepResult
27-
from .chain import Chain
27+
from .chain import _get_chain
2828
from .results import Results, _SECONDS_PER_MINUTE, _SECONDS_PER_HOUR, \
2929
_SECONDS_PER_DAY, _SECONDS_PER_JULIAN_YEAR
3030
from .pool import deplete
@@ -126,8 +126,8 @@ class TransportOperator(ABC):
126126
127127
Parameters
128128
----------
129-
chain_file : str
130-
Path to the depletion chain XML file
129+
chain_file : PathLike or Chain
130+
Path to the depletion chain XML file or instance of openmc.deplete.Chain.
131131
fission_q : dict, optional
132132
Dictionary of nuclides and their fission Q values [eV]. If not given,
133133
values will be pulled from the ``chain_file``.
@@ -145,11 +145,12 @@ class TransportOperator(ABC):
145145
The depletion chain information necessary to form matrices and tallies.
146146
147147
"""
148-
def __init__(self, chain_file, fission_q=None, prev_results=None):
148+
def __init__(self, chain_file=None, fission_q=None, prev_results=None):
149149
self.output_dir = '.'
150150

151151
# Read depletion chain
152-
self.chain = Chain.from_xml(chain_file, fission_q)
152+
self.chain = _get_chain(chain_file, fission_q)
153+
153154
if prev_results is None:
154155
self.prev_res = None
155156
else:

openmc/deplete/chain.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
import lxml.etree as ET
1818
import scipy.sparse as sp
1919

20-
from openmc.checkvalue import check_type, check_greater_than
20+
from openmc.checkvalue import check_type, check_greater_than, PathLike
2121
from openmc.data import gnds_name, zam
22+
from openmc.exceptions import DataError
2223
from .nuclide import FissionYieldDistribution, Nuclide
2324
import openmc.data
2425

@@ -1246,3 +1247,38 @@ def _follow(self, isotopes, level):
12461247
found.update(isotopes)
12471248

12481249
return found
1250+
1251+
1252+
def _get_chain(
1253+
chain_file: PathLike | Chain | None = None,
1254+
fission_q: dict | None = None
1255+
) -> Chain:
1256+
"""Get a depletion chain from a file or the runtime configuration.
1257+
1258+
Parameters
1259+
----------
1260+
chain_file : PathLike or Chain, optional
1261+
Path to depletion chain XML file, a Chain instance, or None to use
1262+
the file specified in ``openmc.config['chain_file']``.
1263+
fission_q : dict, optional
1264+
Dictionary of nuclides and their fission Q values [eV]. If not given,
1265+
values will be pulled from the ``chain_file``.
1266+
1267+
Returns
1268+
-------
1269+
Chain
1270+
Depletion chain instance.
1271+
"""
1272+
if isinstance(chain_file, Chain):
1273+
return chain_file
1274+
elif isinstance(chain_file, PathLike | None):
1275+
if chain_file is None:
1276+
chain_file = openmc.config.get('chain_file')
1277+
if 'chain_file' not in openmc.config:
1278+
raise DataError(
1279+
"No depletion chain specified and could not find depletion "
1280+
"chain in openmc.config['chain_file']"
1281+
)
1282+
return Chain.from_xml(chain_file, fission_q)
1283+
else:
1284+
raise TypeError("chain_file must be path-like, a Chain, or None")

openmc/deplete/coupled_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class CoupledOperator(OpenMCOperator):
102102
----------
103103
model : openmc.model.Model
104104
OpenMC model object
105-
chain_file : str, optional
106-
Path to the depletion chain XML file. Defaults to
107-
``openmc.config['chain_file']``.
105+
chain_file : PathLike or Chain, optional
106+
Path to the depletion chain XML file or instance of openmc.deplete.Chain.
107+
Defaults to ``openmc.config['chain_file']``.
108108
prev_results : Results, optional
109109
Results from a previous depletion calculation. If this argument is
110110
specified, the depletion calculation will start from the latest state

openmc/deplete/d1s.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@
1414
import openmc
1515
from openmc.data import half_life
1616
from .abc import _normalize_timesteps
17-
from .chain import Chain
17+
from .chain import Chain, _get_chain
18+
from ..checkvalue import PathLike
1819

1920

20-
def get_radionuclides(model: openmc.Model, chain_file: str | None = None) -> list[str]:
21+
def get_radionuclides(model: openmc.Model, chain_file: PathLike | Chain | None = None) -> list[str]:
2122
"""Determine all radionuclides that can be produced during D1S.
2223
2324
Parameters
2425
----------
2526
model : openmc.Model
2627
Model that should be used for determining what nuclides are present
27-
chain_file : str, optional
28-
Which chain file to use for inspecting decay data. If None is passed,
29-
defaults to ``openmc.config['chain_file']``
28+
chain_file : PathLike | Chain
29+
Path to the depletion chain XML file or instance of openmc.deplete.Chain.
30+
Used for inspecting decay data. Defaults to ``openmc.config['chain_file']``
3031
3132
Returns
3233
-------
@@ -39,9 +40,7 @@ def get_radionuclides(model: openmc.Model, chain_file: str | None = None) -> lis
3940
for nuc in mat.get_nuclides()}
4041

4142
# Load chain file
42-
if chain_file is None:
43-
chain_file = openmc.config['chain_file']
44-
chain = Chain.from_xml(chain_file)
43+
chain = _get_chain(chain_file)
4544

4645
radionuclides = set()
4746
for nuclide in chain.nuclides:

0 commit comments

Comments
 (0)