Skip to content

Commit

Permalink
add unfold to trajpy if box_length != None
Browse files Browse the repository at this point in the history
  • Loading branch information
phydev authored Aug 10, 2020
1 parent 5d0279c commit fc59691
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion trajpy/trajpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Trajectory(object):
as a dummy object for calling its functions or you can initialize
it with a trajectory array or csv file.
"""
def __init__(self, trajectory=np.zeros((1, 2)), **params):
def __init__(self, trajectory=np.zeros((1, 2)), box_length=None, **params):
"""
Initialization function that can be left blank for using staticmethods.
It can be initialized with an array with shape (N, dim)
Expand All @@ -33,6 +33,9 @@ def __init__(self, trajectory=np.zeros((1, 2)), **params):
else:
raise TypeError('trajectory receives an array or a filename as input.')

if box_length != None:
self._r = aux.unfold(self._r[0], self._r, box_length)

self.msd_ta = None # time-averaged mean squared displacement
self.msd_ea = None # ensemble-averaged mean squared displacement
self.msd_ratio = None
Expand Down Expand Up @@ -130,6 +133,7 @@ def msd_ensemble_averaged(trajectory):
:return msd: ensemble-averaged msd
"""

msd = np.zeros(len(trajectory))
for n in range(0, len(trajectory)):
msd[n] = np.sum(np.power(trajectory[n] - trajectory[0], 2))
Expand Down

0 comments on commit fc59691

Please # to comment.