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

periodic kdtree or balltree #133

Open
moradza opened this issue Jan 13, 2022 · 6 comments · May be fixed by #193
Open

periodic kdtree or balltree #133

moradza opened this issue Jan 13, 2022 · 6 comments · May be fixed by #193

Comments

@moradza
Copy link

moradza commented Jan 13, 2022

I am trying to use this package to build neighbor lists. I am new to Julia. Can you help me in the implementation of periodic elucidation distance or add it as a functionality?

@dkarrasch
Copy link
Contributor

You can find the PeriodicEuclidean distance over at Distances.jl. And then you can pass it as the metric argument to the tree constructor here. You'll need to use a BallTree, though, because PeriodicEuclidean is not a Minkowski-type metric.

@oameye
Copy link

oameye commented Jan 16, 2022

In what sense is PeriodicEucledean not a Minkowski Metric? As it is very similar to the Eucledean would it not be quite easy to also implement it for KDTree?

@oameye
Copy link

oameye commented Jan 16, 2022

In what sense is PeriodicEucledean not a Minkowski Metric? As it is similar to the Eucledean would it not be quite easy to also implement it for KDTree?

Did a quick google search. It seems that for periodic euclidean metric the canonical KD tree structure is not applicable. Nevertheless, as this review indicates there are modified KD Tree structures which can handle periodic boundaries.

@moradza
Copy link
Author

moradza commented Jan 16, 2022

I guess it should be possible https://namdanalyzer.readthedocs.io/en/latest/kdTree/periodic_kdtree.html. I am still learning Julia, do you have an example of using distance.jl with ballTree.

@oameye
Copy link

oameye commented Jan 17, 2022

I guess it should be possible https://namdanalyzer.readthedocs.io/en/latest/kdTree/periodic_kdtree.html. I am still learning Julia, do you have an example of using distance.jl with ballTree.

using NearestNeighbors
using Distances
data = rand(1, 10^4)
r = 0.05
point = rand(1)

balltree = BallTree(data, PeriodicEuclidean([1]))
idxs = inrange(balltree, point, r)

@KristofferC
Copy link
Owner

Searches with periodic boundaries are implemented by mapping all initial data points to one canonical periodic image, building an ordinary kd-tree with these points, then querying this kd-tree multiple times, if necessary, with all the relevant periodic images of the query point.

We could do this.

@KristofferC KristofferC linked a pull request Jun 20, 2024 that will close this issue
3 tasks
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 a pull request may close this issue.

4 participants