pwtools.crys.velocity_traj

pwtools.crys.velocity_traj(arr, dt=1.0, axis=0, endpoints=True)[source]

Calculate velocity from arr (usually coordinates) along time`axis` using timestep dt.

Central differences are used (example x-coord of atom 0: x=coords[:,0,0]):

v[i] = [ x[i+1] - x[i-1] ] / (2*dt)

which returns nstep-2 points belonging to the the middle of the trajectory x[1:-1]. To get an array which is nstep long, the fist and last velocity are set to the first and last calculated value (if endpoints=True):

v[0,...] == v[1,...]
v[-1,...] == v[-2,...]