Langevin dynamics

{{short description|Scientific theory}}

In physics, Langevin dynamics is an approach to the mathematical modeling of the dynamics of molecular systems using the Langevin equation. It was originally developed by French physicist Paul Langevin. The approach is characterized by the use of simplified models while accounting for omitted degrees of freedom by the use of stochastic differential equations. Langevin dynamics simulations are a kind of Monte Carlo simulation.{{Cite book|last=Namiki|first=Mikio|url=https://books.google.com/books?id=MVryCAAAQBAJ&q=langevin+simulations+a+kind+of+monte+carlo&pg=PA176|title=Stochastic Quantization|date=2008-10-04|publisher=Springer Science & Business Media|isbn=978-3-540-47217-9|language=en|pages=176}}

Overview

Real world molecular systems occur in air or solvents, rather than in isolation, in a vacuum. Jostling of solvent or air molecules causes friction, and the occasional high velocity collision will perturb the system. Langevin dynamics attempts to extend molecular dynamics to allow for these effects. Also, Langevin dynamics allows temperature to be controlled as with a thermostat, thus approximating the canonical ensemble.

Langevin dynamics mimics the viscous aspect of a solvent. It does not fully model an implicit solvent; specifically, the model does not account for the electrostatic screening and also not for the hydrophobic effect. For denser solvents, hydrodynamic interactions are not captured via Langevin dynamics.

For a system of N particles with masses M, with coordinates X=X(t) that constitute a time-dependent random variable, the resulting Langevin equation is{{cite book | first=Tamar | last=Schlick | authorlink= Tamar Schlick | year=2002 | title=Molecular Modeling and Simulation | publisher=Springer | isbn=0-387-95404-X | page = 480 }}{{cite book | last1=Pastor | first1=R.W. | year = 1994 | chapter = Techniques and Applications of Langevin Dynamics Simulations | editor1-last = Luckhurst | editor1-first = G.R. | editor2-last = Veracini | editor2-first = C.A. | title = The Molecular Dynamics of Liquid Crystals |series=NATO ASI Series|volume=431|pages=85–138 |publisher= Springer |location=Dordrecht|doi=10.1007/978-94-011-1168-3_5 |isbn=978-94-010-4509-4 }}

M\,\ddot{\mathbf{X}} = - \mathbf{\nabla} U(\mathbf{X}) - \gamma\,M\,\dot{\mathbf{X}} + \sqrt{2\,M\,\gamma\,k_{\rm B} T}\,\mathbf{R}(t)\,,

where U(\mathbf{X}) is the particle interaction potential; \nabla is the gradient operator such that -\mathbf{\nabla} U(\mathbf{X}) is the force calculated from the particle interaction potentials; the dot is a time derivative such that \dot{\mathbf{X}} is the velocity and \ddot{\mathbf{X}} is the acceleration; \gamma is the damping constant (units of reciprocal time), also known as the collision frequency; T is the temperature, k_{\rm B} is the Boltzmann constant; and \mathbf{R}(t) is a delta-correlated stationary Gaussian process with zero-mean, called Gaussian white noise, satisfying

\left\langle \mathbf{R}(t) \right\rangle = 0

\left\langle \mathbf{R}(t)\cdot\mathbf{R}(t') \right\rangle = \delta(t - t')

Here, \delta is the Dirac delta.

= Stochastic Differential Formulation =

Considering the covariance of standard Brownian motion or Wiener process W_t, we can find that

\mathbb{E}(W_tW_\tau) = \min(t,\tau)

Define the covariance matrix of the derivative as

\mathbb{E}(\dot{W_t}\dot{W_\tau}) = \frac{\partial}{\partial t}\frac{\partial}{\partial \tau}\mathbb{E}(W_tW_\tau) = \frac{\partial}{\partial t}\frac{\partial}{\partial \tau}\min(t,\tau) =\delta(t-\tau)

So under the sense of covariance we can say that

{\rm d}W_t = \mathbf{R}(t){\rm d}t

Without loss of generality, let the mass M = 1, \sigma = \sqrt{M\gamma k_{\rm B}T}, then the original SDE will become

{\rm d}\dot{\mathbf{X}} = -\nabla U(\mathbf{X}){\rm d}t-\gamma {\rm d}{\mathbf{X}} +\sqrt{2}\sigma{\rm d} \mathbf{W}(t)

=== Overdamped Langevin dynamics ===

If the main objective is to control temperature, care should be exercised to use a small damping constant \gamma. As \gamma grows, it spans from the inertial all the way to the diffusive (Brownian) regime. The Langevin dynamics limit of non-inertia is commonly described as Brownian dynamics. Brownian dynamics can be considered as overdamped Langevin dynamics, i.e. Langevin dynamics where no average acceleration takes place. Under this limit we have {\rm d}\dot{X}=0, the original SDE then will becomes

{\rm d}{\mathbf{X}} =-\frac{1}{\gamma}\nabla U(\mathbf{X}){\rm d}t+\frac{\sqrt{2}\sigma}{\gamma}{\rm d} \mathbf{W}(t)

The translational Langevin equation can be solved using various numerical methods {{Cite journal

|last1=Tanygin

|first1=Bogdan

|last2=Melchionna

|first2=Simone

|title=Comparison of effective and stable Langevin dynamics integrators

|journal=Computer Physics Communications

|volume=299

|pages=109152

|year=2024

|issn=0010-4655

|doi=10.1016/j.cpc.2024.109152 |url=https://www.sciencedirect.com/science/article/pii/S0010465524000754

|language=en

|arxiv=2304.09030

|bibcode=2024CoPhC.29909152T

}}{{Cite journal

|last1=Leimkuhler

|first1=Benedict

|last2=Matthews

|first2=Charles

|title=Robust and efficient configurational molecular sampling via Langevin dynamics

|journal=The Journal of Chemical Physics

|volume=138

|issue=17

|year=2013

|doi=10.1063/1.4802990

|pmid=23656109

|arxiv=1304.3269

|bibcode=2013JChPh.138q4102L

|language=en

}} with differences in the sophistication of analytical solutions, the allowed time-steps, time-reversibility (symplectic methods), in the limit of zero friction, etc.

The Langevin equation can be generalized to rotational dynamics of molecules, Brownian particles, etc. A standard (according to NIST{{Cite web|url=https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=860163|title=Wayback Machine|website=tsapps.nist.gov}}) way to do it is to leverage a quaternion-based description of the stochastic rotational motion.{{Cite journal |last=Omelyan |first=Igor P. |date=1998-01-01 |title=On the numerical integration of motion for rigid polyatomics: The modified quaternion approach |url=https://pubs.aip.org/cip/article/12/1/97/136748/On-the-numerical-integration-of-motion-for-rigid |journal=Computers in Physics |language=en |volume=12 |issue=1 |pages=97–103 |doi=10.1063/1.168642 |issn=0894-1866|arxiv=physics/9901028 |bibcode=1998ComPh..12...97O }}{{Cite journal |last1=Groot |first1=Robert D. |last2=Warren |first2=Patrick B. |date=1997-09-15 |title=Dissipative particle dynamics: Bridging the gap between atomistic and mesoscopic simulation |url=https://pubs.aip.org/jcp/article/107/11/4423/478600/Dissipative-particle-dynamics-Bridging-the-gap |journal=The Journal of Chemical Physics |language=en |volume=107 |issue=11 |pages=4423–4435 |doi=10.1063/1.474784 |bibcode=1997JChPh.107.4423G |issn=0021-9606}}

Applications

= Langevin thermostat =

Langevin thermostat{{Cite book |last1=Allen |first1=Michael P. |url=https://books.google.com/books?id=WFExDwAAQBAJ&pg=PP1 |title=Computer Simulation of Liquids |last2=Tildesley |first2=Dominic J. |date=2017-08-15 |publisher=Oxford University Press |isbn=978-0-19-252470-6 |language=en}} is a type of Thermostat algorithm in molecular dynamics, which is used to simulate a canonical ensemble (NVT) under a desired temperature. It integrates the following Langevin equation of motion:

M \ddot{\mathbf{X}} = -\nabla U(\mathbf{X}) - \gamma \dot{\mathbf{X}} + \sqrt{2\gamma k_BT} \textbf{R}(t)

-\nabla U(\mathbf{X}) is the deterministic force term; \gamma is the friction coefficient and \gamma \dot{X} is the friction or damping term; the last term is the random force term (k_B: Boltzmann constant, T: temperature). This equation allows the system to couple with an imaginary "heat bath": the kinetic energy of the system dissipates from the friction/damping term, and gain from random force/fluctuation; the strength of coupling is controlled by \gamma. This equation can be simulated with SDE solvers such as Euler–Maruyama method, where the random force term is replaced by a Gaussian random number in every integration step (variance \sigma^2 = 2\gamma k_BT/ \Delta t, \Delta t: time step), or Langevin Leapfrog integration, etc. This method is also known as Langevin Integrator.{{Cite web |title=21. Integrators — OpenMM User Guide 8.2 documentation |url=http://docs.openmm.org/latest/userguide/theory/04_integrators.html#integrators-theory |access-date=2025-05-12 |website=docs.openmm.org}}

= Langevin Monte Carlo =

The overdamped Langevin equation gives

{\rm d} \mathbf{x}_t = - \frac{D}{k_BT} \nabla_\mathbf{x} U(\mathbf{x}_t) {\rm d}t + \sqrt{2D} {\rm d} W_t

Here, D = k_B T / \gamma is the diffusion coefficient from Einstein relation. As proven with Fokker-Planck equation, under appropriate conditions, the stationary distribution of \mathbf x_t is Boltzmann distribution p(\mathbf{x}) \propto e^{-U(\mathbf{x})/k_BT}.

Since that \nabla \log p(\mathbf{x})=-\nabla U(\mathbf{x})/k_BT, this equation is equivalent to the following form:

{\rm d} \mathbf{x}_t = \epsilon \nabla_\mathbf{x}\log p(\mathbf x_t) {\rm d}t + \sqrt{2\epsilon} {\rm d} W_t

And the distribution of \mathbf x_t (t\to \infty) follows p(\mathbf{x}). In other words, Langevin dynamics drives particles towards a stationary distribution p(\mathbf{x}) along a gradient flow, due to the \nabla \log p(\mathbf{x}) term, while still allowing for some random fluctuations. This provides a Markov Chain Monte Carlo method that can be used to sample data \mathbf x from a target distribution p(\mathbf{x}), known as Langevin Monte Carlo.

In many applications, we have a desired distribution p(\mathbf{x}) from which we would like to sample \mathbf x, but direct sampling might be challenging or inefficient. Langevin Monte Carlo offers another way to sample \mathbf x \sim p(\mathbf x) by sampling a Markov chain in accordance with the Langevin dynamics whose stationary state is p(\mathbf{x}). The Metropolis-adjusted Langevin algorithm (MALA) is an example : Given a current state \mathbf x_t, the MALA method proposes a new state \tilde{x}_{t+1} using the Langevin dynamics above. The proposal is then accepted or rejected based on the Metropolis-Hastings algorithm. The incorporation of the Langevin dynamics in the choice of \tilde{x}_{t+1} provides greater computational efficiency, since the dynamics drive the particles into regions of higher p(\mathbf{x}) probability and are thus more likely to be accepted. Read more in Metropolis-adjusted Langevin algorithm.

= Score-based generative model =

Langevin dynamics is one of the basis of score-based generative models. From (overdamped) Langevin dynamics,

{\rm d} \mathbf{x}_t = \epsilon \nabla_\mathbf{x}

\log p(\mathbf x_t) {\rm d}t + \sqrt{2\epsilon} {\rm d} W_t

A generative model aims to generate samples that follow (unknown data distribution) p(\mathbf{x}). To achieve that, a score-based model learns an approximate score function \mathbf{s}_\theta(\mathbf{x}) \approx \nabla_\mathbf{x} \log p(\mathbf{x}) (a process called score matching). With access to a score function, samples are generated by the following iteration,{{Cite web |title=Generative Modeling by Estimating Gradients of the Data Distribution {{!}} Yang Song |url=https://yang-song.net/blog/2021/score/ |access-date=2025-05-12 |website=yang-song.net}}{{cite arXiv | eprint=2011.13456 | last1=Song | first1=Yang | last2=Sohl-Dickstein | first2=Jascha | last3=Kingma | first3=Diederik P. | last4=Kumar | first4=Abhishek | last5=Ermon | first5=Stefano | last6=Poole | first6=Ben | title=Score-Based Generative Modeling through Stochastic Differential Equations | date=2020 | class=cs.LG }}

\mathbf{x}_{i+1} \gets \mathbf{x}_i + \epsilon \nabla_\mathbf{x} \log p(\mathbf{x}_i) + \sqrt{2\epsilon} \mathbf{z}_i,

\quad i=0,1,\cdots, K

with \mathbf{z}_i \sim N(0,1). As \epsilon \to 0 and K \to \infty, the generated \mathbf{x}_K converge to the target distribution p(\mathbf x). Score-based models use \mathbf{s}_\theta(\mathbf{x}) \approx \nabla_\mathbf{x} \log p(\mathbf{x}) as an approximation.

Relation to Other Theories

= Klein-Kramers equation =

As a stochastic differential equation(SDE), Langevin dynamics equation, has its corresponding partial differential equation(PDE), Klein-Kramers equation, a special Fokker–Planck equation that governs the probability distribution of the particles in the phase space. The original Langevin dynamics equation can be reformulated as the following first order SDEs:

{\rm d}\mathbf{X} = \mathbf{P}{\rm d} t

{\rm d} \mathbf{P} = -\gamma\mathbf{P}{\rm d}t-\nabla U(\mathbf{X}){\rm d} t+\sqrt{2}\sigma {\rm d}\mathbf{W}(t)

Now consider the following cases and their law of (\mathbf{X},\mathbf{P}):

1.\mathbf{{\rm d}{X}} = \mathbf{P}{\rm d} t

, \mathbf{{\rm d}{P}} = -\gamma\mathbf{P}{\rm d} t-\nabla U(\mathbf{X}){\rm d} t+\sqrt{2}\sigma {\rm d}\mathbf{W}(t) with (\mathbf{X}_0,\mathbf{P}_0)\sim\rho_0

2. \frac{\partial\rho}{\partial t} = -\mathbf{P}\nabla_{\mathbf{X}}\rho+\nabla_{\mathbf{P}}(\gamma\mathbf{P}\rho+\nabla_{\mathbf{X}}U(\mathbf{X})\rho)+\nabla_{\mathbf{P}}^2(\sigma_{T}^2\rho) with \rho(t=0,\mathbf{X},\mathbf{P})=\rho_0

Consider a general function of momentum and position

\Psi_t = \Psi(\mathbf{X},\mathbf{P})

The expectation value of the function will be

\mathbb{E}[\Psi_t] = \int \rho(t,\mathbf{X},\mathbf{P})\Psi(\mathbf{X},\mathbf{P}){\rm d} \mathbf{P}{\rm d} \mathbf{X}

Taking derivative with respect to time t, and applying Itô's formula, we have

\mathbb{E}[\frac{\rm d}{{\rm d}t}\Psi(\mathbf{X},\mathbf{P})]

=\mathbb{E}[\nabla_{\mathbf{X}} \Psi\frac{{\rm d}\mathbf{X}}{{\rm d}t} + \nabla_{\mathbf{P}}\Psi\frac{{\rm d}\mathbf{P}}{{\rm d}t} + \sigma_T^2\nabla_{\mathbf{P}}^2\Psi\frac{1}{{\rm d} t}({\rm d} \mathbf{W}(t))^2]

which can be simplified to

\int (\frac{\partial}{\partial t}\rho)\Psi(\mathbf{X},\mathbf{P}){\rm d} \mathbf{X}{\rm d}\mathbf{P} =\mathbb{E}[(\nabla_{\mathbf{X}} \Psi)\mathbf{P} + \nabla_{\mathbf{P}}\Psi(-\gamma\mathbf{P}-\nabla_{\mathbf{X}}U(\mathbf{X})) + \sigma_T^2\nabla_{\mathbf{P}}^2\Psi]

Integration by parts on right hand side, due to vanishing density for infinite momentum or velocity we have

(\frac{\partial}{\partial t}\rho)\Psi(\mathbf{X},\mathbf{P}){\rm d} \mathbf{X}{\rm d}\mathbf{P} = \int(-\mathbf{P}\nabla_{\mathbf{X}}\rho+\nabla_{\mathbf{P}}(\gamma\mathbf{P}\rho+\nabla_{\mathbf{X}}U(\mathbf{X})\rho)+\nabla_{\mathbf{P}}^2(\sigma_{T}^2\rho) )\Psi(\mathbf{X},\mathbf{P}){\rm d}\mathbf{X}{\rm d}\mathbf{P}

This equation holds for arbitrary $\Psi$, so we require the density to satisfy

\frac{\partial \rho}{\partial t} = -\mathbf{P}\nabla_{\mathbf{X}}\rho+\nabla_{\mathbf{P}}(\gamma\mathbf{P}\rho+\nabla_{\mathbf{X}}U(\mathbf{X})\rho)+\nabla_{\mathbf{P}}^2(\sigma_{T}^2\rho)

This equation is called the Klein-Kramers equation, a special version of Fokker Planck equation. It's a partial differential equation that describes the evolution of probability density of the system in the phase space.

= Fokker Planck equation =

For the overdamped limit, we have {\rm d}\mathbf{P} = 0, so the evolution of system can be reduced to the position subspace. Following similar logic we can prove that the SDE for position,

{\rm d} \mathbf{X} = -\frac{1}{\gamma}\nabla U(\mathbf{X}){\rm d} t +\sqrt{2}\frac{\sigma}{\gamma}\mathbf{R}(t){\rm d} t

corresponds to the Fokker Planck equation for probability density

\frac{\partial \rho(t,\mathbf{X})}{\partial t} = \nabla_{\mathbf{X}}(\frac{1}{\gamma}\nabla_{\mathbf{X}}U(\mathbf{X})\rho(t,\mathbf{X}))+\Delta_\mathbf{X}(\frac{\sigma^2}{\gamma^2}\rho(t,\mathbf{X}))

= Fluctuation-dissipation theorem =

Consider Langevin dynamics of a free particle (i.e. U(\mathbf{X})=0 ), then the equation for momentum will become

{\rm d}\mathbf{P} = -\frac{1}{\gamma} \mathbf{P}{\rm d}t +\frac{\sqrt{2}\sigma}{\gamma} {\rm d}\mathbf{W}_t

the analytical solution to this SDE is

\mathbf{P} = \mathbf{P}_0e^{- t/\gamma}+\frac{\sqrt{2}\sigma}{\gamma}\int_0^t {\rm e}^{-(t-t')/\gamma}{\rm d}\mathbf{W}_t'

thus the average value of second moment of momentum will becomes (here we apply the Itô isometry)

\mathbb{E}(\mathbf{P}^2) = \mathbf{P}^2_0{\rm e}^{-2 t/\gamma}+ \frac{\sigma^2}{\gamma}(1-{\rm e}^{-2t/\gamma})\overset{t\to\infty}{\to}\frac{\sigma^2}{\gamma}

That is, the limiting behavior when time approaches positive infinity, the momentum fluctuation of this system is related to the energy dissipation (friction term parameter \gamma ) of this system. Combining this result with Equipartition theorem, which relates the average value of kinetic energy of particles with temperature

\langle v^2\rangle = k_{\rm B}T

we can determines the value of the variance \sigma in applications like Langevin thermostat.

\sigma^2/\gamma = k_B T \to \sigma = \sqrt{k_{\rm B} T\gamma}

This is consistent with the original definition assuming M=1.

= Path Integral =

Path Integral Formulation comes from Quantum Mechanics. But for a Langevin SDE we can also induce a corresponding path integral. Considering the following Overdamped Langevin equation under, where without loss of generality we take \gamma = \sigma = 1 ,

{\rm d}{X} = -\nabla U({X}){\rm d}t +\sqrt{2}{\rm d}W_t

Discretize and define t_n = n\Delta t , we get

{X}_{n+1} -{X}_{n} + \nabla U({X})\Delta t= \sqrt{2}(W_{t_n}-W_{t_{n-1}})\sim \mathcal{N}(0,2\sqrt{\Delta t})

Therefore the propagation probability will be

P({X}_{n+1}|{X}_{n}) = \int {\rm d}\xi \frac{1}{2\sqrt{\pi\Delta t}}{\rm e}^{-\frac{\xi^2}{4\Delta t}} \delta({X}_{n+1} -{X}_{n} + \nabla U({X})\Delta t-\xi)

Applying Fourier Transform of delta function, and we will get

P = \int \frac{{\rm d}k}{2\pi}{\rm e}^{{\rm i}k({X}_{n+1}-{X}_n + \nabla U({X})\Delta t)}\int {\rm d}\xi \frac{1}{2\sqrt{\pi\Delta t}}{\rm e}^{-\frac{\xi^2}{4\Delta t}}{\rm e}^{-{\rm i}k\xi}

The second part is a Gaussian Integral, which yields

P = \int \frac{{\rm d}k}{2\pi}{\rm e}^{{\rm i}k({X}_{n+1}-{X}_n + \nabla U({X})\Delta t)}{\rm e}^{-k^2\Delta t}

Now consider the probability from initial X_0

to final X_n.

P(\mathbf{X}_n|\mathbf{X}_0) = \int \frac{1}{2\pi}\prod_i^{N-1} {\rm d}k_i {\rm e}^{({\rm i}k_i(\dot{X} + \nabla U(X))-k_i^2)\Delta t}

take the limit of \Delta t\to 0,we will get

P(\mathbf{X}_n|\mathbf{X}_0) = \int \mathcal{D}[k] {\rm e}^{\int_0^{t_n}({\rm i}k(\dot{X} + \nabla U(X))-k^2){\rm d} t}

See also

References

{{reflist}}