Variance-reduced random batch Langevin dynamics
Abstract
The random batch method is advantageous in accelerating force calculations in particle simulations, but it poses a challenge of removing the artificial heating effect in application to the Langevin dynamics. We develop an approach to solve this issue by estimating the force variance, resulting in a variance-reduced random batch Langevin dynamics. Theoretical analysis shows the high-order local truncation error of the time step in the numerical discretization scheme, in consistent with the fluctuation-dissipation theorem. Numerical results indicate that the method can achieve a significant variance reduction since a smaller batch size provides accurate approximation, demonstrating the attractive feature of the variance-reduced random batch method for Langevin dynamics.
pacs:
02.70.Ns, 87.15.AaI Introduction
Langevin dynamics simulation frenkel2001understanding is a highly influential computational technique utilized in various scientific disciplines, including physics, chemistry, biology, and material science, specifically at the nano- and micro-scales mabey2017strong ; Trullas1989Langevin ; Lee2017computational ; Pastor1994 . Its primary purpose is to investigate the equilibrium properties and dynamics of particles in many-body systems. As a thermostat in molecular dynamics simulation, this computational approach simulates canonical ensembles by integrating Newton’s equation of motion combined with thermal fluctuations and frictions welling2011bayesian ; ma2015complete ; roberts1996 ; dalalyan2017 ; oksendal03 , and its widespread applications have been found in the analysis of irreversible dynamics, stochastic properties, and trajectory instability of various systems norman2013stochastic . Furthermore, in cutting-edge fields such as machine learning, Langevin dynamics and its improved algorithms can efficiently transform stochastic optimization into posterior sampling, demonstrating strong potential for a wide range of learning tasks welling2011bayesian ; ma2015complete ; dalalyan2017 ; dubey2016variance ; coeurdoux2024normalizing .
The computational bottleneck for particle simulations using Langevin dynamics is non-bonded interactions between particles. The recently developed random batch method (RBM) jin2018random shows promise in the fast calculation of interacting particle systems. This method is inspired by the mini-batch idea in stochastic gradient descent algorithms of machine learning robbins1951stochastic ; bottou1998online ; bubeck2015convex , and approximates the force by using a batch of randomly selected neighbors of a fixed batch size such that the approximate force is unbiased, achieving much success CiCP-28-1907 ; li2020Random ; jin2022mean ; li2020some ; fornasier2022anisotropic ; ko2021model ; golse2019random ; ye2024error ; guillin2024some . Particularly, in molecular dynamics, the RBM has been extended to obtain the random batch Ewald method and the random batch sum-of-Gaussians method, which solve the parallel scalability for long-range interactions JinLiXuZhao2020 ; liang2022random ; liang2023random ; gan2024random . For short-range interactions, the singular kernel can be treated by the random batch list (RBL) method liang2021randomRBL ; liang2022IRBE ; lin2024hybrid . The RBL divides the interaction region into a core-shell structure and applies the RBM in the shell region, significantly reducing the neighboring number of particle interactions. The RBM is implemented for molecular dynamics at the graphic processing units and allows the simulation of a system of ten million particles in a single card gao2024rbmd .
The randomness introduced into the deterministic drifting term results in an additional error of at each discrete time step liang2021randomRBL , leading to the failure of the fluctuation-dissipation theorem kubo1966fluctuation . This can be well handled by introducing the Nosé-Hoover thermostat. However, under the Langevin thermostat, this stochastic approach can lead to an artificial heating effect. In the simulation of heterogeneous systems such as the gas-liquid coexistence, it often requires a larger batch size or decreasing time step size to maintain the equilibrium distribution of the system, reducing the efficiency of the RBM jin2022RBMSOI . The artificial heating effect raises the kinetic energy of particles to overcome the intermolecular forces, which may lead to unphysical outcomes in critical issues such as phase transition simulations guillin2024some .
In this paper, we present the variance-reduced random batch method for Langevin dynamics. The covariance matrix of the random forces in the drifting term is approximated and used to correct the Brownian motion, achieving a significant variance reduction and leading to the consistency of the single-step fluctuation-dissipation theorem. Theoretically, we demonstrate that the variance reduction method has higher discrete numerical accuracy in the statistical sense. The method is implemented into the Lennard-Jones fluid systems and Coulomb systems, and numerical results demonstrate the attractive performance with a significant reduction in the force variance. Notably, our algorithm exhibits linear computational complexity and effectively preserves the non-uniform properties observed in strongly correlated systems, thereby holding significant potential for large-scale simulations of heterogeneous systems.
II Method
Consider a system of particles at position for within a simulation box with periodic boundary conditions. Suppose that the system is immersed in an infinite isothermal bath, and the particles obey the second-order Langevin dynamics,
(II.1) |
where is the particle position, is the damping matrix, is the diffusion matrix, and is i.i.d. Brownian motion. The friction term and fluctuation force satisfy the fluctuation-dissipation theorem kubo1966fluctuation ; marconi2008fluctuation ; prost2009generalized
(II.2) |
with being the thermal energy. Introducing the particle velocity with , the classical Langevin dynamics Eq. (II.1) is discretized by the Euler-Maruyama scheme kloeden1992stochastic as follows,
(II.3) |
where is the forward difference operator, is the time step, the superscript denotes the simulation step at , and denotes the discrete Brownian motion.
The total force acting on particle in Eq. (II.3) is composed of the external force and the interparticle forces,
(II.4) |
where one has , and the summation runs over all particles in the central and image boxes. Typically, one considers the LJ potential
(II.5) |
where and are the strength and the interaction distance scale. The classical Langevin dynamics introduces a cutoff radius , and particles beyond this distance are ignored in the force calculation. This results in a linear computational complexity by the linked cell list algorithm yao2004improved ; meloni2007efficient ; brown2011implementing ; welling2011efficiency , but for simulating the state of the gas-liquid coexistence, a large is required for accurate simulations. The RBL liang2021randomRBL has been proposed to reduce the number of interacting neighbors as well as the computational cost, by introducing the second cutoff radius , and dividing the interaction region into a core region , and a shell region . The force is directly calculated inside the core region, and the scaled force is computed in the shell zone by randomly selecting a batch of particles with uniform probability. Denote and as the particle number in the shell region and the set of the selected particles for the -th particle. The total force acting on this particle is given by
(II.6) |
and the average force is subtracted from each particle to conserve the total momentum.
In the RBL-based Langevin dynamics, the second equation of Eq. (II.3) reads
(II.7) |
where the approximation Eq. (II.6) is used as the total force. It can be proved that the approximate force is unbiased with a bounded force variance and the convergent distribution is close to the stationary one liang2021randomRBL . The acceleration ratio can be approximated by the ratio of neighbor list size, as , where is the particle density.
Under the Euler-Maruyama scheme, the mean-field limit of the RBM results in an effective dynamics inass2023quantifying ; guillin2024some , where the random force introduces an additional contribution into the Brownian motion, such that . Here, is the force covariance matrix. Therefore, it is necessary to reduce the force variance to maintain the fluctuation-dissipation theorem. One can approximately calculate the covariance matrix of the random force by
(II.8) |
Clearly, it is bounded due to the core-shell structure of the neighbor list and all particles in satisfying . One subsequently subtracts the variance term from the Brownian motion in discrete Langevin dynamics with time step such that in Eq. (II.7) is replaced by with
(II.9) |
where is calculated by (II.6) at the -th time step. The process of the Langevin dynamics evolved with the Brownian motion (II.9) is presented in Algorithm 1.
Considering the estimate of the local truncation error, one omits the superscript for simplicity. The velocity evolution of a single step in the RBL method is provided by (II.7), where is the unbiased estimation of , hence it can be approximately regarded as with and denoting the covariance matrix of . The discrete scheme can be approximated as
(II.10) |
where denotes the noise term. Hence the local truncation error of the RBL discretization is , which leads to the inconsistency with the fluctuation-dissipation theorem. As for the proposed dynamics with variance reduction technique, Theorem II.1 demonstrates that it reduces the local truncation error to .
Theorem II.1.
Proof.
Along with insights from effective dynamics inass2023quantifying ; guillin2024some , one also obtains that the VR-RBL is in consistent with the fluctuation-dissipation theorem since it holds
(II.12) |
Since the proposed dynamics have a higher order local truncation error, one can select a smaller batch size to achieve accurate simulation results. The primary computational complexity of variance-reduced dynamics centers around the force calculation of particles, while the computation of the variance reduction term entails comparatively lower computing overhead, requiring only the summation process of stored force arrays. The variance-reduced method is demonstrated to be accurate through numerical results of LJ fluid and colloid-ion systems in section III, indicating its potential as a general technique for the RBM that sheds new light on precise and effective Langevin dynamics for various applications.
III Results
We perform simulations to show the effectiveness of the proposed Langevin dynamics method by comparing the results of the three methods: classical Langevin dynamics (CL), the random batch list method without variance reduction (RBL), and the variance-reduced method (VR-RBL). The CL is a brute-force method and is supposed to be accurate as the reference solution. All the methods discretize the Langevin dynamics by the Euler-Maruyama scheme. We study two benchmark systems: one is the LJ fluid exhibiting a gas-liquid coexistence state, and the second is a colloid-ion system with varying correlation coefficients srinivas2004self ; beck2004methods ; miao2015accelerated . The simulations are conducted on a Linux system equipped with an Intel Xeon Scalable Cascade Lake processor running at 2.5 GHz, utilizing 1 single CPU core and 4 GB of memory.


