# NAG FL Interfaced02txf (bvp_​coll_​nlin_​contin)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

d02txf allows a solution to a nonlinear two-point boundary value problem computed by d02tlf to be used as an initial approximation in the solution of a related nonlinear two-point boundary value problem in a continuation call to d02tlf.

## 2Specification

Fortran Interface
 Subroutine d02txf ( mesh,
 Integer, Intent (In) :: mxmesh, nmesh, ipmesh(mxmesh) Integer, Intent (Inout) :: icomm(*), ifail Real (Kind=nag_wp), Intent (In) :: mesh(mxmesh) Real (Kind=nag_wp), Intent (Inout) :: rcomm(*)
#include <nag.h>
 void d02txf_ (const Integer *mxmesh, const Integer *nmesh, const double mesh[], const Integer ipmesh[], double rcomm[], Integer icomm[], Integer *ifail)
The routine may be called by the names d02txf or nagf_ode_bvp_coll_nlin_contin.

## 3Description

d02txf and its associated routines (d02tlf, d02tvf, d02tyf and d02tzf) solve the two-point boundary value problem for a nonlinear system of ordinary differential equations
 $y1(m1) (x) = f1 (x,y1,y1(1),…,y1(m1-1),y2,…,yn(mn-1)) y2(m2) (x) = f2 (x,y1,y1(1),…,y1(m1-1),y2,…,yn(mn-1)) ⋮ yn(mn) (x) = fn (x,y1,y1(1),…,y1(m1-1),y2,…,yn(mn-1))$
over an interval $\left[a,b\right]$ subject to $p$ ($\text{}>0$) nonlinear boundary conditions at $a$ and $q$ ($\text{}>0$) nonlinear boundary conditions at $b$, where $p+q=\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
 $gi(z(y(a)))=0, i=1,2,…,p,$
and the right boundary conditions at $b$ as
 $g¯j(z(y(b)))=0, j=1,2,…,q,$
where $y=\left({y}_{1},{y}_{2},\dots ,{y}_{n}\right)$ and
 $z(y(x)) = (y1(x), y1(1) (x) ,…, y1(m1-1) (x) ,y2(x),…, yn(mn-1) (x) ) .$
First, d02tvf must be called to specify the initial mesh, error requirements and other details. 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. d02tyf can be used to compute the approximate solution anywhere on the interval $\left[a,b\right]$ using interpolation.
If the boundary value problem being solved is one of a sequence of related problems, for example as part of some continuation process, then d02txf should be used between calls to d02tlf. This avoids the overhead of a complete initialization when the setup routine d02tvf is used. d02txf allows the solution values computed in the previous call to d02tlf to be used as an initial approximation for the solution in the next call to d02tlf.
You must specify the new initial mesh. The previous mesh can be obtained by a call to d02tzf. It may be used unchanged as the new mesh, in which case any fixed points in the previous mesh remain as fixed points in the new mesh. Fixed and other points may be added or subtracted from the mesh by manipulation of the contents of the array argument ipmesh. Initial values for the solution components on the new mesh are computed by interpolation on the values for the solution components on the previous mesh.
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).

## 4References

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

## 5Arguments

