D02MWF (PDF version)
D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

D02MWF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

D02MWF is a setup routine which must be called prior to the integrator D02NEF, if the DASSL implementation of Backward Differentiation Formulae (BDF) is to be used.

2  Specification

SUBROUTINE D02MWF ( NEQ, MAXORD, JCEVAL, HMAX, H0, ITOL, ICOM, LICOM, COM, LCOM, IFAIL)
INTEGER  NEQ, MAXORD, ITOL, ICOM(LICOM), LICOM, LCOM, IFAIL
REAL (KIND=nag_wp)  HMAX, H0, COM(LCOM)
CHARACTER(1)  JCEVAL

3  Description

This integrator setup routine must be called before the first call to the integrator D02NEF. This setup routine D02MWF permits you to define options for the DASSL integrator, such as: whether the Jacobian is to be provided or is to be approximated numerically by the integrator; the initial and maximum step-sizes for the integration; whether relative and absolute tolerances are system wide or per system equation; and the maximum order of BDF method permitted.

4  References

None.

5  Parameters

1:     NEQ – INTEGERInput
On entry: the number of differential-algebraic equations to be solved.
Constraint: NEQ1.
2:     MAXORD – INTEGERInput
On entry: the maximum order to be used for the BDF method. Orders up to 5th order are available; setting MAXORD>5 means that the maximum order used will be 5.
Constraint: 1MAXORD.
3:     JCEVAL – CHARACTER(1)Input
On entry: specifies the technique to be used to compute the Jacobian.
JCEVAL='N'
The Jacobian is to be evaluated numerically by the integrator.
JCEVAL='A'
You must supply a subroutine to evaluate the Jacobian on a call to the integrator.
Only the first character of the actual paramater JCEVAL is passed to D02MWF; hence it is permissible for the actual argument to be more descriptive, e.g., ‘Numerical’ or ‘Analytical’, on a call to D02MWF.
Constraint: JCEVAL='N' or 'A'.
4:     HMAX – REAL (KIND=nag_wp)Input
On entry: the maximum absolute step size to be allowed. Set HMAX=0.0 if this option is not required.
Constraint: HMAX0.0.
5:     H0 – REAL (KIND=nag_wp)Input
On entry: the step size to be attempted on the first step. Set H0=0.0 if the initial step size is calculated internally.
6:     ITOL – INTEGERInput
On entry: a value to indicate the form of the local error test.
ITOL=0
RTOL and ATOL are single element vectors.
ITOL=1
RTOL and ATOL are vectors. This should be chosen if you want to apply different tolerances to each equation in the system.
See D02NEF.
Note: the tolerances must either both be single element vectors or both be vectors of length NEQ.
Constraint: ITOL=0 or 1.
7:     ICOM(LICOM) – INTEGER arrayCommunication Array
On exit: used to communicate details of the task to be carried out to the integration routine D02NEF.
8:     LICOM – INTEGERInput
On entry: the dimension of the array ICOM as declared in the (sub)program from which D02MWF is called.
Constraint: LICOMNEQ+50.
9:     COM(LCOM) – REAL (KIND=nag_wp) arrayCommunication Array
On exit: used to communicate problem parameters to the integration routine D02NEF. This must be the same communication array as the array COM supplied to D02NEF. In particular, the values of HMAX and H0 are contained in COM.
10:   LCOM – INTEGERInput
On entry: the dimension of the array COM as declared in the (sub)program from which D02MWF is called.
Constraints:
the array COM must be large enough for the requirements of D02NEF. That is:
  • if the system Jacobian is dense, LCOM 40 + MAXORD+4 × NEQ + NEQ2 ;
  • if the system Jacobian is banded, LCOM 40 + MAXORD+4 × NEQ + 2×ML+MU+1 × NEQ + 2 × NEQ / ML + MU + 1 + 1 .
Here ML and MU are the lower and upper bandwidths respectively that are to be specified in a subsequent call to D02NPF.
11:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. 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,NEQ<1.
IFAIL=2
On entry,MAXORD<1,
orMAXORD>5.
IFAIL=3
On entry,JCEVAL'N' or 'A'.
IFAIL=4
On entry,HMAX<0.0.
IFAIL=6
On entry,ITOL0 or 1.
IFAIL=8
On entry,LICOM<NEQ+50.

7  Accuracy

Not applicable.

8  Further Comments

None.

9  Example

This example solves the plane pendulum problem, defined by the following equations:
x = u y = v u = -λx v = -λy-1 x2+y2 = 1.
Differentiating the algebraic constraint once, a new algebraic constraint is obtained
xu+yv=0 .
Differentiating the algebraic constraint one more time, substituting for x, y, u, v and using x2+y2-1=0, the corresponding DAE system includes the differential equations and the algebraic equation in λ:
u2 + v2 - λ - y = 0 .
We solve the reformulated DAE system
y1 = y3 y2 = y4 y3 = -y5×y1 y4 = -y5×y2-1 y32 + y42 - y5 - y2 = 0.
For our experiments, we take consistent initial values
y10 = 1 , ​ y20 = 0 , ​ y30 = 0 , ​ y40 = 1 ​ and ​ y50 = 1
at t=0.

9.1  Program Text

Program Text (d02mwfe.f90)

9.2  Program Data

Program Data (d02mwfe.d)

9.3  Program Results

Program Results (d02mwfe.r)


D02MWF (PDF version)
D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012