Skip to content

Commit db322f2

Browse files
authored
Add section in depletion user's guide about comparing to other codes (#3955)
1 parent 111eb77 commit db322f2

3 files changed

Lines changed: 63 additions & 24 deletions

File tree

docs/source/usersguide/depletion.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,42 @@ to transfer xenon from one material to another, you'd use::
449449
...
450450

451451
integrator.add_transfer_rate(mat1, ['Xe'], 0.1, destination_material=mat2)
452+
453+
Comparing to Other Codes
454+
========================
455+
456+
Comparing depletion results from OpenMC with those from another code, such as
457+
MCNP or Serpent, requires more than constructing equivalent transport models.
458+
At each depletion step, differences in the transport solution, nuclear data,
459+
reaction rate normalization, and numerical integration can all affect the
460+
result. Small differences can also accumulate over successive depletion steps.
461+
462+
For a meaningful comparison, align as many of the following inputs and methods
463+
as possible:
464+
465+
- Geometry and material definitions and associated physical properties such as
466+
temperature
467+
- Neutron cross section library (e.g., ENDF/B-VIII.0)
468+
- Treatment of thermal scattering and unresolved resonance probability tables
469+
- Neutron reactions accounted for in the depletion chain
470+
- Decay data in the depletion chain
471+
- Isomeric branching ratios for reactions in the depletion chain
472+
- Fission product yields in the depletion chain
473+
- Fission product yield interpolation method
474+
(``CoupledOperator(fission_yield_mode=...)``)
475+
- Reaction rate normalization, including fission Q values
476+
(``CoupledOperator(fission_q=...)``)
477+
- Depletion integration method (``PredictorIntegrator``, ``CECMIntegrator``,
478+
etc.) and time-step sizes
479+
480+
When comparing to codes that use ACE format cross sections, it is recommended to
481+
directly convert the ACE files to HDF5 format using functionality from the
482+
:mod:`openmc.data` module (see :ref:`create_xs_library`). Some of the
483+
LANL-distributed ACE libraries used with MCNP have also been converted to HDF5
484+
format and are available for download at https://openmc.org/data.
485+
486+
Even after these choices have been aligned, exact agreement should not be
487+
expected. Codes may use different approximations or numerical methods that
488+
cannot be configured identically. When investigating a discrepancy, first
489+
compare transport results and one-group reaction rates at the initial time, then
490+
compare changes over subsequent timesteps.

