Skip to content

Commit

Permalink
Speed up neighborlists
Browse files Browse the repository at this point in the history
  • Loading branch information
tovrstra committed Oct 27, 2024
1 parent c062027 commit 43b5713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__
src/tinyff/_version.py
dist
build
tmp
5 changes: 4 additions & 1 deletion src/tinyff/neighborlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

__all__ = ("NLIST_DTYPE", "NBuildSimple", "NBuildCellLists")


NLIST_DTYPE = [
# First atoms.
("iatom0", int),
Expand Down Expand Up @@ -189,7 +190,9 @@ def _apply_mic(deltas: NDArray[float], cell_lengths: NDArray[float]):
deltas /= cell_lengths
deltas -= np.round(deltas)
deltas *= cell_lengths
return np.linalg.norm(deltas, axis=1)
dist = np.einsum("ij,ij->i", deltas, deltas)
np.sqrt(dist, out=dist)
return dist


@attrs.define
Expand Down

0 comments on commit 43b5713

Please sign in to comment.