org.opensourcephysics.numerics
Class Ralston2

java.lang.Object
  extended by org.opensourcephysics.numerics.AbstractODESolver
      extended by org.opensourcephysics.numerics.Ralston2
All Implemented Interfaces:
ODESolver

public class Ralston2
extends AbstractODESolver

Ralston2 implements Ralston's algorithm for solving ODEs by evaluating the rate at the initial state, estimating the rate for the final state, and using a weighted average of these two rates to advance the state.

Version:
1.0

Constructor Summary
Ralston2(ODE ode)
          Constructor Ralston2
 
Method Summary
 void initialize(double stepSize)
          Initializes the ODE solver and allocates the rate and state arrays.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ralston2

public Ralston2(ODE ode)
Constructor Ralston2

Parameters:
ode -
Method Detail

initialize

public void initialize(double stepSize)
Initializes the ODE solver and allocates the rate and state arrays. The number of differential equations is determined by invoking getState().length on the superclass.

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

step

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 then uses this state estimate the rate a intermediate points. Finally, 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
Returns:
the step size