Package org.opensourcephysics.numerics
Class Heun3
java.lang.Object
org.opensourcephysics.numerics.AbstractODESolver
org.opensourcephysics.numerics.Heun3
- All Implemented Interfaces:
ODESolver
Heun3 implements Heun's third order algorithm for solving ODEs by evaluating the rate at the initial state,
and two intermediate states. It then uses a weighted average to advance the state.
Heun's method is known as a predictor-corrector method because it first predicts the state (estimated_state) and
then corrects the rate based on the prediction.
- 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
-
Heun3
Constructor Heun3- 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
-