I have a trajectory file from simulation of 20,000 frames with 5 ps time in between every frame, what I want to do is to calculate diffusion in 2 dimension (x and y axis). but to calculate diffusion in 2D, first I have to calculate Mean square displacement of the selected atom from the trajectory. would also like to calculate MSD and diffusion for all atom. MSD calculates the average time taken by molecule to explore the system.
The formula for MSD would be
I am very new to python programming and I would really want some help to get started this problem and to solve this problem. Hope to get positive response.
I can use the following approach to calculate MSD
import numpy as np r = np.sqrt(xdata**2 + ydata**2) diff = np.diff(r) #this calculates r(t + dt) - r(t) diff_sq = diff**2 MSD = np.mean(diff_sq)
I cannot figure it out how can I make the whole script which adds and take sqroot of position of atoms in x y and z at particular time interval here in the code it is:
r = np.sqrt(xdata**2 + ydata**2)
How can I select the atomic positions (which I have already obtained coordinates in .xyz file from .DCD file using Catdcd.) .xyz file contain x y and z coordiantes from .DCD file and I need to calculate diffusion across x and Y plane. Now how can I calculate MSD from the positions? Can anyone help me with the coding in python. I will be really grateful.