# NAG CL Interfaced02mwc (dae_​dassl_​setup)

## 1Purpose

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

## 2Specification

 #include
 void d02mwc (Integer neq, Integer maxord, Nag_EvaluateJacobian jceval, double hmax, double h0, Nag_Boolean vector_tol, Integer icom[], Integer licom, double com[], Integer lcom, NagError *fail)
The function may be called by the names: d02mwc, nag_ode_dae_dassl_setup or nag_dae_ivp_dassl_setup.

## 3Description

This integrator setup function must be called before the first call to the integrator d02nec. d02mwc 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.

None.

## 5Arguments

1: $\mathbf{neq}$Integer Input
On entry: the number of differential-algebraic equations to be solved.
Constraint: ${\mathbf{neq}}\ge 1$.
2: $\mathbf{maxord}$Integer Input
On entry: the maximum order to be used for the BDF method. Orders up to 5th order are available; setting ${\mathbf{maxord}}>5$ means that the maximum order used will be $5$.
Constraint: $1\le {\mathbf{maxord}}$.
3: $\mathbf{jceval}$Nag_EvaluateJacobian Input
On entry: specifies the technique to be used to compute the Jacobian.
${\mathbf{jceval}}=\mathrm{Nag_NumericalJacobian}$
The Jacobian is to be evaluated numerically by the integrator.
${\mathbf{jceval}}=\mathrm{Nag_AnalyticalJacobian}$
You must supply a function to evaluate the Jacobian on a call to the integrator.
Constraint: ${\mathbf{jceval}}=\mathrm{Nag_NumericalJacobian}$ or $\mathrm{Nag_AnalyticalJacobian}$.
4: $\mathbf{hmax}$double Input
On entry: the maximum absolute step size to be allowed. Set ${\mathbf{hmax}}=0.0$ if this option is not required.
Constraint: ${\mathbf{hmax}}\ge 0.0$.
5: $\mathbf{h0}$double Input
On entry: the step size to be attempted on the first step. Set ${\mathbf{h0}}=0.0$ if the initial step size is calculated internally.
6: $\mathbf{vector_tol}$Nag_Boolean Input
On entry: a value to indicate the form of the local error test.
${\mathbf{vector_tol}}=\mathrm{Nag_FALSE}$
rtol and atol are single element vectors.
${\mathbf{vector_tol}}=\mathrm{Nag_TRUE}$
rtol and atol are vectors. This should be chosen if you want to apply different tolerances to each equation in the system.
See d02nec.
Note: the tolerances must either both be single element vectors or both be vectors of length neq.
7: $\mathbf{icom}\left[{\mathbf{licom}}\right]$Integer Communication Array
On exit: used to communicate details of the task to be carried out to the integration function d02nec.
8: $\mathbf{licom}$Integer Input
On entry: the dimension of the array icom.
Constraint: ${\mathbf{licom}}\ge {\mathbf{neq}}+50$.
9: $\mathbf{com}\left[{\mathbf{lcom}}\right]$double Communication Array
On exit: used to communicate problem parameters to the integration function d02nec. This must be the same communication array as the array com supplied to d02nec. In particular, the values of hmax and h0 are contained in com.
10: $\mathbf{lcom}$Integer Input
On entry: the dimension of the array com.
Constraints:
the array com must be large enough for the requirements of d02nec. That is:
• if the system Jacobian is dense, ${\mathbf{lcom}}\ge 40+\left({\mathbf{maxord}}+4\right)×{\mathbf{neq}}+{{\mathbf{neq}}}^{2}$;
• if the system Jacobian is banded, ${\mathbf{lcom}}\ge 40+\left({\mathbf{maxord}}+4\right)×{\mathbf{neq}}+\left(2×{\mathbf{ml}}+{\mathbf{mu}}+1\right)×{\mathbf{neq}}+2×\phantom{\rule{0ex}{0ex}}\left({\mathbf{neq}}/\left({\mathbf{ml}}+{\mathbf{mu}}+1\right)+1\right)$.
Here ml and mu are the lower and upper bandwidths respectively that are to be specified in a subsequent call to d02npc.
11: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT_ARG_GT
On entry, ${\mathbf{licom}}=〈\mathit{\text{value}}〉$ and ${\mathbf{neq}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{licom}}\ge 50+{\mathbf{neq}}$.
NE_INT_ARG_LT
On entry, ${\mathbf{maxord}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{maxord}}\ge 1$.
On entry, ${\mathbf{neq}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{neq}}\ge 1$.
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 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL_ARG_LT
On entry, ${\mathbf{hmax}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{hmax}}\ge 0.0$.

Not applicable.

## 8Parallelism and Performance

d02mwc is not threaded in any implementation.

None.

## 10Example

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}^{\prime }$, ${y}^{\prime }$, ${u}^{\prime }$, ${v}^{\prime }$ and using ${x}^{2}+{y}^{2}-1=0$, the corresponding DAE system includes the differential equations and the algebraic equation in $\lambda$:
 $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$.

### 10.1Program Text

Program Text (d02mwce.c)

None.

### 10.3Program Results

Program Results (d02mwce.r)