Package org.opensourcephysics.numerics
Class Ralston2
java.lang.Object
org.opensourcephysics.numerics.AbstractODESolver
org.opensourcephysics.numerics.Ralston2
- All Implemented Interfaces:
ODESolver
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
-
Field Summary
Fields inherited from class org.opensourcephysics.numerics.AbstractODESolver
numEqn, ode, stepSize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
-
Constructor Details
-
Ralston2
Constructor Ralston2- Parameters:
ode
-
-
-
Method Details
-
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 interfaceODESolver
- Overrides:
initialize
in classAbstractODESolver
- 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 interfaceODESolver
- Specified by:
step
in classAbstractODESolver
- Returns:
- the step size
-