hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_ode_ivp_stiff_contin (d02nz)

Purpose

nag_ode_ivp_stiff_contin (d02nz) is a setup function which must be called, if optional inputs need resetting, prior to a continuation call to any of those integrators in sub-chapter D02M–N that use methods set up by calls to nag_ode_ivp_stiff_dassl (d02mv), nag_ode_ivp_stiff_bdf (d02nv) or nag_ode_ivp_stiff_blend (d02nw).

Syntax

[rwork, ifail] = d02nz(neqmax, tcrit, h, hmin, hmax, maxstp, mxhnil, rwork)
[rwork, ifail] = nag_ode_ivp_stiff_contin(neqmax, tcrit, h, hmin, hmax, maxstp, mxhnil, rwork)

Description

nag_ode_ivp_stiff_contin (d02nz) is provided to permit you to reset many of the parameters which control the integration ‘on the fly’, that is in conjunction with the interrupt facility permitted through the parameter itask of the integrator (e.g., see nag_ode_ivp_stiff_exp_fulljac (d02nb)). In addition to a number of parameters which you can set initially through one of the integrator setup functions, the step size to be attempted on the next step may be changed.

References

See the D02M–N sub-chapter Introduction.

Parameters

Compulsory Input Parameters

1:     neqmax – int64int32nag_int scalar
The value used for the parameter neqmax when calling the integrator.
Constraint: neqmax1neqmax1.
2:     tcrit – double scalar
A point beyond which integration must not be attempted. The use of tcrit is described under the parameter itask in the specification for the integrator (e.g., see nag_ode_ivp_stiff_exp_fulljac (d02nb)). A value, 0.00.0 say, must be specified even if itask subsequently specifies that tcrit will not be used.
3:     h – double scalar
The next step size to be attempted. Set h = 0.0h=0.0 if the current value of h is not to be changed.
4:     hmin – double scalar
The minimum absolute step size to be allowed. Set hmin = 0.0hmin=0.0 if this option is not required. Set hmin < 0.0hmin<0.0 if the current value of hmin is not to be changed.
5:     hmax – double scalar
The maximum absolute step size to be allowed. Set hmax = 0.0hmax=0.0 if this option is not required. Set hmax < 0.0hmax<0.0 if the current value of hmax is not to be changed.
6:     maxstp – int64int32nag_int scalar
The maximum number of steps to be attempted during one call to the integrator after which it will return with ifail = 2ifail=2 (see nag_ode_ivp_stiff_exp_bandjac (d02nc)). Set maxstp = 0maxstp=0 if this option is not required. Set maxstp < 0maxstp<0 if the current value of maxstp is not to be changed.
7:     mxhnil – int64int32nag_int scalar
The maximum number of warnings printed (if itrace0itrace0, e.g., see nag_ode_ivp_stiff_exp_fulljac (d02nb)) per problem when t + h = tt+h=t on a step (h = ​ current step sizeh=​ current step size). If mxhnil0mxhnil0, a default value of 1010 is assumed.
8:     rwork(50 + 4 × neqmax50+4×neqmax) – double array
This must be the same workspace array as the array rwork supplied to the integrator. It is used to pass information from the integrator to nag_ode_ivp_stiff_contin (d02nz) and therefore its contents must not be changed before calling nag_ode_ivp_stiff_contin (d02nz).

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     rwork(50 + 4 × neqmax50+4×neqmax) – double array
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
neqmax < 1neqmax<1.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_ode_ivp_stiff_contin_example
neqmax = int64(3);
tcrit = 0;
h = 0.7;
hmin = 1e-10;
hmax = 10;
maxstp = int64(200);
mxhnil = int64(5);
rwork = zeros(62,1);
t = 0;
tout = 5;
y = [1; 0; 0];
rtol = [0.0001];
atol = [1e-07; 1e-08; 1e-07];
itol = int64(2);
inform = zeros(32,1,'int64');
ysave = zeros(3, 14);
wkjac = zeros(15, 1);
jacpvt = zeros(3, 1, 'int64');
itask = int64(1);
itrace = int64(0);
[const, rwork, ifail] = ...
    nag_ode_ivp_stiff_blend(int64(3), int64(14), int64(11), zeros(6), 0, 1e-10, 10, 0, ...
    int64(200), int64(5), 'Average-L2', rwork);
[rwork, ifail] = ...
    nag_ode_ivp_stiff_bandjac_setup(int64(3), int64(3), 'Analytical', int64(1), int64(2), int64(15), ...
    int64(3), rwork);
[t, y, ydot, rwork, inform, ysave, wkjac, jacpvt, ifail] = ...
    nag_ode_ivp_stiff_exp_bandjac(t, tout, y, rwork, rtol, atol, itol, inform, @fcn, ...
    ysave, @jac, wkjac, jacpvt, 'nag_ode_ivp_stiff_exp_fulljac_dummy_monit', itask, itrace);
