Add Model.deplete method to make user's life easier

This commit is contained in:
Paul Romano 2018-02-20 16:40:18 -06:00
parent 33dec88bd0
commit 4a500df455
2 changed files with 41 additions and 3 deletions

View file

@ -195,6 +195,11 @@ class Operator(TransportOperator):
"material with ID={}.".format(mat.id))
volume[str(mat.id)] = mat.volume
# Make sure there are burnable materials
if not burnable_mats:
raise RuntimeError(
"No depletable materials were found in the model.")
# Sort the sets
burnable_mats = sorted(burnable_mats, key=int)
model_nuclides = sorted(model_nuclides)

View file

@ -2,6 +2,10 @@ from collections.abc import Iterable
import openmc
from openmc.checkvalue import check_type
import openmc.deplete as dep
_DEPLETE_METHODS = {'predictor': dep.integrator.predictor,
'cecm': dep.integrator.cecm}
class Model(object):
@ -136,9 +140,38 @@ class Model(object):
for plot in plots:
self._plots.append(plot)
def export_to_xml(self):
"""Export model to XML files.
def deplete(self, timesteps, power, chain_file=None, method='cecm', **kwargs):
"""Deplete model using specified timesteps/power
Parameters
----------
timesteps : iterable of float
Array of timesteps in units of [s]. Note that values are not
cumulative.
power : float or iterable of float
Power of the reactor in [W]. A single value indicates that the power
is constant over all timesteps. An iterable indicates potentially
different power levels for each timestep. For a 2D problem, the
power can be given in [W/cm] as long as the "volume" assigned to a
depletion material is actually an area in [cm^2].
chain_file : str, optional
Path to the depletion chain XML file. Defaults to the
:envvar:`OPENMC_DEPLETE_CHAIN` environment variable if it exists.
method : {'cecm', 'predictor'}
Integration method used for depletion
**kwargs
Keyword arguments passed to integration function (e.g.,
:func:`openmc.deplete.integrator.cecm`)
"""
# Create OpenMC transport operator
op = dep.Operator(self.geometry, self.settings, chain_file)
# Perform depletion
_DEPLETE_METHODS[method](op, timesteps, power, **kwargs)
def export_to_xml(self):
"""Export model to XML files."""
self.settings.export_to_xml()
self.geometry.export_to_xml()
@ -166,7 +199,7 @@ class Model(object):
Parameters
----------
**kwargs
All keyword arguments are passed to openmc.run
All keyword arguments are passed to :func:`openmc.run`
Returns
-------