diff --git a/docs/source/usersguide/depletion.rst b/docs/source/usersguide/depletion.rst index 07a7c9645..c58a147a2 100644 --- a/docs/source/usersguide/depletion.rst +++ b/docs/source/usersguide/depletion.rst @@ -188,15 +188,22 @@ Transport-independent depletion possible and likely in the near future. OpenMC supports running depletion calculations independent of the OpenMC -transport solver using the :class:`FluxDepletionOperator` class. Rather than -taking a :class:`openmc.model.Model` object, this class accepts a volume, -a dictionary of nuclide concentrations, a flux spectra, and one-group -microscopic cross sections as a :class:`pandas.DataFrame`. The class includes -helper functions to construct the dataframe from a csv file or from -data arrays:: +transport solver using the :class:`FluxDepletionOperator` class. This class +has two ways to initalize it; the default constructor accepts an +:class:`openmc.Materials` object, a flux spectra, and one-group microscopic +cross sections as a :class:`pandas.Dataframe`, while the `from_nuclides` +method accepts a volume and dictionary of nuclide concentrations in place of +the :class:`openmc.Materials` object in addition to the other parameters. +The class includes helper functions to construct the dataframe from a csv file +or from data arrays:: ... + # load in the microscopic cross sections micro_xs = FluxDepletionOperator.create_micro_xs_from_csv(micro_xs_path) + flux = 1.16e15 + op = FluxDepletionOperator(materials, micro_xs, flux, chain_file) + + # alternate construtor nuclides = {'U234': 8.92e18, 'U235': 9.98e20, 'U238': 2.22e22, @@ -204,10 +211,7 @@ data arrays:: 'O16': 4.64e22, 'O17': 1.76e19} volume = 0.5 - flux = 1.16e15 - - op = FluxDepletionOperator(volume, nuclides, micro_xs, flux. chain_file) - + op = FluxDepletionOperator.from_nuclide_dict(volume, nuclides, micro_xs, flux, chain_file) A user can then define an integrator class as they would for a coupled transport-depletion calculation and follow the same steps from there. diff --git a/openmc/deplete/flux_operator.py b/openmc/deplete/flux_operator.py index 9483c324c..b52ebd159 100644 --- a/openmc/deplete/flux_operator.py +++ b/openmc/deplete/flux_operator.py @@ -38,11 +38,8 @@ class FluxDepletionOperator(OpenMCOperator): Parameters ---------- - volume : float - Volume of the material being depleted in [cm^3] - nuclides : dict of str to float - Dictionary with nuclide names as keys and nuclide concentrations as - values. Nuclide concentration units are [atom/cm^3]. + materials : openmc.Materials + Materials to deplete. micro_xs : pandas.DataFrame DataFrame with nuclides names as index and microscopic cross section data in the columns. Cross section units are [cm^-2]. @@ -88,16 +85,62 @@ class FluxDepletionOperator(OpenMCOperator): results are to be used. """ - # Alternate constructor using a full-fledges Model object - #def __init__(self, model, micro_xs, ...): - # ... - # mode.materials = openmc.Materials(model.geometry.get_all_materials().values()) - # super().__init__(model.materials, ...) + @classmethod + def from_nuclides(cls, volume, nuclides, micro_xs, + flux_spectra, + chain_file, + keff=None, + fission_q=None, + prev_results=None, + reduce_chain=False, + reduce_chain_level=None, + fission_yield_opts=None): + """ + Alternate constructor from a dictionary of nuclide concentrations + volume : float + Volume of the material being depleted in [cm^3] + nuclides : dict of str to float + Dictionary with nuclide names as keys and nuclide concentrations as + values. Nuclide concentration units are [atom/cm^3]. + micro_xs : pandas.DataFrame + DataFrame with nuclides names as index and microscopic cross section + data in the columns. Cross section units are [cm^-2]. + flux_spectra : float + Flux spectrum [n cm^-2 s^-1] + chain_file : str + Path to the depletion chain XML file. + keff : 2-tuple of float, optional + keff eigenvalue and uncertainty from transport calculation. + Default is None. + fission_q : dict, optional + Dictionary of nuclides and their fission Q values [eV]. If not given, + values will be pulled from the ``chain_file``. + prev_results : Results, optional + Results from a previous depletion calculation. + reduce_chain : bool, optional + If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the + depletion chain up to ``reduce_chain_level``. Default is False. + reduce_chain_level : int, optional + Depth of the search when reducing the depletion chain. Only used + if ``reduce_chain`` evaluates to true. The default value of + ``None`` implies no limit on the depth. + """ + check_type('nuclides', nuclides, dict, str) + materials = cls._consolidate_nuclides_to_material(nuclides, volume) + return cls(materials, + micro_xs, + flux_spectra, + chain_file, + keff, + fission_q, + prev_results, + reduce_chain, + reduce_chain_level, + fission_yield_opts) def __init__(self, - volume, - nuclides, + materials, micro_xs, flux_spectra, chain_file, @@ -107,18 +150,15 @@ class FluxDepletionOperator(OpenMCOperator): reduce_chain=False, reduce_chain_level=None, fission_yield_opts=None): - # Validate nuclides and micro-xs parameters - check_type('nuclides', nuclides, dict, str) + # Validate micro-xs parameters + check_type('materials', materials, openmc.Materials) check_type('micro_xs', micro_xs, pd.DataFrame) - - cross_sections = micro_xs if keff is not None: check_type('keff', keff, tuple, float) keff = ufloat(keff) self._keff = keff self.flux_spectra = flux_spectra - materials = self._consolidate_nuclides_to_material(nuclides, volume) diff_burnable_mats=False helper_kwargs = dict() @@ -126,7 +166,7 @@ class FluxDepletionOperator(OpenMCOperator): super().__init__( materials, - cross_sections, + micro_xs, chain_file, prev_results, diff_burnable_mats, @@ -136,7 +176,8 @@ class FluxDepletionOperator(OpenMCOperator): reduce_chain, reduce_chain_level) - def _consolidate_nuclides_to_material(self, nuclides, volume): + @staticmethod + def _consolidate_nuclides_to_material(nuclides, volume): """Puts nuclide list into an openmc.Materials object. """ diff --git a/tests/regression_tests/deplete_no_transport/test.py b/tests/regression_tests/deplete_no_transport/test.py index cdc8c057c..d326a17c1 100644 --- a/tests/regression_tests/deplete_no_transport/test.py +++ b/tests/regression_tests/deplete_no_transport/test.py @@ -47,7 +47,7 @@ def test_no_transport(run_in_tmpdir, vol_nuc, multiproc): micro_xs = FluxDepletionOperator.create_micro_xs_from_csv(micro_xs_file) chain_file = Path(__file__).parents[2] / 'chain_simple.xml' flux = 1164719970082145.0 # flux from pincell example - op = FluxDepletionOperator(vol_nuc[0], vol_nuc[1], micro_xs, flux, chain_file) + op = FluxDepletionOperator.from_nuclides(vol_nuc[0], vol_nuc[1], micro_xs, flux, chain_file) # Power and timesteps dt = [30] # single step diff --git a/tests/unit_tests/test_flux_deplete_operator.py b/tests/unit_tests/test_flux_deplete_operator.py index 99c4e7c8a..315e22cdc 100644 --- a/tests/unit_tests/test_flux_deplete_operator.py +++ b/tests/unit_tests/test_flux_deplete_operator.py @@ -69,5 +69,5 @@ def test_operator_init(): 'O16': 4.639065406771322e+22, 'O17': 1.7588724018066158e+19} micro_xs = FluxDepletionOperator.create_micro_xs_from_csv(ONE_GROUP_XS) - my_flux_operator = FluxDepletionOperator( + nuclide_flux_operator = FluxDepletionOperator.from_nuclides( 1, nuclides, micro_xs, FLUX_SPECTRA, CHAIN_PATH)