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_integ_diag (d02ny)

Purpose

nag_ode_ivp_stiff_integ_diag (d02ny) is a diagnostic function which you may call either after any user-specified exit or after a mid-integration error exit from 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

[hu, h, tcur, tolsf, nst, nre, nje, nqu, nq, niter, imxer, algequ, ifail] = d02ny(neq, neqmax, rwork, inform)
[hu, h, tcur, tolsf, nst, nre, nje, nqu, nq, niter, imxer, algequ, ifail] = nag_ode_ivp_stiff_integ_diag(neq, neqmax, rwork, inform)

Description

nag_ode_ivp_stiff_integ_diag (d02ny) permits you to inspect statistics produced by any integrator in this sub-chapter that has been set up a call to one of nag_ode_ivp_stiff_dassl (d02mv), nag_ode_ivp_stiff_bdf (d02nv) or nag_ode_ivp_stiff_blend (d02nw). These statistics concern the integration only.

References

See the D02M–N sub-chapter Introduction.

Parameters

Compulsory Input Parameters

1:     neq – int64int32nag_int scalar
The value used for the parameter neq when calling the integrator.
Constraint: neq1neq1.
2:     neqmax – int64int32nag_int scalar
The value used for the parameter neqmax when calling the integrator.
Constraint: neqmaxneqneqmaxneq.
3:     rwork(50 + 4 × neq50+4×neq) – double array
Contains information supplied by the integrator.
4:     inform(2323) – int64int32nag_int array
Contains information supplied by the integrator.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     hu – double scalar
The last successful step size.
2:     h – double scalar
The proposed next step size for continuing the integration.
3:     tcur – double scalar
tt, the value of the independent variable which the integrator has actually reached. tcur will always be at least as far as the output value of the argument tt in the direction of integration, but may be further (if overshooting and interpolation at tout was specified, e.g., see nag_ode_ivp_stiff_exp_fulljac (d02nb)).
4:     tolsf – double scalar
A tolerance scale factor, tolsf1.0tolsf1.0, which is computed when a request for too much accuracy is detected by the integrator (indicated by a return with ifail = 3ifail=3 or 1414). If itol is left unaltered but rtol and atol are uniformly scaled up by a factor of tolsf the next call to the integrator is deemed likely to succeed.
5:     nst – int64int32nag_int scalar
The number of steps taken in the integration so far.
6:     nre – int64int32nag_int scalar
The number of function or residual evaluations (fcn (e.g., see nag_ode_ivp_stiff_exp_fulljac (d02nb)) or resid (e.g., see nag_ode_ivp_stiff_imp_fulljac (d02ng)) calls) used in the integration so far.
7:     nje – int64int32nag_int scalar
The number of Jacobian evaluations used in the integration so far. This equals the number of matrix LULU decompositions.
8:     nqu – int64int32nag_int scalar
The order of the method last used (successfully) in the integration.
9:     nq – int64int32nag_int scalar
The proposed order of the method for continuing the integration.
10:   niter – int64int32nag_int scalar
The number of iterations performed in the integration so far by the nonlinear equation solver.
11:   imxer – int64int32nag_int scalar
The index of the component of largest magnitude in the weighted local error vector (ei / wi)(ei/wi), for i = 1,2,,neqi=1,2,,neq.
12:   algequ(neq) – logical array
algequ(i) = truealgequi=true if the iith equation integrated was detected to be algebraic, otherwise algequ(i) = falsealgequi=false. Note that when the integrators for explicit equations are being used, then algequ(i) = falsealgequi=false, for i = 1,2,,neqi=1,2,,neq.
13:   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
On entry,neq < 1neq<1,
orneqmax < 1neqmax<1,
orneq > neqmaxneq>neqmax.

Accuracy

Not applicable.

Further Comments

Statistics for sparse matrix linear algebra calls (if appropriate) may be determined by a call to nag_ode_ivp_stiff_sparjac_diag (d02nx).

Example

