Replace "Nothing" depletion targets with None

This change is more declarative and mitigates any changes
that there are errors if a target is Nothing, None, or their lower
cased varieties. This is helpful as the depletion chain gets
reduced down and we want to keep total removal rates for
isotopes that are present, but their products don't exist
in the new reduced chain.

Chain.form_matrix has been updated to handle targets that
are None for non-fission reactions and for decay reactions.
Documentation for ReactionTuple and DecayTuple have been
updated to indicate that the target attribute could be None.
This commit is contained in:
Andrew Johnson 2020-03-20 18:07:17 -04:00
parent 44563a30a7
commit d1878a205e
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB
2 changed files with 27 additions and 18 deletions

View file

@ -500,7 +500,7 @@ class Chain(object):
# Gain
for _, target, branching_ratio in nuc.decay_modes:
# Allow for total annihilation for debug purposes
if target != 'Nothing':
if target is not None:
branch_val = branching_ratio * decay_constant
if branch_val != 0.0:
@ -525,17 +525,16 @@ class Chain(object):
matrix[i, i] -= path_rate
# Gain term; allow for total annihilation for debug purposes
if target != 'Nothing':
if r_type != 'fission':
if path_rate != 0.0:
k = self.nuclide_dict[target]
matrix[k, i] += path_rate * br
else:
for product, y in fission_yields[nuc.name].items():
yield_val = y * path_rate
if yield_val != 0.0:
k = self.nuclide_dict[product]
matrix[k, i] += yield_val
if r_type != 'fission':
if target is not None and path_rate != 0.0:
k = self.nuclide_dict[target]
matrix[k, i] += path_rate * br
else:
for product, y in fission_yields[nuc.name].items():
yield_val = y * path_rate
if yield_val != 0.0:
k = self.nuclide_dict[product]
matrix[k, i] += yield_val
# Clear set of reactions
reactions.clear()

View file

@ -30,8 +30,10 @@ Parameters
----------
type : str
Type of the decay mode, e.g., 'beta-'
target : str
Nuclide resulting from decay
target : str or None
Nuclide resulting from decay. A value of ``None`` implies the
target does not exist in the currently configured depletion
chain
branching_ratio : float
Branching ratio of the decay mode
@ -53,8 +55,11 @@ Parameters
----------
type : str
Type of the reaction, e.g., 'fission'
target : str
nuclide resulting from reaction
target : str or None
Nuclide resulting from reaction. A value of ``None``
implies either no single target, e.g. from fission,
or that the target nuclide is not considered
in the current depletion chain
Q : float
Q value of the reaction in [eV]
branching_ratio : float
@ -179,6 +184,8 @@ class Nuclide(object):
for decay_elem in element.iter('decay'):
d_type = decay_elem.get('type')
target = decay_elem.get('target')
if target is not None and target.lower() == "nothing":
target = None
branching_ratio = float(decay_elem.get('branching_ratio'))
nuc.decay_modes.append(DecayTuple(d_type, target, branching_ratio))
@ -192,6 +199,8 @@ class Nuclide(object):
# just set null values
if r_type != 'fission':
target = reaction_elem.get('target')
if target is not None and target.lower() == "nothing":
target = None
else:
target = None
if fission_q is not None:
@ -226,7 +235,7 @@ class Nuclide(object):
for mode, daughter, br in self.decay_modes:
mode_elem = ET.SubElement(elem, 'decay')
mode_elem.set('type', mode)
mode_elem.set('target', daughter)
mode_elem.set('target', daughter or "Nothing")
mode_elem.set('branching_ratio', str(br))
elem.set('reactions', str(len(self.reactions)))
@ -234,7 +243,7 @@ class Nuclide(object):
rx_elem = ET.SubElement(elem, 'reaction')
rx_elem.set('type', rx)
rx_elem.set('Q', str(Q))
if rx != 'fission':
if rx != 'fission' or daughter is not None:
rx_elem.set('target', daughter)
if br != 1.0:
rx_elem.set('branching_ratio', str(br))
@ -461,6 +470,7 @@ class FissionYieldDistribution(Mapping):
data_elem.text = " ".join(map(str, yield_obj.yields))
class FissionYield(Mapping):
"""Mapping for fission yields of a parent at a specific energy