public class OdeAdamsGear extends ODE
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) \).| Modifier and Type | Class and Description |
|---|---|
static class |
OdeAdamsGear.DidNotConvergeException
The iteration did not converge within the maximum number of steps allowed (default 500).
|
static interface |
OdeAdamsGear.Function
Public interface for user supplied function to
OdeAdamsGear object. |
static interface |
OdeAdamsGear.Jacobian
Public interface for the user supplied function to
evaluate the Jacobian matrix.
|
static class |
OdeAdamsGear.MaxFcnEvalsExceededException
Maximum function evaluations exceeded.
|
static class |
OdeAdamsGear.SingularMatrixException
The interpolation matrix is singular.
|
static class |
OdeAdamsGear.ToleranceTooSmallException
Tolerance is too small or the problem is stiff.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
METHOD_ADAMS
The Adams integration method
|
static int |
METHOD_BDF
The BDF integration method
|
static int |
SOLVE_CHORD_COMPUTED_DIAGONAL
A chord method and a diagonal matrix based on a directional directive
|
static int |
SOLVE_CHORD_COMPUTED_JACOBIAN
A chord or modified Newton method and a divided differences Jacobian
|
static int |
SOLVE_CHORD_USER_JACOBIAN
A chord or modified Newton method and a user-supplied Jacobian
|
static int |
SOLVE_FUNCTION_ITERATION
A function iteration or successive substitution method
|
AFTER_SUCCESSFUL_STEP, AFTER_UNSUCCESSFUL_STEP, BEFORE_STEP, ERROR_NORM_ABS, ERROR_NORM_EUCLIDEAN, ERROR_NORM_MAX, ERROR_NORM_MINABSREL| Constructor and Description |
|---|
OdeAdamsGear(OdeAdamsGear.Function function)
Constructs an ODE solver to solve the initial value
problem dy/dt = f(t,y)
|
| Modifier and Type | Method and Description |
|---|---|
int |
getIntegrationMethod()
Returns the integration method used.
|
int |
getMaximumFunctionEvaluations()
Returns the maximum number of function evaluations of \(y'\) allowed.
|
int |
getMaxOrder()
Returns the highest order formula to use of implicit
METHOD_ADAMS type or METHOD_BDF type. |
int |
getNumberOfFcnEvals()
Returns the number of function evaluations of \(y'\) made.
|
int |
getNumberOfJacobianEvals()
Returns the number of Jacobian matrix evaluations used.
|
int |
getNumberOfSteps()
Returns the number of internal steps taken.
|
int |
getSolveMethod()
Returns the method for solving the formula equations.
|
void |
setIntegrationMethod(int intMethod)
Indicates which integration method is to be used.
|
void |
setMaximumFunctionEvaluations(int maxfcn)
Sets the maximum number of function evaluations of \(y'\) allowed.
|
void |
setMaximumStepsize(double stepsize)
Sets the maximum internal step size.
|
void |
setMaxOrder(int maxOrder)
Sets the highest order formula to use of implicit
METHOD_ADAMS type or METHOD_BDF type. |
void |
setSolveMethod(int solveMethod)
Indicates which method to use for solving the formula equations.
|
void |
solve(double t,
double tEnd,
double[] y)
Integrates the ODE system from
t to tEnd. |
examineStep, getFloor, getInitialStepsize, getMaximumStepsize, getMaxSteps, getMinimumStepsize, getNorm, getScale, getTolerance, setFloor, setInitialStepsize, setMaxSteps, setMinimumStepsize, setNorm, setScale, setTolerance, vnormpublic static final int METHOD_ADAMS
public static final int METHOD_BDF
public static final int SOLVE_FUNCTION_ITERATION
public static final int SOLVE_CHORD_USER_JACOBIAN
public static final int SOLVE_CHORD_COMPUTED_JACOBIAN
public static final int SOLVE_CHORD_COMPUTED_DIAGONAL
public OdeAdamsGear(OdeAdamsGear.Function function)
function - implementation of interface Function
that defines the right-hand side function
\(f(t,y)\)public void setMaximumFunctionEvaluations(int maxfcn)
maxfcn - an int specifying the maximum number of function
evaluations of \(y'\) allowed.
maxfcn must be greater than zero.
Default: No limit is enforced.public void setIntegrationMethod(int intMethod)
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. |
public void setSolveMethod(int solveMethod)
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.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. |
public void setMaxOrder(int maxOrder)
METHOD_ADAMS type or METHOD_BDF type.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.public void setMaximumStepsize(double stepsize)
setMaximumStepsize in class ODEstepsize - a double specifying the maximum internal step size. stepsize must be
greater than zero.
Default: stepsize = 1.7976931348623157e+308public int getNumberOfSteps()
int specifying the number of internal
steps taken.public int getMaximumFunctionEvaluations()
int specifying the maximum number of function
evaluations of \(y'\) allowed.public int getNumberOfFcnEvals()
int specifying the number of function
evaluations of \(y'\) made.public int getNumberOfJacobianEvals()
int specifying the number of Jacobian matrix
evaluations used.public int getIntegrationMethod()
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. |
public int getSolveMethod()
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. |
public int getMaxOrder()
METHOD_ADAMS type or METHOD_BDF type.int specifying the highest order formula
to use of implicit METHOD_ADAMS type or METHOD_BDF type.public void solve(double t,
double tEnd,
double[] y)
throws OdeAdamsGear.DidNotConvergeException,
OdeAdamsGear.MaxFcnEvalsExceededException,
OdeAdamsGear.ToleranceTooSmallException,
OdeAdamsGear.SingularMatrixException
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.t - a double specifying the independent variabletEnd - a double specifying the value of t at which the
solution is desiredy - on input, a double array containing the initial values.
On output, a double array containing the approximate solution.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.SingularMatrixException - is thrown if the factorization function
encounters a singular matrix during LU
decomposition.OdeAdamsGear.SingularMatrixExceptionCopyright © 2020 Rogue Wave Software. All rights reserved.