mlipops.batch_periodic_displacements#

mlipops.batch_periodic_displacements(displacements: Tensor, batch: Tensor, box_vectors: Tensor | None) Tensor#

Apply periodic boundary conditions to displacement vectors for a batch of systems.

Parameters:
  • displacements (torch.Tensor) – a Tensor of shape (M, 3) where M is arbitrary. Each displacement vector should be the difference between a pair of positions in 3D space.

  • batch (torch.Tensor | None) – a Tensor of shape (M,) containing the index of the system each vector belongs to

  • box_vectors (torch.Tensor | None) – a Tensor of shape (n_systems, 3, 3) containing box vectors defining the periodic box for each system. If None, periodic boundary conditions are not used and the displacement vectors are returned unchanged.

Returns:

a Tensor of the same shape as displacements. The vectors have been modified to apply periodic boundary conditions.

Return type:

torch.Tensor