Langevin Dynamics
At the Langevin level of description, the dynamics of the solvent molecules (e.g. water) are orders of magnitude faster than the solute particles, leaving the positions and momenta of the solute particles as relevant variables. The dynamics of the solute particles are governed by a so-called Langevin equation, a manifestation of the Fokker-Plank equation that is often described as “Molecular Dynamics with a thermostat”.
We can write the Langevin stochastic differential equation as
which can be interpreted as a form of Molecular Dynamics coupled with a thermostat so that noise and drag forces are balanced according to the fluctuation-dissipation relation, guaranteeing the correct thermalization of the system (NVT ensemble). Here are the velocities of the particles.
On the other hand, the LD equation is an expression of the equivalent stochastic differential equation (SDE) for the Fokker-Plank equation with the particle momenta and positions as the relevant variables. The first term in the Langevin SDE , , is the sum of the conservative forces acting on particle
(the ones coming from the underlying potential energy landscape), these interactions can be steric, electrostatic, bonded, etc. In UAMMD, forces are provided to the Integrator modules via Interactors.
The second term represents the drag exerted by the solvent particles in the form of a dissipative force.
Finally, the third term represents the fluctuations produced by the fast and constant collisions of the solvent particles. Here
is a random increment which must be in fluctuation-dissipation balance with the friction term.
The friction coefficient, , is related with the damping rate as
, which represents the decorrelation time of the velocity,
. Additionally,
can be formally derived from a Green-Kubo relation involving the integral of the solvent-solute force time-correlation. Its value is often approximated by the Stokes (macroscopic) value
, of a particle of radius
in a solvent with viscosity
.
The Fokker-Planck formalism teaches us that when a system dissipates energy, for instance, due to a force like the drag force in the Langevin SDE, the fluctuation-dissipation theorem states that there must be an opposite process that reintroduces this energy via thermal fluctuations.
In this case, fluctuation-dissipation enforces a fluctuating term with zero mean,
which is uncorrelated in time (since we are assuming the time interval is small enough to consider the transport coefficients as constants) with standard deviation given by
We can then write the Langevin equation as
Where we have defined .
Technically, the restrictions for would be compatible with any random distribution for the noise,
, that has zero mean and variance
. However, as the noise term comes from the action of countless independent random variables (collisions with the solvent particles) the central limit theorem applies. Thus, it is convenient to choose
as a Gaussian white noise (i.e. a Wiener process).
Hint
At the Langevin level of description, particles move so slowly compared to the solvent characteristic times that hydrodynamic interactions are effectively instantaneous. Only the positions and momenta of the particles remain as relevant variables (Lagrangian description once again), which obey a Langevin equation. The characteristic decorrelation time of the particle’s velocities governs this scale with .
UAMMD exposes a Verlet-like algorithm to numerically integrate the Langevin SDE called Grønbech-Jensen [1]
The update rule, taking the simulation from the time step (time
) to the next,
, can be summarized as
Where
Note that, since we need the force at to compute the velocities at
the forces have to be a function of the positions only (and not velocities).
Note
The code for this module is located in the source code Integrator/VerletNVT/GronbechJensen.cuh.
Usage
Grønbech-Jensen [1] is available as an Integrator.
- The following parameters are available:
real temperatureTemperature of the solvent in units of energy. This isin the formulas.
real frictionFriction,.
real dtTime step.real mass = -1Mass of all the particles. If >0 all particles will have this mass, otherwise the mass for each particle in ParticleData will be used. If masses have not been set in ParticleData the default mass is 1 for all particles.bool initVelocities=trueModify starting velocities to ensure the target temperature from the start. Whenfalsethe velocities of the particles are left untouched at initialization. The default is true and sets particle velocities following the botzmann distribution.bool is2D = falseSet to true if the system is 2D
#include"uammd.cuh"
#include"Integrator/VerletNVT.cuh"
using namespace uammd;
int main(){
//Assume an instance of ParticleData, called "pd", is available
...
using NVT = VerletNVT::GronbechJensen;
NVT::Parameters params;
params.temperature = 1.0;
params.dt = 0.1;
params.friction = 1.0;
auto verlet = std::make_shared<NVT>(pd, params);
...
//Add any interactor
verlet->addInteractor(myInteractor);
...
//Take simulation to the next step
verlet->forwardTime();
...
return 0;
}
Here, pd is a ParticleData instance.
Note
As usual, any Interactor can be added to this Integrator, as long as it is able to compute forces.
Dissipative Particle Dynamics
One of the most popular techniques used to reintroduce some of the degrees of freedom lost with LD is Dissipative Particle Dynamics (DPD). This coarse graining technique can be used to go further in the spatio-temporal scale by choosing groups of fluid particles as the simulation unit, sitting inbetween microscopic (as in MD) and macroscopic (hydrodynamic) descriptions. In practice DPD is a Langevin approach where friction acts by pairs of particles and conserves momentum.
In the standard DPD, particles interact via a soft potential, modelling the interaction between two large groups of fluid particles. In many instances DPD is used as a momentum-conserving thermostat, which thus permits to include hydrodynamics (contrary to a single Langevin approach). Local momemtum conservation results in the emergence of macroscopic hydrodynamic effects. These momentum conserving forces can then be tuned to reproduce not only thermodynamics, but also dynamical and rheological properties of diverse complex fluids. The equations of motion in DPD have the same functional form as LD and can be in fact considered as a momentum-conserving generalization of LD. The equations of motion for DPD read,
Where the three forces are traditionally expressed as,
Where is the relative velocity between particles
and
. Here
represents a friction coefficient and is related to the random force strength via fluctuation-dissipation balance in a familiar way [2]. In general
can be considered to be a tensorial quantity and even derived from atomistic simulations using dynamic coarse graining theory. The factor
is different from the one in LD in that it affects pairs of particles (instead of each individual one), it also represents a Gaussian random number with zero mean and unit standard deviation, but must be chosen independently for each pair while ensuring symmetry so that
.
The weight function
is a soft repulsive force usually defined as
Where is a cut-off distance. The strength parameter,
, can in principle be different for each pair of particles,
-
, but for simplicity we will assume it is the same for every pair.
Note
The code is easily generalized for a different per-particle strength and/or friction.
Being an SDE where the forces depend on the velocities, numerical integration of the DPD equations is tricky. A simple modification can be made, sacrificing stability, by approximating the velocity to just first order in the Gronbech-Jensen update rule, so that the velocity depends only on the force for the current step. Unfortunately, this leads to artifacts in the transport properties and unacceptable temperature drifts. There are several strategies in the literature trying to overcome this, usually presented as modifications of the velocity Verlet algorithm.
All of these methods improve the accuracy of the predicted transport properties and response functions in exchange for increased computational cost. One popular approach is to simply use the energy-conserving velocity Verlet (see Molecular Dynamics) with the DPD forces. This yields “poor” stability and presents certain artifacts due to the mistreatment of the derivative of the noise term incurred by treating the DPD equations as an ordinary differential equation instead of a proper SDE. However, it is often good enough and while it might require a smaller time step to recover measurables to an acceptable tolerance it is the fastest approach and trivial to implement in a code already providing the velocity Verlet algorithm.
This is the approach used in UAMMD, where DPD is encoded as a Molecular Dynamics Integrator coupled with a Pair Forces Interactor encoding the DPD forces.
Note
The force-computing code for this module is located in the source code Interactor/Potential/DPD.cuh
Usage
A DPD Integrator is created by coupling a VerletNVE Molecular Dynamics Integrator with a DPD Potential (the Potential is supplied to a Pair Forces Interactor that can be then added to the Integrator).
- The following parameters are available for the DPD Potential:
real temperatureTemperature of the solvent in units of energy. This isin the formulas.
real cutOffThe cut off,, for the weight function.
real gammaThe friction coefficient,.
real AThe strength of the weight function,.
real dtThe time step. Be sure to pass the same time step to DPD and the Integrator.
#include<uammd.cuh>
#include<Integrator/VerletNVE.cuh>
#include<Interactor/PairForces.cuh>
#include<Interactor/Potential/DPD.cuh>
using namespace uammd;
//A function that creates and returns a DPD integrator
auto createIntegratorDPD(UAMMD sim){
Potential::DPD::Parameters par;
par.temperature = sim.par.temperature;
//The cut off for the weight function
par.cutOff = sim.par.cutOff;
//The friction coefficient
par.gamma = sim.par.friction;
//The strength of the weight function
par.A = sim.par.strength;
par.dt = sim.par.dt;
auto dpd = make_shared<Potential::DPD>(dpd);
//From the example in PairForces
auto interactor = createPairForcesWithPotential(sim, dpd);
//From the example in the MD section
// particle velocities should not be initialized
// by VerletNVE (initVelocities=false)
using NVE = VerletNVE;
NVE::Parameters params;
params.dt = par.dt;
params.initVelocities=false;
verlet = make_shared<NVE>(pd, params);
verlet->addInteractor(interactor);
return verlet;
}
Note
The UAMMD structure in this example is taken from the example/ folders in the repository, containing, for convenience, an instance of ParticleData and a set of parameters
Smoothed Particle Hydrodynamics
Todo
More detailed description of SPH
In SPH [3], particles are understood as interpolation points from which the fluid properties can be calculated. At the end of the day these “points” behave like particles for all intents and purposes. As a matter of fact the equations of motion for particles in SPH are just the Newton equations (see Molecular Dynamics) with a specially crafted interparticle force given by
Note
Similarly to DPD, SPH [3] is encoded as a Molecular Dynamics Integrator coupled with a special Interactor encoding the SPH forces.
The force-computing code for this module is located in the source code Interactor/SPH.cuh
where are the indices of the particles that are neighbours of
(i.e. those within the support distance beyond which the interpolation kernel is zero),
are the masses of the particles. Here
is a length scale and
is a smooth decaying interpolation function with a close support, the so-called cubic spline kernel is commonly used,
Hint
The source file “Interactor/SPH/Kernel.cuh” contains the interpolation function, as well as an easy way to introduce new ones.
The density, , on a given particle is interpolated from its neighbours as
On the other hand is the pressure on the particle as given by a certain equation of state, in UAMMD’s implementation we use an ideal gas approximation given by
Hint
The source file “Interactor/SPH.cu” contains the equation of state for the pressure, which is easily modified.
where is a gas stiffness and
is a rest density.
Finally, is an artificial viscosity introduced to improve numerical stability, in UAMMD’s implementation we use
where is a provided viscosity, and
is the relative velocity of particles i and j.
is introduced to prevent the singularity at
.
Hint
The source file “Interactor/SPH.cu” contains the computation of the artificial viscosity, which is easily modified.
Usage
We couple an SPH Interactor with a VerletNVE Integrator.
- The following parameters are available for the SPH Interactor:
real support. The length scale.
real viscosity. The prefactor for the artificial viscosity,.
real gasStiffness. The prefactor for the ideal gas equation of state,.
real restDensity. The rest density in the equation of state,.
Box box. ABoxwith the simulation domain information.
#include "Integrator/VerletNVE.cuh"
#include "Interactor/SPH.cuh"
using namespace uammd;
//SPH is handled by UAMMD as a VerletNVE integrator with a special interaction
std::shared_ptr<Integrator> createIntegratorSPH(std::shared_ptr<ParticleData> pd){
using NVE = VerletNVE;
NVE::Parameters par;
par.dt = 0.1;
par.initVelocities = false;
auto verlet = std::make_shared<NVE>(pd, par);
SPH::Parameters params;
real3 L = make_real3(32,32,32);
params.box = Box(L);
//Pressure for a given particle "i" in SPH will be computed as gasStiffness·(density_i - restDensity)
//Where density is computed as a function of the masses of the surroinding particles
//Particle mass starts as 1, but you can change this in customizations.cuh
params.support = 2.4; //Cut off distance for the SPH kernel
params.viscosity = 1.0; //Environment viscosity
params.gasStiffness = 1.0;
params.restDensity = 1.0;
auto sph = std::make_shared<SPH>(pd, params);
verlet->addInteractor(sph);
return verlet;
}
References