From 3e5741e1bb688af4a7e56b6389a89ee440b4b749 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 18 Apr 2019 09:45:24 -0500 Subject: [PATCH] Fix CoherentElastic.__call__ --- openmc/data/thermal.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index 7eeca685a2..762de3cd3e 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -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)