According to the Einstein relationship, the diffusion coefficient $D$ is
$$\lim _{t\rightarrow \infty} \frac{\langle \left(\mathbf{r}(t)-\mathbf{r}(0) \right) ^2\rangle}{6t} = D$$
I have run a MD simulation with $N$ particles, and I have a file which has the location of each particle at every time step.
If I want to calculate $D$, I would have to do the following:
$$\langle (\mathbf{r}(t)-\mathbf{r}(0))^2\rangle = \frac{1}{N} \sum _{i=1}^N (\mathbf{r}_i(t)-\mathbf{r}_i(0))^2$$
Divide the above by $6t$, then take the limit as $t$ goes to infinity - which in my case is the final time step of my simulation.
My questions:
- Is this the right way of calculating MSD?
- If it is the right way of doing this, and my system reaches equilibrium and doesn't diverge, as $t\rightarrow \infty$, shouldn't my diffusion coefficient always be $0$, because of that infinity in the denominator?