III.1 Lennard-Jones fluids
Consider the LJ fluid with interparticle potential given in (II.5) and parameters . One sets the particle number in a cubic box such that the average particle density . The reduced units with , and time step are applied. The temperature takes at which the system exhibits gas-liquid coexistence state. The cutoff radius takes such that the CL remains accurate at the gas-liquid coexistence state, and . In the calculation, one performs time steps for equilibrium and then steps for statistics. Fig. 1(a) presents the radial distribution functions (RDF) by the three methods, where one calculates , , and for the RBL, and and for the VR-RBL. One can see that the variance reduction significantly improves the accuracy for given . The VR-RBL converges to the CL with the small batch size . In comparison, the RBL achieves the same accuracy at . In Fig. 1(b), we present CPU performance for the three methods by using the same setup with fixed density, but the number of particles increases up to . The computational cost of all methods increases linearly with the number of particles, but one can observe a significant reduction in the prefactor of the scaling law by imposing random batch techniques. One can roughly estimate that, for the LJ fluid system of , each particle has neighboring particles within with neighbors in the core region. Fig. 1(b) shows that the RBL with is times faster than the CL, and for the VR-RBL the accelerating rate becomes . These results are in agreement with the rough estimate of neighboring number and demonstrate the high efficiency of the VR-RBL given the accuracy level.
III.2 Colloid-ion Systems
The second example is a colloid-ion system in a spherical simulation volume of radius . A colloidal particle with charge and radius is placed at the center, along with monovalent cations and monovalent anions with the same radius in the remaining volume. All quantities are provided in reduced units. The interparticle potential is composed of the LJ potential in (II.5) of parameters , and Coulomb interaction with being the coupling strength. A spherical Wigner-Seitz (WS) cell model groot1991ion ; tamashiro1998donnan is employed for the boundary condition in our simulation with the LJ for the ion-wall interaction. One sets the temperature , the unit damping matrix and time step in the CL, RBL and VR-RBL methods. In the simulation, one performs steps for equilibrium and another steps for statistics. The coupling strength takes and , representing a weak and strong coupling system with corresponding cutoff radii setting and , respectively. Due to the Coulomb interaction, the results of CL are derived from calculating all particle interactions.
Fig. 2 presents the results of the charge density of the cation (normalized by its bulk density) and the integrated charge distribution along the radial direction. The integrated charge distribution is calculated through , where is calculated by a statistical average. One can observe that RBL and VR-RBL methods are accurate at the weak-coupling case of (Fig. 2(a,c)). However, the RBL with a small batch size fails to capture the stationary distribution in the case, which has strong Coulomb interactions (Fig. 2(b,d)). The VR-RBL with has almost the same accuracy as the RBL with , in agreement with the CL result. This result reveals the accuracy and efficiency advantages of the VR-RBL method.




