Skip to content

Commit

Permalink
Adjust decay data reader to better handle non-normalized branching ra…
Browse files Browse the repository at this point in the history
…tios (#3080)

Co-authored-by: Paul Romano <[email protected]>
  • Loading branch information
johvincau and paulromano committed Aug 13, 2024
1 parent 9d9b2da commit 346f751
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions openmc/deplete/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,31 @@ def from_endf(cls, decay_files, fpy_files, neutron_files,
if not data.nuclide['stable'] and data.half_life.nominal_value != 0.0:
nuclide.half_life = data.half_life.nominal_value
nuclide.decay_energy = data.decay_energy.nominal_value
sum_br = 0.0
for i, mode in enumerate(data.modes):
branch_ratios = []
branch_ids = []
for mode in data.modes:
type_ = ','.join(mode.modes)
if mode.daughter in decay_data:
target = mode.daughter
else:
print('missing {} {} {}'.format(
parent, ','.join(mode.modes), mode.daughter))
parent, type_, mode.daughter))
target = replace_missing(mode.daughter, decay_data)

# Write branching ratio, taking care to ensure sum is unity
br = mode.branching_ratio.nominal_value
sum_br += br
if i == len(data.modes) - 1 and sum_br != 1.0:
br = 1.0 - sum(m.branching_ratio.nominal_value
for m in data.modes[:-1])
branch_ratios.append(br)
branch_ids.append((type_, target))

if not math.isclose(sum(branch_ratios), 1.0):
max_br = max(branch_ratios)
max_index = branch_ratios.index(max_br)

# Adjust maximum branching ratio so they sum to unity
new_br = max_br - sum(branch_ratios) + 1.0
branch_ratios[max_index] = new_br
assert math.isclose(sum(branch_ratios), 1.0)

# Append decay mode
# Append decay modes
for br, (type_, target) in zip(branch_ratios, branch_ids):
nuclide.add_decay_mode(type_, target, br)

nuclide.sources = data.sources
Expand Down

0 comments on commit 346f751

Please sign in to comment.