Skip to content

Commit

Permalink
Fix orbital values when an orbital is completely outside of the unit …
Browse files Browse the repository at this point in the history
…cell (#836)

* Fix orbital values

* removed np.maximum calls, no sense for such small arrays

Signed-off-by: Nick Papior <nickpapior@gmail.com>

---------

Signed-off-by: Nick Papior <nickpapior@gmail.com>
Co-authored-by: Nick Papior <nickpapior@gmail.com>
  • Loading branch information
pfebrer and zerothi authored Oct 4, 2024
1 parent d2a8d39 commit e35cb57
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/sisl/_core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e35cb57

Please sign in to comment.