Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ipudu committed Aug 19, 2017
1 parent a660f5b commit 25df622
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions order/msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
class meanSquareD(oto.Orientational):
"""mean square displacement"""
def __init__(self, filename, center, bins=100):
super(Translational, self).__init__(filename, center, bins)
super(meanSquareD, self).__init__(filename, center, bins)

def mean_square_displacement(self, max_t = 1000, freq = 1):
"""compute mean square displacement"""
#progress bar
frames = int(self.traj.n_frames / freq)
bar = ChargingBar('Processing', max=frames,
bar = ChargingBar('Processing', max=max_t,
suffix='%(percent).1f%% - %(eta)ds')

for t in range(max_t):
Expand All @@ -40,8 +39,8 @@ def mean_square_displacement(self, max_t = 1000, freq = 1):
for i in range(0, self.traj.n_frames, freq):
if i + t < self.traj.n_frames:
for j in range(self.traj.n_atoms):
mid += np.square(np.substract(self.traj.coords[i][j],
self.traj.coords[i+t][j]))
mid += np.square(np.subtract(self.traj.coords[i][j],
self.traj.coords[i+t][j]))
ct = np.sum(mid)
ct = ct * 1.0 / (self.traj.n_atoms * (self.traj.n_frames - t))
self.raw.append(ct)
Expand All @@ -51,10 +50,10 @@ def mean_square_displacement(self, max_t = 1000, freq = 1):

def out_put(self, taskname='MSD'):
"""output raw data of msd"""
raw_data = self.fprefix + '_' + taskname + '_raw.dat'
raw_data = self.fprefix + '_' + taskname + '.dat'
with open(raw_data, 'w') as f:
f.write('#' + taskname + ' generated by Order: A Python Tool\n')
f.write('#raw data\n')

for k,i in enumerate(self.raw):
f.write('{}\t{}\n'.format(k, i))
f.write('{}\t{}\n'.format(k, i))

0 comments on commit 25df622

Please sign in to comment.