diff --git a/openmc/deplete/operator.py b/openmc/deplete/operator.py index 1c62bdd40..a1d8ffb0b 100644 --- a/openmc/deplete/operator.py +++ b/openmc/deplete/operator.py @@ -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) diff --git a/openmc/model/model.py b/openmc/model/model.py index 89fa84e60..d6e6ddce3 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -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 -------