mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Faster indexing in MicroXS object (#2702)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
9cf2f22f24
commit
11a4638849
1 changed files with 4 additions and 2 deletions
|
|
@ -189,6 +189,8 @@ class MicroXS:
|
|||
self.data = data
|
||||
self.nuclides = nuclides
|
||||
self.reactions = reactions
|
||||
self._index_nuc = {nuc: i for i, nuc in enumerate(nuclides)}
|
||||
self._index_rx = {rx: i for i, rx in enumerate(reactions)}
|
||||
|
||||
# TODO: Add a classmethod for generating MicroXS directly from cross section
|
||||
# data using a known flux spectrum
|
||||
|
|
@ -224,8 +226,8 @@ class MicroXS:
|
|||
|
||||
def __getitem__(self, index):
|
||||
nuc, rx = index
|
||||
i_nuc = self.nuclides.index(nuc)
|
||||
i_rx = self.reactions.index(rx)
|
||||
i_nuc = self._index_nuc[nuc]
|
||||
i_rx = self._index_rx[rx]
|
||||
return self.data[i_nuc, i_rx]
|
||||
|
||||
def to_csv(self, *args, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue