I've written a basic 2D Langevin dynamics simulator in C++, for a particle in a potential, solving the equation:
$$M\ddot{X} = - \nabla U(X) - \gamma M \dot{X} + \sqrt{2 \gamma k_B T M} R(t)$$
This relies on a source of random numbers for $R(t)$, and I've been using std::random
(in particular, a Mersenne Twister RNG).
My current approach is to generate the random numbers all in one go at the beginning of the simulation, rather than at each time step, as it was (for me at least) faster. This is fine for runs up to $10^{8}$ time steps, but eventually I run out of RAM to store the random numbers.
I'd like to at least have the ability to run longer simulations (I'm investigating diffusion behaviour of particles in simple potentials), and would like to know what potential pitfalls to look out for when either
- splitting the simulation into segments, or
- breaking up the calculation of the random numbers into smaller chunks (say do a block of numbers ever $10^{6}$ steps.
One thing I noticed was the risk of repeating sequences - see "Vulnerability in Popular Molecular Dynamics Packages Concerning Langevin and Andersen Dynamics"