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

Add Matscipy Neighborlist Support #25

Open
tgmaxson opened this issue Jul 29, 2024 · 1 comment
Open

Add Matscipy Neighborlist Support #25

tgmaxson opened this issue Jul 29, 2024 · 1 comment

Comments

@tgmaxson
Copy link

For my test case, this implementation was slightly faster than the pymatgen neighborlist but I did not extensively test this.

from matscipy.neighbours import neighbour_list

def calc_neighbor_by_matscipy(
    pos: Tensor, cell: Tensor, pbc: Tensor, cutoff: float
) -> Tuple[Tensor, Tensor]:
    idx_i, idx_j, S = neighbour_list(
        quantities="ijS",
        pbc=pbc.detach().cpu().numpy(),
        cell=cell.detach().cpu().numpy(),
        positions=pos.detach().cpu().numpy(),
        cutoff=cutoff,
    )
    edge_index = torch.tensor(np.stack([idx_i, idx_j], axis=0), dtype=torch.int64, device=pos.device)
    # convert int64 -> pos.dtype (float)
    S = torch.tensor(S, dtype=pos.dtype, device=pos.device)
    return edge_index, S
@corochann
Copy link
Member

Thank you for opening the issue and sharing the codes.

Recently I have no time to include it in main branch, but it is helpful information for others!

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

No branches or pull requests

2 participants