mdtraj.dipole_moments

mdtraj.dipole_moments(traj, charges)[source]

Calculate the dipole moments of each frame in a trajectory.

Parameters:
  • traj (Trajectory) – An mdtraj trajectory.

  • charges (np.ndarray, shape=(n_atoms), dtype=float) – Charges of each atom in the trajectory, expressed in units of the elementary charge constant.

Returns:

moments – Dipole moments of trajectory, units of nm * elementary charge.

Return type:

np.ndarray, shape=(n_frames, 3), dtype=float

Notes

This code works by first calculating displacements relative to the first atom in each residue (e.g. local frame). Then, this is added to the PBC-corrected displacement between the first atom in the two molecules. This total displacement is then used as to calculate the box dipole moment.