Skip to content

Commit 820648d

Browse files
shimwelljon-proximafusionpaulromano
authored
using reduce chain level to remove need for reduce chain (#3377)
Co-authored-by: Jon Shimwell <[email protected]> Co-authored-by: Paul Romano <[email protected]>
1 parent 5dd6ff6 commit 820648d

File tree

4 files changed

+16
-37
lines changed

4 files changed

+16
-37
lines changed

openmc/deplete/coupled_operator.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,9 @@ class CoupledOperator(OpenMCOperator):
154154
options.
155155
156156
.. versionadded:: 0.12.1
157-
reduce_chain : bool, optional
158-
If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the
159-
depletion chain up to ``reduce_chain_level``.
160-
161-
.. versionadded:: 0.12
162157
reduce_chain_level : int, optional
163-
Depth of the search when reducing the depletion chain. Only used
164-
if ``reduce_chain`` evaluates to true. The default value of
165-
``None`` implies no limit on the depth.
158+
Depth of the search when reducing the depletion chain. The default
159+
value of ``None`` implies no limit on the depth.
166160
167161
.. versionadded:: 0.12
168162
diff_volume_method : str
@@ -214,7 +208,7 @@ def __init__(self, model, chain_file=None, prev_results=None,
214208
normalization_mode="fission-q", fission_q=None,
215209
fission_yield_mode="constant", fission_yield_opts=None,
216210
reaction_rate_mode="direct", reaction_rate_opts=None,
217-
reduce_chain=False, reduce_chain_level=None):
211+
reduce_chain_level=None):
218212

219213
# check for old call to constructor
220214
if isinstance(model, openmc.Geometry):
@@ -270,7 +264,6 @@ def __init__(self, model, chain_file=None, prev_results=None,
270264
diff_volume_method=diff_volume_method,
271265
fission_q=fission_q,
272266
helper_kwargs=helper_kwargs,
273-
reduce_chain=reduce_chain,
274267
reduce_chain_level=reduce_chain_level)
275268

276269
def _differentiate_burnable_mats(self):

openmc/deplete/independent_operator.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,9 @@ class IndependentOperator(OpenMCOperator):
6666
Dictionary of nuclides and their fission Q values [eV]. If not given,
6767
values will be pulled from the ``chain_file``. Only applicable if
6868
``"normalization_mode" == "fission-q"``.
69-
reduce_chain : bool, optional
70-
If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the depletion
71-
chain up to ``reduce_chain_level``.
7269
reduce_chain_level : int, optional
73-
Depth of the search when reducing the depletion chain. Only used if
74-
``reduce_chain`` evaluates to true. The default value of ``None``
75-
implies no limit on the depth.
70+
Depth of the search when reducing the depletion chain. The default
71+
value of ``None`` implies no limit on the depth.
7672
fission_yield_opts : dict of str to option, optional
7773
Optional arguments to pass to the
7874
:class:`openmc.deplete.helpers.FissionYieldHelper` object. Will be
@@ -119,7 +115,6 @@ def __init__(self,
119115
normalization_mode='fission-q',
120116
fission_q=None,
121117
prev_results=None,
122-
reduce_chain=False,
123118
reduce_chain_level=None,
124119
fission_yield_opts=None):
125120
# Validate micro-xs parameters
@@ -157,7 +152,6 @@ def __init__(self,
157152
prev_results=prev_results,
158153
fission_q=fission_q,
159154
helper_kwargs=helper_kwargs,
160-
reduce_chain=reduce_chain,
161155
reduce_chain_level=reduce_chain_level)
162156

