mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Change burn_nuc_to_ind to _burnable_nucs
This commit is contained in:
parent
945675aaaa
commit
65061bdadc
2 changed files with 16 additions and 22 deletions
|
|
@ -123,10 +123,6 @@ class OpenMCOperator(Operator):
|
|||
Reaction rates from the last operator step.
|
||||
burn_mat_to_ind : OrderedDict of str to int
|
||||
Dictionary mapping material ID (as a string) to an index in reaction_rates.
|
||||
burn_nuc_to_ind : OrderedDict of str to int
|
||||
Dictionary mapping nuclide name (as a string) to an index in
|
||||
reaction_rates. Consists of all nuclides with neutron data and appearing
|
||||
in the depletion chain.
|
||||
burnable_mats : list of str
|
||||
All burnable material IDs
|
||||
|
||||
|
|
@ -144,7 +140,9 @@ class OpenMCOperator(Operator):
|
|||
local_mats = _distribute(self.burnable_mats)
|
||||
|
||||
# Determine which nuclides have incident neutron data
|
||||
self._load_participating()
|
||||
self.nuclides_with_data = self._get_nuclides_with_data()
|
||||
self._burnable_nucs = [nuc for nuc in self.nuclides_with_data
|
||||
if nuc in self.chain]
|
||||
|
||||
# Extract number densities from the geometry
|
||||
self._extract_number(local_mats, volume, nuc_dict)
|
||||
|
|
@ -152,7 +150,7 @@ class OpenMCOperator(Operator):
|
|||
# Create reaction rates array
|
||||
index_rx = {rx: i for i, rx in enumerate(self.chain.reactions)}
|
||||
self.reaction_rates = ReactionRates(
|
||||
self.burn_mat_to_ind, self.burn_nuc_to_ind, index_rx)
|
||||
self.burn_mat_to_ind, self._burnable_nucs, index_rx)
|
||||
|
||||
def __call__(self, vec, print_out=True):
|
||||
"""Runs a simulation.
|
||||
|
|
@ -264,7 +262,7 @@ class OpenMCOperator(Operator):
|
|||
len(self.chain))
|
||||
|
||||
if self.settings.dilute_initial != 0.0:
|
||||
for nuc in self.burn_nuc_to_ind:
|
||||
for nuc in self._burnable_nucs:
|
||||
self.number.set_atom_density(np.s_[:], nuc,
|
||||
self.settings.dilute_initial)
|
||||
|
||||
|
|
@ -545,7 +543,7 @@ class OpenMCOperator(Operator):
|
|||
|
||||
return OperatorResult(k_combined, rates)
|
||||
|
||||
def _load_participating(self):
|
||||
def _get_nuclides_with_data(self):
|
||||
"""Loads a cross_sections.xml file to find participating nuclides.
|
||||
|
||||
This allows for nuclides that are important in the decay chain but not
|
||||
|
|
@ -560,7 +558,7 @@ class OpenMCOperator(Operator):
|
|||
except KeyError:
|
||||
filename = None
|
||||
|
||||
self.nuclides_with_data = set()
|
||||
nuclides = set()
|
||||
|
||||
try:
|
||||
tree = ET.parse(filename)
|
||||
|
|
@ -572,9 +570,6 @@ class OpenMCOperator(Operator):
|
|||
raise IOError(msg)
|
||||
|
||||
root = tree.getroot()
|
||||
self.burn_nuc_to_ind = OrderedDict()
|
||||
nuc_ind = 0
|
||||
|
||||
for nuclide_node in root.findall('library'):
|
||||
mats = nuclide_node.get('materials')
|
||||
if not mats:
|
||||
|
|
@ -582,11 +577,10 @@ class OpenMCOperator(Operator):
|
|||
for name in mats.split():
|
||||
# Make a burn list of the union of nuclides in cross_sections.xml
|
||||
# and nuclides in depletion chain.
|
||||
if name not in self.nuclides_with_data:
|
||||
self.nuclides_with_data.add(name)
|
||||
if name in self.chain:
|
||||
self.burn_nuc_to_ind[name] = nuc_ind
|
||||
nuc_ind += 1
|
||||
if name not in nuclides:
|
||||
nuclides.add(name)
|
||||
|
||||
return nuclides
|
||||
|
||||
def get_results_info(self):
|
||||
"""Returns volume list, cell lists, and nuc lists.
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class ReactionRates(np.ndarray):
|
|||
----------
|
||||
index_mat : OrderedDict of str to int
|
||||
A dictionary mapping material ID as string to index.
|
||||
index_nuc : OrderedDict of str to int
|
||||
A dictionary mapping nuclide name as string to index.
|
||||
nuclides : list of str
|
||||
Depletable nuclides
|
||||
index_rx : OrderedDict of str to int
|
||||
A dictionary mapping reaction name as string to index.
|
||||
|
||||
|
|
@ -36,15 +36,15 @@ class ReactionRates(np.ndarray):
|
|||
Number of reactions.
|
||||
|
||||
"""
|
||||
def __new__(cls, index_mat, index_nuc, index_rx):
|
||||
def __new__(cls, index_mat, nuclides, index_rx):
|
||||
# Create appropriately-sized zeroed-out ndarray
|
||||
shape = (len(index_mat), len(index_nuc), len(index_rx))
|
||||
shape = (len(index_mat), len(nuclides), len(index_rx))
|
||||
obj = super().__new__(cls, shape)
|
||||
obj[:] = 0.0
|
||||
|
||||
# Add mapping attributes
|
||||
obj.index_mat = index_mat
|
||||
obj.index_nuc = index_nuc
|
||||
obj.index_nuc = {nuc: i for i, nuc in enumerate(nuclides)}
|
||||
obj.index_rx = index_rx
|
||||
|
||||
return obj
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue