NAG Library Routine Document
D02TLF
1 Purpose
D02TLF solves a general two-point boundary value problem for a nonlinear mixed order system of ordinary differential equations.
2 Specification
SUBROUTINE D02TLF ( |
FFUN, FJAC, GAFUN, GBFUN, GAJAC, GBJAC, GUESS, RCOMM, ICOMM, IUSER, RUSER, IFAIL) |
INTEGER |
ICOMM(*), IUSER(*), IFAIL |
REAL (KIND=nag_wp) |
RCOMM(*), RUSER(*) |
EXTERNAL |
FFUN, FJAC, GAFUN, GBFUN, GAJAC, GBJAC, GUESS |
|
3 Description
D02TLF and its associated routines (
D02TVF,
D02TXF,
D02TYF and
D02TZF) solve the two-point boundary value problem for a nonlinear mixed order system of ordinary differential equations
over an interval
subject to
(
) nonlinear boundary conditions at
and
(
) nonlinear boundary conditions at
, where
. Note that
is the
th derivative of the
th solution component. Hence
. The left boundary conditions at
are defined as
and the right boundary conditions at
as
where
and
First,
D02TVF must be called to specify the initial mesh, error requirements and other details. Note that the error requirements apply only to the solution components
and that no error control is applied to derivatives of solution components. (If error control is required on derivatives then the system must be reduced in order by introducing the derivatives whose error is to be controlled as new variables. See
Section 9 in D02TVF.) Then, D02TLF can be used to solve the boundary value problem. After successful computation,
D02TZF can be used to ascertain details about the final mesh and other details of the solution procedure, and
D02TYF can be used to compute the approximate solution anywhere on the interval
.
A description of the numerical technique used in D02TLF is given in
Section 3 in D02TVF.
D02TLF can also be used in the solution of a series of problems, for example in performing continuation, when the mesh used to compute the solution of one problem is to be used as the initial mesh for the solution of the next related problem.
D02TXF should be used in between calls to D02TLF in this context.
See
Section 9 in D02TVF for details of how to solve boundary value problems of a more general nature.
The routines are based on modified versions of the codes COLSYS and COLNEW (see
Ascher et al. (1979) and
Ascher and Bader (1987)). A comprehensive treatment of the numerical solution of boundary value problems can be found in
Ascher et al. (1988) and
Keller (1992).
4 References
Ascher U M and Bader G (1987) A new basis implementation for a mixed order boundary value ODE solver SIAM J. Sci. Stat. Comput. 8 483–500
Ascher U M, Christiansen J and Russell R D (1979) A collocation solver for mixed order systems of boundary value problems Math. Comput. 33 659–679
Ascher U M, Mattheij R M M and Russell R D (1988) Numerical Solution of Boundary Value Problems for Ordinary Differential Equations Prentice–Hall
Keller H B (1992) Numerical Methods for Two-point Boundary-value Problems Dover, New York
5 Parameters
- 1: – SUBROUTINE, supplied by the user.External Procedure
-
FFUN must evaluate the functions
for given values
.
The specification of
FFUN is:
INTEGER |
NEQ, M(NEQ), IUSER(*) |
REAL (KIND=nag_wp) |
X, Y(NEQ,), F(NEQ), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp)Input
-
On entry: , the independent variable.
- 2: – REAL (KIND=nag_wp) arrayInput
-
On entry: contains , for and .
Note: .
- 3: – INTEGERInput
-
On entry: the number of differential equations.
- 4: – INTEGER arrayInput
-
On entry:
contains , the order of the th differential equation, for .
- 5: – REAL (KIND=nag_wp) arrayOutput
-
On exit: must contain , for .
- 6: – INTEGER arrayUser Workspace
- 7: – REAL (KIND=nag_wp) arrayUser Workspace
-
FFUN is called with the parameters
IUSER and
RUSER as supplied to D02TLF. You are free to use the arrays
IUSER and
RUSER to supply information to
FFUN as an alternative to using COMMON global variables.
FFUN must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02TLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 2: – SUBROUTINE, supplied by the user.External Procedure
-
FJAC must evaluate the partial derivatives of
with respect to the elements of
.
The specification of
FJAC is:
INTEGER |
NEQ, M(NEQ), IUSER(*) |
REAL (KIND=nag_wp) |
X, Y(NEQ,), DFDY(NEQ,NEQ,), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp)Input
-
On entry: , the independent variable.
- 2: – REAL (KIND=nag_wp) arrayInput
-
On entry: contains , for and .
Note: .
- 3: – INTEGERInput
-
On entry: the number of differential equations.
- 4: – INTEGER arrayInput
-
On entry:
contains , the order of the th differential equation, for .
- 5: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: set to zero.
On exit: must contain the partial derivative of with respect to , for , and . Only nonzero partial derivatives need be set.
- 6: – INTEGER arrayUser Workspace
- 7: – REAL (KIND=nag_wp) arrayUser Workspace
-
FJAC is called with the parameters
IUSER and
RUSER as supplied to D02TLF. You are free to use the arrays
IUSER and
RUSER to supply information to
FJAC as an alternative to using COMMON global variables.
FJAC must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02TLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 3: – SUBROUTINE, supplied by the user.External Procedure
-
GAFUN must evaluate the boundary conditions at the left-hand end of the range, that is functions
for given values of
.
The specification of
GAFUN is:
INTEGER |
NEQ, M(NEQ), NLBC, IUSER(*) |
REAL (KIND=nag_wp) |
YA(NEQ,), GA(NLBC), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp) arrayInput
-
On entry: contains , for and .
Note: .
- 2: – INTEGERInput
-
On entry: the number of differential equations.
- 3: – INTEGER arrayInput
-
On entry:
contains , the order of the th differential equation, for .
- 4: – INTEGERInput
-
On entry: the number of boundary conditions at .
- 5: – REAL (KIND=nag_wp) arrayOutput
-
On exit: must contain , for .
- 6: – INTEGER arrayUser Workspace
- 7: – REAL (KIND=nag_wp) arrayUser Workspace
-
GAFUN is called with the parameters
IUSER and
RUSER as supplied to D02TLF. You are free to use the arrays
IUSER and
RUSER to supply information to
GAFUN as an alternative to using COMMON global variables.
GAFUN must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02TLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 4: – SUBROUTINE, supplied by the user.External Procedure
-
GBFUN must evaluate the boundary conditions at the right-hand end of the range, that is functions
for given values of
.
The specification of
GBFUN is:
INTEGER |
NEQ, M(NEQ), NRBC, IUSER(*) |
REAL (KIND=nag_wp) |
YB(NEQ,), GB(NRBC), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp) arrayInput
-
On entry: contains , for and .
Note: .
- 2: – INTEGERInput
-
On entry: the number of differential equations.
- 3: – INTEGER arrayInput
-
On entry:
contains , the order of the th differential equation, for .
- 4: – INTEGERInput
-
On entry: the number of boundary conditions at .
- 5: – REAL (KIND=nag_wp) arrayOutput
-
On exit: must contain , for .
- 6: – INTEGER arrayUser Workspace
- 7: – REAL (KIND=nag_wp) arrayUser Workspace
-
GBFUN is called with the parameters
IUSER and
RUSER as supplied to D02TLF. You are free to use the arrays
IUSER and
RUSER to supply information to
GBFUN as an alternative to using COMMON global variables.
GBFUN must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02TLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 5: – SUBROUTINE, supplied by the user.External Procedure
-
GAJAC must evaluate the partial derivatives of
with respect to the elements of
.
The specification of
GAJAC is:
INTEGER |
NEQ, M(NEQ), NLBC, IUSER(*) |
REAL (KIND=nag_wp) |
YA(NEQ,), DGADY(NLBC,NEQ,), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp) arrayInput
-
On entry: contains , for and .
Note: .
- 2: – INTEGERInput
-
On entry: the number of differential equations.
- 3: – INTEGER arrayInput
-
On entry:
contains , the order of the th differential equation, for .
- 4: – INTEGERInput
-
On entry: the number of boundary conditions at .
- 5: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: set to zero.
On exit: must contain the partial derivative of with respect to , for , and . Only nonzero partial derivatives need be set.
- 6: – INTEGER arrayUser Workspace
- 7: – REAL (KIND=nag_wp) arrayUser Workspace
-
GAJAC is called with the parameters
IUSER and
RUSER as supplied to D02TLF. You are free to use the arrays
IUSER and
RUSER to supply information to
GAJAC as an alternative to using COMMON global variables.
GAJAC must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02TLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 6: – SUBROUTINE, supplied by the user.External Procedure
-
GBJAC must evaluate the partial derivatives of
with respect to the elements of
.
The specification of
GBJAC is:
INTEGER |
NEQ, M(NEQ), NRBC, IUSER(*) |
REAL (KIND=nag_wp) |
YB(NEQ,), DGBDY(NRBC,NEQ,), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp) arrayInput
-
On entry: contains , for and .
Note: .
- 2: – INTEGERInput
-
On entry: the number of differential equations.
- 3: – INTEGER arrayInput
-
On entry:
contains , the order of the th differential equation, for .
- 4: – INTEGERInput
-
On entry: the number of boundary conditions at .
- 5: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: set to zero.
On exit: must contain the partial derivative of with respect to , for , and . Only nonzero partial derivatives need be set.
- 6: – INTEGER arrayUser Workspace
- 7: – REAL (KIND=nag_wp) arrayUser Workspace
-
GBJAC is called with the parameters
IUSER and
RUSER as supplied to D02TLF. You are free to use the arrays
IUSER and
RUSER to supply information to
GBJAC as an alternative to using COMMON global variables.
GBJAC must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02TLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 7: – SUBROUTINE, supplied by the user.External Procedure
-
GUESS must return initial approximations for the solution components
and the derivatives
, for
and
. Try to compute each derivative
such that it corresponds to your approximations to
, for
. You should
not call
FFUN to compute
.
If D02TLF is being used in conjunction with
D02TXF as part of a continuation process, then
GUESS is not called by D02TLF after the call to
D02TXF.
The specification of
GUESS is:
INTEGER |
NEQ, M(NEQ), IUSER(*) |
REAL (KIND=nag_wp) |
X, Y(NEQ,), DYM(NEQ), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp)Input
-
On entry: , the independent variable; .
- 2: – INTEGERInput
-
On entry: the number of differential equations.
- 3: – INTEGER arrayInput
-
On entry:
contains , the order of the th differential equation, for .
- 4: – REAL (KIND=nag_wp) arrayOutput
-
On exit: must contain , for and .
Note: .
- 5: – REAL (KIND=nag_wp) arrayOutput
-
On exit: must contain , for .
- 6: – INTEGER arrayUser Workspace
- 7: – REAL (KIND=nag_wp) arrayUser Workspace
-
GUESS is called with the parameters
IUSER and
RUSER as supplied to D02TLF. You are free to use the arrays
IUSER and
RUSER to supply information to
GUESS as an alternative to using COMMON global variables.
GUESS must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02TLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 8: – REAL (KIND=nag_wp) arrayCommunication Array
-
Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array
must be the same array passed as argument
RCOMM in the previous call to
D02TVF.
On entry: this must be the same array as supplied to
D02TVF and
must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
- 9: – INTEGER arrayCommunication Array
-
Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array
must be the same array passed as argument
ICOMM in the previous call to
D02TVF.
On entry: this must be the same array as supplied to
D02TVF and
must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
- 10: – INTEGER arrayUser Workspace
- 11: – REAL (KIND=nag_wp) arrayUser Workspace
-
IUSER and
RUSER are not used by D02TLF, but are passed directly to
FFUN,
FJAC,
GAFUN,
GBFUN,
GAJAC,
GBJAC and
GUESS and may be used to pass information to these routines as an alternative to using COMMON global variables.
- 12: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if
on exit, the recommended value is
.
When the value 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).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Note: D02TLF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
-
Either the setup routine has not been called or the communication arrays have become corrupted. No solution will be computed.
-
Numerical singularity has been detected in the Jacobian used in the Newton iteration.
No results have been generated. Check the coding of the routines for calculating the Jacobians of system and boundary conditions.
-
All Newton iterations that have been attempted have failed to converge.
No results have been generated. Check the coding of the routines for calculating the Jacobians of system and boundary conditions.
Try to provide a better initial solution approximation.
-
A Newton iteration has failed to converge. The computation has not succeeded but results have been returned for an intermediate mesh on which convergence was achieved.
These results should be treated with extreme caution.
-
The expected number of sub-intervals required to continue the computation exceeds the maximum specified: .
Results have been generated which may be useful.
Try increasing this number or relaxing the error requirements.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
The accuracy of the solution is determined by the parameter
TOLS in the prior call to
D02TVF (see
Sections 3 and
9 in D02TVF for details and advice). Note that error control is applied only to solution components (variables) and not to any derivatives of the solution. An estimate of the maximum error in the computed solution is available by calling
D02TZF.
8 Parallelism and Performance
D02TLF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
D02TLF 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.
If D02TLF returns with , , or and the call to D02TLF was a part of some continuation procedure for which successful calls to D02TLF have already been made, then it is possible that the adjustment(s) to the continuation parameter(s) between calls to D02TLF is (are) too large for the problem under consideration. More conservative adjustment(s) to the continuation parameter(s) might be appropriate.
10 Example
The following example is used to illustrate the treatment of a high-order system, control of the error in a derivative of a component of the original system, and the use of continuation. See also
D02TVF,
D02TXF,
D02TYF and
D02TZF, for the illustration of other facilities.
Consider the steady flow of an incompressible viscous fluid between two infinite coaxial rotating discs. See
Ascher et al. (1979) and the references therein. The governing equations are
subject to the boundary conditions
where
is the Reynolds number and
are the angular velocities of the disks.
We consider the case of counter-rotation and a symmetric solution, that is
. This problem is more difficult to solve, the larger the value of
. For illustration, we use simple continuation to compute the solution for three different values of
(
). However, this problem can be addressed directly for the largest value of
considered here. Instead of the values suggested in
Section 5 in D02TXF for
NMESH,
IPMESH and
MESH in the call to
D02TXF prior to a continuation call, we use every point of the final mesh for the solution of the first value of
, that is we must modify the contents of
IPMESH. For illustrative purposes we wish to control the computed error in
and so recast the equations as
subject to the boundary conditions
For the symmetric boundary conditions considered, there exists an odd solution about
. Hence, to satisfy the boundary conditions, we use the following initial approximations to the solution in
GUESS:
10.1 Program Text
Program Text (d02tlfe.f90)
10.2 Program Data
Program Data (d02tlfe.d)
10.3 Program Results
Program Results (d02tlfe.r)