Created
July 2, 2014 22:15
-
-
Save kyleabeauchamp/8fc55c0b8fa11e509a62 to your computer and use it in GitHub Desktop.
calculate dipole moment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mdtraj as md | |
import numpy as np | |
def dipole_moment(traj, charges): | |
"""Compute the dipole moment of an MDTraj object.""" | |
xyz = md.compute_displacements(traj, np.array([[0, i] for i in range(traj.n_atoms)])).astype('float') | |
return xyz.transpose(0, 2, 1).dot(charges) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment