1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
17 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="dasrt" xml:lang="en">
19 <refname>dasrt</refname>
20 <refpurpose>DAE solver with zero crossing</refpurpose>
24 <synopsis>[r,nn,[,hd]] = dasrt(x0,t0,t [,atol,[rtol]],res [,jac],ng, surf [,info] [,hd])</synopsis>
27 <title>Arguments</title>
33 is either <literal>y0</literal> (<literal>ydot0</literal> is
34 estimated by <literal>dassl</literal> with zero as first estimate)
35 or the matrix <literal>[y0 ydot0]</literal>.
36 <literal>g(t,y0,ydot0)</literal> must be equal to zero. If you only
37 know an estimate of <literal>ydot0</literal> set
38 <literal>info(7)=1</literal>.
44 <para>a real column vector of initial conditions.</para>
50 <para>a real column vector of the time derivative of
51 <literal>y</literal> at <literal>t0</literal> (may be an
62 <para>a real number, it is the initial instant.</para>
68 <para>a real scalar or vector. Gives instants for which you want the
69 solution. Note that you can get solution at each dassl's step point
70 by setting <literal>info(2)=1</literal>.
78 a vector with two entries <literal>[times num]</literal>
79 <literal>times</literal> is the value of the time at which the
80 surface is crossed, <literal>num</literal> is the number of the
86 <term>atol, rtol</term>
88 <para>real scalars or column vectors of same size as
89 <literal>y</literal> or both of size 1. <literal>atol, rtol</literal> give respectively
90 absolute and relative error tolerances of solution. If vectors, the
91 tolerances are specified for each component of
100 <link linkend="external">external</link> (function or list or string). Computes the value of
101 <literal>g(t,y,ydot)</literal>. It may be :
105 <para>A Scilab function.</para>
106 <para>Its syntax must be
107 <literal>[r,ires]=res(t,y,ydot)</literal> and
108 <literal>res</literal> must return the residue
109 <literal>r=g(t,y,ydot)</literal> and error flag
110 <literal>ires</literal>. <literal>ires = 0</literal> if
111 <literal>res</literal> succeeds to compute <literal>r</literal>,
112 <literal>=-1</literal> if residue is locally not defined for
113 <literal>(t,y,ydot)</literal>, <literal>=-2</literal> if
114 parameters are out of admissible range.
119 <para>This form allows to pass parameters other than t,y,ydot to
120 the function. It must be as follows:
125 <para>where the syntax of the function
126 <literal>res</literal> is now
129 r = res(t,y,ydot,x1,x2,...)
132 <literal>res</literal> still returns
133 <literal>r=g(t,y,ydot)</literal> as a function of
134 <literal>(t,y,ydot,x1,x2,...)</literal>.
138 Warning: this form must not be used if there is no extra
139 argument to pass to the function.
144 <para>A string.</para>
145 <para>It must refer to the name of a C or Fortran subroutine
148 <para>In C The syntax must be:</para>
150 void res(double *t, double y[], double yd[], double r[],
151 int *ires, double rpar[], int ipar[])
153 <para>In Fortran it must be:</para>
155 subroutine res(t,y,yd,r,ires,rpar,ipar)
156 double precision t, y(*),yd(*),r(*),rpar(*)
160 The <literal>rpar</literal> and <literal>ipar</literal> arrays must be present but cannot be
171 <link linkend="external">external</link> (function or list or string). Computes the value of
172 <literal>dg/dy + cj*dg/dydot</literal> for a given value of parameter
173 <literal>cj</literal>.
177 <para>A Scilab function.</para>
178 <para>Its syntax must be
179 <literal>r=jac(t,y,ydot,cj)</literal> and the
180 <literal>jac</literal> function must return
181 <literal>r=dg(t,y,ydot)/dy+cj*dg(t,y,ydot)/dydot</literal> where
182 <literal>cj</literal> is a real scalar.
187 <para>It must be as follows</para>
191 <para>where the syntax of the function
192 <literal>jac</literal> is now
195 r = jac(t,y,ydot,cj,x1,x2,...)
198 <literal>jac</literal> still returns
199 <literal>dg/dy + cj*dg/dydot</literal> as a function of
200 <literal>(t,y,ydot,cj,x1,x2,...)</literal>.
204 <para>A character string.</para>
205 <para>It must refer to the name of a Fortran subroutine linked
208 <para>In C The syntax must be:</para>
210 void jac(double *t, double y[], double yd[], double pd[],
211 double *cj, double rpar[], int ipar[])
213 <para>In Fortran it must be:</para>
215 subroutine jac(t,y,yd,pd,cj,rpar,ipar)
216 double precision t, y(*),yd(*),pd(*),cj,rpar(*)
227 <link linkend="external">external</link> (function or list or string). Computes the value of
228 the column vector <literal>surf(t,y)</literal> with
229 <literal>ng</literal> components. Each component defines a surface.
230 It may be defined by:
234 <para>A Scilab function.</para>
235 <para>Its syntax must be
236 <literal>surf(t,y)</literal>
241 <para>It must be as follows</para>
245 <para>where the syntax of the function
246 <literal>surf</literal> is now
249 r = surf(t,y,x1,x2,...)
253 <para>A character string.</para>
254 <para>It must refer to the name of a Fortran subroutine linked
257 <para>In C the syntax must be:</para>
259 void surf(int *ny, double *t, double y[], int *ng, double gout[])
261 <para>In Fortran it must be:</para>
263 subroutine surf(ny,t,y,ng,gout)
264 double precision t, y(*),gout(*)
275 list which contains <literal>7</literal> elements. Default
276 value is <literal>list([],0,[],[],[],0,0)</literal>.
282 <para>real scalar which gives the maximum time for which
283 <literal>g</literal> is allowed to be evaluated or an empty
284 matrix <literal>[]</literal> if no limits imposed for
293 flag which indicates if <literal>dassl</literal> returns
294 its intermediate computed values (<literal>flag=1</literal>)
295 or only the user specified time point values
296 (<literal>flag=0</literal>).
304 <literal>2</literal> components vector which give the
305 definition <literal>[ml,mu]</literal> of band matrix computed
306 by <literal>jac</literal>; <literal>r(i - j + ml + mu + 1,j) =
307 "dg(i)/dy(j)+cj*dg(i)/dydot(j)"
309 .If <literal>jac</literal> returns a full matrix set
310 <literal>info(3)=[]</literal>.
317 <para>real scalar which gives the maximum step size. Set
318 <literal>info(4)=[]</literal> if no limitation.
325 <para>real scalar which gives the initial step size. Set
326 <literal>info(5)=[]</literal> if not specified.
334 set <literal>info(6)=1</literal> if the solution is
335 known to be non negative, else set
336 <literal>info(6)=0</literal>.
344 set <literal>info(7)=1</literal> if
345 <literal>ydot0</literal> is just an estimation,
346 <literal>info(7)=0</literal> if
347 <literal>g(t0,y0,ydot0)=0</literal>.
358 real vector which allows to store the <literal>dassl</literal>
359 context and to resume integration.
367 real matrix . Each column is the vector <literal>[t;x(t);xdot(t)]</literal> where
368 <literal>t</literal> is time index for which the solution had been computed.
375 <title>Description</title>
376 <para>Solution of the implicit differential equation.</para>
379 y(t0) = y0 and ydot(t0) = ydot0
381 <para>Returns the surface crossing instants and the number of the surface
382 reached in <literal>nn</literal>.
384 <para>Detailed examples can be found in SCIDIR/tests/unit_tests/dassldasrt.tst</para>
387 <title>Examples</title>
388 <programlisting role="example"><![CDATA[
389 // dy/dt = ((2*log(y)+8)/t -5)*y, y(1) = 1, 1<=t<=6
390 // g1 = ((2*log(y)+8)/t - 5)*y
391 // g2 = log(y) - 2.2491
392 y0 = 1; t = 2:6; t0 = 1; y0d = 3;
393 atol = 1.d-6; rtol = 0; ng = 2;
395 deff('[delta,ires] = res1(t,y,ydot)', 'ires=0; delta=ydot-((2*log(y)+8)/t-5)*y')
396 deff('rts = gr1(t,y)', 'rts=[((2*log(y)+8)/t-5)*y;log(y)-2.2491]')
398 [yy,nn] = dasrt([y0,y0d],t0,t,atol,rtol,res1,ng,gr1);
399 //(Should return nn=[2.4698972 2])
402 <refsection role="see also">
403 <title>See also</title>
404 <simplelist type="inline">
406 <link linkend="ode">ode</link>
409 <link linkend="dassl">dassl</link>
412 <link linkend="daskr">daskr</link>
415 <link linkend="impl">impl</link>
418 <link linkend="call">call</link>
421 <link linkend="link">link</link>
424 <link linkend="external">external</link>