org.opensourcephysics.numerics
Class AbstractODESolver

java.lang.Object
  extended by org.opensourcephysics.numerics.AbstractODESolver
All Implemented Interfaces:
ODESolver
Direct Known Subclasses:
Butcher5, Euler, EulerRichardson, Fehlberg8, Heun3, LeapFrog, Ralston2, RK4, Verlet

public abstract class AbstractODESolver
extends java.lang.Object
implements ODESolver

AbstractODE provides a common superclass for ODESolvers.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
protected  int numEqn
           
protected  ODE ode
           
protected  double stepSize
           
 
Constructor Summary
AbstractODESolver(ODE _ode)
          Constructs the 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.
abstract  double step()
          Steps (advances) the differential equations by the stepSize.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stepSize

protected double stepSize

numEqn

protected int numEqn

ode

protected ODE ode
Constructor Detail

AbstractODESolver

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

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

step

public abstract 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 at 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

Specified by:
setStepSize in interface ODESolver
Parameters:
_stepSize -

initialize

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