C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3...
Transcript of C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3...
![Page 1: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/1.jpg)
1
常微分方程式系統
之模擬方法與工具(一)
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-2
壹、微分方程式系統之類型
貳、解起始值問題之單一步驟法
參、解起始值問題之預測-修正法
肆、數值解法之應有考量
伍、高階模擬語言
![Page 2: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/2.jpg)
2
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-3
壹、微分方程式系統之類型
一、起始值問題(Initial-value problem) 起始值問題的一般要求為給予一起始條件
y(x0) = y0 及微分方程式
求取滿足起始條件及微分方程式之函數值y(x)。
dydx
= f(x,y)
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-4
求起始值問題的一般步驟:
1.計算曲線(函數)之斜率。
2.應用所計算得之斜率以推測下一步驟(x+h)之函數值。
3.繼續前進至下一點重複(1)及(2)步驟。
解起始值問題之方法:
1.單一步驟法(One-step method):Euler method,Modified Euler method,Runge-Kutta method.
2.預測修正法(Predictor-corrector method):Milne‘s method,Adam-Bashforth method,Hamming method.
![Page 3: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/3.jpg)
3
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-5
二、邊界值問題(Boundary-value problem)
偏微分方程式之主要類別
Parabolic:
Elliptic:
Hyperbolic:
∂∂
2
2u
x = f
∂∂
∂∂
2
2
2
2u
xu
y + a = f
∂∂
∂∂
2
2
2
2u
xu
y - a = f
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-6
常見的偏微分方程式
Diffusion equation:
Poisson equation:
Laplace equation:
Wave equation:
Biharmonic equation:
常用於解偏微分方程式之數值法
1. 有限差分法(Finite difference method)
2. 有限元素法(Finite element method)
∂∂
∂∂
2
2u
x = a u
t∂∂
∂∂
2
2
2
2u
xu
y + = b
∂∂
∂∂
2
2
2
2u
xu
y + = 0
∂∂
∂∂
2
2
2
2u
xu
t = c
∂∂
∂∂ ∂
∂∂
4
4
4
2 2
4
4u
xu
x yu
y + 2 + = 0
![Page 4: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/4.jpg)
4
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-7
貳、解起始值問題之單一步驟法
一、尤拉法(The Euler method) y‘ = f(x,y), y(x0) = y0 原理:應用泰勒展開式
當h值很小時,上式可以簡化為:
y(x0+h) = y(x0) + h y‘(x0) 應用式:
yn+1 = yn + h f(xn, yn), n = 1,2,...
y(x h) = y(x ) + h y' (x ) + 12
h y' ' (x )+...0 0 02
0+
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-8
The Euler method
![Page 5: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/5.jpg)
5
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-9
二、計算之誤差
1.誤差之來源:
(1) 捨去誤差(Round-off error)(2) 截斷誤差(Truncation error)(3) 增殖誤差(Propagation error)
2.可觀察到之誤差:
(1) 區域性誤差(Local error)(2) 總體性誤差(Global error)
3.誤差之次方(Order):例:尤拉法之誤差次方為二次(h2)
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-10
![Page 6: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/6.jpg)
6
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-11
三、修正尤拉法(The modified Euler method) 原理:應用泰勒展開式:
應用式:
y(x h) = y(x ) + h y' (x ) + 12
h y' ' (x )+...
y' ' (x ) = Dy'Dx
= y' (x + h) - y' (x )h
y(x + h) = y(x ) + 12
h [ y' (x + h) + y' (x ) ]
0 0 02
0
00 0
0 0 0 0
+
∴
y = y + h f (x , y )
y = y + 12
h [ f(x ,y ) + f(x ,y ]
n+1*
n n n
n+1 n n n n+1 n+1* )
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-12
The modified Euler method
![Page 7: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/7.jpg)
7
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-13
四、朗格庫達法(Runge-Kutta method)
應用式:
其中 K0 = h f(xn, yn)K1 = h f(xn+0.5h, yn+0.5K0)K2 = h f(xn+0.5h, yn+0.5K1)K3 = h f(xn+h, yn+K2)
6)K + 2K + 2K+ (K + y =y 3210
n1n+
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-14
五、朗格庫達法應用於微分方程組之求解
以解二階方程式為例:
可令 ,則
如此二階方程式可化為二個一階方程式:
應用式:
yn+1 = yn + K, zn+1 = zn + L 其中
K1 = h f(xn, yn, zn) K3 = h f(xn+0.5h, yn+0.5K2, zn+0.5L2)L1 = h g(xn, yn, zn) L3 = h g(xn+0.5h, yn+0.5K2, zn+0.5L2)K2 = h f(xn+0.5h, yn+0.5K1, zn+0.5L1) K4 = h f(xn+h, yn+K3, zn+L3)L2 = h g(xn+0.5h, yn+0.5K1, zn+0.5L1) L4 = h g(xn+h, yn+K3, zn+L3)
d ydx
2
2 = g( x, y, dydx
)
z = dydx
dzdx
= d ydx
2
2
dzdx
dydx
= g( x, y, z ), = f( x, y, z ), ( z = f(x,y,z) )
K = K + 2K + 2K + K6
, L = L + 2L + 2L + L6
1 2 3 4 1 2 3 4
![Page 8: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/8.jpg)
8
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-15
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-16
![Page 9: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/9.jpg)
9
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-17
#include "nr.h" /* Header file of "NUMERICAL RECIPES" */#include "nrutil.h" /* Utility header file of "NUMERICAL RECIPES" */#include "nrutil.c" /* Utility file for "NUMERICAL RECIPES" */
void rk4(y,dydx,n,x,h,yout,derivs)/* Given values for the variables y[1..n] and their derivatives dydx[1..n] known at x, use the fourth-order Runge-Kutta *//* method to advance the solution over an interval h and return the incremented variables as yout[1..n], which need *//* not be a distinct array from y. The user supplies the routine derivs(x,y,dxdy), which returns derivatives dydx at x. */float y[],dydx[],x,h,yout[];void (*derivs)(); /* ANSI: void (*derivs)(float,float *,float *); */int n;{ int i;
float xh,hh,h6,*dym,*dyt,*yt,*vector();void free_vector();
dym=vector(1,n);dyt=vector(1,n);yt=vector(1,n);hh=h*0.5;h6=h/6.0;xh=x+hh;for (i=1;i<=n;i++) yt[i]=y[i]+hh*dydx[i]; /* First step */(*derivs)(xh,yt,dyt); /* Second step */for (i=1;i<=n;i++) yt[i]=y[i]+hh*dyt[i];(*derivs)(xh,yt,dym); /* Third step */for (i=1;i<=n;i++) {
yt[i]=y[i]+h*dym[i];dym[i] += dyt[i]; }
(*derivs)(x+h,yt,dyt); /* Fourth step */for (i=1;i<=n;i++) /* Accumulate increments with proper weights */
yout[i]=y[i]+h6*(dydx[i]+dyt[i]+2.0*dym[i]);free_vector(yt,1,n);free_vector(dyt,1,n);free_vector(dym,1,n);
}
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-18
float **y=0,*xx=0; /* defining declaration */ /* For communication back to main */void rkdumb(vstart,nvar,x1,x2,nstep,derivs)/* Starting from initial values vstart[1..nvar] known at x1 use fourth-order Runge-Kutta to advance nstep equal increments *//* to x2. The user-supplied routine derivs(x,v,dvdx) evaluates derivatives. Results are stored in the global variables *//* y[1..nvar][1..nstep+1] and xx[1..nstep+1]. */int nvar,nstep;float vstart[],x1,x2;void (*derivs)(); /* ANSI: void (*derivs)(float,float *,float *); */{ int i,k;
float x,h;float *v,*vout,*dv,*vector();void rk4(),nrerror(),free_vector();v=vector(1,nvar);vout=vector(1,nvar);dv=vector(1,nvar);for (i=1;i<=nvar;i++) { /* Load starting values */
v[i]=vstart[i];y[i][1]=v[i]; }
xx[1]=x1;x=x1;h=(x2-x1)/nstep;for (k=1;k<=nstep;k++) { /* Take nstep steps */
(*derivs)(x,v,dv);rk4(v,dv,nvar,x,h,vout,derivs);if ((float)(x+h) == x) nrerror("Step size too small in routine RKDUMB");x += h;xx[k+1]=x; /* Store intermediate steps */for (i=1;i<=nvar;i++) {
v[i]=vout[i];y[i][k+1]=v[i]; }
}free_vector(dv,1,nvar);free_vector(vout,1,nvar);free_vector(v,1,nvar);
}
![Page 10: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/10.jpg)
10
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-19
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-20
![Page 11: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/11.jpg)
11
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-21
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-22
![Page 12: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/12.jpg)
12
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-23
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-24
參、解起始值問題之預測-修正法(Predictor-corrector method)
一、方法及流程圖:
![Page 13: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/13.jpg)
13
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-25
二、Milne's method: 預測方程式:
修正方程式:
三、Adams-Bashforth method: 預測方程式:
修正方程式:
四、Hamming's method: 預測方程式:
修正方程式:
yn+1 = y + 4h3
(2y - y + 2y ) + 2890
h yn-3 n'
n-1'
n-2' 5 (5)
(5)5'1-n
'n
'1n1-n1n yh
901 - )y + 4y + (y
3h + y = y ++
yn+1 = y + h24
(55y - 59y + 37y + 9y ) + 251720
h yn n'
n-1'
n-2'
n-3' 5 (5)
yn+1 = y + h24
(9y - 19y - 5y + y ) - 19720
h yn n+1'
n-1'
n-1'
n-2' 5 (5)
yn+1 = y + 4h3
(2y - y + 2y ) + 2890
h yn-3 n'
n-1'
n-2' 5 (5)
yn+1 = 18
[9y - y + 3h (y + 2y + y )] - 140
h yn n-2 n+1'
n'
n-1' 5 (5)
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-26
五、預測-修正法之特性:
1. 需要單一步驟來啟動計算。
2. 需要較大之電腦記憶容量。
3. h之選擇較單一步驟法寬容性大,計算上較有效率。
4. 計算之步驟基本上為兩次,而Runge-Kutta為四次。
![Page 14: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/14.jpg)
14
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-27
肆、數值解法之應有考量
一、解一般微分方程式所應有之考量
1. 考慮問題之形式
(Initial value problem or Boundary value problem)2. 考量微分方程式之複雜性
(Predictor-corrector or Runge-Kutta)3. 考量解決問題所需之時間
(Computer time,preparation time)4. 考量所需之精確度
(computational efficiency vs accuracy)5. 運用以往之經驗
(e.g. stiff problem)
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-28
二、h (step size)之考慮
誤差之預估:C hn+1 for method of order n
![Page 15: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/15.jpg)
15
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-29
依系統特徵方程式預估適當的h
其中為微分方程式的最大特徵值,若特徵值為共軛複數,則依下式決定
對高階微分方程式的h預估,則是由所有特徵值的對數平均值推估:
max101λ
=h
λωτ
λω
λ
11
22
2,1
==
=+=
±=
n
n ba
jba
n
n
L
n
nL
nn
nn
h
ααλα
αλ
αλαλαλα
0
0
011
1
1101
101
0
===
=++++ −− L
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-30
依系統之輸入訊號預估適當的h若對於系統的輸入訊號頻率相對高於系統本身的動態頻率,則h的預估應依輸入訊號的頻率來決定:
10 or
101 in
in
hh τω
==
![Page 16: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/16.jpg)
16
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-31
【範例】系統之微分方程式為
0=++ kyybym &&&
若b/m = 0.5, k/m = 4.
令 yx &=1 yx =2 則yx &&& =
1 12 xyx == &&
0211 =++ xmk
xmb
x&
再分解為兩個一階微分方程式
211 xmk
xmb
x −−=&
12 xx =&
即( )
212111 ,, xmk
xmb
txxfx −−==&
( )12122 ,, xtxxfx ==&
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-32
代入 b/m = 0.5 (1/s)與 k/m = 4.0 (1/s2),可得:
系統之自然頻率為:
因此選擇
( )( ) 20
00 0.45.0
2 12
1211
==
=−−=
xxxxxxx
&
&
rad/s 24 ==mk
sh 05.0410
1==
![Page 17: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/17.jpg)
17
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-33
【MATLAB程式範例】function xdot = smddx(t,x)%file smddx.mxdot(1) = -0.5*x(1)-4*x(2);xdot(2) = x(1);
% driver file for spring-mass-damper using rk4.m% initial timet0 = 0;% final timetf = 10.;% column vector of initial conditionsx0 = [0 2]’;% step sizeh = .05;[t,x]=rk4(‘smddx’, t0, tf, x0, h);plot(t,x)gridxlabel(‘ Time (s) ’)ylabel(‘ Displacement (in) and Velocity (in/s) ‘)
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-34
h 之自動調整
系統之微分方程式為 ,若b/m = 5 (1/s), k/m = 4,則系統為overdamped狀態。代入並降階為兩個一階微分方程式:
( )( ) 20
00 0.45
2 12
1211
==
=−−=
xxxxxxx
&
&
![Page 18: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/18.jpg)
18
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-35
【MATLAB程式範例】function xdot = smd2dx(t,x)%file smd2dx.mxdot(1) = -5*x(1)-4*x(2);xdot(2) = x(1);
% driver file for spring-mass-damper using ode45t0 = 0;tf = 8.;x0 = [0 2]’;[t,x]=rk45(‘smd2dx’, t0, tf, x0);plot(t,x(:,1),’o’)holdplot(t,x(:,2),’+’)gridxlabel(‘ Time (s) ’)ylabel(‘ Displacement (in) and Velocity (in/s) ‘)
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-36
四、邊界值問題之解法:
1. Initial-value method 2. Finite difference method:【範例】
![Page 19: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/19.jpg)
19
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-37
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-38
三、Stiff problem:
“System-governing equations which have eigenvalues that differ by several orders of magnitude are identified as stiff equations.”
【範例】
以State-space型式表示:
( )( ) 00 1999999
10 1998998
2212
1211
=−−=
=+=
xxxxxxxx
&
&
BuAxx +=&
=
−−
=00
B 1999 999
1998 998 A
![Page 20: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/20.jpg)
20
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-39
可求得特徵值分別為
因此對 而言,h之大小可依下式計算,但隨時間增加, 之效應逐漸為 取代:
1000 1 21 −=−= λλ
tt
tt
eCeCxeCeCx
1000432
1000211
−−
−−
+=
+=
s 0001.01101
2
==λ
h
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-40
伍、高階模擬語言一、高階模擬語言概述
進行模擬的工具:
Hand calculation or experimentGeneral-purpose programming languageSimulation packagesHigh-level simulation languageHigh-level simulatorsSpecial-purpose simulators
![Page 21: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/21.jpg)
21
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-41
一、高階模擬語言概述
選用模擬語言的考慮因子:
容易學習
軟體價格
程式碼是否跨電腦平台
所能處理的問題範圍
使用者介面
輸出結果之應用方便性
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-42
一、高階模擬語言概述Nam e Continuous/D
iscrete Source
CSM P C IBM Corporation
CSSL C Control Data Corporation
DYSAC C University of W isconsin
G ASP C-D U .S. S teel Corporation
G PSS D IBM Corporation
M IDAS C W right-Patterson A ir Force Base
M IM IC C W right-Patterson A ir Force Base
PACTO LUS C IBM Corporation
SL-1 C Xerox
DSL C DEC
NDTRAN C University of Notre Dam e
S IM ULINK C M athworks, Inc.
STELLA C H igh Perform ance System s, Inc.
S IM SCR IPT D RAND Corporation
S IM AN C-D Pennsylvania S tate University
SLAM C-D Pritsker & Associates, Inc.
AW ESIM C-D Pritsker & Associates, Inc.
![Page 22: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/22.jpg)
22
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-43
二、以CSMP語言為例
以兔子(x)與狐狸(y)的Predator-Prey模式為例,若其系統微分方程式如下:
x' = ax – bxyy' = cxy – dy
若系統的參數a, b, c, d值分別如下:
a = 5, b = 0.05, c = 0.0004, d = 0.2起始條件為:
x(0) = 10000, y(0) = 1000,請利用CSMP語言進行系統之動態模擬。
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-44
二、以CSMP語言為例
TITLE PREY-PREDATOR MODEL*
XDOT = A*X – B*X*YYDOT = C*X*Y – D*XX = INTGRL (X0, XDOT)Y = INTGRL (Y0, YDOT)
*CONST A = 5, B = 0.05, C = 0.0004, D = 0.2CONST X0 = 10000.0, Y0 = 1000.0*TIMER DELT = 0.1, FINTIM = 500.0, PRDEL = 10.0PRINT X,YENDSTOP
![Page 23: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/23.jpg)
23
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-45
三、以SIMULINK為例
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-46
三、以SIMULINK為例 – 加入模擬結果輸出
![Page 24: C3 LECTURE NOTE 04nova.bime.ntu.edu.tw/~ttlin/Course03/lecture_notes... · 3 國立台灣大學生物機電系林達德 631 U7860 生物系統模擬與分析Lecture 04-5 二、邊界值問題(Boundary-value](https://reader031.fdocuments.net/reader031/viewer/2022013003/5f01b4037e708231d400a295/html5/thumbnails/24.jpg)
24
國立台灣大學生物機電系 林達德
631 U7860 生物系統模擬與分析 Lecture 04-47
三、以SIMULINK為例 – 模擬結果