The function may be called by the names: d02tvc or nag_ode_bvp_coll_nlin_setup.
3Description
d02tvc and its associated functions (d02tlc,d02txc,d02tycandd02tzc) solve the two-point boundary value problem for a nonlinear system of ordinary differential equations
over an interval $[a,b]$ subject to $p$ ($\text{}>0$) nonlinear boundary conditions at $a$ and $q$ ($\text{}>0$) nonlinear boundary conditions at $b$, where $p+q={\displaystyle \sum _{i=1}^{n}}{m}_{i}$. Note that ${y}_{i}^{\left(m\right)}\left(x\right)$ is the $m$th derivative of the $i$th solution component. Hence ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$. The left boundary conditions at $a$ are defined as
and the boundary conditions. To solve these equations numerically the components ${y}_{i}$ are approximated by piecewise polynomials ${v}_{ij}$ using a monomial basis on the $j$th mesh sub-interval. The coefficients of the polynomials ${v}_{ij}$ form the unknowns to be computed. Collocation is applied at Gaussian points
where ${x}_{j+1}$ is the right-hand end of the $j$th mesh sub-interval. The linearized collocation equations and boundary conditions, together with the continuity conditions, form a system of linear algebraic equations, an almost block diagonal system which is solved using special linear solvers. To start the modified Newton process, an approximation to the solution on the initial mesh must be supplied via the procedure argument guess of d02tlc.
where ${v}_{i}$ is the approximate solution for the $i$th solution component and tols is supplied by you. The mesh is refined by trying to equidistribute the estimated error in the computed solution over all mesh sub-intervals, and an extrapolation-like test (doubling the number of mesh sub-intervals) is used to check for (1).
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
Gill P E, Murray W and Wright M H (1981) Practical Optimization Academic Press
Keller H B (1992) Numerical Methods for Two-point Boundary-value Problems Dover, New York
Schwartz I B (1983) Estimating regions of existence of unstable periodic orbits using computer-based techniques SIAM J. Sci. Statist. Comput.20(1) 106–120
5Arguments
1: $\mathbf{neq}$ – IntegerInput
On entry: $n$, the number of ordinary differential equations to be solved.
On entry: ${\mathbf{m}}\left[\mathit{i}-1\right]$ must contain ${m}_{i}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,n$.
Constraint:
$1\le {\mathbf{m}}\left[\mathit{i}-1\right]\le 4$, for $\mathit{i}=1,2,\dots ,n$.
3: $\mathbf{nlbc}$ – IntegerInput
On entry: $p$, the number of left boundary conditions defined at the left-hand end, $a$ ($\text{}={\mathbf{mesh}}\left[0\right]$).
Constraint:
${\mathbf{nlbc}}\ge 1$.
4: $\mathbf{nrbc}$ – IntegerInput
On entry: $q$, the number of right boundary conditions defined at the right-hand end, $b$ ($\text{}={\mathbf{mesh}}\left[{\mathbf{nmesh}}-1\right]$).
On entry: the positions of the initial nmesh mesh points. The remaining elements of mesh need not be set. You should try to place the mesh points in areas where you expect the solution to vary most rapidly. In the absence of any other information the points should be equally distributed on $[a,b]$.
${\mathbf{mesh}}\left[0\right]$ must contain the left boundary point, $a$, and ${\mathbf{mesh}}\left[{\mathbf{nmesh}}-1\right]$ must contain the right boundary point, $b$.
Constraint:
${\mathbf{mesh}}\left[\mathit{i}-1\right]<{\mathbf{mesh}}\left[\mathit{i}\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{nmesh}}-1$.
On entry: ${\mathbf{ipmesh}}\left[\mathit{i}-1\right]$ specifies whether or not the initial mesh point defined in ${\mathbf{mesh}}\left[\mathit{i}-1\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{nmesh}}$, should be a fixed point in all meshes computed during the solution process. The remaining elements of ipmesh need not be set.
${\mathbf{ipmesh}}\left[i-1\right]=1$
Indicates that ${\mathbf{mesh}}\left[i-1\right]$ should be a fixed point in all meshes.
${\mathbf{ipmesh}}\left[i-1\right]=2$
Indicates that ${\mathbf{mesh}}\left[i-1\right]$ is not a fixed point.
Constraints:
${\mathbf{ipmesh}}\left[0\right]=1$ and ${\mathbf{ipmesh}}\left[{\mathbf{nmesh}}-1\right]=1$, (i.e., the left and right boundary points, $a$ and $b$, must be fixed points, in all meshes);
${\mathbf{ipmesh}}\left[\mathit{i}-1\right]=1$ or $2$, for $\mathit{i}=2,3,\dots ,{\mathbf{nmesh}}-1$.
On exit: contains information for use by d02tlc. This must be the same array as will be supplied to d02tlc. The contents of this array must remain unchanged between calls.
12: $\mathbf{lrcomm}$ – IntegerInput
On entry: the dimension of the array rcomm. If ${\mathbf{lrcomm}}=0$, a communication array size query is requested. In this case there is an immediate return with communication array dimensions stored in icomm; ${\mathbf{icomm}}\left[0\right]$ contains the required dimension of rcomm, while ${\mathbf{icomm}}\left[1\right]$ contains the required dimension of icomm.
Constraint:
${\mathbf{lrcomm}}=0$, or ${\mathbf{lrcomm}}\ge 51+{\mathbf{neq}}+{\mathbf{mxmesh}}\times (2+{m}^{*}+{k}_{n})-{k}_{n}+{\mathbf{mxmesh}}/2$, where ${m}^{*}={\displaystyle \sum _{i=1}^{n}}{\mathbf{m}}\left[i-1\right]$ and ${k}_{n}={\mathbf{ncol}}\times {\mathbf{neq}}$.
On exit: contains information for use by d02tlc. This must be the same array as will be supplied to d02tlc. The contents of this array must remain unchanged between calls. If ${\mathbf{lrcomm}}=0$, a communication array size query is requested. In this case, on immediate return, ${\mathbf{icomm}}\left[0\right]$ will contain the required dimension for rcomm while ${\mathbf{icomm}}\left[1\right]$ will contain the required dimension for icomm.
14: $\mathbf{licomm}$ – IntegerInput
On entry: the dimension of the array icomm. If ${\mathbf{lrcomm}}=0$, a communication array size query is requested. In this case icomm need only be of dimension $2$ in order to hold the required communication array dimensions for the given problem and algorithmic parameters.
Constraints:
if ${\mathbf{lrcomm}}=0$, ${\mathbf{licomm}}\ge 2$;
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument $\u27e8\mathit{\text{value}}\u27e9$ had an illegal value.
NE_INT
On entry, ${\mathbf{ipmesh}}\left[0\right]$ or ${\mathbf{ipmesh}}\left[{\mathbf{nmesh}}-1\right]$ does not equal $1$.
On entry, ${\mathbf{ipmesh}}\left[i\right]\ne 1$ or $2$ for some $i$.
On entry, ${\mathbf{licomm}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{licomm}}\ge \u27e8\mathit{\text{value}}\u27e9$.
On entry, ${\mathbf{lrcomm}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{lrcomm}}=0$ or ${\mathbf{lrcomm}}\ge \u27e8\mathit{\text{value}}\u27e9$.
On entry, ${\mathbf{m}}\left[\u27e8\mathit{\text{value}}\u27e9\right]=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: $1\le {\mathbf{m}}\left[i-1\right]\le 4$ for all $i$.
On entry, ${\mathbf{neq}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{neq}}\ge 1$.
On entry, ${\mathbf{nmesh}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{nmesh}}\ge 6$.
NE_INT_2
On entry, ${\mathbf{mxmesh}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{nmesh}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{mxmesh}}\ge 2\times {\mathbf{nmesh}}-1$.
On entry, ${\mathbf{ncol}}=\u27e8\mathit{\text{value}}\u27e9$ and $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[\mathit{i}\right]\right)\le {\mathbf{ncol}}\le 7$.
On entry, ${\mathbf{nlbc}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{nrbc}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{nlbc}}\ge 1$ and ${\mathbf{nrbc}}\ge 1$.
NE_INT_3
On entry, ${\mathbf{nlbc}}=\u27e8\mathit{\text{value}}\u27e9$, ${\mathbf{nrbc}}=\u27e8\mathit{\text{value}}\u27e9$ and $\mathrm{sum}\left({\mathbf{m}}\left[i\right]\right)=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{nlbc}}+{\mathbf{nrbc}}=\mathrm{sum}\left({\mathbf{m}}\left[i\right]\right)$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_NOT_STRICTLY_INCREASING
On entry, the elements of mesh are not strictly increasing.
NE_REAL
On entry, ${\mathbf{tols}}\left[\u27e8\mathit{\text{value}}\u27e9\right]=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{tols}}\left[i-1\right]>\u27e8\mathit{\text{value}}\u27e9$ for all $i$.
7Accuracy
Not applicable.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
d02tvc is not threaded in any implementation.
9Further Comments
For problems where sharp changes of behaviour are expected over short intervals it may be advisable to:
–cluster the initial mesh points where sharp changes in behaviour are expected;
–maintain fixed points in the mesh using the argument ipmesh to ensure that the remeshing process does not inadvertently remove mesh points from areas of known interest before they are detected automatically by the algorithm.
9.1Nonseparated Boundary Conditions
A boundary value problem with nonseparated boundary conditions can be treated by transformation to an equivalent problem with separated conditions. As a simple example consider the system
There is an obvious overhead in adjoining an extra differential equation: the system to be solved is increased in size.
9.2Multipoint Boundary Value Problems
Multipoint boundary value problems, that is problems where conditions are specified at more than two points, can also be transformed to an equivalent problem with two boundary points. Each sub-interval defined by the multipoint conditions can be transformed onto the interval $[0,1]$, say, leading to a larger set of differential equations. The boundary conditions of the transformed system consist of the original boundary conditions and the conditions imposed by the requirement that the solution components be continuous at the interior break-points. For example, consider the equation
$${y}^{\left(3\right)}=f(t,y,{y}^{\left(1\right)},{y}^{\left(2\right)})\text{\hspace{1em} on \hspace{1em}}[a,c]$$
In this instance two of the resulting boundary conditions are nonseparated but they may next be treated as described above.
9.3High Order Systems
Systems of ordinary differential equations containing derivatives of order greater than four can always be reduced to systems of order suitable for treatment by d02tvc and its related functions. For example suppose we have the sixth-order equation
$${y}^{\left(6\right)}=-y\text{.}$$
Writing the variables ${y}_{1}=y$ and ${y}_{2}={y}^{\left(4\right)}$ we obtain the system
which has maximal order three. The best choice of reduction by choosing new variables will depend on the structure and physical meaning of the system. Note that you will control the error in each of the variables ${y}_{1}$ and ${y}_{2}$. Indeed, if you wish to control the error in certain derivatives of the solution of an equation of order greater than $1$, then you should make those derivatives new variables.
9.4Fixed Points and Singularities
The solver function d02tlc employs collocation at Gaussian points in each sub-interval of the mesh. Hence the coefficients of the differential equations are not evaluated at the mesh points. Thus, fixed points should be specified in the mesh where either the coefficients are singular, or the solution has less smoothness, or where the differential equations should not be evaluated. Singular coefficients at boundary points often arise when physical symmetry is used to reduce partial differential equations to ordinary differential equations. These do not pose a direct numerical problem for using this code but they can severely impact its convergence.
9.5Numerical Jacobians
The solver function d02tlc requires an external function fjac to evaluate the partial derivatives of ${f}_{i}$ with respect to the elements of $z\left(y\right)$ ($\text{}=({y}_{1},{y}_{1}^{1},\dots ,{y}_{1}^{({m}_{1}-1)},{y}_{2},\dots ,{y}_{n}^{({m}_{n}-1)})$). In cases where the partial derivatives are difficult to evaluate, numerical approximations can be used. However, this approach might have a negative impact on the convergence of the modified Newton method. You could consider the use of symbolic mathematic packages and/or automatic differentiation packages if available to you.
10Example
The following example is used to illustrate the treatment of nonseparated boundary conditions. See also d02tlc,d02txc,d02tycandd02tzc, for the illustration of other facilities.
The following equations model of the spread of measles. See Schwartz (1983). Under certain assumptions the dynamics of the model can be expressed as
Here ${y}_{1},{y}_{2}$ and ${y}_{3}$ are respectively the proportions of susceptibles, infectives and latents to the whole population. $\lambda $ ($\text{}=0.0279$ years) is the latent period, $\eta $ ($\text{}=0.01$ years) is the infectious period and $\mu $ ($\text{}=0.02$) is the population birth rate. $\beta \left(x\right)={\beta}_{0}(1.0+\mathrm{cos}2\pi x)$ is the contact rate where ${\beta}_{0}=1575.0$.
The nonseparated boundary conditions are treated as described in Section 9 by adjoining the trivial differential equations
This is a relatively easy problem and an (arbitrary) initial guess of $1$ for each component suffices, even though two components of the solution are much smaller than $1$.