It is also interesting to investigate how the time step affects the simulation accuracy. One considers the RBL and VR-RBL for the case simulating the same times for the equilibrium and statistics, with the time step ranging from to . Fig. 3 presents the relative errors of the kinetic energies and potential energies in the system. These errors are calculated by statistical averages of the energies compared with those of the CL. One can clearly observe the linear convergence of the VR-RBL with for both the kinetic and potential energies. Both methods exhibit a convergence rate of ; however, the prefactor for the VR-RBL is significantly smaller than that of the RBL. Moreover, the VR-RBL method can accurately capture the property of the system with strong coupling strength even at larger , further highlighting its application potential.


IV Conclusions
In summary, we have proposed a variance-reduced random batch Langevin dynamics for the efficient and accurate simulations of particle systems. The VR-RBL computes interactions using the random batch method while simultaneously estimating the covariance matrix of the forces. The covariance matrix is used to correct the Brownian motion with little additional computational cost to mitigate artificial heating effects and maintain the consistency with the fluctuation-dissipation theorem. Numerical experiments conducted on LJ fluids with gas-liquid coexistence state and colloid-ion systems with different Coulomb strengths demonstrate the accuracy and computational efficiency of the VR-RBL. It is promising for simulations of large-scale heterogeneous systems, allowing for the use of larger time steps to reduce computational time. The rigorous analysis on the convergence of the VR-RBL, along with strategies for further optimizing its accuracy and computational efficiency, will be studied in our subsequent work. It is noteworthy that, the extension of our proposed dynamics to other random batch processes, such as the random batch Ewald and the random batch sum-of-Gaussians methods for long-range interaction systems in molecular dynamics simulations JinLiXuZhao2020 ; liang2023random , is straightforward to implement.
Acknowledgement
This work is supported by the National Natural Science Foundation of China (grant No. 12325113) and the Science and Technology Commission of Shanghai Municipality (grant Nos. 23JC1402300 and 21JC1403700). The authors also acknowledge the support from the HPC center of Shanghai Jiao Tong University.
Conflict of interest
The authors declare that they have no conflict of interest.
Data Availability Statement
The data that support the findings of this study are available from the corresponding author upon reasonable request.
References
- (1) D. Frenkel, B. Smit, Understanding molecular simulation: From algorithms to applications, Vol. 1, Elsevier, 2001.
- (2) P. Mabey, S. Richardson, T. White, L. Fletcher, S. Glenzer, N. Hartley, J. Vorberger, D. O. Gericke, G. Gregori, A strong diffusive ion mode in dense ionized matter predicted by langevin dynamics, Nature Communications 8 (1) (2017) 14125.
- (3) J. Trullàs, A. Giró, J. A. Padró, Langevin dynamics simulation of ions in solution: Influence of the solvent structure, The Journal of Chemical Physics 91 (1) (1989) 539–545.
- (4) J. Lee, H. Koh, D.-N. Kim, A computational model for structural dynamics and reconfiguration of dna assemblies, Nature Communications 14 (1) (2023) 7079.
- (5) R. W. Pastor, Techniques and applications of Langevin dynamics simulations, Springer Netherlands, Dordrecht, 1994, pp. 85–138.
- (6) M. Welling, Y. W. Teh, Bayesian learning via stochastic gradient Langevin dynamics, in: Proceedings of the 28th International Conference on Machine Learning (ICML-11), 2011, pp. 681–688.
- (7) Y.-A. Ma, T. Chen, E. Fox, A complete recipe for stochastic gradient MCMC, in: Advances in Neural Information Processing Systems, Vol. 28, 2015, pp. 2917–2925.
- (8) G. O. Roberts, R. L. Tweedie, Exponential convergence of Langevin distributions and their discrete approximations, Bernoulli 2 (4) (1996) 341–363.
- (9) A. S. Dalalyan, Theoretical guarantees for approximate sampling from smooth and log-concave densities, Journal of the Royal Statistical Society Series B 79 (3) (2017) 651–676.
- (10) B. Øksendal, Stochastic differential equations: An introduction with applications, 6th Edition, Springer, Berlin, Heidelberg, 2003.
- (11) G. E. Norman, V. V. Stegailov, Stochastic theory of the classical molecular dynamics method, Mathematical Models and Computer Simulations 5 (2013) 305–333.
- (12) K. A. Dubey, S. J Reddi, S. A. Williamson, B. Poczos, A. J. Smola, E. P. Xing, Variance reduction in stochastic gradient Langevin dynamics, Advances in Neural Information Processing Systems 29 (2016) 1154–1162.
- (13) F. Coeurdoux, N. Dobigeon, P. Chainais, Normalizing flow sampling with langevin dynamics in the latent space, Machine Learning (2024) 1–26.
- (14) S. Jin, L. Li, J.-G. Liu, Random batch methods (RBM) for interacting particle systems, Journal of Computational Physics 400 (1) (2020) 108877.
- (15) H. Robbins, S. Monro, A stochastic approximation method, The Annals of Mathematical Statistics 22 (3) (1951) 400 – 407.
- (16) L. Bottou, Online learning and stochastic approximations, in: Saad, D. (Ed.), On-line Learning in Neural Networks, Vol. 17, 1998, pp. 9–42.
- (17) S. Bubeck, Convex optimization: Algorithms and complexity, Foundations and Trends in Machine Learning 8 (3-4) (2015) 231–358.
- (18) S. Jin, X. Li, Random batch algorithms for quantum Monte Carlo simulations, Communications in Computational Physics 28 (5) (2020) 1907–1936.
- (19) L. Li, Z. Xu, Y. Zhao, A random-batch Monte Carlo method for many-body systems with singular kernels, SIAM Journal on Scientific Computing 42 (3) (2020) A1486–A1509.
- (20) S. Jin, L. Li, On the mean field limit of the random batch method for interacting particle systems, Science China Mathematics 65 (2022) 169–202.
- (21) L. Li, J. G. Liu, Y. Tang, Some random batch particle methods for the Poisson-Nernst-Planck and Poisson-Boltzmann equations, Communications in Computational Physics 32 (1) (2022) 41–82.
- (22) M. Fornasier, H. Huang, L. Pareschi, P. Sünnen, Anisotropic diffusion in consensus-based optimization on the sphere, SIAM Journal on Optimization 32 (3) (2022) 1984–2012.
- (23) D. Ko, E. Zuazua, Model predictive control with random batch methods for a guiding problem, Mathematical Models and Methods in Applied Sciences 31 (08) (2021) 1569–1592.
- (24) F. Golse, S. Jin, T. Paul, The random batch method for -body quantum dynamics, Journal of Computational Mathematics 39 (6) (2021) 897–922.
- (25) X. Ye, Z. Zhou, Error analysis of time-discrete random batch method for interacting particle systems and associated mean-field limits, IMA Journal of Numerical Analysis 44 (3) (2024) 1660–1698.
- (26) A. Guillin, P. Le Bris, P. Monmarché, Some remarks on the effect of the random batch method on phase transition, Stochastic Processes and their Applications 179 (2025) 104498.
- (27) S. Jin, L. Li, Z. Xu, Y. Zhao, A random batch Ewald method for particle systems with Coulomb interactions, SIAM Journal on Scientific Computing 43 (4) (2021) B937–B960.
- (28) J. Liang, P. Tan, L. Hong, S. Jin, Z. Xu, L. Li, A random batch Ewald method for charged particles in the isothermal–isobaric ensemble, The Journal of Chemical Physics 157 (14) (2022) 144102.
- (29) J. Liang, Z. Xu, Q. Zhou, Random batch sum-of-Gaussians method for molecular dynamics simulations of particle systems, SIAM Journal on Scientific Computing 45 (5) (2023) B591–B617.
- (30) Z. Gan, X. Gao, J. Liang, Z. Xu, Random batch Ewald method for dielectrically confined Coulomb systems, arXiv preprint arXiv:2405.06333.
- (31) J. Liang, Z. Xu, Y. Zhao, Random-batch list algorithm for short-range molecular dynamics simulations, The Journal of Chemical Physics 155 (4) (2021) 044108.
- (32) J. Liang, Z. Xu, Y. Zhao, Improved random batch Ewald method in molecular dynamics simulations, The Journal of Physical Chemistry A 126 (22) (2022) 3583–3593.
- (33) H. Lin, Y. Shi, S. Dai, Hybrid random batch idea and nonlinear conjugate gradient method for accelerating charged polymer dynamics simulation, Journal of Mathematical Chemistry 62 (3) (2024) 555–578.
- (34) W. Gao, T. Zhao, Y. Guo, J. Liang, H. Liu, M. Luo, Z. Luo, W. Qin, Y. Wang, Q. Zhou, S. Jin, Z. Xu, RBMD: A molecular dynamics package enabling to simulate 10 million all-atom particles in a single graphics processing unit, arXiv preprint arXiv:2407.09315.
- (35) R. Kubo, The fluctuation-dissipation theorem, Reports on Progress in Physics 29 (1) (1966) 255.
- (36) S. Jin, L. Li, Y. Sun, On the random batch method for second order interacting particle systems, Multiscale Modeling & Simulation 20 (2) (2022) 741–768.
- (37) U. M. B. Marconi, A. Puglisi, L. Rondoni, A. Vulpiani, Fluctuation–dissipation: Response theory in statistical physics, Physics Reports 461 (4-6) (2008) 111–195.
- (38) J. Prost, J.-F. Joanny, J. M. Parrondo, Generalized fluctuation-dissipation theorem for steady-state systems, Physics Review Letters 103 (9) (2009) 090601.
- (39) P. E. Kloeden, E. Platen, Stochastic differential equations, in: Numerical Solution of Stochastic Differential Equations, Springer, 1992, pp. 103–160.
- (40) Z. Yao, J.-S. Wang, G.-R. Liu, M. Cheng, Improved neighbor list algorithm in molecular simulations using cell decomposition and data sorting method, Computer Physics Communications 161 (1-2) (2004) 27–35.
- (41) S. Meloni, M. Rosati, L. Colombo, Efficient particle labeling in atomistic simulations, The Journal of Chemical Physics 126 (12) (2007) 121102.
- (42) W. M. Brown, P. Wang, S. J. Plimpton, A. N. Tharrington, Implementing molecular dynamics on hybrid high performance computers – short range forces, Computer Physics Communications 182 (4) (2011) 898–911.
- (43) U. Welling, G. Germano, Efficiency of linked cell algorithms, Computer Physics Communications 182 (3) (2011) 611–615.
- (44) S. Inass, G. Stoltz, Quantifying the mini-batching error in Bayesian inference for adaptive Langevin dynamics, The Journal of Machine Learning Research 24 (1) (2024) 15638–15695.
- (45) G. Srinivas, D. E. Discher, M. L. Klein, Self-assembly and properties of diblock copolymers by coarse-grain molecular dynamics, Nature Materials 3 (9) (2004) 638–644.
- (46) D. A. Beck, V. Daggett, Methods for molecular dynamics simulations of protein folding/unfolding in solution, Methods 34 (1) (2004) 112–120.
- (47) Y. Miao, F. Feixas, C. Eun, J. A. McCammon, Accelerated molecular dynamics simulations of protein folding, Journal of Computational Chemistry 36 (20) (2015) 1536–1549.
- (48) R. D. Groot, Ion condensation on solid particles: Theory and simulations, The Journal of Chemical Physics 95 (12) (1991) 9191–9203.
- (49) M. N. Tamashiro, Y. Levin, M. C. Barbosa, Donnan equilibrium and the osmotic pressure of charged colloidal lattices, The European Physical Journal B-Condensed Matter and Complex Systems 1 (1998) 337–343.