Table of contents
No headersMolecular dynamics simulations are reproducible if rerun from the same (binary) input file on the same computer, or on a computer with an identical processor and the identical operating system. Unfortunately, identical computers are scarce, even in dedicated clusters. The following factors affect reproducibility (predominantly through accumulation of round-off errors of comparable magnitude but different value):
- Precision (mixed / double) with double giving "better" reproducibility.
- Number of processors, due to different order of addition of force. For instance (a+b)+c is not necessarily binary identical to a+(b+c).
- Type of processors. Even within the same processor family there can be slight differences.
- Optimization level when compiling.
- Optimizations at run time: e.g. the FFTW library that we use for fast Fourier transforms determines at startup which version of their algorithms is fastest, and uses that for the remainder of the calculations. Since the speed estimate is not deterministic, the results may vary from run to run. In GROMACS versions prior to 3.3 this optimization could be turned off in the .mdp file.
- Random numbers used for instance as a seed for generating velocities (in GROMACS at the preprocessing stage).
- Uninitialized variables in the code (but there shouldn't be any)
- Dynamic linking to different versions of shared libraries (e.g. for FFTs)
- Dynamic load balancing, since particles are redistributed to processors based on elapsed wallclock time, which will lead to (a+b)+c != a+(b+c) issues as above
- Number of PME-only nodes (for parallel PME simulations)
- MPI reductions typically do not guarantee the order of the operations, and so the absence of floating-point associativity means the result of a reduction depends on the order
The important question is whether it is a problem if simulations are not completely reproducible? The answer is yes and no. Reproducibility is a cornerstone of science in general, and hence it is important, right? Well, yes it is, but what should be reproduced? The Central Limit Theorem tells us that in the case of infinitely long simulation all observables converge to their equilibrium values. Simulations adhere to this theorem, and hence for instance the energy of your system will converge to a finite value, the diffusion constant of your water molecules will converge to a finite value, and so on. That means all the important observables, which are the values you would like to get out of your simulation, are reproducible.
However, it would be useful for debugging if trajectories were reproducible, too. In order to obtain this it is important to look over the list above and eliminate the factors that could affect reproducibility.
As of GROMACS 4, mdrun -reprod
will eliminate all sources of non-reproducibility that it can, i.e. same executable + same hardware + same shared libraries + same run input file + same command line parameters will lead to reproducible results.