mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Add minor changes from code review to deplete.Nuclide.validate
This commit is contained in:
parent
0de7618f95
commit
32f3c27cf6
3 changed files with 5 additions and 8 deletions
|
|
@ -623,7 +623,7 @@ class Chain(object):
|
|||
1) For all non-fission reactions, does the sum of branching
|
||||
ratios equal about one?
|
||||
2) For fission reactions, does the sum of fission yield
|
||||
fractions equal about 2?
|
||||
fractions equal about two?
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
|
@ -639,6 +639,7 @@ class Chain(object):
|
|||
value ``x`` to intended value ``y`` as::
|
||||
|
||||
valid = (y - tolerance <= x <= y + tolerance)
|
||||
|
||||
Returns
|
||||
-------
|
||||
valid : bool
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ Contains the per-nuclide components of a depletion chain.
|
|||
"""
|
||||
|
||||
from collections import namedtuple, defaultdict
|
||||
from operator import attrgetter, itemgetter
|
||||
from warnings import warn
|
||||
try:
|
||||
import lxml.etree as ET
|
||||
|
|
@ -266,10 +265,8 @@ class Nuclide(object):
|
|||
openmc.deplete.Chain.validate
|
||||
"""
|
||||
|
||||
branch_getter = attrgetter("branching_ratio")
|
||||
msg_func = ("Nuclide {name} has {prop} that sum to {actual} "
|
||||
"instead of {expected} +/- {tol:7.4e}").format
|
||||
type_map = defaultdict(set)
|
||||
valid = True
|
||||
|
||||
# check decay modes
|
||||
|
|
@ -288,7 +285,7 @@ class Nuclide(object):
|
|||
valid = False
|
||||
|
||||
if self.reactions:
|
||||
type_map.clear()
|
||||
type_map = defaultdict(set)
|
||||
for reaction in self.reactions:
|
||||
type_map[reaction.type].add(reaction)
|
||||
for rxn_type, reactions in type_map.items():
|
||||
|
|
@ -306,8 +303,7 @@ class Nuclide(object):
|
|||
warn(msg)
|
||||
valid = False
|
||||
|
||||
if self.yield_data > 0:
|
||||
yield_getter = itemgetter(1)
|
||||
if self.yield_data:
|
||||
for energy, yield_list in self.yield_data.items():
|
||||
sum_yield = sum(y[1] for y in yield_list)
|
||||
stat = 2.0 - tolerance <= sum_yield <= 2.0 + tolerance
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ def test_validate():
|
|||
|
||||
# restore reactions, invalidate fission yields
|
||||
nuc.reactions.append(reaction)
|
||||
fission_yields = nuc.yield_data[1e6].pop()
|
||||
nuc.yield_data[1e6].pop()
|
||||
|
||||
with pytest.raises(ValueError, match=r"fission yields.*1\.0*e"):
|
||||
nuc.validate(strict=True, quiet=False, tolerance=0.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue