Package org.opensourcephysics.numerics
Class EulerRichardson
java.lang.Object
org.opensourcephysics.numerics.AbstractODESolver
org.opensourcephysics.numerics.EulerRichardson
- All Implemented Interfaces:
ODESolver
An Euler-Richardson (midpoint) method ODE solver.
The Euler-Richardson method uses the state at the beginning of the interval
to estimate the state at the midpoint.
x(midpoint) = x(n) + v(n)*dt/2
v(midpoint) = v(n) + a(n)*dt/2
t(midpoint) = t(n) + dt/2
The midpoint state is then used to calculate the final state.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Field Summary
Fields inherited from class org.opensourcephysics.numerics.AbstractODESolver
numEqn, ode, stepSize
-
Constructor Summary
ConstructorsConstructorDescriptionEulerRichardson
(ODE ode) Constructs the EulerRichardson ODESolver for a system of ordinary differential equations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
initialize
(double stepSize) Initializes the ODE solver.double
step()
Steps (advances) the differential equations by the stepSize.Methods inherited from class org.opensourcephysics.numerics.AbstractODESolver
getStepSize, setStepSize
-
Constructor Details
-
EulerRichardson
Constructs the EulerRichardson ODESolver for a system of ordinary differential equations.- Parameters:
ode
- the system of differential equations.
-
-
Method Details
-
initialize
public void initialize(double stepSize) Initializes the ODE solver. The rate and midstate arrays are allocated. The number of differential equations is determined by invoking getState().length on the ODE.- 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 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
-