mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
added stable and unstable nuclides to the Chain object (#3338)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
e12c65dff9
commit
e360cb467e
2 changed files with 26 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ from collections import defaultdict, namedtuple
|
|||
from collections.abc import Mapping, Iterable
|
||||
from numbers import Real, Integral
|
||||
from warnings import warn
|
||||
from typing import List
|
||||
|
||||
import lxml.etree as ET
|
||||
import scipy.sparse as sp
|
||||
|
|
@ -244,6 +245,10 @@ class Chain:
|
|||
Reactions that are tracked in the depletion chain
|
||||
nuclide_dict : dict of str to int
|
||||
Maps a nuclide name to an index in nuclides.
|
||||
stable_nuclides : list of openmc.deplete.Nuclide
|
||||
List of stable nuclides available in the chain.
|
||||
unstable_nuclides : list of openmc.deplete.Nuclide
|
||||
List of unstable nuclides available in the chain.
|
||||
fission_yields : None or iterable of dict
|
||||
List of effective fission yields for materials. Each dictionary
|
||||
should be of the form ``{parent: {product: yield}}`` with
|
||||
|
|
@ -256,7 +261,7 @@ class Chain:
|
|||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.nuclides = []
|
||||
self.nuclides: List[Nuclide] = []
|
||||
self.reactions = []
|
||||
self.nuclide_dict = {}
|
||||
self._fission_yields = None
|
||||
|
|
@ -272,7 +277,18 @@ class Chain:
|
|||
"""Number of nuclides in chain."""
|
||||
return len(self.nuclides)
|
||||
|
||||
def add_nuclide(self, nuclide):
|
||||
|
||||
@property
|
||||
def stable_nuclides(self) -> List[Nuclide]:
|
||||
"""List of stable nuclides available in the chain"""
|
||||
return [nuc for nuc in self.nuclides if nuc.half_life is None]
|
||||
|
||||
@property
|
||||
def unstable_nuclides(self) -> List[Nuclide]:
|
||||
"""List of unstable nuclides available in the chain"""
|
||||
return [nuc for nuc in self.nuclides if nuc.half_life is not None]
|
||||
|
||||
def add_nuclide(self, nuclide: Nuclide):
|
||||
"""Add a nuclide to the depletion chain
|
||||
|
||||
Parameters
|
||||
|
|
|
|||
|
|
@ -86,6 +86,14 @@ def test_from_endf(endf_chain):
|
|||
assert nuc == chain[nuc.name]
|
||||
|
||||
|
||||
def test_unstable_nuclides(simple_chain: Chain):
|
||||
assert [nuc.name for nuc in simple_chain.unstable_nuclides] == ["A", "B"]
|
||||
|
||||
|
||||
def test_stable_nuclides(simple_chain: Chain):
|
||||
assert [nuc.name for nuc in simple_chain.stable_nuclides] == ["H1", "C"]
|
||||
|
||||
|
||||
def test_from_xml(simple_chain):
|
||||
"""Read chain_test.xml and ensure all values are correct."""
|
||||
# Unfortunately, this routine touches a lot of the code, but most of
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue