The routine may be called by the names d02psf or nagf_ode_ivp_rkts_interp.
d02psf and its associated routines (d02pff,d02pqf,d02prf,d02ptfandd02puf) solve the initial value problem for a first-order system of ordinary differential equations. The routines, 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.
d02pff computes the solution at the end of an integration step. Using the information computed on that step d02psf computes the solution by interpolation at any point on that step. It cannot be used if or was specified in the call to setup routine d02pqf.
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
1: – IntegerInput
On entry: , the number of ordinary differential equations in the system to be solved by the integration routine.
2: – Real (Kind=nag_wp)Input
On entry: , the value of the independent variable where a solution is desired.
3: – IntegerInput
On entry: determines whether the solution and/or its first derivative are to be computed
compute approximate solution.
compute approximate first derivative.
compute approximate solution and first derivative.
, or .
4: – IntegerInput
On entry: the number of components of the solution to be computed. The first nwant components are evaluated.
5: – Real (Kind=nag_wp) arrayOutput
On exit: an approximation to the first nwant components of the solution at twant if or . Otherwise ywant is not defined.
6: – Real (Kind=nag_wp) arrayOutput
On exit: an approximation to the first nwant components of the first derivative at twant if or . Otherwise ypwant is not defined.
7: – Subroutine, supplied by the user.External Procedure
f must evaluate the functions (that is the first derivatives ) for given values of the arguments . It must be the same procedure as supplied to d02pff.
On entry: , the current value of the independent variable.
2: – IntegerInput
On entry: , the number of ordinary differential equations in the system to be solved.
3: – Real (Kind=nag_wp) arrayInput
On entry: the current values of the dependent variables,
, for .
4: – Real (Kind=nag_wp) arrayOutput
On exit: the values of
, for .
5: – Integer arrayUser Workspace
6: – Real (Kind=nag_wp) arrayUser Workspace
f is called with the arguments iuser and ruser as supplied to d02psf. You should use the arrays iuser and ruser to supply information to f.
f must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02psf is called. Arguments denoted as Input must not be changed by this procedure.
Note:f should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02psf. If your code inadvertently does return any NaNs or infinities, d02psf is likely to produce unexpected results.
8: – Real (Kind=nag_wp) arrayCommunication Array
On entry: this array stores information that can be utilized on subsequent calls to d02psf.
iuser and ruser are not used by d02psf, but are passed directly to f and may be used to pass information to this routine.
12: – Integer arrayCommunication Array
13: – Real (Kind=nag_wp) arrayCommunication Array
On entry: these must be the same arrays supplied in a previous call d02pff. They must remain unchanged between calls.
On exit: information about the integration for use on subsequent calls to d02pff, d02psf or other associated routines.
14: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
or in setup, but interpolation is not available for this method. Either use or in setup or use reset routine to force the integrator to step to particular points.
On entry, a previous call to the setup routine has not been made or the communication arrays have become corrupted, or a catastrophic error has already been detected elsewhere. You cannot continue integrating the problem.
On entry, . Constraint: , or .
On entry, , and .
Constraint: for or , .
On entry, .
Constraint: for or , .
On entry, , but the value passed to the setup routine was .
On entry, and . Constraint: .
You cannot call this routine after the integrator has returned an error.
You cannot call this routine before you have called the step integrator.
You cannot call this routine when you have specified, in the setup routine, that the range integrator will be used.
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
The computed values will be of a similar accuracy to that computed by d02pff.
8Parallelism and Performance
d02psf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
This example solves the equation
over the range with initial conditions and . Relative error control is used with threshold values of for each solution component. d02pff is used to integrate the problem one step at a time and d02psf is used to compute the first component of the solution and its derivative at intervals of length across the range whenever these points lie in one of those integration steps. A low order Runge–Kutta method () is also used with tolerances and in turn so that solutions may be compared.