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

find k nearest neighbors within r_cutoff #32

Open
yzchen08 opened this issue Dec 3, 2024 · 1 comment
Open

find k nearest neighbors within r_cutoff #32

yzchen08 opened this issue Dec 3, 2024 · 1 comment

Comments

@yzchen08
Copy link

yzchen08 commented Dec 3, 2024

Can vesin find k nearest neighbors within r_cutoff and output idx_i, idx_j, shifts? For now I can only calculate all neighbors within r_cutoff.

calculator = vesin.NeighborList(cutoff=self.r_cutoff, full_list=True)
idx_i, idx_j, shifts, distances = calculator.compute(
    points=atoms.positions, 
    box=atoms.cell.array, 
    periodic=True, 
    quantities="ijSd"
    )
@Luthaf
Copy link
Owner

Luthaf commented Dec 3, 2024

In the current state, you'll need to do some post-processing to get the k nearest neighbors: sorting the distances array; sorting the (i, j, S) arrays in the same way; and then taking the first k elements.

It could make sense to add an option on vesin side to do the sorting according to distances (the current sorted argument sorts the pair indices); and then you would only have to slice the arrays to get the data you need.

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