mdtraj.compute_displacements

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

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

Parameters
trajTrajectory

Trajectory to compute distances in

atom_pairsnp.ndarray, shape[num_pairs, 2], dtype=int

Each row gives the indices of two atoms.

periodicbool, default=True

If periodic is True and the trajectory contains unitcell information, we will compute distances under the minimum image convention.

optbool, 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
displacementsnp.ndarray, shape=[n_frames, n_pairs, 3], dtype=float32

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