# Diffusion constant using gmx msd

GROMACS version: 2018.4
GROMACS modification: No
For my bulk simulation of compound, the diffusion constant (D) came out to be 0.4069 (+/- 0.0303) 1e-5 cm^2/s from gmx msd command, the gmx msd discription says it calculates D by fitting a line to msd vs time plot, but when I fitted a line to msd vs time data, I get slope = 0.002462 and intercept of 0.204, the slope value is not matching with the D value given by gmx msd, am I missing something here? Is there some constant we need to multiply at the end to get answer in cm^2/s units. Please help. Thank you. Hi,

`gmx msd` by default fits the center range 10%–90% along your time axis, making the assumption that the slope is linear there (which one should confirm).

Is your fit using that same range?

Regards,
Petter

Even if I do so, by looking at the data points it seems to me, it will not make much of a difference, the data is almost linear, slope will not change much from 0.002. Still I fitted data for 10%-90% data, I got new slope of 0.00244.

Ahh, I got it.
msd = 6D + intercept
So, slope is equal to 6 multiplied by diffusion constant, also default msd units are nm2/ps, hence when we change it to cm2/s, we need to multiply by 0.01, so we get gromacs given value:
D = 0.002462*0.01/6 = 0.4

1 Like

Sorry for asking question in continuation to this post…
But I have query regarding the fitting of msd vs tau data to linear model and also is there any basis of upto which time the msd data can presented for the article.
Since I have gone through many article and each one shows different time on x-axis and there is no specific discussion or talk about the plot and mostly the decorrelation of msd of waters occurs by 100ps