NAG C Library Function Document

nag_ode_bvp_coll_nlin_contin (d02txc)

1
Purpose

nag_ode_bvp_coll_nlin_contin (d02txc) allows a solution to a nonlinear two-point boundary value problem computed by nag_ode_bvp_coll_nlin_solve (d02tlc) to be used as an initial approximation in the solution of a related nonlinear two-point boundary value problem in a continuation call to nag_ode_bvp_coll_nlin_solve (d02tlc).

2
Specification

#include <nag.h>
#include <nagd02.h>
void  nag_ode_bvp_coll_nlin_contin (Integer mxmesh, Integer nmesh, const double mesh[], const Integer ipmesh[], double rcomm[], Integer icomm[], NagError *fail)

3
Description

nag_ode_bvp_coll_nlin_contin (d02txc) and its associated functions (nag_ode_bvp_coll_nlin_solve (d02tlc), nag_ode_bvp_coll_nlin_setup (d02tvc), nag_ode_bvp_coll_nlin_interp (d02tyc) and nag_ode_bvp_coll_nlin_diag (d02tzc)) solve the two-point boundary value problem for a nonlinear system of ordinary differential equations
y1m1 x = f1 x,y1,y11,,y1m1-1,y2,,ynmn-1 y2m2 x = f2 x,y1,y11,,y1m1-1,y2,,ynmn-1 ynmn x = fn x,y1,y11,,y1m1-1,y2,,ynmn-1  
over an interval a,b subject to p (>0) nonlinear boundary conditions at a and q (>0) nonlinear boundary conditions at b, where p+q = i=1 n mi . Note that yi m x is the mth derivative of the ith solution component. Hence yi 0 x=yix. The left boundary conditions at a are defined as
gizya=0,  i=1,2,,p,  
and the right boundary conditions at b as
g-jzyb=0,  j=1,2,,q,  
where y=y1,y2,,yn and
zyx = y1x, y11 x ,, y1m1-1 x ,y2x,, ynmn-1 x .  
First, nag_ode_bvp_coll_nlin_setup (d02tvc) must be called to specify the initial mesh, error requirements and other details. Then, nag_ode_bvp_coll_nlin_solve (d02tlc) can be used to solve the boundary value problem. After successful computation, nag_ode_bvp_coll_nlin_diag (d02tzc) can be used to ascertain details about the final mesh. nag_ode_bvp_coll_nlin_interp (d02tyc) can be used to compute the approximate solution anywhere on the interval a,b 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 nag_ode_bvp_coll_nlin_contin (d02txc) should be used between calls to nag_ode_bvp_coll_nlin_solve (d02tlc). This avoids the overhead of a complete initialization when the setup function nag_ode_bvp_coll_nlin_setup (d02tvc) is used. nag_ode_bvp_coll_nlin_contin (d02txc) allows the solution values computed in the previous call to nag_ode_bvp_coll_nlin_solve (d02tlc) to be used as an initial approximation for the solution in the next call to nag_ode_bvp_coll_nlin_solve (d02tlc).
You must specify the new initial mesh. The previous mesh can be obtained by a call to nag_ode_bvp_coll_nlin_diag (d02tzc). 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 functions 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
Arguments

1:     mxmesh IntegerInput
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 nag_ode_bvp_coll_nlin_setup (d02tvc).
2:     nmesh IntegerInput
On entry: the number of points to be used in the new initial mesh. It is strongly recommended that if this function is called that the suggested value (see below) for nmesh is used. In this case the arrays mesh and ipmesh returned by nag_ode_bvp_coll_nlin_diag (d02tzc) can be passed to this function without any modification.
Suggested value: n*+1/2, where n* is the number of mesh points used in the previous mesh as returned in the argument nmesh of nag_ode_bvp_coll_nlin_diag (d02tzc).
Constraint: 6nmeshmxmesh+1/2.
3:     mesh[mxmesh] const doubleInput
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 nag_ode_bvp_coll_nlin_diag (d02tzc).
Constraint: mesh[ij-1] < mesh[ij+1-1], for j=1,2,,nmesh-1, the values of i1,i2,,inmesh are defined in ipmesh.
mesh[i1-1] must contain the left boundary point, a, and mesh[inmesh-1] must contain the right boundary point, b, as specified in the previous call to nag_ode_bvp_coll_nlin_setup (d02tvc).
4:     ipmesh[mxmesh] const IntegerInput
On entry: specifies the points in mesh to be used as the new initial mesh. Let ij:j=1,2,,nmesh be the set of array indices of ipmesh such that ipmesh[ij-1]=1 or 2 and 1=i1<i2<<inmesh. Then mesh[ij-1] will be included in the new initial mesh.
If ipmesh[ij-1]=1, mesh[ij-1] will be a fixed point in the new initial mesh.
If ipmesh[k-1]=3 for any k, mesh[k-1] will not be included in the new mesh.
Suggested value: the argument ipmesh returned in a call to nag_ode_bvp_coll_nlin_diag (d02tzc).
Constraints:
  • ipmesh[k-1]=1, 2 or 3, for k=1,2,,inmesh;
  • ipmesh[0]=ipmesh[inmesh-1]=1.
