Package org.opensourcephysics.numerics
Class DormandPrince45
java.lang.Object
org.opensourcephysics.numerics.DormandPrince45
- All Implemented Interfaces:
ODEAdaptiveSolver
,ODESolver
- Direct Known Subclasses:
RK45
DormandPrince45 implements a RKF 4/5 ODE solver with variable step size using Dormand-Prince coefficients.
- Version:
- 1.0
- Author:
- W. Christian, F. Esquembre
-
Field Summary
FieldsFields inherited from interface org.opensourcephysics.numerics.ODEAdaptiveSolver
BISECTION_EVENT_NOT_FOUND, DID_NOT_CONVERGE, NO_ERROR
-
Constructor Summary
ConstructorsConstructorDescriptionDormandPrince45
(ODE _ode) Constructs the DormandPrince45 ODESolver for a system of ordinary differential equations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
enableRuntimeExpecptions
(boolean enable) Enables runtime exceptions if the solver does not converge.int
Gets the error code.double
Gets the step size.double
Method getTolerancevoid
initialize
(double _stepSize) Initializes the ODE solver.void
setStepSize
(double stepSize) Sets the step size.void
setTolerance
(double _tol) Method setTolerancedouble
step()
Steps (advances) the differential equations by the stepSize.
-
Field Details
-
tol
protected double tol -
enableExceptions
protected boolean enableExceptions
-
-
Constructor Details
-
DormandPrince45
Constructs the DormandPrince45 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. Temporary state and rate arrays are allocated. The number of differential equations is determined by invoking getState().length on the ODE.- Specified by:
initialize
in interfaceODESolver
- Parameters:
_stepSize
-
-
step
public double step()Steps (advances) the differential equations by the stepSize. The ODESolver invokes the ODE's getRate 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. -
enableRuntimeExpecptions
public void enableRuntimeExpecptions(boolean enable) Enables runtime exceptions if the solver does not converge.- Parameters:
enable
- boolean
-
setStepSize
public void setStepSize(double stepSize) Sets the step size. The step size may change when the step method is invoked.- Specified by:
setStepSize
in interfaceODESolver
- Parameters:
stepSize
-
-
getStepSize
public double getStepSize()Gets the step size. The stepsize is adaptive and may change as the step() method is invoked.- Specified by:
getStepSize
in interfaceODESolver
- Returns:
- the step size
-
setTolerance
public void setTolerance(double _tol) Method setTolerance- Specified by:
setTolerance
in interfaceODEAdaptiveSolver
- Parameters:
_tol
-
-
getTolerance
public double getTolerance()Method getTolerance- Specified by:
getTolerance
in interfaceODEAdaptiveSolver
- Returns:
-
getErrorCode
public int getErrorCode()Gets the error code. Error codes: ODEAdaptiveSolver.NO_ERROR ODEAdaptiveSolver.DID_NOT_CONVERGE- Specified by:
getErrorCode
in interfaceODEAdaptiveSolver
- Returns:
- int
-