1: $\mathbf{mxmesh}$Integer Input
On entry: the maximum number of points allowed in the mesh.
Constraint: this must be identical to the value supplied for the argument mxmesh in the prior call to d02tvf.
2: $\mathbf{nmesh}$Integer Input
On entry: the number of points to be used in the new initial mesh. It is strongly recommended that if this routine is called that the suggested value (see below) for nmesh is used. In this case the arrays mesh and ipmesh returned by d02tzf can be passed to this routine without any modification.
Suggested value: $\left({n}^{*}+1\right)/2$, where ${n}^{*}$ is the number of mesh points used in the previous mesh as returned in the argument nmesh of d02tzf.
Constraint: $6\le {\mathbf{nmesh}}\le \left({\mathbf{mxmesh}}+1\right)/2$.
3: $\mathbf{mesh}\left({\mathbf{mxmesh}}\right)$Real (Kind=nag_wp) array Input
On entry: the nmesh points to be used in the new initial mesh as specified by ipmesh.
Suggested value: the argument mesh returned from a call to d02tzf.
Constraint: ${\mathbf{mesh}}\left({i}_{\mathit{j}}\right)<{\mathbf{mesh}}\left({i}_{\mathit{j}+1}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{nmesh}}-1$, the values of ${i}_{1},{i}_{2},\dots ,{i}_{{\mathbf{nmesh}}}$ are defined in ipmesh.
${\mathbf{mesh}}\left({i}_{1}\right)$ must contain the left boundary point, $a$, and ${\mathbf{mesh}}\left({i}_{{\mathbf{nmesh}}}\right)$ must contain the right boundary point, $b$, as specified in the previous call to d02tvf.
4: $\mathbf{ipmesh}\left({\mathbf{mxmesh}}\right)$Integer array Input
On entry: specifies the points in mesh to be used as the new initial mesh. Let $\left\{{i}_{j}:j=1,2,\dots ,{\mathbf{nmesh}}\right\}$ be the set of array indices of ipmesh such that ${\mathbf{ipmesh}}\left({i}_{j}\right)=1$ or $2$ and $1={i}_{1}<{i}_{2}<\cdots <{i}_{{\mathbf{nmesh}}}$. Then ${\mathbf{mesh}}\left({i}_{j}\right)$ will be included in the new initial mesh.
If ${\mathbf{ipmesh}}\left({i}_{j}\right)=1$, ${\mathbf{mesh}}\left({i}_{j}\right)$ will be a fixed point in the new initial mesh.
If ${\mathbf{ipmesh}}\left(k\right)=3$ for any $k$, ${\mathbf{mesh}}\left(k\right)$ will not be included in the new mesh.
Suggested value: the argument ipmesh returned in a call to d02tzf.
Constraints:
• ${\mathbf{ipmesh}}\left(\mathit{k}\right)=1$, $2$ or $3$, for $\mathit{k}=1,2,\dots ,{i}_{{\mathbf{nmesh}}}$;
• ${\mathbf{ipmesh}}\left(1\right)={\mathbf{ipmesh}}\left({i}_{{\mathbf{nmesh}}}\right)=1$.
5: $\mathbf{rcomm}\left(*\right)$Real (Kind=nag_wp) array Communication 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 d02tlf.
On entry: this must be the same array as supplied to d02tlf and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
6: $\mathbf{icomm}\left(*\right)$Integer array Communication 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 d02tlf.
On entry: this must be the same array as supplied to d02tlf and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
7: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
An element of ipmesh was set to $-1$ before nmesh elements containing $1$ or $2$ were detected.
Expected $⟨\mathit{\text{value}}⟩$ elements of ipmesh to be $1$ or $2$, but $⟨\mathit{\text{value}}⟩$ such elements found.
${\mathbf{ipmesh}}\left(i\right)\ne -1$, $1$, $2$ or $3$ for some $i$.
On entry, ${\mathbf{ipmesh}}\left(1\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ipmesh}}\left(1\right)=1$.
On entry, ${\mathbf{mxmesh}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{mxmesh}}=⟨\mathit{\text{value}}⟩$ in d02tvf.
Constraint: ${\mathbf{mxmesh}}={\mathbf{mxmesh}}$ in d02tvf.
On entry, ${\mathbf{nmesh}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nmesh}}\ge 6$.
On entry, ${\mathbf{nmesh}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{mxmesh}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nmesh}}\le \left({\mathbf{mxmesh}}+1\right)/2$.
The entries in mesh are not strictly increasing.
The first element of array mesh does not coincide with the left-hand end of the range previously specified.
First element of mesh: $⟨\mathit{\text{value}}⟩$; left-hand of the range: $⟨\mathit{\text{value}}⟩$.
The last point of the new mesh does not coincide with the right hand end of the range previously specified.
Last point of the new mesh: $⟨\mathit{\text{value}}⟩$; right-hand end of the range: $⟨\mathit{\text{value}}⟩$.
The solver routine did not produce any results suitable for remeshing.
The solver routine does not appear to have been called.
You have set the element of ipmesh corresponding to the last element of mesh to be included in the new mesh as $⟨\mathit{\text{value}}⟩$, which is not $1$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

d02txf is not threaded in any implementation.

For problems where sharp changes of behaviour are expected over short intervals it may be advisable to:
• cluster the 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.
In the absence of any other information about the expected behaviour of the solution, using the values suggested in Section 5 for nmesh, ipmesh and mesh is strongly recommended.

## 10Example

This example illustrates the use of continuation, solution on an infinite range, and solution of a system of two differential equations of orders $3$ and $2$. See also d02tlf, d02tvf, d02tyf and d02tzf, for the illustration of other facilities.
Consider the problem of swirling flow over an infinite stationary disk with a magnetic field along the axis of rotation. See Ascher et al. (1988) and the references therein. After transforming from a cylindrical coordinate system $\left(r,\theta ,z\right)$, in which the $\theta$ component of the corresponding velocity field behaves like ${r}^{-n}$, the governing equations are
 $f′′′+12(3-n)ff′′+n (f′) 2+g2-sf′ = γ2 g′′+12(3-n)fg′+(n-1)gf′-s(g-1) = 0$
with boundary conditions
 $f(0)=f′(0)=g(0)= 0, f′(∞)= 0, g(∞)=γ,$
where $s$ is the magnetic field strength, and $\gamma$ is the Rossby number.
Some solutions of interest are for $\gamma =1$, small $n$ and $s\to 0$. An added complication is the infinite range, which we approximate by $\left[0,L\right]$. We choose $n=0.2$ and first solve for $L=60.0,s=0.24$ using the initial approximations $f\left(x\right)=-{x}^{2}{e}^{-x}$ and $g\left(x\right)=1.0-{e}^{-x}$, which satisfy the boundary conditions, on a uniform mesh of $21$ points. Simple continuation on the parameters $L$ and $s$ using the values $L=120.0,s=0.144$ and then $L=240.0,s=0.0864$ is used to compute further solutions. We use the suggested values for nmesh, ipmesh and mesh in the call to d02txf prior to a continuation call, that is only every second point of the preceding mesh is used.
The equations are first mapped onto $\left[0,1\right]$ to yield
 $f′′′ = L3(γ2-g2)+L2sf′-L(12(3-n)ff′′+n (f′) 2) g′′ = L2s(g-1)-L(12(3-n)fg′+(n-1)f′g).$

### 10.1Program Text

Program Text (d02txfe.f90)

### 10.2Program Data

Program Data (d02txfe.d)

### 10.3Program Results

Program Results (d02txfe.r)