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 * This file must be used under the terms of the CeCILL.
8 * This source file is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at
11 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 <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">
16 <refname>dasrt</refname>
17 <refpurpose>DAE solver with zero crossing</refpurpose>
20 <title>Calling Sequence</title>
21 <synopsis>[r,nn,[,hd]]=dasrt(x0,t0,t [,atol,[rtol]],res [,jac],ng, surf [,info] [,hd])</synopsis>
24 <title>Arguments</title>
30 is either <literal>y0</literal> (<literal>ydot0</literal> is
31 estimated by <literal>dassl</literal> with zero as first estimate)
32 or the matrix <literal>[y0 ydot0]</literal>.
33 <literal>g(t,y0,ydot0)</literal> must be equal to zero. If you only
34 know an estimate of <literal>ydot0</literal> set
35 <literal>info(7)=1</literal>.
41 <para>a real column vector of initial conditions.</para>
47 <para>a real column vector of the time derivative of
48 <literal>y</literal> at <literal>t0</literal> (may be an
59 <para>a real number, it is the initial instant.</para>
65 <para>a real scalar or vector. Gives instants for which you want the
66 solution. Note that you can get solution at each dassl's step point
67 by setting <literal>info(2)=1</literal>.
75 a vector with two entries <literal>[times num]</literal>
76 <literal>times</literal> is the value of the time at which the
77 surface is crossed, <literal>num</literal> is the number of the
83 <term>atol, rtol</term>
85 <para>real scalars or column vectors of same size as
86 <literal>y</literal>. <literal>atol, rtol</literal> give respectively
87 absolute and relative error tolerances of solution. If vectors the
88 tolerances are specified for each component of
97 <link linkend="external">external</link> (function or list or string). Computes the value of
98 <literal>g(t,y,ydot)</literal>. It may be :
102 <para>A Scilab function.</para>
103 <para>Its calling sequence must be
104 <literal>[r,ires]=res(t,y,ydot)</literal> and
105 <literal>res</literal> must return the residue
106 <literal>r=g(t,y,ydot)</literal> and error flag
107 <literal>ires</literal>. <literal>ires = 0</literal> if
108 <literal>res</literal> succeeds to compute <literal>r</literal>,
109 <literal>=-1</literal> if residue is locally not defined for
110 <literal>(t,y,ydot)</literal>, <literal>=-2</literal> if
111 parameters are out of admissible range.
116 <para>This form allows to pass parameters other than t,y,ydot to
117 the function. It must be as follows:
119 <programlisting role="no-scilab-exec"><![CDATA[
122 <para>where the calling sequence of the function
123 <literal>res</literal> is now
125 <programlisting role="no-scilab-exec"><![CDATA[
126 r=res(t,y,ydot,x1,x2,...)
129 <literal>res</literal> still returns
130 <literal>r=g(t,y,ydot)</literal> as a function of
131 <literal>(t,y,ydot,x1,x2,...)</literal>.
135 Warning: this form must not be used if there is no extra
136 argument to pass to the function.
141 <para>A string.</para>
142 <para>It must refer to the name of a C or Fortran subroutine
145 <para>In C The calling sequence must be:</para>
146 <programlisting role="no-scilab-exec"><![CDATA[
147 void res(double *t, double y[], double yd[], double r[],
148 int *ires, double rpar[], int ipar[])
150 <para>In Fortran it must be:</para>
151 <programlisting role="no-scilab-exec"><![CDATA[
152 subroutine res(t,y,yd,r,ires,rpar,ipar)
153 double precision t, y(*),yd(*),r(*),rpar(*)
157 The <literal>rpar</literal> and <literal>ipar</literal> arrays must be present but cannot be
168 <link linkend="external">external</link> (function or list or string). Computes the value of
169 <literal>dg/dy + cj*dg/dydot</literal> for a given value of parameter
170 <literal>cj</literal>.
174 <para>A Scilab function.</para>
175 <para>Its calling sequence must be
176 <literal>r=jac(t,y,ydot,cj)</literal> and the
177 <literal>jac</literal> function must return
178 <literal>r=dg(t,y,ydot)/dy+cj*dg(t,y,ydot)/dydot</literal> where
179 <literal>cj</literal> is a real scalar.
184 <para>It must be as follows</para>
185 <programlisting role="no-scilab-exec"><![CDATA[
188 <para>where the calling sequence of the function
189 <literal>jac</literal> is now
191 <programlisting role="no-scilab-exec"><![CDATA[
192 r=jac(t,y,ydot,cj,x1,x2,...)
195 <literal>jac</literal> still returns
196 <literal>dg/dy + cj*dg/dydot</literal> as a function of
197 <literal>(t,y,ydot,cj,x1,x2,...)</literal>.
201 <para>A character string.</para>
202 <para>It must refer to the name of a Fortran subroutine linked
205 <para>In C The calling sequence must be:</para>
206 <programlisting role="no-scilab-exec"><![CDATA[
207 void jac(double *t, double y[], double yd[], double pd[],
208 double *cj, double rpar[], int ipar[])
210 <para>In Fortran it must be:</para>
211 <programlisting role="no-scilab-exec"><![CDATA[
212 subroutine jac(t,y,yd,pd,cj,rpar,ipar)
213 double precision t, y(*),yd(*),pd(*),cj,rpar(*)
224 <link linkend="external">external</link> (function or list or string). Computes the value of
225 the column vector <literal>surf(t,y)</literal> with
226 <literal>ng</literal> components. Each component defines a surface.
227 It may be defined by:
231 <para>A Scilab function.</para>
232 <para>Its calling sequence must be
233 <literal>surf(t,y)</literal>
238 <para>It must be as follows</para>
239 <programlisting role="no-scilab-exec"><![CDATA[
242 <para>where the calling sequence of the function
243 <literal>surf</literal> is now
245 <programlisting role="no-scilab-exec"><![CDATA[
246 r=surf(t,y,x1,x2,...)
250 <para>A character string.</para>
251 <para>It must refer to the name of a Fortran subroutine linked
254 <para>In C the calling sequence must be:</para>
255 <programlisting role="no-scilab-exec"><![CDATA[
256 void surf(int *ny, double *t, double y[], int *ng, double gout[])
258 <para>In Fortran it must be:</para>
259 <programlisting role="no-scilab-exec"><![CDATA[
260 subroutine surf(ny,t,y,ng,gout)
261 double precision t, y(*),gout(*)
272 list which contains <literal>7</literal> elements. Default
273 value is <literal>list([],0,[],[],[],0,0)</literal>.
279 <para>real scalar which gives the maximum time for which
280 <literal>g</literal> is allowed to be evaluated or an empty
281 matrix <literal>[]</literal> if no limits imposed for
290 flag which indicates if <literal>dassl</literal> returns
291 its intermediate computed values (<literal>flag=1</literal>)
292 or only the user specified time point values
293 (<literal>flag=0</literal>).
301 <literal>2</literal> components vector which give the
302 definition <literal>[ml,mu]</literal> of band matrix computed
303 by <literal>jac</literal>; <literal>r(i - j + ml + mu + 1,j) =
304 "dg(i)/dy(j)+cj*dg(i)/dydot(j)"
306 .If <literal>jac</literal> returns a full matrix set
307 <literal>info(3)=[]</literal>.
314 <para>real scalar which gives the maximum step size. Set
315 <literal>info(4)=[]</literal> if no limitation.
322 <para>real scalar which gives the initial step size. Set
323 <literal>info(5)=[]</literal> if not specified.
331 set <literal>info(6)=1</literal> if the solution is
332 known to be non negative, else set
333 <literal>info(6)=0</literal>.
341 set <literal>info(7)=1</literal> if
342 <literal>ydot0</literal> is just an estimation,
343 <literal>info(7)=0</literal> if
344 <literal>g(t0,y0,ydot0)=0</literal>.
355 real vector which allows to store the <literal>dassl</literal>
356 context and to resume integration.
364 real matrix . Each column is the vector <literal>[t;x(t);xdot(t)]</literal> where
365 <literal>t</literal> is time index for which the solution had been computed.
372 <title>Description</title>
373 <para>Solution of the implicit differential equation.</para>
374 <programlisting role="no-scilab-exec"><![CDATA[
376 y(t0)=y0 and ydot(t0)=ydot0
378 <para>Returns the surface crossing instants and the number of the surface
379 reached in <literal>nn</literal>.
381 <para>Detailed examples can be found in SCIDIR/tests/unit_tests/dassldasrt.tst</para>
384 <title>Examples</title>
385 <programlisting role="example"><![CDATA[
386 //dy/dt = ((2*log(y)+8)/t -5)*y, y(1) = 1, 1<=t<=6
387 //g1 = ((2*log(y)+8)/t - 5)*y
388 //g2 = log(y) - 2.2491
389 y0=1;t=2:6;t0=1;y0d=3;
390 atol=1.d-6;rtol=0;ng=2;
392 deff('[delta,ires]=res1(t,y,ydot)','ires=0;delta=ydot-((2*log(y)+8)/t-5)*y')
393 deff('[rts]=gr1(t,y)','rts=[((2*log(y)+8)/t-5)*y;log(y)-2.2491]')
395 [yy,nn]=dasrt([y0,y0d],t0,t,atol,rtol,res1,ng,gr1);
396 //(Should return nn=[2.4698972 2])
399 <refsection role="see also">
400 <title>See Also</title>
401 <simplelist type="inline">
403 <link linkend="ode">ode</link>
406 <link linkend="dassl">dassl</link>
409 <link linkend="daskr">daskr</link>
412 <link linkend="impl">impl</link>
415 <link linkend="fort">fort</link>
418 <link linkend="link">link</link>
421 <link linkend="external">external</link>