Class Verlet

  extended by org.opensourcephysics.numerics.AbstractODESolver
      extended by org.opensourcephysics.numerics.Verlet
All Implemented Interfaces:

public class Verlet
extends AbstractODESolver

Verlet: A velocity Verlet method ODE solver. The velocity Verlet algorithm is a self-starting equivalent of the Verlet algorithm. It assumes a constant acceleration to estimate the final position and an average accleration to estimate the final velocity. The position is first updated, the force is calcualted at the new position, and then the velocity is updated. x(n+1) = x(n) + v(n)* dt + a(n)*dt*dt/2 a_est=F(x(n+1),v(n),t)/m v(n+1) = v(n) + (a(n)+a_est)*dt/2 CAUTION! This implementation assumes that the state variables alternate between position and velocity with the last variable being time. That is, the state vector is ordered as follows: x1, d x1/dt, x2, d x2/dt, x3, d x3/dt ..... xN, d xN/dt, t

Wolfgang Christian

Field Summary
Fields inherited from class org.opensourcephysics.numerics.AbstractODESolver
numEqn, ode, stepSize
Constructor Summary
Verlet(ODE ode)
          Constructs the velocity Verlet ODESolver for a system of ordinary differential equations.
Method Summary
 int getRateCounter()
          Gets the counter that records the number of times the rate has been evaluated during the current step.
 void initialize(double stepSize)
          Initializes the ODE solver.
 double step()
          Steps (advances) the differential equations by the stepSize.
Methods inherited from class org.opensourcephysics.numerics.AbstractODESolver
getStepSize, setStepSize
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Verlet(ODE ode)
Constructs the velocity Verlet ODESolver for a system of ordinary differential equations.

ode - the system of differential equations.
Method Detail


public void initialize(double stepSize)
Initializes the ODE solver. The rate array is allocated. The number of differential equations is determined by invoking getState().length on the ODE.

Specified by:
initialize in interface ODESolver
initialize in class AbstractODESolver
stepSize -


public int getRateCounter()
Gets the counter that records the number of times the rate has been evaluated during the current step. This method allows a model to improve its performance by enabling the model to determine if this is the first or second time that the rate is being evaluated. The Verlet algorithm first invokes the model's getRate method to update the position and then again to update velocity. Because the force at the new position is computed the second time that getRate is invoked, a model can improve its performance if it skips the force computation during the first call to getRate. A typical dynamics simulation should comptute the force when rateCounter is one and stores this force for use during the next postion update. The Verlet algorithm will perform correctly (but more slowly) if the force is computed every time that getRate is invoked.

int the counter


public double step()
Steps (advances) the differential equations by the stepSize. The ODESolver invokes the ODE's getState method to obtain the initial state of the system. The ODESolver advances the solution and copies the new state into the state array at the end of the solution step.

Specified by:
step in interface ODESolver
Specified by:
step in class AbstractODESolver
the step size