[rwork, ifail] = ...
    nag_ode_ivp_stiff_contin(neqmax, tcrit, h, hmin, hmax, maxstp, mxhnil, rwork)

function [f, ires] = fcn(neq, t, y, ires)
% Evaluate derivative vector.
f = zeros(3,1);
f(1) = -0.04d0*y(1) + 1.0d4*y(2)*y(3);
f(2) = 0.04d0*y(1) - 1.0d4*y(2)*y(3) - 3.0d7*y(2)*y(2);
f(3) = 3.0d7*y(2)*y(2);
function p = jac(neq, t, y, h, d, ml, mu, pIn)
% Evaluate the Jacobian.
p = zeros(ml+mu+1, neq);
hxd = h*d;
p(1,1) = 1.0d0 - hxd*(-0.04d0);
p(2,1) = -hxd*(1.0d4*y(3));
p(3,1) = -hxd*(1.0d4*y(2));
p(1,2) = -hxd*(0.04d0);
p(2,2) = 1.0d0 - hxd*(-1.0d4*y(3)-6.0d7*y(2));
p(3,2) = -hxd*(-1.0d4*y(2));
p(1,3) = -hxd*(6.0d7*y(2));
p(2,3) = 1.0d0 - hxd*(0.0d0);
 

rwork =

   1.0e+07 *

         0
    0.0000
    0.0000
         0
         0
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0001
    0.0000
    0.0000
    0.0000
    0.0000
         0
         0
         0
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
         0
    0.0000
         0
         0
         0
         0
         0
    0.0000
    0.0000
         0
    0.0000
         0
    0.0011
    8.2671
    0.0092
    0.0000
    0.0000
   -0.0000
    0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
    0.0000


ifail =

                    0


function d02nz_example
neqmax = int64(3);
tcrit = 0;
h = 0.7;
hmin = 1e-10;
hmax = 10;
maxstp = int64(200);
mxhnil = int64(5);
rwork = zeros(62,1);
t = 0;
tout = 5;
y = [1; 0; 0];
rtol = [0.0001];
atol = [1e-07; 1e-08; 1e-07];
itol = int64(2);
inform = zeros(32,1,'int64');
ysave = zeros(3, 14);
wkjac = zeros(15, 1);
jacpvt = zeros(3, 1, 'int64');
itask = int64(1);
itrace = int64(0);
[const, rwork, ifail] = ...
    d02nw(int64(3), int64(14), int64(11), zeros(6), 0, 1e-10, 10, 0, ...
    int64(200), int64(5), 'Average-L2', rwork);
[rwork, ifail] = ...
    d02nt(int64(3), int64(3), 'Analytical', int64(1), int64(2), int64(15), ...
    int64(3), rwork);
[t, y, ydot, rwork, inform, ysave, wkjac, jacpvt, ifail] = ...
    d02nc(t, tout, y, rwork, rtol, atol, itol, inform, @fcn, ...
    ysave, @jac, wkjac, jacpvt, 'd02nby', itask, itrace);
[rwork, ifail] = d02nz(neqmax, tcrit, h, hmin, hmax, maxstp, mxhnil, rwork)

function [f, ires] = fcn(neq, t, y, ires)
% Evaluate derivative vector.
f = zeros(3,1);
f(1) = -0.04d0*y(1) + 1.0d4*y(2)*y(3);
f(2) = 0.04d0*y(1) - 1.0d4*y(2)*y(3) - 3.0d7*y(2)*y(2);
f(3) = 3.0d7*y(2)*y(2);
function p = jac(neq, t, y, h, d, ml, mu, pIn)
% Evaluate the Jacobian.
p = zeros(ml+mu+1, neq);
hxd = h*d;
p(1,1) = 1.0d0 - hxd*(-0.04d0);
p(2,1) = -hxd*(1.0d4*y(3));
p(3,1) = -hxd*(1.0d4*y(2));
p(1,2) = -hxd*(0.04d0);
p(2,2) = 1.0d0 - hxd*(-1.0d4*y(3)-6.0d7*y(2));
p(3,2) = -hxd*(-1.0d4*y(2));
p(1,3) = -hxd*(6.0d7*y(2));
p(2,3) = 1.0d0 - hxd*(0.0d0);
 

rwork =

   1.0e+07 *

         0
    0.0000
    0.0000
         0
         0
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0001
    0.0000
    0.0000
    0.0000
    0.0000
         0
         0
         0
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
         0
    0.0000
         0
         0
         0
         0
         0
    0.0000
    0.0000
         0
    0.0000
         0
    0.0011
    8.2671
    0.0092
    0.0000
    0.0000
   -0.0000
    0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
    0.0000


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013