Removed deprecated use of fifth argument of ilib_for_link.
See http://help.scilab.org/docs/5.4.1/fr_FR/ilib_for_link.html ,
"This parameter is useless since Scilab 5.0."
"A warning will be displayed in Scilab 5.3 if you use another value that the default."
Change-Id: Ie42345c22c7ced4aefc5fbac27846f849687c3f0
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2008 - INRIA
* ...
- *
+ *
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at
+ * are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
*
-->
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
- <synopsis> y=dae(initial,t0,t,res)
+ <synopsis> y=dae(initial,t0,t,res)
[y [,hd]]=dae(initial,t0,t [,rtol, [atol]],res [,jac] [,hd])
[y,rd]=dae("root",initial,t0,t,res,ng,surface)
[y ,rd [,hd]]=dae("root",initial,t0,t [,rtol, [atol]],res [,jac], ng, surface [,hd])
<listitem>
<para>a real scalar or vector. Gives instants for which you want the
solution. Note that you can get solution at each dae's step point by
- setting
+ setting
<literal>
<link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
</literal>
<para>This form of external is used to pass parameters to the
function. It must be as follows:
</para>
- <programlisting role="no-scilab-exec"><![CDATA[
+ <programlisting role="no-scilab-exec"><![CDATA[
list(res,p1,p2,...)
]]></programlisting>
<para>where the calling sequence of the function
<literal>res</literal> is now
</para>
- <programlisting role="no-scilab-exec"><![CDATA[
+ <programlisting role="no-scilab-exec"><![CDATA[
r=res(t,y,ydot,p1,p2,...)
]]></programlisting>
<para>
<para>This form of external is used to pass parameters to the
function. It must be as follows:
</para>
- <programlisting role="no-scilab-exec"><![CDATA[
-list(jac,p1,p2,...)
+ <programlisting role="no-scilab-exec"><![CDATA[
+list(jac,p1,p2,...)
]]></programlisting>
<para>where the calling sequence of the function
<literal>jac</literal> is now
</para>
- <programlisting role="no-scilab-exec"><![CDATA[
-r=jac(t,x,xdot,p1,p2,...)
+ <programlisting role="no-scilab-exec"><![CDATA[
+r=jac(t,x,xdot,p1,p2,...)
]]></programlisting>
<para>
<literal>jac</literal> still returns
This form of <link linkend="external">external</link> is used to pass parameters to the
function. It must be as follows:
</para>
- <programlisting role="no-scilab-exec"><![CDATA[
+ <programlisting role="no-scilab-exec"><![CDATA[
list(surface,p1,p2,...)
]]></programlisting>
<para>where the calling sequence of the function
<literal>surface</literal> is now
</para>
- <programlisting role="no-scilab-exec"><![CDATA[
+ <programlisting role="no-scilab-exec"><![CDATA[
r=surface(t,x,p1,p2,...)
]]></programlisting>
</listitem>
<term>rd</term>
<listitem>
<para>
- a vector with two entries <literal>[times num]</literal> where
+ a vector with two entries <literal>[times num]</literal> where
<literal>times</literal> is the value of the time at which the
surface is crossed, <literal>num</literal> is the number of the
crossed surface
<term>y</term>
<listitem>
<para>
- a real matrix. If
+ a real matrix. If
<literal>
<link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
</literal>
<link linkend="dassl">dassl</link> and <link linkend="dasrt">dasrt</link>
function designed for implicit differential equations integration.
</para>
- <programlisting role="no-scilab-exec"><![CDATA[
+ <programlisting role="no-scilab-exec"><![CDATA[
g(t,x,xdot)=0
x(t0)=x0 and xdot(t0)=xdot0
]]></programlisting>
<para>
- If <literal>xdot0</literal> is not given in the <emphasis>initial</emphasis>
+ If <literal>xdot0</literal> is not given in the <emphasis>initial</emphasis>
argument, the <literal>dae</literal> function tries to compute it solving
<literal>g(t,x0,xdot0)=0</literal>.
</para>
</refsection>
<refsection>
<title>Examples</title>
- <programlisting role="example"><![CDATA[
+ <programlisting role="example"><![CDATA[
//Example with Scilab code
function [r,ires]=chemres(t,y,yd)
r(1) = -0.04*y(1) + 1d4*y(2)*y(3) - yd(1);
mputl(code, 't22.c')
//-2- compile and load them
-ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c','Makefile','t22loader.sce');
+ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',[],'t22loader.sce');
exec('t22loader.sce')
//-3- run
previous_dir = pwd();
cd TMPDIR;
mputl(code, 't22.c')
-ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c','Makefile','t22loader.sce');
+ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',[],'t22loader.sce');
exec('t22loader.sce')
rtol=[1.d-6;1.d-6];
atol=[1.d-6;1.d-4];
'}']
mputl(ccode,TMPDIR+'/myode.c') //create the C file
// Compile
-ilib_for_link('myode','myode.c',[],'c',TMPDIR+'/Makefile',TMPDIR+'/loader.sce');
+ilib_for_link('myode','myode.c',[],'c',[],TMPDIR+'/loader.sce');
exec(TMPDIR+'/loader.sce') //incremental linking
y0=0;
t0=0;
' ydot[0]=y[0]*y[0]-y[0]*sin(*t)+cos(*t);'
'}']
mputl(ccode,TMPDIR+'/myode.c') //create the C file
-ilib_for_link('myode','myode.c',[],'c',TMPDIR+'/Makefile',TMPDIR+'/loader.sce');//compile
+ilib_for_link('myode','myode.c',[],'c',[],TMPDIR+'/loader.sce');//compile
exec(TMPDIR+'/loader.sce') //incremental linking
y0=0;t0=0;t=0:0.1:%pi;
y=ode(y0,t0,t,'myode');
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2008 - INRIA
* ...
- *
+ *
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at
+ * are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
*
-->
</refnamediv>
<refsynopsisdiv>
<title>呼び出し手順</title>
- <synopsis> y=dae(initial,t0,t,res)
+ <synopsis> y=dae(initial,t0,t,res)
[y [,hd]]=dae(initial,t0,t [,rtol, [atol]],res [,jac] [,hd])
[y,rd]=dae("root",initial,t0,t,res,ng,surface)
[y ,rd [,hd]]=dae("root",initial,t0,t [,rtol, [atol]],res [,jac], ng, surface [,hd])
<term>res</term>
<listitem>
<para>
- <link linkend="external" role="" version="">外部ルーチン</link>.
+ <link linkend="external" role="" version="">外部ルーチン</link>.
<literal>g(t,y,ydot)</literal>の値を計算します. 以下のようになります
</para>
<variablelist>
<literal>[r,ires]=res(t,x,xdot)</literal> とする
必要があり,<literal>res</literal> は
残差<literal>r=g(t,x,xdot)</literal> とエラーフラグ
- <literal>ires</literal>を返す必要があります.
+ <literal>ires</literal>を返す必要があります.
<literal>res</literal>が<literal>r</literal>の計算に
成功した場合には<literal>ires = 0</literal>,
<literal>(t,x,xdot)</literal>のローカルな残差が定義されない
関数にパラメータを指定する際に使用されます.
以下のような形式とします:
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
list(res,p1,p2,...)
]]></programlisting>
<para>
ただし,ここで関数<literal>res</literal>の呼び出し手順は以下のようになります
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
r=res(t,y,ydot,p1,p2,...)
]]></programlisting>
<para>
<term>jac</term>
<listitem>
<para>
- <link linkend="external" role="" version="">外部ルーチン</link>.
+ <link linkend="external" role="" version="">外部ルーチン</link>.
指定したパラメータの値 <literal>cj</literal>を用いて
<literal>dg/dx+cj*dg/dxdot</literal>の値を計算します. 以下のようになります
</para>
関数にパラメータを指定する際に使用されます.
以下のような形式とします:
</para>
- <programlisting role=""><![CDATA[
-list(jac,p1,p2,...)
+ <programlisting role=""><![CDATA[
+list(jac,p1,p2,...)
]]></programlisting>
<para>
ただしこの場合の関数<literal>jac</literal>の呼び出し手順は
以下となります
</para>
- <programlisting role=""><![CDATA[
-r=jac(t,x,xdot,p1,p2,...)
+ <programlisting role=""><![CDATA[
+r=jac(t,x,xdot,p1,p2,...)
]]></programlisting>
<para>
この場合でも<literal>jac</literal> は,
<term>surface</term>
<listitem>
<para>
- <link linkend="external" role="" version="">外部ルーチン</link>.
+ <link linkend="external" role="" version="">外部ルーチン</link>.
<literal>ng</literal>個の要素を有する列ベクトル
- <literal>surface(t,x)</literal>の値を計算します.
+ <literal>surface(t,x)</literal>の値を計算します.
各要素は面(surface)を定義します.
</para>
<variablelist>
関数にパラメータを指定する際に使用されます.
以下のような形式とします:
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
list(surface,p1,p2,...)
]]></programlisting>
<para>
ただしこの場合の関数<literal>surface</literal>の呼び出し手順は
以下となります
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
r=surface(t,x,p1,p2,...)
]]></programlisting>
</listitem>
<para>
ただし,<literal>t</literal>, x, rpar, ipar は
上記と同じ定義を有し,<literal>ng </literal> は
- surfacesの数, <literal>nx</literal> は状態量の次元,
+ surfacesの数, <literal>nx</literal> は状態量の次元,
r は結果の配列です.
</para>
</listitem>
<varlistentry>
<term>hd</term>
<listitem>
- <para>実数のベクトル,
+ <para>実数のベクトル,
<literal>dae</literal> コンテキストを保持する出力.
(ホットスタートで)積分を再開するための入力引数として使用可能です.
</para>
<term>y</term>
<listitem>
<para>
- 実数の行列.
+ 実数の行列.
<literal>
<link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
</literal>
<link linkend="dassl">dassl</link> および <link linkend="dasrt">dasrt</link>
関数の上位に構築されたゲートウエイです.
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
g(t,x,xdot)=0
x(t0)=x0 and xdot(t0)=xdot0
]]></programlisting>
</refsection>
<refsection>
<title>例</title>
- <programlisting role="example"><![CDATA[
+ <programlisting role="example"><![CDATA[
// Scilabコードを使用する例
function [r,ires]=chemres(t,y,yd)
r(1) = -0.04*y(1) + 1d4*y(2)*y(3) - yd(1);
' '
'void gr22(int *neq, double *t, double *y, int *ng, double *groot, double *rpar, int *ipar)'
'{ groot[0] = y[0];}']
-mputl(code,TMPDIR+'/t22.c')
+mputl(code,TMPDIR+'/t22.c')
//-2- コンパイルの後,ロード
-ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',TMPDIR+'/Makefile',TMPDIR+'/t22loader.sce');
+ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',[],TMPDIR+'/t22loader.sce');
exec(TMPDIR+'/t22loader.sce')
//-3- 実行
rtol=[1.d-6;1.d-6];atol=[1.d-6;1.d-4];
<term>"root":</term>
<listitem>
<para>解を得る機能を有するODE ソルバ. ODEPACKパッケージの
- <literal>lsodar</literal> ソルバが使用されます.
+ <literal>lsodar</literal> ソルバが使用されます.
使用されているのは<literal>lsoda</literal> ソルバを改変したもので,
指定したベクトル関数の根を見つけることができます.
詳細は <link linkend="ode_root">ode_root</link> のヘルプを参照してください.
<para>
<literal>ode</literal>の最も簡単なコールは次のようになります:
<literal>y=ode(y0,t0,t,f)</literal> ただし <literal>y0</literal> は
- 初期条件のベクトル,<literal>t0</literal> は初期時間,
+ 初期条件のベクトル,<literal>t0</literal> は初期時間,
<literal>t</literal> は解<literal>y</literal>を計算する時間のベクトル,
<literal>y</literal>は解ベクトルの行列<literal>y=[y(t(1)),y(t(2)),...]</literal>
です.
<itemizedlist>
<listitem>
<para>
- <literal>f</literal> が Scilab 関数の場合,
+ <literal>f</literal> が Scilab 関数の場合,
その構文は <literal>ydot = f(t,y)</literal>となります.
ただし,<literal>t</literal>は実数スカラー(時間),
- <literal>y</literal> は実数ベクトル (状態量),
+ <literal>y</literal> は実数ベクトル (状態量),
<literal>ydot</literal>は実数ベクトル (dy/dt)です.
</para>
</listitem>
<listitem>
<para>
- <literal>f</literal> が文字列の場合,
+ <literal>f</literal> が文字列の場合,
FortranサブルーチンまたはC関数の名前が参照されます.
すなわち,<literal>ode(y0,t0,t,"fex")</literal>がコマンドの
場合,サブルーチン<literal>fex</literal>がコールされます.
</para>
<para>Fortranルーチンは以下の呼び出し手順とする
- 必要があります: <literal>fex(n,t,y,ydot)</literal>,
+ 必要があります: <literal>fex(n,t,y,ydot)</literal>,
ただし n は整数, t は倍精度実数, y と ydot は倍精度ベクトルです.
</para>
<para>C 関数は以下のプロトタイプとする必要があります:
</listitem>
<listitem>
<para>オプションの入力パラメータとして次の
- 解の誤差を指定できます:
+ 解の誤差を指定できます:
相対および絶対推定誤差の閾値である
<literal>rtol</literal> および <literal>atol</literal>.
<literal>y(i)</literal>の指定誤差は次のようになります:
</para>
<para>
<literal>jac</literal> が関数の場合,
- 構文は
+ 構文は
<literal>J=jac(t,y)</literal>とする必要があります.
</para>
<para>
以下の呼び出し手順となります:
</para>
<para>Fortranの場合:</para>
- <programlisting role=""><![CDATA[
-subroutine fex(n,t,y,ml,mu,J,nrpd)
+ <programlisting role=""><![CDATA[
+subroutine fex(n,t,y,ml,mu,J,nrpd)
integer n,ml,mu,nrpd
double precision t,y(*),J(*)
]]></programlisting>
<para>Cの場合:</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
void fex(int *n,double *t,double *y,int *ml,int *mu,double *J,int *nrpd,)
]]></programlisting>
<para>
</refsection>
<refsection>
<title>例</title>
- <programlisting role="example"><![CDATA[
+ <programlisting role="example"><![CDATA[
// ---------- Simple one dimension ODE (Scilab function external)
// dy/dt=y^2-y sin(t)+cos(t), y(0)=0
function ydot=f(t,y),ydot=y^2-y*sin(t)+cos(t),endfunction
' ydot[0]=y[0]*y[0]-y[0]*sin(*t)+cos(*t);'
'}']
mputl(ccode,TMPDIR+'/myode.c') //create the C file
-ilib_for_link('myode','myode.c',[],'c',TMPDIR+'/Makefile',TMPDIR+'/loader.sce');//compile
+ilib_for_link('myode','myode.c',[],'c',[],TMPDIR+'/loader.sce');//compile
exec(TMPDIR+'/loader.sce') //incremental linking
y0=0;t0=0;t=0:0.1:%pi;
y=ode(y0,t0,t,'myode');
// ---------- Simulation of dx/dt = A x(t) + B u(t) with u(t)=sin(omega*t),
// x0=[1;0]
// solution x(t) desired at t=0.1, 0.2, 0.5 ,1.
-// A and u function are passed to RHS function in a list.
+// A and u function are passed to RHS function in a list.
// B and omega are passed as global variables
function xdot=linear(t,x,A,u),xdot=A*x+B*u(t),endfunction
function ut=u(t),ut=sin(omega*t),endfunction
// ---------- Matrix notation Integration of the Riccati differential equation
// Xdot=A'*X + X*A - X'*B*X + C , X(0)=Identity
-// Solution at t=[1,2]
-function Xdot=ric(t,X),Xdot=A'*X+X*A-X'*B*X+C,endfunction
+// Solution at t=[1,2]
+function Xdot=ric(t,X),Xdot=A'*X+X*A-X'*B*X+C,endfunction
A=[1,1;0,2]; B=[1,0;0,1]; C=[1,0;0,1];
t0=0;t=0:0.1:%pi;
X=ode(eye(A),0,t,ric)
// ---------- Matrix notation, Computation of exp(A)
A=[1,1;0,2];
-function xdot=f(t,x),xdot=A*x;,endfunction
+function xdot=f(t,x),xdot=A*x;,endfunction
ode(eye(A),0,1,f)
ode("adams",eye(A),0,1,f)
// ---------- Matrix notation, Computation of exp(A) with stiff matrix, Jacobian given
A=[10,0;0,-1];
-function xdot=f(t,x),xdot=A*x,endfunction
-function J=Jacobian(t,y),J=A,endfunction
+function xdot=f(t,x),xdot=A*x,endfunction
+function J=Jacobian(t,y),J=A,endfunction
ode("stiff",[0;1],0,1,f,Jacobian)
]]></programlisting>
</refsection>
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2008 - INRIA
* ...
- *
+ *
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at
+ * are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
*
-->
</refnamediv>
<refsynopsisdiv>
<title>Seqüência de Chamamento</title>
- <synopsis> y=dae(initial,t0,t,res)
+ <synopsis> y=dae(initial,t0,t,res)
[y [,hd]]=dae(initial,t0,t [,rtol, [atol]],res [,jac] [,hd])
[y,rd]=dae("root",initial,t0,t,res,ng,surface)
[y ,rd [,hd]]=dae("root",initial,t0,t [,rtol, [atol]],res [,jac], ng, surface [,hd])
<listitem>
<para>escalar real ou vetor. Fornece instantes para os quais você
deseja uma solução. Note que você pode obter soluções para cada
- ponto de passo de dae fazendo
+ ponto de passo de dae fazendo
<literal>
<link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
</literal>
<para>Esta forma é utilizada para passar parâmetros à função.
Deve ser como segue:
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
list(res,p1,p2,...)
]]></programlisting>
<para>Onde a seqüência de chamamento da função
<literal>res</literal> é agora
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
r=res(t,y,ydot,p1,p2,...)
]]></programlisting>
<para>
<para>
<literal>rpar</literal> é o array de valores de
parâmetros em ponto flutuante, necessário, mas não pode
- ser definido pela função <literal>dae</literal>
+ ser definido pela função <literal>dae</literal>
</para>
</listitem>
<listitem>
<para>
<literal>ipar</literal> é o array de valores de
parâmetros inteiros, necessário, mas não pode ser definido
- pela função <literal>dae</literal>
+ pela função <literal>dae</literal>
</para>
</listitem>
</itemizedlist>
<para>Esta forma é utilizada para passar parâmetros à função.
Deve ser como segue:
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
list(jac,p1,p2,...)
]]></programlisting>
<para>Onde a seqüência de chamamento da função
<literal>jac</literal> é agora
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
r=jac(t,x,xdot,p1,p2,...)
]]></programlisting>
<para>
<para>Esta forma é utilizada para passar parâmetros à função.
Deve ser como segue:
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
list(surface,p1,p2,...)
]]></programlisting>
<para>Onde a seqüência de chamamento da função
<literal>surface</literal> é agora
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
r=surface(t,x,p1,p2,...)
]]></programlisting>
</listitem>
<term>y</term>
<listitem>
<para>
- matriz de reais. Se
+ matriz de reais. Se
<literal>
<link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
</literal>
funções <link linkend="dassl">dassl</link> e <link linkend="dasrt">dasrt</link> designada para equações diferenciais
implícitas.
</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
g(t,x,xdot)=0
x(t0)=x0 e xdot(t0)=xdot0
]]></programlisting>
initial
</literal>
,pode ser tanto uma derivada compatível satisfazendo
- g(t,x0,xdot0)=0 ou um valor aproximado . No último caso
+ g(t,x0,xdot0)=0 ou um valor aproximado . No último caso
<literal>
<link linkend="daeoptions">%DAEOPTIONS</link>(7) deve ser ajustado para
1.
</refsection>
<refsection>
<title>Exemplos</title>
- <programlisting role="example"><![CDATA[
+ <programlisting role="example"><![CDATA[
//Exemplo com um código Scilab
function [r,ires]=chemres(t,y,yd)
r(1) = -0.04*y(1) + 1d4*y(2)*y(3) - yd(1);
' '
'void gr22(int *neq, double *t, double *y, int *ng, double *groot, double *rpar, int *ipar)'
'{ groot[0] = y[0];}']
-mputl(code,TMPDIR+'/t22.c')
+mputl(code,TMPDIR+'/t22.c')
//-2- compilando e carregando
-ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',TMPDIR+'/Makefile',TMPDIR+'/t22loader.sce');
+ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',[],TMPDIR+'/t22loader.sce');
exec(TMPDIR+'/t22loader.sce')
//-3- executando
chamamento:
</para>
<para>No caso Fortran:</para>
- <programlisting role=""><![CDATA[
-subroutine fex(n,t,y,ml,mu,J,nrpd)
+ <programlisting role=""><![CDATA[
+subroutine fex(n,t,y,ml,mu,J,nrpd)
integer n,ml,mu,nrpd
double precision t,y(*),J(*)
]]></programlisting>
<para>No caso C:</para>
- <programlisting role=""><![CDATA[
+ <programlisting role=""><![CDATA[
void fex(int *n,double *t,double *y,int *ml,int *mu,double *J,int *nrpd,)
]]></programlisting>
<para>
</refsection>
<refsection>
<title>Exemplos</title>
- <programlisting role="example"><![CDATA[
+ <programlisting role="example"><![CDATA[
// ---------- EDO simples de uma dimensão (função externa do Scilab)
// dy/dt=y^2-y sin(t)+cos(t), y(0)=0
function ydot=f(t,y),ydot=y^2-y*sin(t)+cos(t),endfunction
' ydot[0]=y[0]*y[0]-y[0]*sin(*t)+cos(*t);'
'}']
mputl(ccode,TMPDIR+'/myode.c') //criando o arquivo C
-ilib_for_link('myode','myode.c',[],'c',TMPDIR+'/Makefile',TMPDIR+'/loader.sce');//compilando
+ilib_for_link('myode','myode.c',[],'c',[],TMPDIR+'/loader.sce');//compilando
exec(TMPDIR+'/loader.sce') //linking incremental
y0=0;t0=0;t=0:0.1:%pi;
y=ode(y0,t0,t,'myode');
-
+
// ---------- Simulação de dx/dt = A x(t) + B u(t) com u(t)=sin(omega*t),
// x0=[1;0]
// solução x(t) desejada em t=0.1, 0.2, 0.5 ,1.
-// A e a função u são passados para a função do lado direito em uma lista.
+// A e a função u são passados para a função do lado direito em uma lista.
// B e omega são passados como variáveis globais
function xdot=linear(t,x,A,u),xdot=A*x+B*u(t),endfunction
function ut=u(t),ut=sin(omega*t),endfunction
// ---------- Integração com notação matricial da equação diferencial de Ricatti
// Xdot=A'*X + X*A - X'*B*X + C , X(0)=Identity
-// Solução em t=[1,2]
-function Xdot=ric(t,X),Xdot=A'*X+X*A-X'*B*X+C,endfunction
+// Solução em t=[1,2]
+function Xdot=ric(t,X),Xdot=A'*X+X*A-X'*B*X+C,endfunction
A=[1,1;0,2]; B=[1,0;0,1]; C=[1,0;0,1];
t0=0;t=0:0.1:%pi;
X=ode(eye(A),0,t,ric)
// ---------- Notação matricial, computação de exp(A)
A=[1,1;0,2];
-function xdot=f(t,x),xdot=A*x;,endfunction
+function xdot=f(t,x),xdot=A*x;,endfunction
ode(eye(A),0,1,f)
ode("adams",eye(A),0,1,f)
// ---------- Notação de matriz, computação de exp(A) com matriz rígida, Jacobian fornecida
A=[10,0;0,-1];
-function xdot=f(t,x),xdot=A*x,endfunction
-function J=Jacobian(t,y),J=A,endfunction
+function xdot=f(t,x),xdot=A*x,endfunction
+function J=Jacobian(t,y),J=A,endfunction
ode("stiff",[0;1],0,1,f,Jacobian)
]]></programlisting>
</refsection>
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2008 - INRIA
* ...
- *
+ *
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at
+ * are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
*
-->
</refnamediv>
<refsynopsisdiv>
<title>Последовательность вызова</title>
- <synopsis>
- y=dae(initial,t0,t,res)
+ <synopsis>
+ y=dae(initial,t0,t,res)
[y [,hd]]=dae(initial,t0,t [,rtol, [atol]],res [,jac] [,hd])
[y,rd]=dae("root",initial,t0,t,res,ng,surface)
[y ,rd [,hd]]=dae("root",initial,t0,t [,rtol, [atol]],res [,jac], ng, surface [,hd])
<listitem>
<para>Вещественный скаляр или вектор. Указывает моменты времени для
которых нужно найти решение. Заметьте, что вы можете получить
- решение в каждой точке шага ДАУ с помощью установки
+ решение в каждой точке шага ДАУ с помощью установки
<literal>
- <link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
+ <link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
</literal>
.
</para>
<para>Эта форма внешней функции используется для передачи
параметров в функцию. Она может иметь следующий вид:
</para>
- <programlisting role="no-scilab-exec">
+ <programlisting role="no-scilab-exec">
list(res,p1,p2,...)
</programlisting>
<para>где последовательность вызова функции
<literal>res</literal> теперь
</para>
- <programlisting role="no-scilab-exec">
+ <programlisting role="no-scilab-exec">
r=res(t,y,ydot,p1,p2,...)
</programlisting>
<para>
<para>Эта форма внешней функции используется для передачи
параметров в функцию. Она может иметь следующий вид:
</para>
- <programlisting role="no-scilab-exec">
- list(jac,p1,p2,...)
+ <programlisting role="no-scilab-exec">
+ list(jac,p1,p2,...)
</programlisting>
<para>где последовательность вызова функции
<literal>jac</literal> теперь
</para>
- <programlisting role="no-scilab-exec">
- r=jac(t,x,xdot,p1,p2,...)
+ <programlisting role="no-scilab-exec">
+ r=jac(t,x,xdot,p1,p2,...)
</programlisting>
<para>
Функция <literal>jac</literal> по-прежнему возвращает
<para>Последовательность вызова Fortran должна быть</para>
<para>
<literal><j_name>(t, x, xdot, r, cj, ires,
- rpar, ipar)
+ rpar, ipar)
</literal>
</para>
<para>
<para>Эта форма внешней функции используется для передачи
параметров в функцию. Она может иметь следующий вид:
</para>
- <programlisting role="no-scilab-exec">
+ <programlisting role="no-scilab-exec">
list(surface,p1,p2,...)
</programlisting>
<para>где последовательность вызова функции
<literal>surface</literal> теперь имеет вид:
</para>
- <programlisting role="no-scilab-exec">
+ <programlisting role="no-scilab-exec">
r=surface(t,x,p1,p2,...)
</programlisting>
</listitem>
<para>Последовательность вызова Fortran должна быть</para>
<para>
<literal><j_name>(t, x, xdot, r, cj, ires,
- rpar, ipar)
+ rpar, ipar)
</literal>
</para>
<para>
<term>y</term>
<listitem>
<para>
- вещественная матрица. Если
+ вещественная матрица. Если
<literal>
<link linkend="daeoptions">%DAEOPTIONS</link>(2)=1
</literal>
функциями <link linkend="dassl">dassl</link> и <link linkend="dasrt">dasrt</link>, разработанными для явного интегрирования
дифференциальных уравнений.
</para>
- <programlisting role="no-scilab-exec">
+ <programlisting role="no-scilab-exec">
g(t,x,xdot)=0
x(t0)=x0 and xdot(t0)=xdot0
</programlisting>
x0=[1; 0; 0];
xd0=[-0.04; 0.04; 0];
t=[1.d-5:0.02:.4, 0.41:.1:4, 40, 400, 4000, 40000, 4d5, 4d6, 4d7, 4d8, 4d9, 4d10];
-
+
y=dae([x0,xd0],0,t,chemres);// возвращает запрошенные моменты времени наблюдения
-
+
%DAEOPTIONS=list([],1,[],[],[],0,0); // просит вернуть сетку точек dae
y=dae([x0,xd0],0,4d10,chemres); // без якобиана
y=dae([x0,xd0],0,4d10,chemres,chemjac); // с якобианом
mputl(code, 't22.c')
//-2- скомпилировать и загрузить его
-ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c','Makefile','t22loader.sce');
+ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',[],'t22loader.sce');
exec('t22loader.sce')
//-3- запустить
previous_dir = pwd();
cd TMPDIR;
mputl(code, 't22.c')
-ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c','Makefile','t22loader.sce');
+ilib_for_link(['res22' 'jac22' 'gr22'],'t22.c',[],'c',[],'t22loader.sce');
exec('t22loader.sce')
rtol=[1.d-6;1.d-6];
atol=[1.d-6;1.d-4];
'}']
mputl(ccode,TMPDIR+'/myode.c') // создаём C-файл
// Компилируем
-ilib_for_link('myode','myode.c',[],'c',TMPDIR+'/Makefile',TMPDIR+'/loader.sce');
+ilib_for_link('myode','myode.c',[],'c',[],TMPDIR+'/loader.sce');
exec(TMPDIR+'/loader.sce') // пошаговая компоновка
y0=0;
t0=0;