xnn.ffnn.models.geometry.pair_vectors#
- xnn.ffnn.models.geometry.pair_vectors(data, a, b, shift=None)[source]#
Minimum-image displacement vectors
pos[b] - pos[a].For periodic structures the integer image shift is recomputed from the fractional displacement (rounded, then the shortest of the 27 images around it for non-orthogonal cells, detached), so bonded terms are correct for molecules wrapped across the boundary while gradients still flow to positions and cell. Only periodic axes shift: a slab’s images are searched on its two-dimensional lattice, and molecular structures of a mixed batch (zero cell, no periodic axis) keep their plain displacement.
- Parameters:
data (AtomicGraph) – The batched graph.
a (Tensor) – Atom indices of shape
(M,).b (Tensor) – Atom indices of shape
(M,).shift (Tensor, optional) – Image shifts from
pair_image_shifts()to reuse instead of searching them again (they stay valid while the atoms move by less than half the distance to the next image).
- Returns:
Displacements of shape
(M, 3).- Return type:
Tensor