I am calculating MSDs for the first time and have been struggling to find newbie-level resources on understanding them. If anyone could please suggest any resources or provide guidance on how to interpret MSD results, I would be grateful.

I have been running NPT simulations to collect data for use in fluid dynamics simulations. However, I now realize that I have used low temperatures compared to people who have looked at similar systems. So I want to evaluate MSDs to make sure the simulations are ergodic.

  • I don't have much experience with statistics and a basic point I don't understand is whether it is the slope of the MSD or the R value that matters. Or both.

  • An example of an MSD I have calculated is below. I get this output (I can't control the time interval used, the software chooses it):

Linear regression interval 41.52 - 83.03 ps.
MSD(t) = -10806.283111 + 1575.888517 * t
R = 0.977891

When I calculate a slope on the interval 1 ps to where the curve goes vertical, I get ~0.8, which I know is not great. I don't know what an acceptable value would be but am guessing >0.9. I do get 0.95 if I calculate the slope not from 1 ps, but from 10 ps. But on a log-log plot, that's a small interval. Is it unacceptably small?

enter image description here

  • $\begingroup$ Might this be deceptive to some degree taking a linear fit to a log based plot? It might be good to show the fit on the plot (I am quickly looking at this though, maybe I misunderstood) $\endgroup$ Commented Nov 20, 2020 at 20:58
  • $\begingroup$ +1. @TristanMaxson why not do a linear fit on a log-based plot? I agree though that showing the fit would not hurt. Also the data clearly isn't linear but has an upwards bias towards the end, but this is separate from the fact that it's a log-log plot. But actually the data is quite linear in the user's regression interval of 41.52 - 83.03 ps. To the user NTS: the part about the data going upwards at the end, has to be asked as a separate question. It's different from your other question of whether the slope or R matters. You can provide a link to this question in your next question. $\endgroup$ Commented Nov 20, 2020 at 21:17
  • $\begingroup$ @TristanMaxson, thanks for your comments. I thought I should use a linear fit for the log-based plot; I was not aware I shouldn't because all of the information I have seen about calculating MSDs refers to the need for a "straight" line for ergodicity. I may very well have misunderstood though. What kind of fit do you think would be more appropriate? $\endgroup$
    – NTS
    Commented Nov 20, 2020 at 21:35
  • $\begingroup$ @Nike Dattani, thank you for pointing out that I should move my question about the vertical trend of the curve to a distinct question. I am about to leave my computer but will do so in the morning. I hope it's OK to leave it overnight. Also, may I ask if you think the regression interval of 41.52 - 83.03 ps is reasonable? Or too small? $\endgroup$
    – NTS
    Commented Nov 20, 2020 at 21:36
  • 2
    $\begingroup$ What is MSD? It's central to your question and probably worth defining for posterity even though you already have a good answer. $\endgroup$ Commented Nov 21, 2020 at 13:24

1 Answer 1


Short introduction to ergodicity

  • Ergodicity is when the time-average equals the ensemble-average.
  • A process is ergodic if the time-average "converges in the square mean" to the ensemble average.
  • A sequence $X_t$ converges in the square mean to $X$ if:

$$ \tag{1} \lim_{t\rightarrow \infty}\langle \left|X_t - X\right|^2 \rangle = 0, $$

where $\langle x \rangle$ means the mean (average) of $x$. So if the mean of the square of the absolute difference between the time-average and ensemble-average (i.e. the MSD between them) approaches zero, then the process can be said to be ergodic.

Short introduction to generalized diffusion

If we plot MSD$(t)$ with MSD on the vertical axis and $t$ on the horizontal axis, and fit the data to a power law form:

$$ \tag{2} \textrm{MSD}(t) = Dt^\alpha, $$

where $D$ is the diffusion constant, and $\alpha$ is the generalized diffusion exponent:

  • normal diffusion is characterized by $\alpha=1$, meaning MSD$(t)$ is linear.
  • sub-diffusion is characterized by $0<\alpha<1$, meaning MSD$(t)$ is sub-linear.
  • super-diffusion is characterized by $\alpha>1$, meaning MSD$(t)$ is super-linear.

Short introduction to statistical regression

The coefficient of determination is given by $R^2$ and is a measure of the "goodness of fit". Specifically, when you fit a line or curve through data, how well does that line or curve predict the data? If $R^2 = 1$ then the data is perfectly predicted by your fitted line or curve.

Application to your case

"I don't understand is whether it is the slope of the MSD or the R value that matters. Or both."

You could plot your MSD$(t)$ and fit the data to Eq. 2, which will give you an $\alpha$, which will tell you what type of diffusion you have. But since you chose to do a log-log plot, Eq. 2 has to be modified accordingly:

\begin{align} \tag{3} \log\textrm{MSD}(t) &= \frac{\alpha \log D}{\log 10} \log(t), \\ y &= m x, ~~~ m \equiv\alpha\left(\frac{ \log D}{\log 10}\right). \tag{4} \end{align}

Slope: Eq. 4 tells us that a very large slope may be indicative of super-diffusion, and a very small slope may be indicative of sub-diffusion.

$R$-value: Your $R$ value implies an $R^2$ of 0.956, which means that in the area where you did the fit (41.52 - 83.03 ps) the data is fairly linear (could be more linear but could be a lot worse).

  • $\begingroup$ thank you very much for taking the time to explain this so clearly. It's very useful. So from any log-log plot, when the R-squared value is close to 1, that means the MSD(t) is quite linear and that a simulation approaches ergodicity. The example I posted is for a single atom type. My system has five different atom types. Four of them have R-squared values ~1. However, one atom type has a shallow slope (R-squared=0.8) on a log-log plot (sub-diffusion) and I guess this means that my simulation is not ergodic. $\endgroup$
    – NTS
    Commented Nov 21, 2020 at 17:00
  • $\begingroup$ Out of curiosity, why did you choose to do a log-log plot? Do you have a reference that you followed? Also: sub-diffusion isn't necessarily non-ergodic. Ergodicity and diffusion exponent are different things. Ergodicity means the ensemble average converges to the time average. Fractional Brownian motion is an example of something that is ergodic but alpha is not necessarily 1. Maybe you want to ask a new question: how do I check if my MD simulation demonstrates ergodicity? $\endgroup$ Commented Nov 21, 2020 at 17:09
  • $\begingroup$ thank you again. At this point, I owe you a beverage for taking time to clarify these issues! I just assumed that MSD log-log plots are standard because an older colleague mentioned them before lockdown as a good idea. Also, when searching around online a couple of weeks ago for examples of how to calculate MSDs, I only saw log-log plots. If I can remember any of the examples I used, I'll post them here. I vaguely recall (but may be confused) that my older colleague said my log-log plots should be linear, which is where I got the idea that a linear plot = ergodic. $\endgroup$
    – NTS
    Commented Nov 21, 2020 at 17:22
  • $\begingroup$ I don't want to exhaust everyone's patience with my questions, but yes, I would certainly like clarification on how to ensure a simulation is ergodic. I'd also be interested to find out about that vertical uptick in my example MSD curve here. I'll ask in a few days so I'm not overwhelming the board. Thanks. $\endgroup$
    – NTS
    Commented Nov 21, 2020 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .