Questions tagged [verlet-integration]

Verlet integration is a method for the numerical solution of differential equations that simulate mechanical systems or more generally conservative or Hamiltonian systems. The method belongs to the family of symplectic integration methods, preserving energy and other first integrals almost perfectly.

The problem to solve

Verlet integration is a method for the numerical solution of differential equations

x''(t) = a( x(t) ),    x(t0)=x0, x'(t0)=v0

that simulate mechanical systems and other conservative or Hamiltonian systems. The objects of the system are assumed to be enumerated and their positions assembled into the vector x(t), their velocities assembled in the vector valued function v(t)=x'(t). a(t) consists of the accelerations of the single objects corresponding to the force acting on each object, divided by its mass.

Verlet integration is a symplectic integrator and will only work as expected on conservative systems, which, for example, excludes the consideration of friction. More precisely this means that the system is required do possess an energy function

E(x,v) = 0.5 * vT*M*v + P(x)

where the first term is the kinetic energy, M is the (symmetric, and often diagonal) mass matrix and P(x) the potential energy. Then the force acting on the objects of the system is minus the gradient of the potential energy and thus the acceleration is

a(x) = - M-1 * grad P(x).

Usually the dynamically system is encoded via evaluation of the function a(x), such a procedure is named eval_a(x) in this article.


The solution obtained

Verlet integration, like any numerical integration of ODE, produces sequences

(xn), (vn), (n in IN)

of sample points in the phase space of positions and velocities corresponding to a prescribed sequence (tn) of time instants, so that xn and vn approximate the exact solutions x(tn) and v(tn)=x'(tn).

In the formulation of the method the velocities are of secondary importance, the basic version even leaves them out.


The numerical method(s)

Verlet integration comes in three main flavors, all three for a constant time step dt, so that tn=t0+n*dt. All three compute the same position sequence, basic Verlet computes only this. The other two also compute velocities, while the leapfrog variant has the least operations, for exact velocities the velocity Verlet method should be used.

  • basic Verlet: before each step n->n+1, the variables t, x, x_old are tn, xn, xn-1, initialization returns with the state for n=1.

    verlet_init:
        x_old = x0
        a = eval_a( x0 );
        x = x0 + v0*dt + 0.5*a*dt*dt;   t=t0+dt;
    
    verlet_step:
        a = eval_a(x);
        x_new = 2*x-x_old + a*dt*dt;
        x_old = x;
        x = x_new; t+=dt;
        do_collisions(t,x,x_old);
    
  • velocity verlet: before each step n->n+1, the variables t, x, v are tn, xn, vn, initialization returns with the state for n=0.

    verlet_init:
        a = eval_a( x0 );
        v = v0;
        x = x0; t = t0;
    
    verlet_step:
        v += a*0.5*dt;
        x += v*dt; t += dt;
        do_collisions(t,x,v,dt);
        a = eval_a(x);
        v += a*0.5*dt;
        do_statistics(t,x,v); 
    
  • leapfrog verlet: before each step n->n+1, the variables t, x, v are tn, xn, vn+0.5, where tn+0.5=tn+0.5*dt, initialization returns with the state for n=0.

    verlet_init:
        a = eval_a( x0 );
        v = v0 + 0.5*a*dt;
        x = x0;     t=t0;
    
    verlet_step:
        x += v*dt; t += dt;
        do_collisions(t,x,v,dt);
        a = eval_a(x);
        v += a*dt;
    

