mdtraj.compute_displacements

mdtraj.compute_displacements(traj, atom_pairs, periodic=True, opt=True)[source]

Compute the displacement vector between pairs of atoms in each frame of a trajectory.

Parameters:
  • traj (Trajectory) – Trajectory to compute distances in

  • atom_pairs (np.ndarray, shape[num_pairs, 2], dtype=int) – Each row gives the indices of two atoms.

  • periodic (bool, default=True) – If periodic is True and the trajectory contains unitcell information, we will compute distances under the minimum image convention.

  • opt (bool, default=True) – Use an optimized native library to calculate distances. Our optimized minimum image convention calculation implementation is over 1000x faster than the naive numpy implementation.

Returns:

displacements – The displacememt vector, in each frame, between each pair of atoms.

Return type:

np.ndarray, shape=[n_frames, n_pairs, 3], dtype=float32