# Understanding the mean square displacement in molecular dynamics

In a Molecular Dynamics (MD) simulation, the mean square displacement $\text{MSD}$ is given by

$$\text{MSD}(\delta t) = \left\langle\left|\vec{r}(\delta t)-\vec{r}(0)\right|^2\right\rangle,$$

where $\vec{r}$ is the position vector of an atom and $\delta t$ is some time step. Often the time step dependence of the $\text{MSD}$ is left out, which seems to relate to my question, but no problems so far.

However, the practical calculation of the ensemble average $\langle\ldots\rangle$ is usually somewhat vaguely explained and seems to depend on where you look. This source states that we must average over all atoms and many time steps (I would assume all time steps in a given simulation). This and this source on the other hand mention only the average over all atoms (though the latter does indicate a time (step) dependence). This last source seems to support the first one. Note that both the first and last source give the $\text{MSD}$ a dependence upon the time step.

My interpretation is as follows. I would expect the $\text{MSD}$ to have a time step dependence, so I'm inclined to follow the first and last source I've quoted. So in the case of an MD simulation of $N$ atoms spanning a total time $N_{k\tau}k\tau$ one would calculate the $k\tau$ mean square displacement as

$$\text{MSD}(k\tau) = \frac{1}{N}\frac{1}{N_{k\tau}}\sum_{n=1}^{N}{\sum_{i=1}^{N_{k\tau}}{\Big|\vec{r}_n\big(ik\tau\big)-\vec{r}_n\big((i-1)k\tau\big)\Big|^2}}.\qquad(*)$$

My question is really just: is this correct? And if so, what's the difference with the other two sources I've mentioned? Why do they not mention averaging over the time steps? Do they simply discuss the formula for a single time step? (i.e. $N_{k\tau} = 1$)

• Retagging is welcomed, I don't know if there's a more specific one that applies. – Wouter Jun 17 '14 at 0:21
• What are you trying to get out of the MD simulation? I don't know much about MD, but if you're trying to get diffusion constants, that often means taking the time correlation function of the MSD. I've heard that it's difficult to get the time correlation function from MD simulations, and one way around that is to do it for many times and average them together. So, my guess is that the pure MSD does not involve an average over time, but a time average may be needed for practical purposes (at least with MD -- it's not needed for some other types of simulations). – lnmaurer Jun 17 '14 at 15:19
• @lnmaurer Well, this came up in an assignment and the MSD is more of an on-the-side calculation, but I think the idea is that you should be able to calculate the diffusion coefficient and correlaction function from it. – Wouter Jun 17 '14 at 22:06
• If you're interested in the theory, I'd take a look at a book like Nonequilibrium Statistical Mechanics by Robert Zwanzig; see the first chapter. However, like I wrote, my understanding is that it's trickier to do in MD simulations. In practice, I think that often means taking time averages -- even if they're not part of the MSD per se. I think that's why different sources say different things. So, I'd go with the sources that talk about the MSD in the context of molecular dynamics simulations. – lnmaurer Jun 18 '14 at 1:39
• Thanks for the reference! I'm going with the expression $(*)$ that I wrote down, i.e. with time averaging, as the clearly MD-related sources do indeed suggest. – Wouter Jun 18 '14 at 11:46

Actually, all of your references are correct. In a MD simulation, for homogeneous systems, you can calculate the ensemble average of a thermodynamic property in several different ways.

1. You can simply average over all the particles in your system during one time step.

2. You can average over a single particle over many time steps.

3. You can average over all particles and over all time steps.

4. You can average over a random number of particles over randomly selected time steps.

There are many other options also. If your sample space (number of particles and time steps) is large enough the all methods should produce the same answer. This is called the Ergodic Principle. Many Statistical Mechanics references will not mention averaging over time because they are assuming the system is Ergodic. But in MD simulations, your system is in general not Ergodic due to the limited size of your system. That's why MD reference discuss time averages.

The trick in MD or MC simulations is knowing whether or not your sample space is large enough, but that is a different topic. You also have to be careful with non-homogeneous systems.