The sequence of the computations must be preserved, however the lines inside `verlet_step' may be rotated. Then the initialization needs to be adapted so that the unrolled loop stays the same.


Numerical errors

The approximation error at time t behaves as O(eLt*dt2), it is a second order method.

The Verlet integration method belongs to the family of symplectic integration methods. These preserve the energy E and other first integrals of the system almost perfectly. In the Verlet method the energy oscillates with time constant amplitude O(dt2) around the initial energy level.

46 questions
25
votes
3 answers

Why is Verlet integration better than Euler integration?

Can someone explain to me why Verlet integration is better than Euler integration? And why RK4 is better than Verlet? I don't understand why it is a better method.
16
votes
1 answer

How to make verlet integration collisions more stable?

I'm not using any engine, but instead trying to build my own softbody dynamics for fun using verlet integeration. I made a cube defined by 4x4 points with segments keeping its shape like so: I have the points collide against the edges of the scene…
Green Cell
  • 4,677
  • 2
  • 18
  • 49
16
votes
4 answers

Writing a faster Python physics simulator

I have been playing around with writing my own physics engine in Python as an exercise in physics and programming. I started out by following the tutorial located here. That went well, but then I found the article "Advanced character physics" by…
mooglinux
  • 815
  • 1
  • 11
  • 27
8
votes
3 answers

The time-corrected Verlet numerical integration formula

There is a commonly used verlet-integration formula on the web by Johnathan Dummer, called Time-Corrected Verlet. However I've read several forum posts, that people get weird or unexpected results with it in certain conditions. Formula by Johnathan…
7
votes
3 answers

Runge–Kutta RK4 not better than Verlet?

I'm just testing several integration schemes for orbital dynamics in game. I took RK4 with constant and adaptive step here http://www.physics.buffalo.edu/phy410-505/2011/topic2/app1/index.html and I compared it to simple verlet integration (and…
Prokop Hapala
  • 2,424
  • 2
  • 30
  • 59
5
votes
3 answers

Verlet Integration in Haskell

I am new to Haskell, and as an exercise I've been trying to implement some of the code (written in Mathematica) from Joel Franklin's book Computational Methods in Physics. I've written the following code to take a lambda expression (acceleration) as…
castle-bravo
  • 1,389
  • 15
  • 34
5
votes
2 answers

Time Corrected Verlet Integration and too big timesteps

i use a Time Corrected Verlet Integration found here: http://www.gamedev.net/page/resources/_/technical/math-and-physics/a-simple-time-corrected-verlet-integration-method-r2200 But when my ball is on a wall (horizontal wall, ball upon it and the…
thebestneo
  • 137
  • 1
  • 6
4
votes
3 answers

Improve performance of Velocity-Verlet integration algorithm

I am trying to integrate orbits of stars using a Velocity-Verlet integrator inside a potential. However, my current algorithm takes around 25 seconds per orbit, I aim to integrate around 1000 orbits which would take around 7 hours. Therefore I hope…
Viktor VN
  • 235
  • 2
  • 7
3
votes
2 answers

Velocity verlet algorithm - energy increasing for n-body problem

The problem I implemented velocity verlet algorithm to compute trajectories of 2 bodies interacting with each other gravitationally (newtonian gravity only). Orbiting smaller body has a very small mass, body that is in the center of the orbit has a…
3
votes
1 answer

Drawing a Turkey in unity2d using Verlet method

This is a homework problem(Do not copy, copy is not smart): We need to draw a 2d turkey in unity 2d using Verlet method to update the positions of the vertices. However, We don't know the forces involved to trace the Turkey. Here is a picture of the…
user42493
  • 813
  • 4
  • 14
  • 34
3
votes
3 answers

Verlet integrator + friction

I have been following "A Verlet based approach for 2D game physics" on Gamedev.net and I have written something similar. The problem I am having is that the boxes slide along the ground too much. How can I add a simple rested state thing where the…
Kachinsky
  • 573
  • 1
  • 7
  • 20
2
votes
0 answers

N-Body Simulation of Globular Cluster

I am trying to code an n-body simulation using the leap frog scheme to simulate a globular cluster however am running into the issue of particles being flung out of the system from (I think) approaching to close to the other particles as well as…
2
votes
1 answer

Very basic collision resolution with verlet integration

I'm learning how to do some very basic physics stuff for my own amusement, but I'm running into an odd issue. I'm using a time-corrected verlet integration method as described on http://www.lonesock.net/article/verlet.html , and so far, it's worked…
Kozaki
  • 615
  • 2
  • 7
  • 13
2
votes
1 answer

Verlet 3D Ball Breaking

I am trying to use verlet integration for making a soft body sphere. I basically create a mesh and attach each vertex by springs. I am using three.js to render the sphere. I believe everything is working correctly, but I am unsure about how to get…
Luple
  • 481
  • 3
  • 21
2
votes
1 answer

Haskell: Slow infinite list for Verlet Integration

I am using Haskell to make a Verlet integrator to model gravity. The integrator uses the first two positions of the object as seeds and generates the rest after this. I thought a nice way of making this in Haskell would be to use an infinite list.…
user668074
  • 1,111
  • 10
  • 16
1
2 3 4