nag_ode_ivp_adams_setup (d02qw) is a setup function which must be called prior to the first call of
either of the integrators
nag_ode_ivp_adams_roots (d02qf) and
nag_ode_ivp_adams_roots_revcom (d02qg) and may be called prior to any continuation call to these functions.
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: |
lrwork and liwork were removed from the interface |
nag_ode_ivp_adams_setup (d02qw) permits initialization of the integration method and setting of optional inputs prior to any call of
nag_ode_ivp_adams_roots (d02qf) or
nag_ode_ivp_adams_roots_revcom (d02qg).
It must be called before the first call of
either of the functions
nag_ode_ivp_adams_roots (d02qf) or
nag_ode_ivp_adams_roots_revcom (d02qg) and it may be called before any continuation call of either of the functions
nag_ode_ivp_adams_roots (d02qf) or
nag_ode_ivp_adams_roots_revcom (d02qg).
None.
Not applicable.
Prior to a continuation call of the integration function, you may reset any of the optional parameters by calling
nag_ode_ivp_adams_setup (d02qw) with
. You may reset:
hmax |
to alter the maximum step size selection; |
rtol, atol |
to change the error requirements; |
maxstp |
to increase or decrease the number of attempted steps before an error exit is returned; |
onestp |
to change the operation mode of the integration function; |
crit, tcrit |
to alter the point beyond which integration must not be attempted; and |
neqg, alterg, sophst |
to alter the number and type of event functions, and also the search method. |
If the behaviour of the system of differential equations has altered and you wish to restart the integration method from the value of
t
output from the integration function (see
nag_ode_ivp_adams_roots (d02qf) and
nag_ode_ivp_adams_roots_revcom (d02qg)),
then
statef should be set to
and any of the optional parameters may be reset also. If you want to redefine the system of differential equations or start a new integration problem, then
statef should be set to
. Resetting
or
on normal continuation calls causes a restart in the integration process, which is very inefficient when not needed.
function d02qw_example
fprintf('d02qw example results\n\n');
neqf = int64(2);
neqg = int64(2);
vectol = true;
atol = [1e-06; 1e-06];
rtol = [0.0001; 0.0001];
onestp = false;
crit = true;
tcrit = 10;
hmax = 0;
maxstp = int64(0);
lrwork = 23*(1+neqf) + 14*neqg;
alterg = false;
sophst = true;
lrwork = 23*(1+neqf) + 14*neqg;
rwork = zeros(lrwork,1);
liwork = 21 + 4*neqg;
iwork = zeros(liwork, 1, 'int64');
[statefOut, altergOut, rwork, iwork, ifail] = ...
d02qw('Start', neqf, vectol, atol, rtol, onestp, crit, tcrit, hmax, ...
maxstp, neqg, alterg, sophst, rwork, iwork);
t = 0;
y = [0; 1];
tout = 10;
[t, y, root, rwork, iwork, ifail] = ...
d02qf(@fcn, t, y, tout, @g, neqg, rwork, iwork);
fprintf('Solution and root functions at t = %7.4f is:\n',t);
fprintf('\n y :');
fprintf('%10.4f',y);
yp = fcn(neqf,t,y);
fprintf('\n y'':');
fprintf('%10.4f',yp);
fprintf('\n g :');
for i=1:neqg
root = g(neqf,t,y,yp,i);
fprintf('%10.4f',root);
end
fprintf('\n');
function f = fcn(neqf, x, y)
f=zeros(neqf,1);
f(1)=y(2);
f(2)=-y(1);
function result = g(neqf, x, y, yp, k)
if (k == 1)
result = yp(1)+0.5;
else
result = y(1)-sqrt(0.5);
end