compute_distances_with_cell_shifts

torch_sim.transforms.compute_distances_with_cell_shifts(pos, mapping, cell_shifts)[source]
Compute distances between pairs of positions, optionally

including cell shifts.

This function calculates the Euclidean distances between pairs of positions specified by the mapping tensor. If cell shifts are provided, they are added to the distance calculation to account for periodic boundary conditions.

Parameters:
  • pos (Tensor) – A tensor of shape (n_atoms, 3) representing the positions of atoms.

  • mapping (Tensor) – A tensor of shape (2, n_pairs) that specifies pairs of indices in pos for which to compute distances.

  • cell_shifts (Optional[Tensor]) – A tensor of shape (n_pairs, 3) representing the shifts to apply to the distances for periodic boundary conditions. If None, no shifts are applied.

Returns:

A tensor of shape (n_pairs,) containing the

computed distances for each pair.

Return type:

Tensor