Skip to content

Conversation

KristofferC
Copy link
Owner

@KristofferC KristofferC commented Jun 20, 2024

Similar to what is described in https://namdanalyzer.readthedocs.io/en/latest/kdTree/periodic_kdtree.html.

then querying this kd-tree multiple times, if necessary, with all the relevant periodic images of the query point.

I don't understand why this is needed..

TODO:

  • Check query point is inside periodic box?
  • Docs
  • Tests

Fixes #133

@dkarrasch
Copy link
Contributor

I don't understand why this is needed..

I think this is because some points may be far from the query point, represented by some point in the canonical image, but close to a shifted one version of the query point. So you may need to query for the canonical version and the shifted one, and out of those find the nearest neighbors.

@KristofferC
Copy link
Owner Author

Aha, I misunderstood the link I think. What I thought they did was to duplicate the input points to all the mirrors (which is what this implementation does) but instead they map the input points to a single "canonical image". In the first case you only need to query once but in the latter you might need to query multiple times (for example if the ball around the query point is outside the image).

That is probably a better idea than what I did here.

@KristofferC KristofferC force-pushed the kc/periodic branch 3 times, most recently from c57c643 to 37889e0 Compare June 30, 2024 13:25
@KristofferC KristofferC force-pushed the kc/periodic branch 3 times, most recently from 9e7266b to 465e86f Compare July 11, 2025 21:41
@KristofferC KristofferC changed the title wip: implement a periodic tree that maps points to "mirrors" Implement a periodic tree that maps points to "mirrors" Jul 11, 2025
- Fix periodic tree implementation with proper boundary validation and mixed dimension support
- Add mirror box pruning optimization for KNN searches to skip irrelevant periodic images
- Implement comprehensive tests covering mixed periodic/non-periodic dimensions and boundary cases
- Add extensive periodic tree benchmarks to benchmark suite for performance tracking
- Add detailed PeriodicTree documentation with examples and usage patterns to README

The periodic tree now properly handles:
- Mixed periodic/non-periodic dimensions (using Inf for non-periodic bounds)
- Boundary validation ensuring all data points are within the periodic box
- Performance optimization by pruning irrelevant mirror boxes during searches
- Comprehensive error handling for invalid box configurations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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.

periodic kdtree or balltree

2 participants