function nag_ode_ivp_stiff_integ_diag_example
neq = int64(3);
neqmax = int64(3);
t = 0;
tout = 10;
y = [1; 0; 0];
rwork = zeros(62,1);
rtol = [0.0001];
atol = [1e-07];
itol = int64(1);
inform = zeros(23, 1, 'int64');
ysave = zeros(3, 6);
wkjac = zeros(12, 1);
itask = int64(4);
itrace = int64(0);
[const, rwork, ifail] = ...
    nag_ode_ivp_stiff_bdf(int64(3), int64(6), int64(5), 'Newton', false, zeros(6), ...
    10, 1e-10, 10, 0, int64(200), int64(5), 'Average-L2', rwork);
[rwork, ifail] = ...
    nag_ode_ivp_stiff_fulljac_setup(int64(3), int64(3), 'Numerical', int64(12), rwork);
[t, y, ydot, rwork, inform, ysave, wkjac, ifail] = ...
    nag_ode_ivp_stiff_exp_fulljac(t, tout, y, rwork, rtol, atol, itol, inform, ...
    @fcn, ysave, @jac, wkjac, 'nag_ode_ivp_stiff_exp_fulljac_dummy_monit', itask, itrace);
[hu, h, tcur, tolsf, nst, nre, nje, nqu, nq, niter, imxer, algequ, ifail] = ...
    nag_ode_ivp_stiff_integ_diag(neq, neqmax, rwork, inform)

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, p)
% Evaluate the Jacobian.
p = zeros(neq, neq);
hxd = h*d;
p(1,1) = 1.0d0 - hxd*(-0.04d0);
p(1,2) = -hxd*(1.0d4*y(3));
p(1,3) = -hxd*(1.0d4*y(2));
p(2,1) = -hxd*(0.04d0);
p(2,2) = 1.0d0 - hxd*(-1.0d4*y(3)-6.0d7*y(2));
p(2,3) = -hxd*(-1.0d4*y(2));
p(3,2) = -hxd*(6.0d7*y(2));
p(3,3) = 1.0d0 - hxd*(0.0d0);
 

hu =

    0.5187


h =

    0.5187


tcur =

    10


tolsf =

   9.0311e-13


nst =

                   55


nre =

                  132


nje =

                   17


nqu =

                    3


nq =

                    3


niter =

                   79


imxer =

                    3


algequ =

     0
     0
     0


ifail =

                    0


function d02ny_example
neq = int64(3);
neqmax = int64(3);
t = 0;
tout = 10;
y = [1; 0; 0];
rwork = zeros(62,1);
rtol = [0.0001];
atol = [1e-07];
itol = int64(1);
inform = zeros(23, 1, 'int64');
ysave = zeros(3, 6);
wkjac = zeros(12, 1);
itask = int64(4);
itrace = int64(0);
[const, rwork, ifail] = ...
    d02nv(int64(3), int64(6), int64(5), 'Newton', false, zeros(6), ...
    10, 1e-10, 10, 0, int64(200), int64(5), 'Average-L2', rwork);
[rwork, ifail] = d02ns(int64(3), int64(3), 'Numerical', int64(12), rwork);
[t, y, ydot, rwork, inform, ysave, wkjac, ifail] = ...
    d02nb(t, tout, y, rwork, rtol, atol, itol, inform, ...
    @fcn, ysave, @jac, wkjac, 'd02nby', itask, itrace);
[hu, h, tcur, tolsf, nst, nre, nje, nqu, nq, niter, imxer, algequ, ifail] = ...
    d02ny(neq, neqmax, rwork, inform)

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, p)
% Evaluate the Jacobian.
p = zeros(neq, neq);
hxd = h*d;
p(1,1) = 1.0d0 - hxd*(-0.04d0);
p(1,2) = -hxd*(1.0d4*y(3));
p(1,3) = -hxd*(1.0d4*y(2));
p(2,1) = -hxd*(0.04d0);
p(2,2) = 1.0d0 - hxd*(-1.0d4*y(3)-6.0d7*y(2));
p(2,3) = -hxd*(-1.0d4*y(2));
p(3,2) = -hxd*(6.0d7*y(2));
p(3,3) = 1.0d0 - hxd*(0.0d0);
 

hu =

    0.5187


h =

    0.5187


tcur =

    10


tolsf =

   9.0311e-13


nst =

                   55


nre =

                  132


nje =

                   17


nqu =

                    3


nq =

                    3


niter =

                   79


imxer =

                    3


algequ =

     0
     0
     0


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