From e35cb57da7ed5cb6e9ec832d20ec4c20513560c5 Mon Sep 17 00:00:00 2001 From: pfebrer <42074085+pfebrer@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:37:06 +0200 Subject: [PATCH] Fix orbital values when an orbital is completely outside of the unit cell (#836) * Fix orbital values * removed np.maximum calls, no sense for such small arrays Signed-off-by: Nick Papior --------- Signed-off-by: Nick Papior Co-authored-by: Nick Papior --- src/sisl/_core/geometry.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sisl/_core/geometry.py b/src/sisl/_core/geometry.py index 9d33988cf..708c6f059 100644 --- a/src/sisl/_core/geometry.py +++ b/src/sisl/_core/geometry.py @@ -3749,12 +3749,13 @@ def sphere_grid_index(grid, center, R): corners_i = grid.index(corners) - cmin = np.maximum(corners_i.min(axis=0), 0) - cmax = np.maximum(corners_i.max(axis=0) + 1, 0) + cmin = corners_i.min(axis=0) + cmax = corners_i.max(axis=0) + 1 - rx = slice(cmin[0], min(cmax[0], grid.shape[0])) - ry = slice(cmin[1], min(cmax[1], grid.shape[1])) - rz = slice(cmin[2], min(cmax[2], grid.shape[2])) + sh = grid.shape + rx = slice(min(max(cmin[0], 0), sh[0]), min(max(cmax[0], 0), sh[0])) + ry = slice(min(max(cmin[1], 0), sh[1]), min(max(cmax[1], 0), sh[1])) + rz = slice(min(max(cmin[2], 0), sh[2]), min(max(cmax[2], 0), sh[2])) indices = np.mgrid[rx, ry, rz].reshape(3, -1).T