naginterfaces.library.ode.ivp_​stiff_​imp_​revcom

naginterfaces.library.ode.ivp_stiff_imp_revcom(t, tout, y, ydot, comm, rtol, atol, itol, wkjac, imon, inln, ires, irevcm, lderiv, itask, itrace, io_manager=None)[source]

ivp_stiff_imp_revcom is a reverse communication function for integrating stiff systems of implicit ordinary differential equations coupled with algebraic equations.

For full information please refer to the NAG Library document for d02nn

https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/d02/d02nnf.html

Parameters
tfloat

On initial entry: , the value of the independent variable. The input value of is used only on the first call as the initial point of the integration.

toutfloat

On initial entry: the next value of at which a computed solution is desired. For the initial , the input value of is used to determine the direction of integration. Integration is permitted in either direction (see also ).

yfloat, ndarray, shape , modified in place

On initial entry: the values of the dependent variables (solution). On the first call the first elements of must contain the vector of initial values.

On final exit: the computed solution vector evaluated at (usually ).

ydotfloat, ndarray, shape , modified in place

On initial entry: if , must contain approximations to the time derivatives of the vector . If , need not be set on entry.

On final exit: contains the time derivatives of the vector at the last integration point.

commdict, communication object, modified in place

Communication structure.

This argument must have been initialized by prior calls to one of ivp_stiff_fulljac_setup(), ivp_stiff_bandjac_setup() or ivp_stiff_sparjac_setup() and one of ivp_stiff_dassl(), ivp_stiff_bdf() or ivp_stiff_blend().

rtolfloat, array-like, shape

Note: the required length for this argument is determined as follows: if : ; otherwise: .

On initial entry: the relative local error tolerance.

atolfloat, array-like, shape

Note: the required length for this argument is determined as follows: if : ; otherwise: .

On initial entry: the absolute local error tolerance.

itolint

On initial entry: a value to indicate the form of the local error test. indicates to ivp_stiff_imp_revcom whether to interpret either or both of or as a vector or a scalar. The error test to be satisfied is , where is defined as follows:

1

scalar

scalar

2

scalar

vector

3

vector

scalar

4

vector

vector

is an estimate of the local error in , computed internally, and the choice of norm to be used is defined by a previous call to an integrator setup function.

wkjacfloat, ndarray, shape , modified in place

On intermediate entry: elements of the Jacobian as defined under the description of . If a numerical Jacobian was requested then is used for workspace.

On intermediate exit: the Jacobian is overwritten.

imonint

On intermediate entry: may be reset to determine subsequent action in ivp_stiff_imp_revcom.

Integration is to be halted. A return will be made from ivp_stiff_imp_revcom to the calling (sub)program with = 12.

Allow ivp_stiff_imp_revcom to continue with its own internal strategy. The integrator will try up to three restarts unless .

Return to the internal nonlinear equation solver, where the action taken is determined by the value of .

Normal exit to ivp_stiff_imp_revcom to continue integration.

Restart the integration at the current time point. The integrator will restart from order when this option is used. The internal initialization module solves for new values of and by using the values supplied in and by the operation (see Notes) as initial estimates.

Try to continue with the same step size and order as was to be used before entering the operation (see Notes). and may be altered if desired.

Continue the integration but using a new value of and possibly new values of and .

inlnint

On intermediate entry: with and , specifies the action to be taken by the internal nonlinear equation solver. By setting and returning to ivp_stiff_imp_revcom, the residual vector is evaluated and placed in , for and then the operation (see Notes) is invoked again. At present this is the only option available: must not be set to any other value.

iresint

On intermediate entry: should be unchanged unless one of the following actions is required of ivp_stiff_imp_revcom in which case should be set accordingly.

Indicates to ivp_stiff_imp_revcom that control should be passed back immediately to the calling (sub)program with the error indicator set to = 11.

Indicates to ivp_stiff_imp_revcom that an error condition has occurred in the solution vector, its time derivative or in the value of . The integrator will use a smaller time step to try to avoid this condition. If this is not possible ivp_stiff_imp_revcom returns to the calling (sub)program with the error indicator set to = 7.

Indicates to ivp_stiff_imp_revcom to stop its current operation and to enter the operation (see Notes) immediately.

irevcmint

On initial entry: must contain .

On intermediate entry: should remain unchanged.

lderivbool, ndarray, shape , modified in place

On initial entry: must be set to if you have supplied both an initial and an initial . must be set to if only the initial has been supplied.

must be set to if the integrator is to use a modified Newton method to evaluate the initial and .

Note that and , if supplied, are used as initial estimates.

This method involves taking a small step at the start of the integration, and if on entry, and will be set to the result of taking this small step. must be set to if the integrator is to use functional iteration to evaluate the initial and , and if this fails a modified Newton method will then be attempted. is recommended if there are implicit equations or the initial and are zero.

On final exit: is normally unchanged. However if and internal initialization was successful then .

, if implicit equations were detected.

Otherwise .

itaskint

On initial entry: the task to be performed by the integrator.

Normal computation of output values of at (by overshooting and interpolating).

Take one step only and return.

Stop at the first internal integration point at or beyond and return.

Normal computation of output values of at but without overshooting . must be specified as an option in one of the integrator setup functions before the first call to the integrator, or specified in the optional input function before a continuation call. (e.g., see ivp_stiff_bdf()) may be equal to or beyond , but not before it in the direction of integration.

Take one step only and return, without passing (e.g., see ivp_stiff_bdf()). must be specified under .

The integrator will solve for the initial values of and only and then return to the calling (sub)program without doing the integration. This option can be used to check the initial values of and . Functional iteration or a ‘small’ backward Euler method used in conjunction with a damped Newton iteration is used to calculate these values (see ). Note that if a backward Euler step is used then the value of will have been advanced a short distance from the initial point.

Note: if ivp_stiff_imp_revcom is recalled with a different value of (and altered) then the initialization procedure is repeated, possibly leading to different initial conditions.

itraceint

On initial entry: the level of output that is printed by the integrator. may take the value , , , or .

is assumed and similarly if , is assumed.

No output is generated.

Only warning messages are printed on the current error message unit (see FileObjManager).

Warning messages are printed as above, and on the file object associated with the advisory I/O unit (see FileObjManager) output is generated which details Jacobian entries, the nonlinear iteration and the time integration. The advisory messages are given in greater detail the larger the value of .

io_managerFileObjManager, optional

Manager for I/O in this routine.

Returns
tfloat

On final exit: the value at which the computed solution is returned (usually at ).

toutfloat

Is unaltered unless and on entry (see also and ) in which case will be set to the result of taking a small step at the start of the integration.

imonint

On intermediate exit: used to pass information between ivp_stiff_imp_revcom and the operation (see Notes). With , contains a flag indicating under what circumstances the return from ivp_stiff_imp_revcom occurred:

Exit from ivp_stiff_imp_revcom after (set in the operation (see Notes) caused an early termination (this facility could be used to locate discontinuities).

The current step failed repeatedly.

Exit from ivp_stiff_imp_revcom after a call to the internal nonlinear equation solver.

The current step was successful.

inlnint

On intermediate exit: contains a flag indicating the action to be taken, if any, by the internal nonlinear equation solver.

iresint

On intermediate exit: with , , , , , , or , specifies the form of the residual to be returned by the operation (see Notes).

If , must be returned.

If , must be returned.

irevcmint

On intermediate exit: indicates what action you must take before re-entering ivp_stiff_imp_revcom. The possible exit values of are , , , , , , , , , or which should be interpreted as follows:

, , , , , , or

Indicates that a operation (see Notes) is required: you must supply the residual of the system. For each of these values of , is located in , for .

For , , or , is located in and should be stored in , for .

For , is located in and should be stored in , for .

For or , is located in and should be stored in , for .

For , is located in and should be stored in , for .

Indicates that a operation (see Notes) is required: you must supply the Jacobian matrix.

If full matrix linear algebra is being used, the th element of the Jacobian must be stored in .

If banded matrix linear algebra is being used, the th element of the Jacobian must be stored in , where and ; here and are the number of subdiagonals and superdiagonals, respectively, in the band.

If sparse matrix linear algebra is being used, ivp_stiff_sparjac_enq() must be called to determine which column of the Jacobian is required and where it should be stored.

Indicates that a operation (see Notes) can be performed.

Indicates that the current step was not successful, due to error test failure or convergence test failure. The only information supplied to you on this return is the current value of the variable , located in . No values must be changed before re-entering ivp_stiff_imp_revcom; this facility enables you to determine the number of unsuccessful steps.

On final exit: indicating that the user-specified task has been completed or an error has been encountered (see the descriptions for and ).

Raises
NagValueError
(errno )

On entry, and for all elements.

Check the evaluation of the residual for this value of .

(errno )

On re-entry, has been set to an illegal value during initialization.

at time .

(errno )

On re-entry, .

Constraint: .

(errno )

Failure during internal time interpolation. and the current time are too close.

and and the current time is .

(errno )

On entry, or and is before the current time in the direction of integration.

, and the current time is .

(errno )

and is more than an integration step behind the current time.

, current time minus step size: .

(errno )

The initial stepsize, , is too small.

(errno )

Weight number used in the local error test is too small. Check the values of and .

and may both be zero.

Weight .

(errno )

On entry, or and is before in the direction of integration.

, and .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

Either the value of is not the same as the value supplied to the setup function or a communication array has become corrupted.

, (setup) .

(errno )

Either the value of is not the same as the value supplied to the setup function or a communication array has become corrupted.

, (setup) .

(errno )

On entry, an illegal (negative) minimum stepsize was provided in a prior call to a setup function. .

(errno )

On entry, is less than with respect to the direction of integration given by the sign of in a prior call to a setup function.

, and .

(errno )

On entry, an illegal (negative) maximum number of steps was provided in a prior call to a setup function. .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

Either the function was entered on a continuation call without a prior call of this function, or a communication array has become corrupted.

(errno )

On entry, is too close to to start integration.

and .

(errno )

On entry, .

Constraint: .

(errno )

Either the integrator setup function has not been called prior to the first call of this function, or a communication array has become corrupted.

(errno )

On entry, an illegal (negative) maximum stepsize was provided in a prior call to a setup function. .

(errno )

Either the linear algebra setup function has not been called prior to the first call of this function, or a communication array has become corrupted.

(errno )

On re-entry, for the case and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On re-entry, the solution vector appears to have been overwritten.

Further integration will not be attempted.

(errno )

At time the maximum number of allowed steps on this call was taken before reaching the next output point .

Maximum number of steps .

(errno )

On re-entry, which signals that an error condition has occurred in the solution vector, its time derivative or in the value of . It was not possible to remove this condition.

at .

(errno )

Attempt was made to reduce the step size to a value less than the minimum step size during the calculation of initial values.

Minimum stepsize: .

(errno )

The user problem has one or more inconsistencies between the and parts. Integration will not be attempted.

(errno )

The residual function returned an error when calculating the initial values of the solution and its time derivative.

(errno )

Workspace error occurred when trying to form the Jacobian matrix in calculating the initial values of the solution and its time derivative.

(errno )

A singular Jacobian has been encountered. You should check the problem formulation and Jacobian calculation.

(errno )

Workspace error occurred when trying to form the Jacobian matrix in calculating the initial values of the solution and its time derivative.

(errno )

Not enough integer store provided for sparse matrix solver.

Units of store needed: . Amount provided: .

(errno )

Larger integer workspace required.

Provided: ; required: .

(errno )

Not enough real store provided for sparse matrix solver.

Units of store needed: . Amount provided: .

(errno )

On entry, too much accuracy requested for precision of the machine at the start of problem. The tolerances should be checked; the requested accuracy should be reduced by a factor of at least .

Warns
NagAlgorithmicWarning
(errno )

Too much accuracy requested for precision of the machine at time .

The tolerances should be checked; the requested accuracy should be reduced by a factor of at least .

(errno )

There were repeated error-test failures on an attempted step, before completing the requested task, but the integration was successful as far as . The problem may have a singularity, or the local error requirements may be inappropriate.

(errno )

Nonlinear solver failed to converge using a damped Newton method to solve for initial values.

Damping factor: ; convergence rate: .

(errno )

At time , error weight became zero. Check the values of , and supplied.

(errno )

On re-entry, , which signals that the integration should terminate. at time .

(errno )

A return was forced by setting , but the integration was successful as far as .

(errno )

The requested task has been completed, but it is estimated that a small change in and is unlikely to produce any change in the computed solution. (This ONLY applies when you are NOT operating in one step mode; that is, when or .)

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

ivp_stiff_imp_revcom is a general purpose function for integrating the initial value problem for a stiff system of implicit ordinary differential equations coupled with algebraic equations, written in the form

An outline of a typical calling program is

call the linear algebra setup routine

call the integrator setup routine

set

start looping

call ivp_stiff_imp_revcom

if then

supply the Jacobian matrix

else if then

perform monitoring tasks requested by the user

else if then

indicates an unsuccessful step

else if then

evaluate the residual

else

stop looping

post processing; optional linear algebra diagnostic call (sparse case only), optional integrator diagnostic call

There are three major operations that may be required of the calling function on an intermediate return () from ivp_stiff_imp_revcom; these are denoted (i), (ii) and (iii).

The following sections describe in greater detail exactly what is required of each of these operations.

  1. Supply the Jacobian matrix

    You need only provide this facility if the argument (or if using sparse matrix linear algebra) in a call to the linear algebra setup function (see in ivp_stiff_sparjac_setup()). If the Jacobian matrix is to be evaluated numerically by the integrator, then the remainder of section (i) can be ignored.

    We must define the system of nonlinear equations which is solved internally by the integrator. The time derivative, , has the form

    where is the current step size and is an argument that depends on the integration method in use. The vector is the current solution and the vector depends on information from previous time steps. This means that .

    The system of nonlinear equations that is solved has the form

    but is solved in the form

    where is the function defined by

    It is the Jacobian matrix that you must supply as follows:

    where , and are located in , and respectively and the arrays and contain the current solution and time derivatives respectively. Only the nonzero elements of the Jacobian need be set, since the locations where it is to be stored are preset to zero.

    In this document this operation is referred to as JAC.

  2. Perform tasks requested by you

    This operation is essentially a monitoring function and additionally provides the opportunity of changing the current values of , , (the step size that the integrator proposes to take on the next step), (the minimum step size to be taken on the next step), and (the maximum step size to be taken on the next step). The scaled local error at the end of a time step may be obtained by calling ivp_stiff_errest().

    The following gives details of the location within the array [‘rwork’] of variables that may be of interest to you:

    Variable

    Specification

    Location

    the current value of the independent variable

    last step size successfully used by the integrator

    step size that the integrator proposes to take on the next step

    minimum step size to be taken on the next step

    maximum step size to be taken on the next step

    the order of the integrator used on the last step

    You are advised to consult the description of in ivp_stiff_imp_fulljac() for details on what optional input can be made.

    If either or are changed, then must be set to before return to ivp_stiff_imp_revcom. If either of the values or are changed, then must be set before return to ivp_stiff_imp_revcom. If is changed, then must be set to before return to ivp_stiff_imp_revcom.

    In addition you can force ivp_stiff_imp_revcom to evaluate the residual vector

    by setting and and then returning to ivp_stiff_imp_revcom; on return to this monitoring operation the residual vector will be stored in , for .

    In this document this operation is referred to as MONITR.

  3. Evaluate the residual

    This operation must evaluate the residual

    in one case and the reduced residual

    in another, where is located in . The form of the residual that is returned is determined by the value of returned by ivp_stiff_imp_revcom. If , then the residual defined by equation (2) above must be returned; if , then the residual returned by equation (1) above must be returned.

    In this document this operation is referred to as RESID.