openmc/model/model.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,22 @@ def add_kinetics_parameters_tallies(self, num_groups: int | None = None):
265265
denom_tally = openmc.Tally(name='IFP denominator')
266266
denom_tally.scores = ['ifp-denominator']
267267
self.tallies.append(denom_tally)
268-
269-
# TODO: This should also be incorporated into lower-level calls in
268+
269+
# TODO: This should also be incorporated into lower-level calls in
270270
# settings.py, but it requires information about the tallies currently
271271
# on the active Model
272272
def _assign_fw_cadis_tally_IDs(self):
273-
# Verify that all tallies assigned as targets on WeightWindowGenerators
274-
# exist within model.tallies. If this is the case, convert the .targets
273+
# Verify that all tallies assigned as targets on WeightWindowGenerators
274+
# exist within model.tallies. If this is the case, convert the .targets
275275
# attribute of each WeightWindowGenerator to a sequence of tally IDs.
276276
if len(self.settings.weight_window_generators) == 0:
277277
return
278-
278+
279279
# List of valid tally IDs
280280
reference_tally_ids = np.asarray([tal.id for tal in self.tallies])
281-
281+
282282
for wwg in self.settings.weight_window_generators:
283-
# Only proceeds if the "targets" attribute is an openmc.Tallies,
283+
# Only proceeds if the "targets" attribute is an openmc.Tallies,
284284
# which means it hasn't been checked against model.tallies.
285285
if isinstance(wwg.targets, openmc.Tallies):
286286
id_vec = []
@@ -291,7 +291,7 @@ def _assign_fw_cadis_tally_IDs(self):
291291
if tal == reference_tal:
292292
id_next = reference_tal.id
293293
break
294-
294+
295295
if id_next == None:
296296
raise RuntimeError(
297297
f'Local FW-CADIS target tally {tal.id} not found on model.tallies!')
@@ -1750,8 +1750,8 @@ def differentiate_mats(self, diff_volume_method: str = None, depletable_only: bo
17501750
def _auto_generate_mgxs_lib(
17511751
model: openmc.model.model,
17521752
groups: openmc.mgxs.EnergyGroups,
1753-
correction: str | none,
1754-
directory: pathlike,
1753+
correction: str | None,
1754+
directory: PathLike,
17551755
) -> openmc.mgxs.Library:
17561756
"""
17571757
Automatically generate a multi-group cross section libray from a model
@@ -1958,7 +1958,7 @@ def _isothermal_infinite_media_mgxs(
19581958

19591959
# Set materials on the model
19601960
model.materials = [material]
1961-
if temperature != None:
1961+
if temperature is not None:
19621962
model.materials[-1].temperature = temperature
19631963

19641964
# Settings
@@ -1985,7 +1985,7 @@ def _isothermal_infinite_media_mgxs(
19851985
mgxs_lib = Model._auto_generate_mgxs_lib(
19861986
model, groups, correction, directory)
19871987

1988-
if temperature != None:
1988+
if temperature is not None:
19891989
return mgxs_lib.get_xsdata(domain=material, xsdata_name=name,
19901990
temperature=temperature)
19911991
else:
@@ -2058,12 +2058,12 @@ def _generate_infinite_medium_mgxs(
20582058
)
20592059

20602060
temp_settings = {}
2061-
if temperature_settings == None:
2061+
if temperature_settings is None:
20622062
temp_settings = self.settings.temperature
20632063
else:
20642064
temp_settings = temperature_settings
20652065

2066-
if temperatures == None:
2066+
if temperatures is None:
20672067
mgxs_sets = []
20682068
for material in self.materials:
20692069
xs_data = Model._isothermal_infinite_media_mgxs(
@@ -2236,7 +2236,7 @@ def _isothermal_stochastic_slab_mgxs(
22362236
model = openmc.Model()
22372237
model.geometry = stoch_geom
22382238

2239-
if temperature != None:
2239+
if temperature is not None:
22402240
for material in model.geometry.get_all_materials().values():
22412241
material.temperature = temperature
22422242

@@ -2260,7 +2260,7 @@ def _isothermal_stochastic_slab_mgxs(
22602260
model, groups, correction, directory)
22612261

22622262
# Fetch all of the isothermal results.
2263-
if temperature != None:
2263+
if temperature is not None:
22642264
return {
22652265
mat.name : mgxs_lib.get_xsdata(domain=mat, xsdata_name=mat.name,
22662266
temperature=temperature)
@@ -2346,12 +2346,12 @@ def _generate_stochastic_slab_mgxs(
23462346
)
23472347

23482348
temp_settings = {}
2349-
if temperature_settings == None:
2349+
if temperature_settings is None:
23502350
temp_settings = self.settings.temperature
23512351
else:
23522352
temp_settings = temperature_settings
23532353

2354-
if temperatures == None:
2354+
if temperatures is None:
23552355
mgxs_sets = Model._isothermal_stochastic_slab_mgxs(
23562356
geo,
23572357
groups,
@@ -2444,7 +2444,7 @@ def _isothermal_materialwise_mgxs(
24442444
model = copy.deepcopy(input_model)
24452445
model.tallies = openmc.Tallies()
24462446

2447-
if temperature != None:
2447+
if temperature is not None:
24482448
for material in model.geometry.get_all_materials().values():
24492449
material.temperature = temperature
24502450

@@ -2460,7 +2460,7 @@ def _isothermal_materialwise_mgxs(
24602460
model, groups, correction, directory)
24612461

24622462
# Fetch all of the isothermal results.
2463-
if temperature != None:
2463+
if temperature is not None:
24642464
return {
24652465
mat.name : mgxs_lib.get_xsdata(domain=mat, xsdata_name=mat.name,
24662466
temperature=temperature)
@@ -2515,12 +2515,12 @@ def _generate_material_wise_mgxs(
25152515
entries in openmc.Settings.temperature_settings.
25162516
"""
25172517
temp_settings = {}
2518-
if temperature_settings == None:
2518+
if temperature_settings is None:
25192519
temp_settings = self.settings.temperature
25202520
else:
25212521
temp_settings = temperature_settings
25222522

2523-
if temperatures == None:
2523+
if temperatures is None:
25242524
mgxs_sets = Model._isothermal_materialwise_mgxs(
25252525
self,
25262526
groups,

tests/unit_tests/test_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ def test_material(lib_init):
251251
m.name = "Not hot borated water"
252252
assert m.name == "Not hot borated water"
253253

254-
assert m.depletable == False
254+
assert not m.depletable
255255
m.depletable = True
256-
assert m.depletable == True
256+
assert m.depletable
257257

258258

259259
def test_properties_density(lib_init):

0 commit comments

Comments
 (0)