NAG FL Interface
d02tvf (bvp_​coll_​nlin_​setup)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

d02tvf is a setup routine which must be called prior to the first call of the nonlinear two-point boundary value solver d02tlf.

2 Specification

Fortran Interface
Subroutine d02tvf ( neq, m, nlbc, nrbc, ncol, tols, mxmesh, nmesh, mesh, ipmesh, rcomm, lrcomm, icomm, licomm, ifail)
Integer, Intent (In) :: neq, m(neq), nlbc, nrbc, ncol, mxmesh, nmesh, ipmesh(mxmesh), lrcomm, licomm
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: icomm(licomm)
Real (Kind=nag_wp), Intent (In) :: tols(neq), mesh(mxmesh)
Real (Kind=nag_wp), Intent (Out) :: rcomm(lrcomm)
C Header Interface
#include <nag.h>
void  d02tvf_ (const Integer *neq, const Integer m[], const Integer *nlbc, const Integer *nrbc, const Integer *ncol, const double tols[], const Integer *mxmesh, const Integer *nmesh, const double mesh[], const Integer ipmesh[], double rcomm[], const Integer *lrcomm, Integer icomm[], const Integer *licomm, Integer *ifail)
The routine may be called by the names d02tvf or nagf_ode_bvp_coll_nlin_setup.

3 Description

d02tvf and its associated routines (d02tlf, d02txf, 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 [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)=yi(x). 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=(y1,y2,,yn) and
z(y(x)) = (y1(x), y1(1) (x) ,, y1(m1-1) (x) ,y2(x),, yn(mn-1) (x) ) .  
See Section 9 for information on how boundary value problems of a more general nature can be treated.
d02tvf is used to specify an initial mesh, error requirements and other details. d02tlf is then used to solve the boundary value problem.
The solution routine d02tlf proceeds as follows. A modified Newton method is applied to the equations
yi (mi) (x)-fi(x,z(y(x)))= 0,   i= 1,,n  
and the boundary conditions. To solve these equations numerically the components yi are approximated by piecewise polynomials vij using a monomial basis on the jth mesh sub-interval. The coefficients of the polynomials vij form the unknowns to be computed. Collocation is applied at Gaussian points
vij (mi) (xjk)-fi(xjk,z(v(xjk)))=0,  i=1,2,,n,  
where xjk is the kth collocation point in the jth mesh sub-interval. Continuity at the mesh points is imposed, that is
vij(xj+1)-vi,j+1(xj+1)=0,  i=1,2,,n,  
where xj+1 is the right-hand end of the jth 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 d02tlf.
The solver attempts to satisfy the conditions
yi-vi (1.0+vi) tols(i),  i=1,2,,n, (1)
where vi is the approximate solution for the ith 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).
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
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

5 Arguments

1: neq Integer Input
On entry: n, the number of ordinary differential equations to be solved.
Constraint: neq1.
2: m(neq) Integer array Input
On entry: m(i) must contain mi, the order of the ith differential equation, for i=1,2,,n.
Constraint: 1m(i)4, for i=1,2,,n.
3: nlbc Integer Input
On entry: p, the number of left boundary conditions defined at the left-hand end, a (=mesh(1)).
Constraint: nlbc1.
4: nrbc Integer Input
On entry: q, the number of right boundary conditions defined at the right-hand end, b (=mesh(nmesh)).
Constraints:
  • nrbc1;
  • nlbc+nrbc=i=1nm(i).
5: ncol Integer Input
On entry: the number of collocation points to be used in each mesh sub-interval.
Constraint: mmaxncol7, where mmax=max(m(i)).
6: tols(neq) Real (Kind=nag_wp) array Input
On entry: tols(i) must contain the error requirement for the ith solution component.
Constraint: 100×machine precision<tols(i)<1.0, for i=1,2,,n.
7: mxmesh Integer Input
On entry: the maximum number of mesh points to be used during the solution process.
Constraint: mxmesh2×nmesh-1.
8: nmesh Integer Input
On entry: the number of points to be used in the initial mesh of the solution process.
Constraint: nmesh6.
9: mesh(mxmesh) Real (Kind=nag_wp) array Input
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].
mesh(1) must contain the left boundary point, a, and mesh(nmesh) must contain the right boundary point, b.
Constraint: mesh(i)<mesh(i+1), for i=1,2,,nmesh-1.
10: ipmesh(mxmesh) Integer array Input
On entry: ipmesh(i) specifies whether or not the initial mesh point defined in mesh(i), for i=1,2,,nmesh, should be a fixed point in all meshes computed during the solution process. The remaining elements of ipmesh need not be set.
ipmesh(i)=1
Indicates that mesh(i) should be a fixed point in all meshes.
ipmesh(i)=2
Indicates that mesh(i) is not a fixed point.
Constraints:
  • ipmesh(1)=1 and ipmesh(nmesh)=1, (i.e., the left and right boundary points, a and b, must be fixed points, in all meshes);
  • ipmesh(i)=1 or 2, for i=2,3,,nmesh-1.
11: rcomm(lrcomm) Real (Kind=nag_wp) array Communication Array
On exit: contains information for use by d02tlf. This must be the same array as will be supplied to d02tlf. The contents of this array must remain unchanged between calls.
12: lrcomm Integer Input
On entry: the dimension of the array rcomm as declared in the (sub)program from which d02tvf is called. If lrcomm=0, a communication array size query is requested. In this case there is an immediate return with communication array dimensions stored in icomm; icomm(1) contains the required dimension of rcomm, while icomm(2) contains the required dimension of icomm.
Constraint: lrcomm=0, or lrcomm51+neq+mxmesh×(2+m*+kn)-kn+mxmesh/2, where m*=i=1nm(i) and kn=ncol×neq.
13: icomm(licomm) Integer array Communication Array
On exit: contains information for use by d02tlf. This must be the same array as will be supplied to d02tlf. The contents of this array must remain unchanged between calls. If lrcomm=0, a communication array size query is requested. In this case, on immediate return, icomm(1) will contain the required dimension for rcomm while icomm(2) will contain the required dimension for icomm.
14: licomm Integer Input
On entry: the dimension of the array icomm as declared in the (sub)program from which d02tvf is called. If 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 lrcomm=0, licomm2;
  • otherwise licomm23+neq+mxmesh.
