org.opensourcephysics.numerics
Class Euler

java.lang.Object
  extended byorg.opensourcephysics.numerics.AbstractODESolver
      extended byorg.opensourcephysics.numerics.Euler
All Implemented Interfaces:
ODESolver

public class Euler
extends AbstractODESolver

Euler implements an Euler method ODE solver. The Euler method is unstable for many systems. It is included as an example of how to use the ODE and ODESolver interface.


Field Summary
protected  double[] rate
           
 
Fields inherited from class org.opensourcephysics.numerics.AbstractODESolver
numEqn, ode, stepSize
 
Constructor Summary
Euler(ODE ode)
          Constructs the Euler ODESolver for a system of ordinary differential equations.
 
Method Summary
 void initialize(double stepSize)
          Initializes the ODE solver and allocates the rate array.
 double step()
          Steps (advances) the differential equations by the stepSize.
 
Methods inherited from class org.opensourcephysics.numerics.AbstractODESolver
createODESolver, getStepSize, setStepSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rate

protected double[] rate
Constructor Detail

Euler

public Euler(ODE ode)
Constructs the Euler 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 and allocates the rate array. 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 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