I am trying to calculate the mean squared displacement and had written a code in fortran. I wrote this code using a reference book by Daan Frenkel and Berend Smit on Molecular Dynamics Simulation. I am having a hard time in getting the exact plot as proposed for a particular system. Can anybody have a look at it and suggest me where I am doing wrong in calculating the Mean Squared displacement as function of time.
Also, I would like to mention a little detail of the code. I used Origin shift method here in code where "i1" is for origin shift and calculating particles displacement over (total_time - 1) for all the particles present in a simulation cell. First, I am averaging over the number of data points (tau) accumulated (due to the shift of origin) for each atom for a particular origin (i1) in loop and finally after accumulating it over total number of particles (ntotal) and averaging it(ensemble_avg).