Verlet integration
Encyclopedia : V : VE : VER : Verlet integration
Verlet integration is a method for calculating the trajectories of particles in molecular dynamics simulations. The verlet integrator offers greater stability than the much simpler Euler integration methods, as well as other properties that are important in physical systems such as time-reversibility and area preserving properties. Stability of the technique depends fairly heavily upon either a uniform update rate, or the ability to accurately identify positions at a small time delta into the past. Verlet integrators are also sometimes used in the physics engines of video games. The method was developed by French physicist Loup Verlet in 1967.
The algorithm
At first it may seem natural to simply calculate trajectories using Euler integration, which is defined by
- [x(t_0 + \Delta t) = x(t_0) + v(t_0) \Delta t\,]
- [v(t_0 + \Delta t) = v(t_0) + a(t_0) \Delta t\,]
- [x(t_0 + \Delta t) = 2x(t_0) - x(t_0 - \Delta t) + a\Delta t^2\,]
- [v(t_0) = \frac]
The Verlet equations can also be modified to create a very simple damping effect (for instance, to emulate air friction in computer games):
- [x(t_0 + \Delta t) = (2-f) x(t_0) -(1-f) x(t_0 - \Delta t) + at^2.\,]
Derivation
The Verlet integrator can be derived from the Taylor expansion of a trajectory. Let [x(t)] be the trajectory of a particle at time [t]. The Taylor expansion around time [t_0] then gives:
- [x(t_0 + \Delta t) = x(t_0) + \Delta t x'(t_0) + \frac \Delta t^2 x(t_0) + \frac \Delta t^3 x'(t_0) + O(\Delta t^4) ]
- [x(t_0 - \Delta t) = x(t_0) - \Delta t x'(t_0) + \frac \Delta t^2 x(t_0) - \frac \Delta t^3 x'(t_0) + O(\Delta t^4) ]
- [x(t_0 + \Delta t) + x(t_0 - \Delta t) = 2x(t_0) + \Delta t^2 x''(t_0) + O(\Delta t^4) \, ]
- [x(t_0 + \Delta t) = 2x(t_0) - x(t_0 - \Delta t) + \Delta t^2 x''(t_0) + O(\Delta t^4) \, ]
This offers the clear advantage that the third-order term from the Taylor expansion cancels out, thus making the Verlet integrator an order more accurate than integration by simple Taylor expansion alone.
Furthermore, by subtracting the two original Taylors series, we obtain the velocity as:
- [v(t_0) = \frac + O(\Delta t^2). ]
Error terms
The local error in position of the Verlet integrator is [O(\Delta t^4)] as described above, and the local error in velocity is [O(\Delta t^2)].
The global error in position, in contrast, is [O(\Delta t^2)] and the global error in velocity is [O(\Delta t^2)]. These can be derived by noting the following:
- [\mathrm(x(t_0 + \Delta t)) = O(\Delta t^4) \, ]
- [x(t_0 + 2\Delta t) = 2x(t_0 + \Delta t) - x(t_0) + \Delta t^2 x''(t_0 + \Delta t) + O(\Delta t^4) \, ]
- [\mathrm(x(t_0 + 2\Delta t)) = 2\mathrm(x(t_0)) + O(\Delta t^4) = 3O(\Delta t^4) \, ]
- [\mathrm(x(t_0 + 3\Delta t)) = 6O(\Delta t^4) \, ]
- [\mathrm(x(t_0 + 4\Delta t)) = 10O(\Delta t^4) \, ]
- [\mathrm(x(t_0 + 5\Delta t)) = 15O(\Delta t^4) \, ]
- [\mathrm(x(t_0 + n\Delta t)) = \fracO(\Delta t^4) \, ]
- [\mathrm(x(t_0 + T)) = \left(\frac + \frac\right) O(\Delta t^4) \, ]
- [\mathrm(x(t_0 + T)) = O(\Delta t^2) \, ]
In molecular dynamics simulations, the global error is typically far more important than the local error, and the Verlet integrator is therefore known as a second-order integrator.
Constraints
The most notable thing that is now easier due to using Verlet integration rather than Newtonian is that constraints between particles are very easy to do. A constraint is a connection between multiple points that limits them in some way, perhaps setting them at a specific distance or keeping them apart, or making sure they are closer than a specific distance. Often times physics systems use springs between the points in order to keep them in the locations they are supposed to be. However, using springs of infinite stiffness between two points usually gives the best results coupled with the verlet algorithm. Here's how:
- [d_1=x_2-x_1\,]
- [d_2=\sqrt\,]
- [d_3=(d_2-r)/d_2\,]
- [x_1=x_1+0.5d_1d_3\,]
- [x_2=x_2-0.5d_1d_3\,]
Here's what an optimized 2D verlet constraint would look like in C:
dx = x2-x1; dy = y2-y1; d1 = sqrt(dx*dx + dy*dy); d2 = 0.5*(d1-r)/d1; dx = dx*d2; dy = dy*d2; x1 += dx; x2 -= dx; y1 += dy; y2 -= dy;3D:
dx = x2-x1; dy = y2-y1; dz = z2-z1; d1 = sqrt(dx*dx+dy*dy+dz*dz); d2 = 0.5*(d1-r)/d1; dx = dx*d2; dy = dy*d2; dz = dz*d2; x1 += dx; x2 -= dx; y1 += dy; y2 -= dy; z1 += dz; z2 -= dz;Problems, however, arise when multiple constraints position a point. It is extremely hard not to violate at least one. One way to solve this is to loop through all the constraints multiple times, eventually coming to a set of positions that satisfies the constraints enough to be accurate, or have it simply loop a set number of times.
Collision reactions
One way of reacting to collisions is to use a penalty-based system which basically applies a set force to a point upon contact. The problem with this is that it is very difficult to choose the force imparted. Use too strong a force and objects will become unstable, too weak and the objects will penetrate each other. Another way is to use projection collision reactions which takes the offending point and attempts to move it the shortest distance possible to move it out of the other object.The Verlet integration would automatically handle the velocity imparted via the collision in the latter case, however note that this is not guaranteed to do so in a way that is consistent with collision physics (that is, changes in momentum are not guaranteed to be realistic).
See also
External links
- [Advanced Character Physics by Thomas Jakobsen]
- [The Verlet algorithm]
- [Theory of Molecular Dynamics Simulations] - bottom of page
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