15: 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 -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry 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:
ifail=1
On entry, ipmesh(1) or ipmesh(nmesh) does not equal 1.
On entry, ipmesh(i)1 or 2 for some i.
On entry, licomm=value.
Constraint: licommvalue.
On entry, lrcomm=value.
Constraint: lrcomm=0 or lrcommvalue.
On entry, m(value)=value.
Constraint: 1m(i)4 for all i.
On entry, mxmesh=value and nmesh=value.
Constraint: mxmesh2×nmesh-1.
On entry, ncol=value and max(m(i))=value.
Constraint: max(m(i))ncol7.
On entry, neq=value.
Constraint: neq1.
On entry, nlbc=value, nrbc=value and sum(m(i))=value.
Constraint: nlbc+nrbc=sum(m(i)).
On entry, nlbc=value and nrbc=value.
Constraint: nlbc1 and nrbc1.
On entry, nmesh=value.
Constraint: nmesh6.
On entry, the elements of mesh are not strictly increasing.
On entry, tols(value)=value.
Constraint: tols(i)>value for all i.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
d02tvf 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:

9.1 Nonseparated 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
y1=f1(x,y1,y2) y2=f2(x,y1,y2)  
on [a,b] subject to the boundary conditions
g1(y1(a))=0 g2(y2(a),y2(b))=0.  
By adjoining the trivial ordinary differential equation
r=0,  
which implies r(a)=r(b), and letting r(b)=y2(b), say, we have a new system
y1 = f1(x,y1,y2) y2 = f2(x,y1,y2) r = 0,  
subject to the separated boundary conditions
g1(y1(a))=0 g2(y2(a),r(a))=0 y2(b)-r(b)=0.  
There is an obvious overhead in adjoining an extra differential equation: the system to be solved is increased in size.

9.2 Multipoint 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 (3) =f(t,y,y (1) ,y (2) )  on  [a,c]  
subject to the conditions
y(a)=A y(b)=B y(1)(c)=C  
where a<b<c. This can be transformed to the system
y1 (3) = f(t,y1,y1 (1) ,y1 (2) ) y2 (3) = f(t,y2,y2 (1) ,y2 (2) ) }   on ​ [0,1]  
where
y1 y   on   [a,b] y2 y   on   [b,c],  
subject to the boundary conditions
y1(0) = A y1(1) = B y2 (1) (1) = C y2(0) = B(from ​y1(1)=y2(0)) y1 (1) (1) = y2 (1) (0) y1 (2) (1) = y2 (2) (0).  
In this instance two of the resulting boundary conditions are nonseparated but they may next be treated as described above.

9.3 High 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 d02tvf and its related routines. For example suppose we have the sixth-order equation
y (6) =-y.  
Writing the variables y1=y and y2=y (4) we obtain the system
y1 (4) = y2 y2 (2) = -y1  
which has maximal order four, or writing the variables y1=y and y2=y (3) we obtain the system
y1 (3) = y2 y2 (3) = -y1  
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 y1 and y2. 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.4 Fixed Points and Singularities

The solver routine d02tlf 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.5 Numerical Jacobians

The solver routine d02tlf requires an external routine fjac to evaluate the partial derivatives of fi with respect to the elements of z(y) (=(y1,y11,,y1 (m1-1) ,y2,,yn (mn-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.

10 Example

The following example is used to illustrate the treatment of nonseparated boundary conditions. See also d02tlf, d02txf, d02tyf and d02tzf, 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
y1=μ-β(x)y1y3 y2=β(x)y1y3-y2/λ y3=y2/λ-y3/η  
subject to the periodic boundary conditions
yi(0)=yi(1) ,   i= 1,2,3.  
Here y1,y2 and y3 are respectively the proportions of susceptibles, infectives and latents to the whole population. λ (=0.0279 years) is the latent period, η (=0.01 years) is the infectious period and μ (=0.02) is the population birth rate. β(x)=β0(1.0+cos2πx) is the contact rate where β0=1575.0.
The nonseparated boundary conditions are treated as described in Section 9 by adjoining the trivial differential equations
y4=0 y5=0 y6=0  
that is y4,y5 and y6 are constants. The boundary conditions of the augmented system can then be posed in the separated form
y1(0)-y4(0)=0 y2(0)-y5(0)=0 y3(0)-y6(0)=0 y1(1)-y4(1)=0 y2(1)-y5(1)=0 y3(1)-y6(1)=0.  
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.

10.1 Program Text

Program Text (d02tvfe.f90)

10.2 Program Data

Program Data (d02tvfe.d)

10.3 Program Results

Program Results (d02tvfe.r)
GnuplotProduced by GNUPLOT 5.4 patchlevel 6 0.01 0.02 0.03 0.04 0.05 0.06 0.08 0 0.2 0.4 0.6 0.8 1 0.00000001 0.00000010 0.00000100 0.00001000 0.00010000 0.00100000 0.01000000 0.10000000 susceptibles infectives latents Susceptibles Infectives and Latents Time y1 y2 y3 Example Program Model of Spread of Measles