Class ODEMultistepSolver

java.lang.Object
org.opensourcephysics.numerics.ODEMultistepSolver
All Implemented Interfaces:
ODEAdaptiveSolver, ODESolver

public class ODEMultistepSolver extends Object implements ODEAdaptiveSolver
ODEMultistepSolver performs multiple ODE steps so that a uniform step size is maintained.
Version:
1.0
Author:
Wolfgang Christian
  • Field Details

    • err_code

      protected int err_code
    • maxIterations

      protected int maxIterations
    • enableExceptions

      protected boolean enableExceptions
    • err_msg

      protected String err_msg
    • odeEngine

      protected ODEAdaptiveSolver odeEngine
    • fixedStepSize

      protected double fixedStepSize
    • internalODE

      protected ODEMultistepSolver.InternalODE internalODE
  • Constructor Details

    • ODEMultistepSolver

      public ODEMultistepSolver(ODE ode)
      Constructs an ODEMultiStep ODE solver for a system of ordinary differential equations. The default ODESolver is DormandPrince45. Other solvers can be selected using factory methods.
      Parameters:
      ode -
    • ODEMultistepSolver

      protected ODEMultistepSolver()
      Constructs a ODEMultistepSolver without an ODE so that a factory method can create a custom solver.
  • Method Details

    • setODE

      protected ODEMultistepSolver.InternalODE setODE(ODE ode)
      Sets the ODE for this solver.
      Parameters:
      ode - ODE
      Returns:
      MyODE
    • MultistepRK45

      public static ODEAdaptiveSolver MultistepRK45(ODE ode)
      A factory method that creates a multisetp solver using the RK45 engine.
      Parameters:
      ode - ODE
      Returns:
      ODESolver
    • enableRuntimeExpecptions

      public void enableRuntimeExpecptions(boolean enable)
      Enables runtime exceptions if the solver does not converge.
      Parameters:
      enable - boolean
    • setMaxIterations

      public void setMaxIterations(int n)
      Sets the maximum number of iterations.
      Parameters:
      n - maximum
    • setTolerance

      public void setTolerance(double tol)
      Sets the tolerance of the adaptive ODE solver.
      Specified by:
      setTolerance in interface ODEAdaptiveSolver
      Parameters:
      tol - the tolerance
    • getTolerance

      public double getTolerance()
      Gets the tolerance of the adaptive ODE solver.
      Specified by:
      getTolerance in interface ODEAdaptiveSolver
      Returns:
    • getErrorCode

      public int getErrorCode()
      Gets the error code. Error codes: ODEAdaptiveSolver.NO_ERROR ODEAdaptiveSolver.DID_NOT_CONVERGE ODEAdaptiveSolver.BISECTION_EVENT_NOT_FOUND=2;
      Specified by:
      getErrorCode in interface ODEAdaptiveSolver
      Returns:
      int
    • 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 if desired tolerance was reached.
      Specified by:
      step in interface ODESolver
      Returns:
      the actual step
    • initialize

      public void initialize(double stepSize)
      Initializes the ODE solver. Temporary arrays may be allocated within the ODE solver.
      Specified by:
      initialize in interface ODESolver
      Parameters:
      stepSize -
    • setStepSize

      public void setStepSize(double stepSize)
      Sets the fixed step size. Multi-step solvers will perform one or more internal steps in order to perform a step with the given size.
      Specified by:
      setStepSize in interface ODESolver
      Parameters:
      stepSize -
    • setMaximumNumberOfErrorMessages

      public void setMaximumNumberOfErrorMessages(int n)
      Sets the number of error messages if ODE solver did not converge.
      Parameters:
      n - int
    • getStepSize

      public double getStepSize()
      Gets the step size. The step size is the fixed step size, not the size of the ODEAdaptiveSolver steps that are combined into a single step.
      Specified by:
      getStepSize in interface ODESolver
      Returns:
      the step size