When simulating liquids or solids under periodic boundary conditions, we are making two fundamental approximations:
Here, we want to calculate the diffusion constant of water at room temperature ($T=300\,\text{K}$). Since we are interested in a property of bulk water, we don't need to worry about the first approximation. But we need to pay attention to the second one. The theory derived in 10.1021/jp0477147 allows us to estimate the finite size effects in the diffusion constant $D_{pbc}(L)$, calculated under periodic boundary conditions with cell size $L$. With this information at hand, we will be able to extrapolate the results for finite cell sizes to the diffusion constant $D=\lim\limits_{L\rightarrow \infty}D_{pbc}(L)$, effectively getting rid of the second approximation.
Calculating transport properties typically requires lots of sampling. Start the MD simulation for 32 water molecules and see how far you can get (aim at least for 200 ps).
./get_t_sigma file.ener
to calculate the standard deviation of the temperature for your simulation as well as for the provided simulations of larger cells containing 64, 128 and 256 water molecules.The mean squared displacement (msd) is defined as $$\text{msd}(t) = \langle |r(t+t_0)-r(t_0)|^2 \rangle$$ where the average $\langle ... \rangle$ runs over all particles in the system.
Our simulations are not large enough to obtain reasonable statistics just from averaging over all water molecules.
We therefore perform an additional average over the time $t_0$: $\text{msd}(t)$ is calculated as an average over all non-overlapping time windows of width $t$ that fit into the total simulation time $T$.
We have provided a Fortran program that uses this algorithm to extract the msd from a trajectory in a .xyz
file.
gfortran msd.f90 -o msd.x # compile msd.x executable ./msd.x < msd.in # check input file 'msd.in' before you run!
Per default, msd.x
writes the msd in units of $\unicode{x212B}^2$ as a function of time in fs.
Once you have calculated the msd, have a look into section III of the article on how to fit the diffusion constant.
msd.x
to calculate the msd, modifying msd.in
as needed. Note: msd.x
may run up to 30 minutes for the largest cell.When your MD of the 32 water molecules has finished (for example on the next day), you can start fitting the diffusion constant.