math.numerics
Class Verlet

java.lang.Object
  extended by math.numerics.Verlet
All Implemented Interfaces:
ODESolver

public class Verlet
extends java.lang.Object
implements ODESolver

Verlet method ODE solver. The Verlet algorithm is a third order algorithm that uses the acceleration to estimate the final position. Note that the velocity plays no part in the integration of the equations. x(n+1) = 2*x(n) - x(n-1) + a(n)*dt*dt v(n+1) = (x(n+1) - x(n-1))/(2 dt) + a(n)*dt CAUTION! You MUST call the initialize if the state array is changed. The Verlet algorithm is not self-starting. The current state and a prior state must both be known to advance the solution. Since the prior state is not known for the initial conditions, a prior state is estimated when the initialize method is invoked. CAUTION! This implementation assumes that the state vector has 2*N + 1 variables. These 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

Version:
1.0
Author:
Wolfgang Christian

Constructor Summary
Verlet(ODE _ode)
          Constructs the VelocityVerlet ODESolver for a system of ordinary differential equations.
 
Method Summary
 double getStepSize()
          Gets the step size.
 void initialize(double _stepSize)
          Initializes the ODE solver.
 void setStepSize(double _stepSize)
          Sets the step size.
 double step()
          Steps (advances) the differential equations by the stepSize.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Verlet

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

Parameters:
_ode - the system of differential equations.
Method Detail

initialize

public void initialize(double _stepSize)
Initializes the ODE solver. Two temporary state arrays and one rate array are allocated. The number of differential equations is determined by invoking getState2().length on the ODE.

Specified by:
initialize in interface ODESolver
Parameters:
_stepSize -

step

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

Specified by:
step in interface ODESolver
Returns:
the step size

setStepSize

public void setStepSize(double _stepSize)
Sets the step size. The step size remains fixed in this algorithm. The prior state array is reinitialized.

Specified by:
setStepSize in interface ODESolver
Parameters:
_stepSize -

getStepSize

public double getStepSize()
Gets the step size. The stepsize is constant in this algorithm.

Specified by:
getStepSize in interface ODESolver
Returns:
the step size