Package com.imsl.math
Class OdeAdamsGear
java.lang.Object
com.imsl.math.ODE
com.imsl.math.OdeAdamsGear
- All Implemented Interfaces:
Serializable,Cloneable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe iteration did not converge within the maximum number of steps allowed (default 500).static interfacePublic interface for user supplied function toOdeAdamsGearobject.static interfacePublic interface for the user supplied function to evaluate the Jacobian matrix.static classMaximum function evaluations exceeded.static classThe interpolation matrix is singular.static classTolerance is too small or the problem is stiff. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe Adams integration methodstatic final intThe BDF integration methodstatic final intA chord method and a diagonal matrix based on a directional directivestatic final intA chord or modified Newton method and a divided differences Jacobianstatic final intA chord or modified Newton method and a user-supplied Jacobianstatic final intA function iteration or successive substitution methodFields inherited from class com.imsl.math.ODE
AFTER_SUCCESSFUL_STEP, AFTER_UNSUCCESSFUL_STEP, BEFORE_STEP, ERROR_NORM_ABS, ERROR_NORM_EUCLIDEAN, ERROR_NORM_MAX, ERROR_NORM_MINABSREL -
Constructor Summary
ConstructorsConstructorDescriptionOdeAdamsGear(OdeAdamsGear.Function function) Constructs an ODE solver to solve the initial value problem dy/dt = f(t,y) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the integration method used.intReturns the maximum number of function evaluations of \(y'\) allowed.intReturns the highest order formula to use of implicitMETHOD_ADAMStype orMETHOD_BDFtype.intReturns the number of function evaluations of \(y'\) made.intReturns the number of Jacobian matrix evaluations used.intReturns the number of internal steps taken.intReturns the method for solving the formula equations.voidsetIntegrationMethod(int intMethod) Indicates which integration method is to be used.voidsetMaximumFunctionEvaluations(int maxfcn) Sets the maximum number of function evaluations of \(y'\) allowed.voidsetMaximumStepsize(double stepsize) Sets the maximum internal step size.voidsetMaxOrder(int maxOrder) Sets the highest order formula to use of implicitMETHOD_ADAMStype orMETHOD_BDFtype.voidsetSolveMethod(int solveMethod) Indicates which method to use for solving the formula equations.voidsolve(double t, double tEnd, double[] y) Integrates the ODE system fromttotEnd.Methods inherited from class com.imsl.math.ODE
examineStep, getFloor, getInitialStepsize, getMaximumStepsize, getMaxSteps, getMinimumStepsize, getNorm, getScale, getTolerance, setFloor, setInitialStepsize, setMaxSteps, setMinimumStepsize, setNorm, setScale, setTolerance, vnorm
-
Field Details
-
METHOD_ADAMS
public static final int METHOD_ADAMSThe Adams integration method- See Also:
-
METHOD_BDF
public static final int METHOD_BDFThe BDF integration method- See Also:
-
SOLVE_FUNCTION_ITERATION
public static final int SOLVE_FUNCTION_ITERATIONA function iteration or successive substitution method- See Also:
-
SOLVE_CHORD_USER_JACOBIAN
public static final int SOLVE_CHORD_USER_JACOBIANA chord or modified Newton method and a user-supplied Jacobian- See Also:
-
SOLVE_CHORD_COMPUTED_JACOBIAN
public static final int SOLVE_CHORD_COMPUTED_JACOBIANA chord or modified Newton method and a divided differences Jacobian- See Also:
-
SOLVE_CHORD_COMPUTED_DIAGONAL
public static final int SOLVE_CHORD_COMPUTED_DIAGONALA chord method and a diagonal matrix based on a directional directive- See Also:
-
-
Constructor Details
-
OdeAdamsGear
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- anintspecifying the maximum number of function evaluations of \(y'\) allowed.maxfcnmust 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- anintspecifying the integration method to be used.intMethodmust be one of the values specified in the table which follows. Default:intMethod=METHOD_BDFintMethod Description METHOD_ADAMSUse the implicit Adams method. METHOD_BDFUse backward differentiation formula (BDF) methods.
-
setSolveMethod
public void setSolveMethod(int solveMethod) Indicates which method to use for solving the formula equations.- Parameters:
solveMethod- anintspecifying 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, useSOLVE_CHORD_USER_JACOBIANorSOLVE_CHORD_COMPUTED_JACOBIAN.solveMethodmust be one of the values specified in the table which follows.
Default:solveMethod=SOLVE_CHORD_COMPUTED_JACOBIAN.solveMethod Description SOLVE_FUNCTION_ITERATIONUse a function iteration or successive substitution method. SOLVE_CHORD_USER_JACOBIANUse a chord or modified Newton method and a user-supplied Jacobian. SOLVE_CHORD_COMPUTED_JACOBIANUse a chord or modified Newton method and a divided differences Jacobian. SOLVE_CHORD_COMPUTED_DIAGONALUse 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 implicitMETHOD_ADAMStype orMETHOD_BDFtype.- Parameters:
maxOrder- anintspecifying the highest order formula to use of implicitMETHOD_ADAMStype orMETHOD_BDFtype.maxOrdermust be greater than zero. Default:maxOrder= 12 forMETHOD_ADAMSandmaxOrder= 5 forMETHOD_BDF.
-
setMaximumStepsize
public void setMaximumStepsize(double stepsize) Sets the maximum internal step size.- Overrides:
setMaximumStepsizein classODE- Parameters:
stepsize- adoublespecifying the maximum internal step size.stepsizemust be greater than zero. Default:stepsize= 1.7976931348623157e+308
-
getNumberOfSteps
public int getNumberOfSteps()Returns the number of internal steps taken.- Returns:
- an
intspecifying the number of internal steps taken.
-
getMaximumFunctionEvaluations
public int getMaximumFunctionEvaluations()Returns the maximum number of function evaluations of \(y'\) allowed.- Returns:
- an
intspecifying the maximum number of function evaluations of \(y'\) allowed.
-
getNumberOfFcnEvals
public int getNumberOfFcnEvals()Returns the number of function evaluations of \(y'\) made.- Returns:
- an
intspecifying the number of function evaluations of \(y'\) made.
-
getNumberOfJacobianEvals
public int getNumberOfJacobianEvals()Returns the number of Jacobian matrix evaluations used.- Returns:
- an
intspecifying the number of Jacobian matrix evaluations used.
-
getIntegrationMethod
public int getIntegrationMethod()Returns the integration method used.- Returns:
- an
intindicating the integration method used. One of the following is returned:Value Description METHOD_ADAMSUse the implicit Adams method. METHOD_BDFUse backward differentiation formula (BDF) methods.
-
getSolveMethod
public int getSolveMethod()Returns the method for solving the formula equations.- Returns:
- an
intindicating the method used for solving the formula equations. One of the following is returned:Value Description SOLVE_FUNCTION_ITERATIONUse a function iteration or successive substitution method. SOLVE_CHORD_USER_JACOBIANUse a chord or modified Newton method and a user-supplied Jacobian. SOLVE_CHORD_COMPUTED_JACOBIANUse a chord or modified Newton method and a Jacobian approximated by divided differences. SOLVE_CHORD_COMPUTED_DIAGONALUse a chord method and a diagonal matrix based on a directional directive.
-
getMaxOrder
public int getMaxOrder()Returns the highest order formula to use of implicitMETHOD_ADAMStype orMETHOD_BDFtype.- Returns:
- an
intspecifying the highest order formula to use of implicitMETHOD_ADAMStype orMETHOD_BDFtype.
-
solve
public void solve(double t, double tEnd, double[] y) throws OdeAdamsGear.DidNotConvergeException, OdeAdamsGear.MaxFcnEvalsExceededException, OdeAdamsGear.ToleranceTooSmallException, OdeAdamsGear.SingularMatrixException Integrates the ODE system fromttotEnd. On all but the first call tosolve, the value oftmust equal the value oftEndfrom the previous call.- Parameters:
t- adoublespecifying the independent variabletEnd- adoublespecifying the value oftat which the solution is desiredy- on input, adoublearray containing the initial values. On output, adoublearray 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.
-