<< intl Differential Equations, Integration ode_discrete >>

Scilab help >> Differential Equations, Integration > ode

ode

常微分方程式ソルバ

呼び出し手順

y=ode(y0,t0,t,f)
[y,w,iw]=ode([type],y0,t0,t [,rtol [,atol]],f [,jac] [,w,iw])
[y,rd,w,iw]=ode("root",y0,t0,t [,rtol [,atol]],f [,jac],ng,g [,w,iw])
y=ode("discrete",y0,k0,kvect,f)

パラメータ

y0

実数ベクトルまたは行列 (初期条件).

t0

実数スカラー (初期時間).

t

実数ベクトル (解を計算する時間).

f

外部 (関数または文字列またはリスト).

type

以下の文字列のどれか: "adams" "stiff" "rk" "rkf" "fix" "discrete" "roots"

rtol,atol

実数定数またはyと同じ大きさの実数ベクトル.

jac

外部 (関数または文字列またはリスト).

w,iw

実数ベクトル.

ng

整数.

g

外部 (関数または文字列またはリスト).

k0

整数 (初期時間).

kvect

整数ベクトル.

説明

ode は,dy/dt=f(t,y) , y(t0)=y0で定義された 明示的なODEシステムを解くための標準関数です. この関数は,種々のソルバ,特に ODEPACKへのインターフェイスです. 解く問題の型と使用される手法は最初のオプション引数type の値に依存します. typeは,以下の文字列のどれかになります:

<not given>:

パッケージODEPACKのlsoda ソルバが デフォルトでコールされます. このソルバは非スティッフな問題用の予測子/修正子 Adams 法とスティッフな問題用の 後退差分法(BDF)を自動的に選択します. まず非スティッフな手法が使用され,使用する手法を 決定するためにデータを動的にモニタします.

"adams":

これは非スティッフな問題用です. ODEPACKパッケージの lsode ソルバがコールされ, この関数は Adams法を使用します.

"stiff":

これはスティッフな問題用です. ODEPACKパッケージの lsode ソルバがコールされ, BDF法が使用されます.

"rk":

4次の適応型 Runge-Kutta (RK4) 法.

"rkf":

Fehlbergの4次と5次の Runge-Kutta法に基づくShampine および Wattsのプログラム (RKF45) が使用されます. この方法は非スティッフおよびややスティッフな問題用で, 微係数の評価コストが低い場合に適しています. この手法は一般にユーザが高い精度を望む場合には使用するべきではありません.

"fix":

"rkf"と同じソルバですがユーザインターフェイスが非常にシンプルで, rtol および atolパラメータのみを ソルバに指定することが可能です. この手法は使用できる中で最も簡単な手法です.

"root":

解を得る機能を有するODE ソルバ. ODEPACKパッケージの lsodar ソルバが使用されます. 使用されているのはlsoda ソルバを改変したもので, 指定したベクトル関数の根を見つけることができます. 詳細は ode_root のヘルプを参照してください.

"discrete":

離散時間シミュレーション. 詳細は ode_discrete のヘルプを参照してください.

このヘルプでは,標準的な陽のODEシステムに関するode の使用法のみについて記述します.

例

// ---------- 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
y0=0;t0=0;t=0:0.1:%pi;
y=ode(y0,t0,t,f)
plot(t,y)

// ---------- Simple one dimension ODE (C coded external)
ccode=['#include <math.h>'
       'void myode(int *n,double *t,double *y,double *ydot)'
       '{'
       '  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
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. 
// 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
A=[1 1;0 2];B=[1;1];omega=5;
ode([1;0],0,[0.1,0.2,0.5,1],list(linear,A,u))

// ---------- 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  
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 
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 
ode("stiff",[0;1],0,1,f,Jacobian)

参照

作者

Alan C. Hindmarsh

, mathematics and statistics division, l-316 livermore, ca 94550.19

参考文献

Alan C. Hindmarsh, lsode and lsodi, two new initial value ordinary differential equation solvers, acm-signum newsletter, vol. 15, no. 4 (1980), pp. 10-11.

使用される関数

関連する関数は SCI/modules/differential_equations/src/fortran directory :

lsode.f lsoda.f lsodar.f です.

<< intl Differential Equations, Integration ode_discrete >>