5:     rcomm[dim] doubleCommunication Array
Note: the dimension, dim, 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 nag_ode_bvp_coll_nlin_solve (d02tlc).
On entry: this must be the same array as supplied to nag_ode_bvp_coll_nlin_solve (d02tlc) and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated functions.
6:     icomm[dim] IntegerCommunication Array
Note: the dimension, dim, 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 nag_ode_bvp_coll_nlin_solve (d02tlc).
On entry: this must be the same array as supplied to nag_ode_bvp_coll_nlin_solve (d02tlc) and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated functions.
7:     fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_CONVERGENCE_SOL
The solver function did not produce any results suitable for remeshing.
NE_INT
An element of ipmesh was set to -1 before nmesh elements containing 1 or 2 were detected.
ipmesh[i]-1, 1, 2 or 3 for some i.
On entry, ipmesh[0]=value.
Constraint: ipmesh[0]=1.
On entry, nmesh=value.
Constraint: nmesh6.
You have set the element of ipmesh corresponding to the last element of mesh to be included in the new mesh as value, which is not 1.
NE_INT_2
On entry, nmesh=value and mxmesh=value.
Constraint: nmeshmxmesh+1/2.
NE_INT_CHANGED
On entry, mxmesh=value and mxmesh=value in nag_ode_bvp_coll_nlin_setup (d02tvc).
Constraint: mxmesh=mxmesh in nag_ode_bvp_coll_nlin_setup (d02tvc).
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 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_MESH_ERROR
The first element of array mesh does not coincide with the left-hand end of the range previously specified.
First element of mesh: value; left-hand of the range: 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: value; right-hand end of the range: value.
NE_MISSING_CALL
The solver function does not appear to have been called.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_NOT_STRICTLY_INCREASING
The entries in mesh are not strictly increasing.

7
Accuracy

Not applicable.

8
Parallelism and Performance

nag_ode_bvp_coll_nlin_contin (d02txc) is not threaded in any implementation.

9
Further Comments

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.

10
Example

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 nag_ode_bvp_coll_nlin_solve (d02tlc), nag_ode_bvp_coll_nlin_setup (d02tvc), nag_ode_bvp_coll_nlin_interp (d02tyc) and nag_ode_bvp_coll_nlin_diag (d02tzc), 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 r,θ,z, in which the θ component of the corresponding velocity field behaves like r-n, the governing equations are
f+123-nff+n f 2+g2-sf = γ2 g+123-nfg+n-1gf-sg-1 = 0  
with boundary conditions
f0=f0=g0= 0,   f= 0,   g=γ,  
where s is the magnetic field strength, and γ is the Rossby number.
Some solutions of interest are for γ=1, small n and s0. An added complication is the infinite range, which we approximate by 0,L. We choose n=0.2 and first solve for L=60.0,s=0.24 using the initial approximations fx=-x2e-x and gx=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 nag_ode_bvp_coll_nlin_contin (d02txc) prior to a continuation call, that is only every second point of the preceding mesh is used.
The equations are first mapped onto 0,1 to yield
f = L3γ2-g2+L2sf-L123-nff+n f 2 g = L2sg-1-L123-nfg+n-1fg.  

10.1
Program Text

Program Text (d02txce.c)

10.2
Program Data

Program Data (d02txce.d)

10.3
Program Results

Program Results (d02txce.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −3 −2.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 0 10 20 30 40 50 60 Velocities Radial Distance from Magnetic Field Example Program Swirling Flow over Disc under Axial Magnetic Field using L=60 and Magnetic Field Strength, s=0.24 tangential velocity axial velocity gnuplot_plot_1 gnuplot_plot_2
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −5 −4 −3 −2 −1 0 1 2 0 20 40 60 80 100 120 Velocities Radial Distance from Magnetic Field Swirling Flow over Disc under Axial Magnetic Field Continued to L=120 and Magnetic Field Strength, s=0.144 tangential velocity axial velocity gnuplot_plot_1 gnuplot_plot_2
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −7 −6 −5 −4 −3 −2 −1 0 1 2 0 50 100 150 200 250 Velocities Radial Distance from Magnetic Field Swirling Flow over Disc under Axial Magnetic Field Continued to L=240 and Magnetic Field Strength, s=0.0864 tangential velocity axial velocity gnuplot_plot_1 gnuplot_plot_2