diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index 1c9d96f67..3da8c5c9e 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -268,6 +268,11 @@ class FluxCollapseHelper(ReactionRateHelper): if self._reactions_direct and self._nuclides_direct is None: self._rate_tally.nuclides = nuclides + # Make sure nuclide data is loaded + for nuclide in self.nuclides: + if nuclide not in openmc.lib.nuclides: + openmc.lib.load_nuclide(nuclide) + def generate_tallies(self, materials, scores): """Produce multigroup flux spectrum tally diff --git a/tests/unit_tests/test_deplete_activation.py b/tests/unit_tests/test_deplete_activation.py index 357e303cd..6afea8c9f 100644 --- a/tests/unit_tests/test_deplete_activation.py +++ b/tests/unit_tests/test_deplete_activation.py @@ -11,7 +11,7 @@ import pytest @pytest.fixture def model(): """Sphere of single nuclide""" - model = openmc.model.Model() + model = openmc.Model() w = openmc.Material(name='tungsten') w.add_nuclide('W186', 1.0) @@ -161,3 +161,30 @@ def test_decay(run_in_tmpdir): # Ensure density goes down by a factor of 2 after each half-life assert atoms[1] / atoms[0] == pytest.approx(0.5) assert atoms[2] / atoms[1] == pytest.approx(0.25) + + +def test_flux_rr_missing_nuclide(run_in_tmpdir, model): + # Create two-nuclide depletion chain -- since W184 is not in the model, this + # test ensures that FluxCollapseHelper loads missing nuclides appropriately + chain = openmc.deplete.Chain() + w184 = openmc.deplete.Nuclide('W184') + w184.add_reaction('(n,gamma)', None, 0.0, 1.0) + chain.add_nuclide(w184) + w186 = openmc.deplete.Nuclide('W186') + w186.add_reaction('(n,gamma)', None, 0.0, 1.0) + chain.add_nuclide(w186) + chain.export_to_xml('test_chain.xml') + + # Create transport operator + op = openmc.deplete.CoupledOperator( + model, 'test_chain.xml', + normalization_mode="source-rate", + reaction_rate_mode="flux", + reaction_rate_opts={'energies': [0.0, 20.0e6]}, + ) + + # Deplete with two decay steps + integrator = openmc.deplete.PredictorIntegrator( + op, [100.0], source_rates=[10.0] + ) + integrator.integrate()