NAG FL Interface
d02tyf (bvp_​coll_​nlin_​interp)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

d02tyf interpolates on the solution of a general two-point boundary value problem computed by d02tlf.

2 Specification

Fortran Interface
Subroutine d02tyf ( x, y, neq, mmax, rcomm, icomm, ifail)
Integer, Intent (In) :: neq, mmax, icomm(*)
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: x
Real (Kind=nag_wp), Intent (Inout) :: rcomm(*)
Real (Kind=nag_wp), Intent (Out) :: y(neq,mmax)
C Header Interface
#include <nag.h>
void  d02tyf_ (const double *x, double y[], const Integer *neq, const Integer *mmax, double rcomm[], const Integer icomm[], Integer *ifail)
The routine may be called by the names d02tyf or nagf_ode_bvp_coll_nlin_interp.

3 Description

d02tyf and its associated routines (d02tlf, d02tvf, d02txf and d02tzf) solve the two-point boundary value problem for a nonlinear mixed order 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) ) .  
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 and other details of the solution procedure, and d02tyf can be used to compute the approximate solution anywhere on the interval [a,b] using interpolation.
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
Grossman C (1992) Enclosures of the solution of the Thomas–Fermi equation by monotone discretization J. Comput. Phys. 98 26–32
Keller H B (1992) Numerical Methods for Two-point Boundary-value Problems Dover, New York

5 Arguments

1: x Real (Kind=nag_wp) Input
On entry: x, the independent variable.
Constraint: axb, i.e., not outside the range of the original mesh specified in the initialization call to d02tvf.
2: y(neq,mmax) Real (Kind=nag_wp) array Output
On exit: y(i,j) contains an approximation to yi (j) (x), for i=1,2,,neq and j=0,1,,mi-1. The remaining elements of y (where mi<mmax) are initialized to 0.0.
3: neq Integer Input
On entry: the number of differential equations.
Constraint: neq must be the same value as supplied to d02tvf.
4: mmax Integer Input
On entry: the maximal order of the differential equations, max(mi), for i=1,2,,neq.
Constraint: mmax must contain the maximum value of the components of the argument m as supplied to d02tvf.
5: rcomm(*) 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: icomm(*) 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: 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 -1 is recommended since useful values can be provided in some output arguments even when ifail0 on exit. 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:
Note: in some cases d02tyf may return useful information.
ifail=1
On entry, mmax=value and maxm(i)=value in d02tvf.
Constraint: mmax=maxm(i) in d02tvf.
On entry, neq=value and neq=value in d02tvf.
Constraint: neq=neq in d02tvf.
On entry, x=value.
Constraint: xvalue.
On entry, x=value.
Constraint: xvalue.
The solver routine did not produce any results suitable for interpolation.
The solver routine does not appear to have been called.
ifail=2
The solver routine did not converge to a suitable solution.
A converged intermediate solution has been used.
Interpolated values should be treated with caution.
The solver routine did not satisfy the error requirements.
Interpolated values should be treated with caution.
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

If d02tyf returns the value ifail=0, the computed values of the solution components yi should be of similar accuracy to that specified by the argument tols of d02tvf. Note that during the solution process the error in the derivatives yi(j), for j=1,2,,mi-1, has not been controlled and that the derivative values returned by d02tyf are computed via differentiation of the piecewise polynomial approximation to yi. See also Section 9.

8 Parallelism and Performance

d02tyf 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.

9 Further Comments

If d02tyf returns the value ifail=2 in this routine and ifail=5 in d02tlf, then the accuracy of the interpolated values may be proportional to the quantity ermx as returned by d02tzf.
If d02tlf returned a value for ifail other than ifail=0, then nothing can be said regarding either the quality or accuracy of the values computed by d02tyf.

10 Example

The following example is used to illustrate that a system with singular coefficients can be treated without modification of the system definition. See also d02tlf, d02tvf, d02txf and d02tzf, for the illustration of other facilities.
Consider the Thomas–Fermi equation used in the investigation of potentials and charge densities of ionized atoms. See Grossman (1992), for example, and the references therein. The equation is
y=x-1/2y3/2  
with boundary conditions
y(0)= 1,   y(a)= 0,   a> 0.  
The coefficient x-1/2 implies a singularity at the left-hand boundary x=0.
We use the initial approximation y(x)=1-x/a, which satisfies the boundary conditions, on a uniform mesh of six points. For illustration we choose a=1, as in Grossman (1992). Note that in ffun and fjac (see d02tlf) we have taken the precaution of setting the function value and Jacobian value to 0.0 in case a value of y becomes negative, although starting from our initial solution profile this proves unnecessary during the solution phase. Of course the true solution y(x) is positive for all x<a.

10.1 Program Text

Program Text (d02tyfe.f90)

10.2 Program Data

Program Data (d02tyfe.d)

10.3 Program Results

Program Results (d02tyfe.r)
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −2 −1.5 −1 −0.5 0 0.5 1 0 0.2 0.4 0.6 0.8 1 Effective Nuclear Charge Relative Distance Example Program Thomas-Fermi Equation for Determining Effective Nuclear Charge in Heavy Atoms nuclear charge charge gradient gnuplot_plot_1 gnuplot_plot_2