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
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
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.