Class DormandPrince45

java.lang.Object
org.opensourcephysics.numerics.DormandPrince45
All Implemented Interfaces:
ODEAdaptiveSolver, ODESolver
Direct Known Subclasses:
RK45

public class DormandPrince45 extends Object implements ODEAdaptiveSolver
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 Details

    • tol

      protected double tol
    • enableExceptions

      protected boolean enableExceptions
  • Constructor Details

    • DormandPrince45

      public DormandPrince45(ODE _ode)
      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 interface ODESolver
      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.
      Specified by:
      step in interface ODESolver
      Returns:
      the step size
    • 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 interface ODESolver
      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 interface ODESolver
      Returns:
      the step size
    • setTolerance

      public void setTolerance(double _tol)
      Method setTolerance
      Specified by:
      setTolerance in interface ODEAdaptiveSolver
      Parameters:
      _tol -
    • getTolerance

      public double getTolerance()
      Method getTolerance
      Specified by:
      getTolerance in interface ODEAdaptiveSolver
      Returns:
    • getErrorCode

      public int getErrorCode()
      Gets the error code. Error codes: ODEAdaptiveSolver.NO_ERROR ODEAdaptiveSolver.DID_NOT_CONVERGE
      Specified by:
      getErrorCode in interface ODEAdaptiveSolver
      Returns:
      int