163157
@classmethod
@@ -170,7 +164,6 @@ def from_nuclides(cls, volume, nuclides,
170164
normalization_mode='fission-q',
171165
fission_q=None,
172166
prev_results=None,
173-
reduce_chain=False,
174167
reduce_chain_level=None,
175168
fission_yield_opts=None):
176169
"""
@@ -206,13 +199,9 @@ def from_nuclides(cls, volume, nuclides,
206199
applicable if ``"normalization_mode" == "fission-q"``.
207200
prev_results : Results, optional
208201
Results from a previous depletion calculation.
209-
reduce_chain : bool, optional
210-
If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the
211-
depletion chain up to ``reduce_chain_level``. Default is False.
212202
reduce_chain_level : int, optional
213-
Depth of the search when reducing the depletion chain. Only used
214-
if ``reduce_chain`` evaluates to true. The default value of
215-
``None`` implies no limit on the depth.
203+
Depth of the search when reducing the depletion chain. The default
204+
value of ``None`` implies no limit on the depth.
216205
fission_yield_opts : dict of str to option, optional
217206
Optional arguments to pass to the
218207
:class:`openmc.deplete.helpers.FissionYieldHelper` class. Will be
@@ -232,7 +221,6 @@ def from_nuclides(cls, volume, nuclides,
232221
normalization_mode=normalization_mode,
233222
fission_q=fission_q,
234223
prev_results=prev_results,
235-
reduce_chain=reduce_chain,
236224
reduce_chain_level=reduce_chain_level,
237225
fission_yield_opts=fission_yield_opts)
238226

openmc/deplete/openmc_operator.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import numpy as np
1212

1313
import openmc
14-
from openmc.checkvalue import check_value
14+
from openmc.checkvalue import check_value, check_type, check_greater_than
1515
from openmc.exceptions import DataError
1616
from openmc.mpi import comm
1717
from .abc import TransportOperator, OperatorResult
@@ -49,13 +49,9 @@ class OpenMCOperator(TransportOperator):
4949
Dictionary of nuclides and their fission Q values [eV].
5050
helper_kwargs : dict
5151
Keyword arguments for helper classes
52-
reduce_chain : bool, optional
53-
If True, use :meth:`openmc.deplete.Chain.reduce()` to reduce the
54-
depletion chain up to ``reduce_chain_level``.
5552
reduce_chain_level : int, optional
56-
Depth of the search when reducing the depletion chain. Only used
57-
if ``reduce_chain`` evaluates to true. The default value of
58-
``None`` implies no limit on the depth.
53+
Depth of the search when reducing the depletion chain. The default
54+
value of ``None`` implies no limit on the depth.
5955
6056
diff_volume_method : str
6157
Specifies how the volumes of the new materials should be found. Default
@@ -107,7 +103,6 @@ def __init__(
107103
diff_volume_method='divide equally',
108104
fission_q=None,
109105
helper_kwargs=None,
110-
reduce_chain=False,
111106
reduce_chain_level=None):
112107

113108
# If chain file was not specified, try to get it from global config
@@ -126,10 +121,13 @@ def __init__(
126121

127122
check_value('diff volume method', diff_volume_method,
128123
{'divide equally', 'match cell'})
124+
if reduce_chain_level:
125+
check_type('reduce_chain_level', reduce_chain_level, int)
126+
check_greater_than('reduce_chain_level', reduce_chain_level, 0)
129127
self.diff_volume_method = diff_volume_method
130128

131129
# Reduce the chain to only those nuclides present
132-
if reduce_chain:
130+
if reduce_chain_level is not None:
133131
init_nuclides = set()
134132
for material in self.materials:
135133
if not material.depletable:

tests/unit_tests/test_model.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def test_deplete(run_in_tmpdir, pin_model_attributes, mpi_intracomm):
448448
# In this test we first run without pre-initializing the shared library
449449
# data and then compare. Then we repeat with the C API already initialized
450450
# and make sure we get the same answer
451-
test_model.deplete([1e6], 'predictor', final_step=False,
451+
test_model.deplete(timesteps=[1e6], method='predictor', final_step=False,
452452
operator_kwargs=op_kwargs,
453453
power=1., output=False)
454454
# Get the new Xe136 and U235 atom densities
@@ -482,7 +482,7 @@ def check_tally_output():
482482

483483
# Now we can re-run with the pre-initialized API
484484
test_model.init_lib(output=False, intracomm=mpi_intracomm)
485-
test_model.deplete([1e6], 'predictor', final_step=False,
485+
test_model.deplete(timesteps=[1e6], method='predictor', final_step=False,
486486
operator_kwargs=op_kwargs,
487487
power=1., output=False)
488488
# Get the new Xe136 and U235 atom densities

0 commit comments

Comments
 (0)