Allow Operator to reduce depletion chain from geometry

A new parameter, reduce_chain, can be used to instruct the
operator to create a smaller depletion chain. The geometry is
used to find all nuclides in burnable materials. The argument
can be a boolean, or a non-negative integer. A value of True
indicates no depth for following the paths, while an integer
can be used to directly specify the depth.
This commit is contained in:
Andrew Johnson 2020-03-20 18:11:54 -04:00
parent b01a3e011b
commit d67d0cd0f9
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB

View file

@ -113,6 +113,12 @@ class Operator(TransportOperator):
``fission_yield_mode``. Will be passed directly on to the
helper. Passing a value of None will use the defaults for
the associated helper.
reduce_chain : bool or int, optional
If ``True`` or an integer, create a reduced depletion chain by
following transmuation paths for isotopes in burnable materials.
A value of ``True`` implies to follow all paths to completion,
while a non-negative integer indicates the depth. See
:meth:`openmc.deplete.Chain.reduce`
Attributes
----------
@ -158,7 +164,8 @@ class Operator(TransportOperator):
def __init__(self, geometry, settings, chain_file=None, prev_results=None,
diff_burnable_mats=False, energy_mode="fission-q",
fission_q=None, dilute_initial=1.0e3,
fission_yield_mode="constant", fission_yield_opts=None):
fission_yield_mode="constant", fission_yield_opts=None,
reduce_chain=False):
if fission_yield_mode not in self._fission_helpers:
raise KeyError(
"fission_yield_mode must be one of {}, not {}".format(
@ -179,6 +186,17 @@ class Operator(TransportOperator):
self.geometry = geometry
self.diff_burnable_mats = diff_burnable_mats
# Reduce the chain before we create more materials
if reduce_chain is not False:
all_isotopes = set()
for material in geometry.get_all_materials().values():
if not material.depletable:
continue
for name, _dens_percent, _dens_type in material.nuclides:
all_isotopes.add(name)
level = None if reduce_chain is True else reduce_chain
self.chain = self.chain.reduce(all_isotopes, level)
# Differentiate burnable materials with multiple instances
if self.diff_burnable_mats:
self._differentiate_burnable_mats()