From 5160417e3e01097934eb0ef36610c35aa3fa6639 Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Wed, 22 Mar 2023 12:45:33 -0500 Subject: [PATCH 1/4] load any nuclide requested that is not present in materials prior to constructing tally --- openmc/deplete/helpers.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index e51106544..90d1ddde4 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -15,7 +15,7 @@ from openmc.mpi import comm from openmc.checkvalue import check_type, check_greater_than from openmc.data import JOULE_PER_EV, REACTION_MT from openmc.lib import ( - Tally, MaterialFilter, EnergyFilter, EnergyFunctionFilter) + Tally, MaterialFilter, EnergyFilter, EnergyFunctionFilter, load_nuclide) import openmc.lib from .abc import ( ReactionRateHelper, NormalizationHelper, FissionYieldHelper) @@ -189,7 +189,7 @@ class DirectReactionRateHelper(ReactionRateHelper): def reset_tally_means(self): """Reset the cached mean rate tallies. .. note:: - + This step must be performed after each transport cycle """ self._rate_tally_means_cache = None @@ -306,6 +306,12 @@ class FluxCollapseHelper(ReactionRateHelper): self._rate_tally.filters = [MaterialFilter(materials)] self._rate_tally_means_cache = None if self._nuclides_direct is not None: + # check if any direct tally nuclides are requested that are not + # already loaded with the materials. Load separately if so. + mat_nuclides = [n for mat in materials for n in mat.nuclides] + extra_nuclides = set(self._nuclides_direct) - set(mat_nuclides) + for nuc in extra_nuclides: + load_nuclide(nuc) self._rate_tally.nuclides = self._nuclides_direct @property @@ -327,7 +333,7 @@ class FluxCollapseHelper(ReactionRateHelper): def reset_tally_means(self): """Reset the cached mean rate and flux tallies. .. note:: - + This step must be performed after each transport cycle """ self._flux_tally_means_cache = None From e93dd66430d7cae137cae8798b72645cd2d32726 Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Thu, 23 Mar 2023 15:07:32 -0500 Subject: [PATCH 2/4] eliminate set/list redundancy Co-authored-by: Paul Romano --- openmc/deplete/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index 90d1ddde4..ec0f65650 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -308,8 +308,8 @@ class FluxCollapseHelper(ReactionRateHelper): if self._nuclides_direct is not None: # check if any direct tally nuclides are requested that are not # already loaded with the materials. Load separately if so. - mat_nuclides = [n for mat in materials for n in mat.nuclides] - extra_nuclides = set(self._nuclides_direct) - set(mat_nuclides) + mat_nuclides = {n for mat in materials for n in mat.nuclides} + extra_nuclides = set(self._nuclides_direct) - mat_nuclides for nuc in extra_nuclides: load_nuclide(nuc) self._rate_tally.nuclides = self._nuclides_direct From 7f68462e3a4d6f10914e4812eba67d482e2cb7f1 Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Thu, 23 Mar 2023 15:43:03 -0500 Subject: [PATCH 3/4] add nuclide that is not in model; (fails locally) --- tests/unit_tests/test_deplete_activation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit_tests/test_deplete_activation.py b/tests/unit_tests/test_deplete_activation.py index 1842ad8ac..cef614f82 100644 --- a/tests/unit_tests/test_deplete_activation.py +++ b/tests/unit_tests/test_deplete_activation.py @@ -47,7 +47,7 @@ ENERGIES = np.logspace(log10(1e-5), log10(2e7), 100) ("direct", {}, 1e-5), ("flux", {'energies': ENERGIES}, 0.01), ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)']}, 1e-5), - ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)'], 'nuclides': ['W186']}, 1e-5), + ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)'], 'nuclides': ['W186', 'H3']}, 1e-5), ]) def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts, tolerance): # Determine (n.gamma) reaction rate using initial run From 2d6938553a6a987d0b766ed5f42e4fe16669480e Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Sat, 25 Mar 2023 09:13:58 -0500 Subject: [PATCH 4/4] Update tests/unit_tests/test_deplete_activation.py Co-authored-by: Paul Romano --- tests/unit_tests/test_deplete_activation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit_tests/test_deplete_activation.py b/tests/unit_tests/test_deplete_activation.py index cef614f82..4c3d1de09 100644 --- a/tests/unit_tests/test_deplete_activation.py +++ b/tests/unit_tests/test_deplete_activation.py @@ -47,7 +47,7 @@ ENERGIES = np.logspace(log10(1e-5), log10(2e7), 100) ("direct", {}, 1e-5), ("flux", {'energies': ENERGIES}, 0.01), ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)']}, 1e-5), - ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)'], 'nuclides': ['W186', 'H3']}, 1e-5), + ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)'], 'nuclides': ['W186', 'H3']}, 1e-2), ]) def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts, tolerance): # Determine (n.gamma) reaction rate using initial run