mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Fix CoherentElastic.__call__
This commit is contained in:
parent
fbacfa0e5c
commit
3e5741e1bb
1 changed files with 7 additions and 2 deletions
|
|
@ -145,10 +145,15 @@ class CoherentElastic(EqualityMixin):
|
|||
self.factors = factors
|
||||
|
||||
def __call__(self, E):
|
||||
idx = np.searchsorted(self.bragg_edges, E) - 1
|
||||
if isinstance(E, Iterable):
|
||||
E = np.asarray(E)
|
||||
idx = np.searchsorted(self.bragg_edges, E)
|
||||
return self.factors[idx] / E
|
||||
nonzero = idx >= 0
|
||||
xs = np.zeros_like(E)
|
||||
xs[nonzero] = self.factors[idx[nonzero]] / E[nonzero]
|
||||
return xs
|
||||
else:
|
||||
return self.factors[idx] / E if idx >= 0 else 0.0
|
||||
|
||||
def __len__(self):
|
||||
return len(self.bragg_edges)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue