Online-demo: https://xiaonanfu-ucsd.github.io/verlet-gravity/
Differential equations are an important tool for classical mechanics, such as analyzing force and movement. In the simulation of the physical phenomenon of real-world objects, numerical differentiation is usually good enough to reveal the truth about the relationships in a system. The computer can easily handle discrete calculations in the simulation. That is why finite difference is common in the industry. For example, finite element analysis about a vehicle involves finite difference; the trajectory calculation of a satellite uses finite difference.
For those Newton’s equations of motion, there are many finite difference methods (FDMs) to find the solution. Generally, those FDMs segment the motion as a bunch of sub-motions that happened in a very short time interval. FDMs assume that the object moves along a constant vector in a particular time interval. If the movement is non-linear, then there is a cumulative error in FDMs’ results. Different FDMs have different degrees of error. Verlet Integration is one of the FDMs which have a relatively small error term. It does not have extra computational cost compared with the Euler method, and it is numerically stable enough for most of the calculations. Therefore, Verlet Integration is popular in computer graphics, such as simulating fluids with particles, and the gravity effect in space.
FDMs can be understanded as the Taylor series of a particle position function x. The function x here is the one-dimensional position of a particle.
Taylor series gives the approximation to an unknown position which is close to the knowing position . Since the time interval is small (i.e. is small), even if we ignore the high-order terms, the error will not be significant. Taylor series is helpful in particles simulation because we need to know the position of the particle in the next “step”, which means the position after the time interval .
Eq1.
The function here represents the ignored high-order terms in Taylor series has this upper bound. The expression represent has a similar magnitude as . It is small because time interval < 1. Since Euler method (Note: ) have a error term , Verlet Integration is more precise.
Eq2.
Eq2 is the position for the last step.
Eq3.
. It is a middle step to get the equation of Verlet Integration.
Eq4.
Eq4 is the equation that can be used to estimate the next step position, and it removes the because they are not important in the calculation. This equation means Verlet Integration only depends on current position, previous step position, and acceleration.
Depending on previous step position means this method is not self-starting. In most particle simulation test, we only have the initial value about the position and velocity vectors, but not the previous position. Hence we may only estimate the previous position using the initial velocity. It brings in more error.
The improved Verlet method is velocity Verlet Integration. It depends on the current velocity rather than previous position. Therefore, velocity Verlet Integration is self-starting.
Eq5.
Eq5 is the equation to update the velocity, which depends on acceleration.
Acceleration is the key factor in Verlet Integration. By changing , Verlet Integration can simulate different physical phenomenon. Using the Newton’s second law, , , if we find , then will be obvious.
For gravity simulation in the demonstration I provide, the program iteratively finds the gravity between mass points in the system, and accumulates those force vectors to find the acceleration within that step. Then the program can easily find the next position for mass points. This demonstration does not precisely simulate real-world gravity nor the size and distance of stars. Besides gravity, Verlet Integration can also be applied in simulating a rope. A rope can be modeled as particles linked by spring. After replacing a(t) using Hooke’s law, Verlet Integration can predict the position of each rope particle.