mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
make sure locating window is not out of bounds
This commit is contained in:
parent
361767ad2d
commit
fe0221445e
2 changed files with 4 additions and 2 deletions
|
|
@ -1143,7 +1143,8 @@ class WindowedMultipole(EqualityMixin):
|
|||
# the 1-based vs. 0-based indexing. Similarly startw needs to be
|
||||
# decreased by 1. endw does not need to be decreased because
|
||||
# range(startw, endw) does not include endw.
|
||||
i_window = int(np.floor((sqrtE - sqrt(self.E_min)) / self.spacing))
|
||||
i_window = min(self.n_windows - 1,
|
||||
int(np.floor((sqrtE - sqrt(self.E_min)) / self.spacing)))
|
||||
startw = self.windows[i_window, 0] - 1
|
||||
endw = self.windows[i_window, 1]
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ WindowedMultipole::evaluate(double E, double sqrtkT)
|
|||
double invE = 1.0 / E;
|
||||
|
||||
// Locate window containing energy
|
||||
int i_window = (sqrtE - std::sqrt(E_min_)) / spacing_;
|
||||
int i_window = std::min(windows_.shape()[0] - 1,
|
||||
(sqrtE - std::sqrt(E_min_)) / spacing_);
|
||||
int startw = windows_(i_window, 0) - 1;
|
||||
int endw = windows_(i_window, 1) - 1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue