neighbor_algorithm
This is summary documentation for hippynn.layers.pairs.csr_pairs.neighbor_algorithm module. Click here for full documentation.
Links to Full Documentation:
This file was written with assistance from an LLM.
Neighbor list construction over triclinic periodic cells using PyTorch + CSR.
This module builds neighbor pairs for batched molecular/atomistic systems with
triclinic cells. It uses a light CSR “algebra” (see csrtable) to stage
row-wise joins and filtering:
Pipeline (high level)
build_initial_data()— wrap raw inputs into CSRs for systems/atoms.normalize_atoms()— wrap positions to fractional [0,1)^3 and record integer image offsets.build_image_offsets()— compute per-system image-shift stencils large enough forcutoff.build_image_atoms()— cartesian-expand primary atoms × image shifts.voxelize_images()— voxel grid per system with edge ≈cutoffand assign image-atoms to voxels.voxel_adjacency()— build voxel–voxel edges via a fixed stencil (includes self-edges).expand_pairs()— expand voxel edges into candidate atom pairs.prune_pairs()— filter by cutoff; drop same-atom self-edges for primary images.calc_neighbors()— orchestration entry point that returns final pairs.
All tensor operations are batched and device/dtype agnostic. Index tensors are
torch.long. Distances/displacements remain differentiable w.r.t. input positions.
Functions
|
Expand primary atoms across image offsets (row-wise outer join). |
|
Compute per-system periodic image offsets sufficient for |
|
Package raw inputs (positions/mask/cells/cutoff) into CSR containers. |
|
Full neighbor-list pipeline (batched triclinic PBC). |
|
Compute per-system axis-aligned bounding boxes (AABB). |
|
Expand voxel edges to candidate atom pairs. |
|
Wrap atoms into the primary triclinic cell and record image offsets. |
|
Apply geometric/pruning predicates to candidate pairs. |
|
Build voxel–voxel edges using a fixed stencil (includes self-edges). |
|
Partition image-atoms into near-cubic voxels of edge ≈ cutoff. |