# [Pw_forum] How to calculate Mean Square Displacement (MSD)

Tue Oct 31 12:41:38 CET 2017

```Dear Nam,

My understanding is that the trajectory as printed in VASP’s XDATCAR is folded or wrapped. As you can see in msd.f90,:

write(6,*) 'Name of unwrapped xyz file’

So the input file should be unwrapped. In other words, you have to first unwrap the coordinates in XDATCAR. Then you can use msd.f90.

To unwrap the coordinates, there are other codes on that website such as unwrap_PBC.f90.

Cheers,

Vahid

On Oct 30, 2017, at 9:25 PM, Nam Tran <vnt981 at uowmail.edu.au<mailto:vnt981 at uowmail.edu.au>> wrote:

Dear Vahid

I don't know whether VASP folds back atoms in their output or not. If they do then the msd.f90 you recommended is not accurate. Because the code simply calculate the distance between two position

dRx = Rx(j) - Rx0(j)
dRy = Ry(j) - Ry0(j)
dRz = Rz(j) - Rz0(j)
sum_msd = sum_msd + (dRx**2 + dRy**2 + dRz**2)

One thing is that I tried to create a .axsf file using cppx. And the atoms seem to be not folded back. Can someone confirm me that?

Best Regards,
Nam Tran

________________________________
From: pw_forum-bounces at pwscf.org<mailto:pw_forum-bounces at pwscf.org> <pw_forum-bounces at pwscf.org<mailto:pw_forum-bounces at pwscf.org>> on behalf of Vahid Askarpour <vh261281 at dal.ca<mailto:vh261281 at dal.ca>>
Sent: Monday, October 30, 2017 11:00:01 PM
To: PWSCF Forum
Subject: Re: [Pw_forum] How to calculate Mean Square Displacement (MSD)

There is a collection of fortran codes (for VASP mainly but can easily be adapted) for processing simulation output including MSD calculation and the treatment of periodic images. They can be found at https://github.com/boates under the Physics repository (see msd.f90).

Cheers,

Vahid

Department of Physics and Atmospheric Science
Dalhousie University,

On Oct 30, 2017, at 4:29 AM, Nam Tran <vnt981 at uowmail.edu.au<mailto:vnt981 at uowmail.edu.au>> wrote:

Dear QE experts,

I am trying to evaluate MSD for my simulation.
My problem is that when an atom exits the simulation cell.
I do not know whether I should consider the distance with atom that goes about outside the box (a) or its image (b). Please check the image below (Blue is the original position t=0, red is the position at time t)

<Screenshot from 2017-10-30 14-53-57.png>
Best Regards
Nam Tran
_______________________________________________
Pw_forum mailing list
Pw_forum at pwscf.org<mailto:Pw_forum at pwscf.org>
http://pwscf.org/mailman/listinfo/pw_forum

_______________________________________________
Pw_forum mailing list
Pw_forum at pwscf.org<mailto:Pw_forum at pwscf.org>
http://pwscf.org/mailman/listinfo/pw_forum

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quantum-espresso.org/pipermail/users/attachments/20171031/032176c6/attachment.html>
```