mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Improve array filling/accessing for Operator.__call__
When possible, replaced ``x[:, :, :] = y`` with ``x.fill(y)``. Simple performance tests showed the approaches to be identical with respect to process time. The latter maintains more flexibility; whatever the shape of x becomes, no changes need to be made, so long as x has a ``fill`` method. Replaced ``rates[i, :, :] = ...`` with ``rates[i]`` per reviewer comments
This commit is contained in:
parent
d23fa7cf65
commit
3b8d9758bf
1 changed files with 3 additions and 4 deletions
|
|
@ -513,7 +513,7 @@ class Operator(TransportOperator):
|
|||
|
||||
"""
|
||||
rates = self.reaction_rates
|
||||
rates[:, :, :] = 0.0
|
||||
rates.fill(0.0)
|
||||
|
||||
# Get k and uncertainty
|
||||
k_combined = openmc.capi.keff()
|
||||
|
|
@ -527,7 +527,6 @@ class Operator(TransportOperator):
|
|||
react_ind = [rates.index_rx[react] for react in self.chain.reactions]
|
||||
|
||||
# Compute fission power
|
||||
# TODO : improve this calculation
|
||||
|
||||
# Keep track of energy produced from all reactions in eV per source
|
||||
# particle
|
||||
|
|
@ -545,7 +544,7 @@ class Operator(TransportOperator):
|
|||
slab = materials.index(mat)
|
||||
|
||||
# Zero out reaction rates and nuclide numbers
|
||||
number[:] = 0.0
|
||||
number.fill(0.0)
|
||||
|
||||
# Get new number densities
|
||||
for nuc, i_nuc_results in zip(nuclides, nuc_ind):
|
||||
|
|
@ -559,7 +558,7 @@ class Operator(TransportOperator):
|
|||
tally_rates[:, fission_ind], i)
|
||||
|
||||
# Divide by total number and store
|
||||
rates[i, :, :] = self._rate_helper.divide_by_adens(number)
|
||||
rates[i] = self._rate_helper.divide_by_adens(number)
|
||||
|
||||
# Reduce energy produced from all processes
|
||||
energy = comm.allreduce(energy)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue