From 5fb8ec2d7aeb0af1d408898b6f57b620132bf39e Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 8 Aug 2019 08:30:23 -0500 Subject: [PATCH] Document and test the default Chain fission yields --- openmc/deplete/chain.py | 26 +++++++++++++++++++++----- tests/unit_tests/test_deplete_chain.py | 8 ++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/openmc/deplete/chain.py b/openmc/deplete/chain.py index 31b074bddb..2354158562 100644 --- a/openmc/deplete/chain.py +++ b/openmc/deplete/chain.py @@ -375,9 +375,19 @@ class Chain(object): tree.write(str(filename), encoding='utf-8') def get_thermal_fission_yields(self): - """Return dictionary {str: {str: float}}""" - # Take lowest energy for back compatability - # Should be removed by end of this feature + """Return fission yields at lowest incident neutron energy + + Used as the default set of fission yields for :meth:`form_matrix` + if ``fission_yields`` are not provided + + Returns + ------- + fission_yields : dict + Dictionary of ``{parent : {product : f_yield}}`` + where ``parent`` and ``product`` are both string + names of nuclides with yield data and ``f_yield`` + is a float for the fission yield. + """ out = {} for nuc in self.nuclides: if len(nuc.yield_data) == 0: @@ -393,14 +403,20 @@ class Chain(object): ---------- rates : numpy.ndarray 2D array indexed by (nuclide, reaction) - fission_yields : dictionary of tuple to float, optional - Option to use a custom set of fission yields + fission_yields : dict, optional + Option to use a custom set of fission yields. Expected + to be of the form ``{parent : {product : f_yield}}`` + with string nuclide names for ``parent`` and ``product``, + and ``f_yield`` as the respective fission yield Returns ------- scipy.sparse.csr_matrix Sparse matrix representing depletion. + See Also + -------- + :meth:`get_thermal_fission_yields` """ matrix = defaultdict(float) reactions = set() diff --git a/tests/unit_tests/test_deplete_chain.py b/tests/unit_tests/test_deplete_chain.py index d31933c34a..546fa99c3e 100644 --- a/tests/unit_tests/test_deplete_chain.py +++ b/tests/unit_tests/test_deplete_chain.py @@ -230,6 +230,7 @@ def test_form_matrix(simple_chain): for r, c in product(range(3), range(3)): assert new_mat[r, c] == mat[r, c] + def test_getitem(): """ Test nuc_by_ind converter function. """ chain = Chain() @@ -338,3 +339,10 @@ def test_capture_branch_failures(simple_chain): br = {"C": {"A": 1.0, "B": 1.0}} with pytest.raises(ValueError, match="C ratios"): simple_chain.set_capture_branches(br) + + +def test_simple_fission_yields(simple_chain): + """Check the default fission yields that can be used to form the matrix + """ + fission_yields = simple_chain.get_thermal_fission_yields() + assert fission_yields == {"C": {"A": 0.0292737, "B": 0.002566345}}