mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Build mapping to avoid O(N) lookup in FluxCollapseHelper.get_material_rates
This commit is contained in:
parent
fbcd789f20
commit
2e1e669e8a
1 changed files with 5 additions and 6 deletions
|
|
@ -183,14 +183,13 @@ class FluxCollapseHelper(ReactionRateHelper):
|
|||
flux = mean_value[mat_index]
|
||||
|
||||
mat = self._materials[mat_index]
|
||||
|
||||
# Build nucname: density mapping to enable O(1) lookup in loop below
|
||||
densities = dict(zip(mat.nuclides, mat.densities))
|
||||
|
||||
for name, i_nuc in zip(self.nuclides, nuc_index):
|
||||
# Determine density of nuclide
|
||||
# TODO: O(N) search for nuclide is not ideal
|
||||
for nucname, density in zip(mat.nuclides, mat.densities):
|
||||
if nucname == name:
|
||||
break
|
||||
else:
|
||||
raise ValueError("Couldn't find {} in material {}".format(name, mat_id))
|
||||
density = densities[name]
|
||||
|
||||
for mt, i_react in zip(self._mts, react_index):
|
||||
# Use flux to collapse reaction rate (per N)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue