naginterfaces.library.ode.ivp_​rk_​step_​revcomm

naginterfaces.library.ode.ivp_rk_step_revcomm(irevcm, yp, comm)[source]

ivp_rk_step_revcomm is a reverse communication one-step function for solving an initial value problem for a first-order system of ordinary differential equations using Runge–Kutta methods. The direct communication version of this function is ivp_rkts_onestep(). See Direct and Reverse Communication Routines for the difference between forward and reverse communication.

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

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/d02/d02pgf.html

Parameters
irevcmint

On initial entry must be set to zero, otherwise should be unchanged from the previous call.

ypfloat, array-like, shape

On initial entry: need not be set.

On intermediate entry: must contain the value of the derivatives where is supplied in and is supplied in the array .

commdict, communication object, modified in place

Communication structure.

This argument must have been initialized by a prior call to ivp_rkts_setup().

Returns
irevcmint

On intermediate exit returns a value to indicate that a function evaluation is required prior to re-entry.

On final exit returns or denoting success or failure, respectively.

tfloat

On intermediate exit: contains the value of the independent variable at which the derivatives are to be evaluated.

On final exit: the value of at which a solution has been computed following a successful step.

yfloat, ndarray, shape

On intermediate exit: contains the value of the solution at which the derivatives are to be evaluated.

On final exit: the approximation to the solution computed following a successful step.

Raises
NagValueError
(errno )

, as specified in the setup function, has already been reached. To start a new problem, you will need to call the setup function. To continue integration beyond then ivp_rkts_reset_tend() must first be called to reset to a new end value.

(errno )

A call to this function cannot be made after it has returned an error.

The setup function must be called to start another problem.

(errno )

On entry, a previous call to the setup function has not been made or the communication arrays have become corrupted.

(errno )

on entry.

(errno )

On entry, , but the value passed to the setup function was .

(errno )

On entry, the communication arrays have become corrupted, or a catastrophic error has already been detected elsewhere. You cannot continue integrating the problem.

Warns
NagAlgorithmicWarning
(errno )

More than output points have been obtained by integrating to (as specified in the setup function). They have been so clustered that it would probably be (much) more efficient to use the interpolation function. However, you can continue integrating the problem.

(errno )

Approximately function evaluations have been used to compute the solution since the integration started or since this message was last printed. However, you can continue integrating the problem.

(errno )

Approximately function evaluations have been used to compute the solution since the integration started or since this message was last printed. Your problem has been diagnosed as stiff. If the situation persists, it will cost roughly times as much to reach (setup) as it has cost to reach the current time. You should probably call functions intended for stiff problems. However, you can continue integrating the problem.

(errno )

Your problem has been diagnosed as stiff. If the situation persists, it will cost roughly times as much to reach (setup) as it has cost to reach the current time. You should probably call functions intended for stiff problems. However, you can continue integrating the problem.

(errno )

In order to satisfy your error requirements the solver has to use a step size of at the current time, . This step size is too small for the machine precision, and is smaller than .

(errno )

The global error assessment may not be reliable for times beyond .

The integration is being terminated.

(errno )

The global error assessment algorithm failed at start of integration.

The integration is being terminated.

Notes

ivp_rk_step_revcomm and its associated functions (ivp_rk_interp_setup(), ivp_rk_interp_eval(), ivp_rkts_setup(), ivp_rkts_reset_tend(), ivp_rkts_diag() and ivp_rkts_errass()) solve an initial value problem for a first-order system of ordinary differential equations. The functions, based on Runge–Kutta methods and derived from RKSUITE (see Brankin et al. (1991)), integrate

where is the vector of solution components and is the independent variable.

ivp_rk_step_revcomm is designed to be used in complicated tasks when solving systems of ordinary differential equations. You must first call ivp_rkts_setup() to specify the problem and how it is to be solved. Thereafter you (repeatedly) call ivp_rk_step_revcomm in reverse communication loops to take one integration step at a time from in the direction of (as specified in ivp_rkts_setup()). In this manner ivp_rk_step_revcomm returns an approximation to the solution and its derivative at successive points . If ivp_rk_step_revcomm encounters some difficulty in taking a step, the integration is not advanced and the function returns with the same values of , and as returned on the previous successful step. ivp_rk_step_revcomm tries to advance the integration as far as possible subject to passing the test on the local error and not going past .

In the call to ivp_rkts_setup() you can specify either the first step size for ivp_rk_step_revcomm to attempt or it computes automatically an appropriate value. Thereafter ivp_rk_step_revcomm estimates an appropriate step size for its next step. This value and other details of the integration can be obtained after a completed step by ivp_rk_step_revcomm by a call to ivp_rkts_diag(). The local error is controlled at every step as specified in ivp_rkts_setup(). If you wish to assess the true error, you must set to a positive value in the call to ivp_rkts_setup(). This assessment can be obtained after any call to ivp_rk_step_revcomm by a call to ivp_rkts_errass().

If you want answers at specific points there are two ways to proceed:

  1. The more efficient way is to step past the point where a solution is desired, and then call ivp_rk_interp_setup() and ivp_rk_interp_eval() to get an answer there. Within the span of the current step, you can get all the answers you want at very little cost by repeated calls to ivp_rk_interp_eval(). This is very valuable when you want to find where something happens, e.g., where a particular solution component vanishes.

  2. Alternatively, set to the desired value and integrate to . ivp_rk_step_revcomm will not step past , so when a step would carry it past, it will reduce the step size so as to produce an answer at exactly. After getting an answer there (), you can reset to the next point where you want an answer, and repeat. could be reset by a call to ivp_rkts_setup(), but you should not do this. You should use ivp_rkts_reset_tend() instead because it is both easier to use and much more efficient. This way of getting answers at specific points can be used with any of the available methods, but it can be inefficient. Should this be the case, the code will bring the matter to your attention.

References

Brankin, R W, Gladwell, I and Shampine, L F, 1991, RKSUITE: A suite of Runge–Kutta codes for the initial value problems for ODEs, SoftReport 91-S1, Southern Methodist University