Document and test the default Chain fission yields

This commit is contained in:
Andrew Johnson 2019-08-08 08:30:23 -05:00
parent c732336536
commit 5fb8ec2d7a
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB
2 changed files with 29 additions and 5 deletions

View file

@ -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()

View file

@ -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}}