Changes in deplete/chain.py and nuclide.py from PullRequest Inc. review

This commit is contained in:
Paul Romano 2020-04-14 16:28:00 -05:00
parent 6468a027b1
commit 07ee5344d5
2 changed files with 17 additions and 14 deletions

View file

@ -95,9 +95,11 @@ def replace_missing(product, decay_data):
# Iterate until we find an existing nuclide
while product not in decay_data:
if Z > 98:
# Assume alpha decay occurs for Z=99 and above
Z -= 2
A -= 4
else:
# Otherwise assume a beta- or beta+
if beta_minus:
Z += 1
else:
@ -334,10 +336,10 @@ class Chain:
yield_energies = [0.0]
yield_data = {}
for E, table in zip(yield_energies, fpy.independent):
for E, yield_table in zip(yield_energies, fpy.independent):
yield_replace = 0.0
yields = defaultdict(float)
for product, y in table.items():
for product, y in yield_table.items():
# Handle fission products that have no decay data
if product not in decay_data:
daughter = replace_missing(product, decay_data)
@ -735,26 +737,27 @@ class Chain:
rxn_Q = parent.reactions[rxn_index[0]].Q
# Remove existing reactions
for ix in reversed(rxn_index):
parent.reactions.pop(ix)
# Add new reactions
all_meta = True
for tgt, br in new_ratios.items():
all_meta = all_meta and ("_m" in tgt)
for target, br in new_ratios.items():
all_meta = all_meta and ("_m" in target)
parent.reactions.append(ReactionTuple(
reaction, tgt, rxn_Q, br))
reaction, target, rxn_Q, br))
# If branching ratios don't add to unity, add reaction to ground
# with remainder of branching ratio
if all_meta and sums[parent_name] != 1.0:
ground_br = 1.0 - sums[parent_name]
ground_tgt = grounds.get(parent_name)
if ground_tgt is None:
ground_target = grounds.get(parent_name)
if ground_target is None:
pz, pa, pm = zam(parent_name)
ground_tgt = gnd_name(pz, pa + 1, 0)
new_ratios[ground_tgt] = ground_br
ground_target = gnd_name(pz, pa + 1, 0)
new_ratios[ground_target] = ground_br
parent.reactions.append(ReactionTuple(
reaction, ground_tgt, rxn_Q, ground_br))
reaction, ground_target, rxn_Q, ground_br))
@property
def fission_yields(self):

View file

@ -232,9 +232,9 @@ class Nuclide:
elem.set('half_life', str(self.half_life))
elem.set('decay_modes', str(len(self.decay_modes)))
elem.set('decay_energy', str(self.decay_energy))
for mode, daughter, br in self.decay_modes:
for mode_type, daughter, br in self.decay_modes:
mode_elem = ET.SubElement(elem, 'decay')
mode_elem.set('type', mode)
mode_elem.set('type', mode_type)
mode_elem.set('target', daughter or "Nothing")
mode_elem.set('branching_ratio', str(br))