Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix orbital values when an orbital is completely outside of the unit cell #836

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

pfebrer
Copy link
Contributor

@pfebrer pfebrer commented Oct 4, 2024

The orbital values computation was failing if there were orbitals that were completely outside of the unit cell.

@pfebrer
Copy link
Contributor Author

pfebrer commented Oct 4, 2024

E.g. I tested one case where rx,ry,rz was slice(354, 300, None), slice(0, 4, None), slice(8, 12, None)

which resulted in:

File ~/webDevelopement/sislGUI/sisl/src/sisl/_core/geometry.py:3825, in Geometry._orbital_values(self, grid_shape)
   3822     warn(f"Atom '{atom}' does not have a wave-function, skipping atom.")
   3823     continue
-> 3825 idx = sphere_grid_index(grid, ia_xyz, R)
   3827 if len(idx) == 0:
   3828     continue

File ~/webDevelopement/sislGUI/sisl/src/sisl/_core/geometry.py:3765, in Geometry._orbital_values.<locals>.sphere_grid_index(grid, center, R)
   3761 rz = slice(cmin[2], min(cmax[2], grid.shape[2]))
   3763 print(rx, ry, rz)
-> 3765 indices = np.mgrid[rx, ry, rz].reshape(3, -1).T
   3767 return indices

File ~/miniconda3/envs/simulationspy311/lib/python3.11/site-packages/numpy/lib/index_tricks.py:173, in nd_grid.__getitem__(self, key)
    170     nn = [_nx.arange(_x, dtype=_t)
    171           for _x, _t in zip(size, (typ,)*len(size))]
    172 else:
--> 173     nn = _nx.indices(size, typ)
    174 for k, kk in enumerate(key):
    175     step = kk.step

File ~/miniconda3/envs/simulationspy311/lib/python3.11/site-packages/numpy/core/numeric.py:1764, in indices(dimensions, dtype, sparse)
   1762     res = tuple()
   1763 else:
-> 1764     res = empty((N,)+dimensions, dtype=dtype)
   1765 for i, dim in enumerate(dimensions):
   1766     idx = arange(dim, dtype=dtype).reshape(
   1767         shape[:i] + (dim,) + shape[i+1:]
   1768     )

ValueError: negative dimensions are not allowed

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.68%. Comparing base (52d83bd) to head (9ea4768).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #836   +/-   ##
=======================================
  Coverage   86.68%   86.68%           
=======================================
  Files         402      402           
  Lines       51886    51887    +1     
=======================================
+ Hits        44979    44980    +1     
  Misses       6907     6907           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Nick Papior <nickpapior@gmail.com>
@zerothi
Copy link
Owner

zerothi commented Oct 4, 2024

Removed np.maximum I think they were too heavy for such small arrays. Will merge once coveraged.

@zerothi zerothi merged commit e35cb57 into zerothi:main Oct 4, 2024
16 of 17 checks passed
@zerothi
Copy link
Owner

zerothi commented Oct 4, 2024

Thanks @pfebrer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants