Package com.imsl.math

Class OdeAdamsGear

java.lang.Object
com.imsl.math.ODE
com.imsl.math.OdeAdamsGear
All Implemented Interfaces:
Serializable, Cloneable

public class OdeAdamsGear extends ODE
Extension of the ODE class to solve a stiff initial-value problem for ordinary differential equations using the Adams-Gear methods.

Class OdeAdamsGear finds an approximation to the solution of a system of first-order differential equations of the form

$$ \frac{dy}{dt} = y' = f(t,y) $$

with given initial conditions for \(y\) at the starting value for \(t\). The class attempts to keep the global error proportional to a user-specified tolerance. The proportionality depends on the differential equation and the range of integration.

The code is based on using backward difference formulas not exceeding order five as outlined in Gear (1971) and implemented by Hindmarsh (1974). There is an optional use of the code that employs implicit Adams formulas. This use is intended for nonstiff problems with expensive functions \( y' = f(t,y) \).

See Also:
  • Field Details

    • METHOD_ADAMS

      public static final int METHOD_ADAMS
      The Adams integration method
      See Also:
    • METHOD_BDF

      public static final int METHOD_BDF
      The BDF integration method
      See Also:
    • SOLVE_FUNCTION_ITERATION

      public static final int SOLVE_FUNCTION_ITERATION
      A function iteration or successive substitution method
      See Also:
    • SOLVE_CHORD_USER_JACOBIAN

      public static final int SOLVE_CHORD_USER_JACOBIAN
      A chord or modified Newton method and a user-supplied Jacobian
      See Also:
    • SOLVE_CHORD_COMPUTED_JACOBIAN

      public static final int SOLVE_CHORD_COMPUTED_JACOBIAN
      A chord or modified Newton method and a divided differences Jacobian
      See Also:
    • SOLVE_CHORD_COMPUTED_DIAGONAL

      public static final int SOLVE_CHORD_COMPUTED_DIAGONAL
      A chord method and a diagonal matrix based on a directional directive
      See Also:
  • Constructor Details

    • OdeAdamsGear

      public OdeAdamsGear(OdeAdamsGear.Function function)
      Constructs an ODE solver to solve the initial value problem dy/dt = f(t,y)
      Parameters:
      function - implementation of interface Function that defines the right-hand side function \(f(t,y)\)
  • Method Details

    • setMaximumFunctionEvaluations

      public void setMaximumFunctionEvaluations(int maxfcn)
      Sets the maximum number of function evaluations of \(y'\) allowed.
      Parameters:
      maxfcn - an int specifying the maximum number of function evaluations of \(y'\) allowed. maxfcn must be greater than zero. Default: No limit is enforced.
    • setIntegrationMethod

      public void setIntegrationMethod(int intMethod)
      Indicates which integration method is to be used.
      Parameters:
      intMethod - an int specifying the integration method to be used. intMethod must be one of the values specified in the table which follows. Default: intMethod = METHOD_BDF

      intMethod Description
      METHOD_ADAMS Use the implicit Adams method.
      METHOD_BDF Use backward differentiation formula (BDF) methods.

    • setSolveMethod

      public void setSolveMethod(int solveMethod)
      Indicates which method to use for solving the formula equations.
      Parameters:
      solveMethod - an int specifying the method to be used for solving the formula equations. Note that if the problem is stiff and a chord or modified Newton method is most efficient, use SOLVE_CHORD_USER_JACOBIAN or SOLVE_CHORD_COMPUTED_JACOBIAN. solveMethod must be one of the values specified in the table which follows.
      Default: solveMethod = SOLVE_CHORD_COMPUTED_JACOBIAN.

      solveMethod Description
      SOLVE_FUNCTION_ITERATION Use a function iteration or successive substitution method.
      SOLVE_CHORD_USER_JACOBIAN Use a chord or modified Newton method and a user-supplied Jacobian.
      SOLVE_CHORD_COMPUTED_JACOBIAN Use a chord or modified Newton method and a divided differences Jacobian.
      SOLVE_CHORD_COMPUTED_DIAGONAL Use a chord method and a diagonal matrix based on a directional directive.

    • setMaxOrder

      public void setMaxOrder(int maxOrder)
      Sets the highest order formula to use of implicit METHOD_ADAMS type or METHOD_BDF type.
      Parameters:
      maxOrder - an int specifying the highest order formula to use of implicit METHOD_ADAMS type or METHOD_BDF type. maxOrder must be greater than zero. Default: maxOrder = 12 for METHOD_ADAMS and maxOrder = 5 for METHOD_BDF.
    • setMaximumStepsize

      public void setMaximumStepsize(double stepsize)
      Sets the maximum internal step size.
      Overrides:
      setMaximumStepsize in class ODE
      Parameters:
      stepsize - a double specifying the maximum internal step size. stepsize must be greater than zero. Default: stepsize = 1.7976931348623157e+308
    • getNumberOfSteps

      public int getNumberOfSteps()
      Returns the number of internal steps taken.
      Returns:
      an int specifying the number of internal steps taken.
    • getMaximumFunctionEvaluations

      public int getMaximumFunctionEvaluations()
      Returns the maximum number of function evaluations of \(y'\) allowed.
      Returns:
      an int specifying the maximum number of function evaluations of \(y'\) allowed.
    • getNumberOfFcnEvals

      public int getNumberOfFcnEvals()
      Returns the number of function evaluations of \(y'\) made.
      Returns:
      an int specifying the number of function evaluations of \(y'\) made.
    • getNumberOfJacobianEvals

      public int getNumberOfJacobianEvals()
      Returns the number of Jacobian matrix evaluations used.
      Returns:
      an int specifying the number of Jacobian matrix evaluations used.
    • getIntegrationMethod

      public int getIntegrationMethod()
      Returns the integration method used.
      Returns:
      an int indicating the integration method used. One of the following is returned:

      Value Description
      METHOD_ADAMS Use the implicit Adams method.
      METHOD_BDF Use backward differentiation formula (BDF) methods.

    • getSolveMethod

      public int getSolveMethod()
      Returns the method for solving the formula equations.
      Returns:
      an int indicating the method used for solving the formula equations. One of the following is returned:

      Value Description
      SOLVE_FUNCTION_ITERATION Use a function iteration or successive substitution method.
      SOLVE_CHORD_USER_JACOBIAN Use a chord or modified Newton method and a user-supplied Jacobian.
      SOLVE_CHORD_COMPUTED_JACOBIAN Use a chord or modified Newton method and a Jacobian approximated by divided differences.
      SOLVE_CHORD_COMPUTED_DIAGONAL Use a chord method and a diagonal matrix based on a directional directive.

    • getMaxOrder

      public int getMaxOrder()
      Returns the highest order formula to use of implicit METHOD_ADAMS type or METHOD_BDF type.
      Returns:
      an int specifying the highest order formula to use of implicit METHOD_ADAMS type or METHOD_BDF type.
    • solve

      Integrates the ODE system from t to tEnd. On all but the first call to solve, the value of t must equal the value of tEnd from the previous call.
      Parameters:
      t - a double specifying the independent variable
      tEnd - a double specifying the value of t at which the solution is desired
      y - on input, a double array containing the initial values. On output, a double array containing the approximate solution.
      Throws:
      OdeAdamsGear.DidNotConvergeException - is thrown if the number of internal steps exceeds maxSteps (default 500). This can be an indication that the ODE system is stiff. This exception can also be thrown if the error tolerance condition could not be met.
      OdeAdamsGear.ToleranceTooSmallException - is thrown if the computation does not converge on some step.
      OdeAdamsGear.MaxFcnEvalsExceededException - is thrown if the maximum number of function evaluations allowed has been exceeded.
      OdeAdamsGear.SingularMatrixException - is thrown if the factorization function encounters a singular matrix during LU decomposition.