mdtraj.compute_distances

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

Compute the distances between pairs of atoms in each frame.

Parameters:

traj : Trajectory

An mtraj trajectory.

atom_pairs : np.ndarray, shape=(num_pairs, 2), dtype=int

Each row gives the indices of two atoms involved in the interaction.

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 SSE minimum image convention calculation implementation is over 1000x faster than the naive numpy implementation.

Returns:

distances : np.ndarray, shape=(n_frames, num_pairs), dtype=float

The distance, in each frame, between each pair of atoms.