softmatter:Velocity Verlet Algorithm
From NSDL Materials Digital Library Soft Matter Wiki
The original Verlet Algorithm does not use the velocity to compute the new position; therefore the velocity is only derived from the old and new positions. Velocity Verlet algorithm utilizes the new forces to update velocities at time (t + Δt), allowing the position and velocity are automatically synchronized. This velocity Verlet algorithm proceeds as follows 1:
Contents |
General Algorithm
Expand the position of a particle at time t in a truncated Taylor series:
where
are the mass, position and velocity of the particle,
is the force acting on the particle at time t and Δt is the time step of integration.
Unlike the original Verlet Algorithm, the velocity now is updated from the forces at the previous and current time steps, i.e.
This integration scheme is indeed equivalent to the original scheme [1] when we write down the expression of position at the next time step (t + 2Δt)
and re-arrange equation [1] into
By addition of [3] and [4], we get
Finally, substitution of equation [2] for
into [5] gives us the coordinate equation of the Verlet Algorithm:
This result shows that velocity Verlet algorithm yields the same order of accuracy in velocity as in the original scheme, i.e. (Δt)2. Higher order of velocity accuracy can be achieved when additional corrections are added, e.g Beeman algorithm or Velocity-corrected Verlet Algorithm.
Example Source Code
The velocity Verlet algorithm is implemented based on equation [1] and [2]. Given initial positions and velocities, the trajectories of particles will be determined as the simulation progresses. Additionally initial force should be also computed to boot up the integrating loop. A typical integration routine is given below 2:
void Integrate()
{
// Initialize positions and velocities
Initialize();
// Compute the forces from the initial positions and velocities
ComputeForce();
for (int timestep = _begin; timestep <= _end; timestep++)
{
// Initial integration using the forces from the previous step, noting that velocities are advanced in half time step
for (int i = 0; i < Nparticles; i++)
{
v[i] = v[i] + (f[i] / mass[i]) * delta_t / 2;
x[i] = x[i] + v[i] * delta_t;
}
// Compute new forces from new positions
ComputeForce();
// Final integration, update the velocities by half time step using the new forces
for (int i = 0; i < Nparticles; i++)
v[i] = v[i] + (f[i] / mass[i]) * delta_t / 2;
}
}
Comments:
- In this implementation, the update of velocities is divided into 2 steps. The initial integration uses the forces from the previous time step to advance velocity by half time step
The new position is computed using equation [1] where the last two terms in the right hand side is exactly the half time step velocity
obtained above
The final integration completes the velocity update in equation [2], after the new forces are computed:
Algorithm for Rigid Bodies
The velocity Verlet algorithm can be extended to the motion of rigid particles (for more on rigid body motion, see quaternions). For rigid object motion, the rotational degrees of freedom are governed by
where
,
and
are the angular momentum, angular velocity and moment of inertia tentor of the rigid body, respectively.
is the torque applied to the rigid body. All of these quantities are in space-fixed coordinates. The angular momentum can be updated in the same manner as translational velocity. For more details, please see Rigid Body Motion.
The following listing illustrates a typical implementation of velocity Verlet algorithm for rigid body motion 2.
Example Source Code
void Integrate_Rigidbody()
{
// Initialize positions and velocities
Initialize();
// Compute the forces from the initial positions and velocities
ComputeForceAndTorque();
for (int timestep = _begin; timestep <= _end; timestep++)
{
// Initial integration using the forces from the previous step, noting that velocities are advanced in half time step
for (int i = 0; i < Nbodies; i++)
{
// Translational part
vm[i] = vm[i] + (fm[i] / mass[i]) * delta_t / 2;
xm[i] = xm[i] + vm[i] * delta_t;
// Rotational part
angular_momentum[i] = angular_momentum[i] + torque[i] * delta_t / 2;
// Update the position, linear and angular velocities of body i
SetPositionAndVelocity(i);
}
// Compute new forces from new positions
ComputeForceAndTorque();
// Final integration, update the velocities by half time step using the new forces
for (int i = 0; i < Nbodies; i++)
{
// Translational part
vm[i] = vm[i] + (fm[i] / mass[i]) * delta_t / 2;
// Rotational part
angular_momentum[i] = angular_momentum[i] + torque[i] * delta_t / 2;
// Update the linear and angular velocities of body i
SetVelocity(i);
}
}
}
Comments
- SetPositionAndVelocity(i) updates the position and velocity of constituent components of the rigid body i and its angular velocity.
- SetVelocity(i) updates the velocity of constituent components of the rigid body i and its angular velocity.
References
- [1] Understanding molecular simulation : from algorithms to applications
- [2] LAMMPS source code, LAMMPS website


