Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 最小二平方法 與 方程式求解 張基昇製作. 2 目錄   最小二平方法 最小二平方法   方程式求解 方程式範例: van der Waals EOS van der Waals EOS Analysis of the problem 嘗試錯誤法 Bisection methodBisection.

Similar presentations


Presentation on theme: "1 最小二平方法 與 方程式求解 張基昇製作. 2 目錄   最小二平方法 最小二平方法   方程式求解 方程式範例: van der Waals EOS van der Waals EOS Analysis of the problem 嘗試錯誤法 Bisection methodBisection."— Presentation transcript:

1 1 最小二平方法 與 方程式求解 張基昇製作

2 2 目錄   最小二平方法 最小二平方法   方程式求解 方程式範例: van der Waals EOS van der Waals EOS Analysis of the problem 嘗試錯誤法 Bisection methodBisection method Secant method ; False position methodSecant methodFalse position method Newton’s method ; Muller’s methodNewton’s method 疊代法: Fixed-point iteration 疊代法

3 3 最小二平方法  實驗量測取得數據 N123456 x i0.050.110.150.310.460.52 y i0.9560.8900.8320.7170.5710.539 N7891011 x i0.700.740.820.981.17 y i0.3780.3700.3060.2420.104

4 4  數據處理 數據點作圖 數據點作圖 選擇三個數學模 式來吻合數據, 何者最適當? 選擇三個數學模 式來吻合數據, 何者最適當? 最小二平方法

5 5  最適當數學模式的觀念: 該模式計算值與實驗值間之誤差較小 該模式計算值與實驗值間之誤差較小 取誤差的平方和最小為判別標的 取誤差的平方和最小為判別標的

6 6 最小二平方法   在數學上極值的取得 對函數作變數之一次偏導數等於 0 時之 變數值

7 7 最小二平方法   移項整理得兩個方程式的方程組   兩個未知變數 a 與 b ,有兩個方程式, 系統自由度為 0

8 8 最小二平方法   第 (1) 式與第 (2) 式除以數據點數 N , 可以得到如下平均值表示為 (3) 、 (4)

9 9 最小二平方法   第 (1) 式減去第 (4) 式乘以  x i 值,將消 去 b 變數,取得 a (5) 式 ( 或值 )

10 10 最小二平方法   將 a (5) 式 ( 或值 ) 帶入第 (4) 式,即可求 取 b (6) 式 ( 或值 )

11 11 Fit1.for 程式解說   宣告因次與宣告實數 (426) dimension x(100),y(100) real*4 interp,meanx,meany   開啟檔案 open(1,file='fit1d.dat', status='old') open(6,file='fit1.prn', status='new')

12 12 Fit1.for 程式解說   讀入數據組數 (430) read(1,*)n   用迴圈讀入數據 (431) do 1 i=1,n read(1,*)x(i),y(i) 1 continue

13 13 Fit1.for 程式解說   宣告各個計算變數為 0.0 的值 (434) sumx = 0.0 sumy = 0.0 sumx2 = 0.0 sumy2 = 0.0 sumxy = 0.0 meanx = 0.0 meany = 0.0

14 14 Fit1.for 程式解說   利用迴圈計算各個總和數值 (441) do 2 i = 1, n sumx = sumx + x(i) sumy = sumy + y(i) sumx2 = sumx2 + x(i)*x(i) sumy2 = sumy2 + y(i)*y(i) sumxy = sumxy + x(i)*y(i) 2 continue enddo

15 15 Fit1.for 程式解說   計算平均值、斜率與截距 (449) meanx = sumx / n meany = sumy / n (a 值 ) slope = (sumxy - sumx*meany) /(sumx2 - sumx*meanx) (b 值 ) interp = meany - slope*meanx coef = (…) 計算統計上的標準偏差值

16 16 Fit1.for 程式解說   依指定格式列印結果 (455) write(6,1000) slope,interp,coef 1000 format( …) stop end

17 17 最小二平方法   ㄧㄝˋ ! 完成最小二平方法之數據處理,取得系 統之最適當數學模式的參數 a 與 b 。

18 18 van der Waals equation of state   立方型體積狀態方程式 ㄧ、 二、 三、

19 19   立方型體積狀態 方程式 臨界常數應用於 方程式物質參數 的求取 Cubic EOS

20 20 van der Waals equation of state   vdW 狀態方程式的物質參數 ㄧ、,,. 二、,.

21 21 Phase Diagram

22 22 Phase Diagram

23 23 Cubic Equation of State   體積的一元三 次方程式 在一指定溫 度與指定壓 力之下,可 以解得三個 體積的根。

24 24

25 25   立方型體積狀態 方程式 蒸氣相莫耳體積 的求取計算式 Cubic EOS

26 26   立方型體積狀態 方程式 液相莫耳體積的 求取計算式 Cubic EOS

27 27 題解分析   Degree of Freedom of problems 自由度:數學的與熱力學的觀點 依 Gibbs 相律計算,自由度為 2 ,指 定 T 與 P , V 為所剩唯一變數 ; 一個未知變數,一個方程式,自由度 F = 0

28 28 ( 一 ) 嘗試錯誤法求解   嘗試錯誤法 給一個解的起猜值 V ,計算函數值是否 為 0 ,若函數值小於容忍誤差 () ,即 可視為計算收斂,取得函數的解。 否則,繼續嘗試可能的解,ㄧ直到得到 適當解為止。

29 29 Bisection method   解題的邏輯觀念示意圖

30 30 Bisection method  Step A Read: T 、 P 、 T c 、 P c , calculate a and b 。 Read: T 、 P 、 T c 、 P c , calculate a and b 。 Set V 0 and V 1 , calculate f 0 and f 1, have to satisfy [ f 0 * f 1 < 0 ] Set V 0 and V 1 , calculate f 0 and f 1, have to satisfy [ f 0 * f 1 < 0 ] IF ( | f 0 | < .or. | f 1 | <  ) THEN Stop 。 IF ( | f 0 | < .or. | f 1 | <  ) THEN Stop 。

31 31 Bisection method  Step B Repeat Repeat Calculate V 2 and f 2 Calculate V 2 and f 2 IF ( f 2 * f 0 > 0 ) THEN Set V 0 = V 2 and f 0 = f 2 ELSE Set V 1 = V 2 and f 1 = f 2 ENDIF IF ( f 2 * f 0 > 0 ) THEN Set V 0 = V 2 and f 0 = f 2 ELSE Set V 1 = V 2 and f 1 = f 2 ENDIF Until | f 2 | <  Then Stop 。 Until | f 2 | <  Then Stop 。

32 32 Bisection method   Formula by Bisection method

33 33 Secant method   解題的邏輯觀念示意圖

34 34 Secant method  Step A Read: T 、 P 、 T c 、 P c , calculate a and b 。 Read: T 、 P 、 T c 、 P c , calculate a and b 。 Set V 0 and V 1 , calculate f 0 and f 1 Set V 0 and V 1 , calculate f 0 and f 1 IF ( | f 0 | < .or. | f 1 | <  ) THEN Stop 。 IF ( | f 0 | < .or. | f 1 | <  ) THEN Stop 。 IF ( | f 1 | > | f 0 | ) THEN Swap V 0 withV 1 and f 0 with f 1 IF ( | f 1 | > | f 0 | ) THEN Swap V 0 withV 1 and f 0 with f 1

35 35 Secant method  Step B Repeat Repeat Calculate V 2 and f 2 Calculate V 2 and f 2 Set V 0 = V 1 and f 0 = f 1 Set V 1 = V 2 and f 1 = f 2 Set V 0 = V 1 and f 0 = f 1 Set V 1 = V 2 and f 1 = f 2 Until | f 2 | <  Then Stop 。 Until | f 2 | <  Then Stop 。

36 36 Secant method   Formula by Secant method

37 37 False position method   解題的邏輯觀念示意圖

38 38 False position method  Step A Read: T 、 P 、 T c 、 P c , calculate a and b 。 Read: T 、 P 、 T c 、 P c , calculate a and b 。 Set V 0 and V 1 , calculate f 0 and f 1, have to satisfy [ f 0 * f 1 > 0 ] Set V 0 and V 1 , calculate f 0 and f 1, have to satisfy [ f 0 * f 1 > 0 ] IF ( | f 0 | < .or. | f 1 | <  ) THEN Stop 。 IF ( | f 0 | < .or. | f 1 | <  ) THEN Stop 。

39 39 False position method  Step B Repeat Repeat Calculate V 2 and f 2 Calculate V 2 and f 2 IF ( f 2 * f 0 > 0 ) THEN Set V 0 = V 2 and f 0 = f 2 ELSE Set V 1 = V 2 and f 1 = f 2 ENDIF IF ( f 2 * f 0 > 0 ) THEN Set V 0 = V 2 and f 0 = f 2 ELSE Set V 1 = V 2 and f 1 = f 2 ENDIF Until | f 2 | <  Then Stop 。 Until | f 2 | <  Then Stop 。

40 40 False position method   Formula by False position method

41 41 Newton’s methods   解題的邏輯觀念示意圖

42 42 Newton’s methods  Step A Read: T 、 P 、 T c 、 P c , calculate a and b 。 Read: T 、 P 、 T c 、 P c , calculate a and b 。 Set V i , calculate f i and f i ’, Set V i , calculate f i and f i ’, IF ( | f i | <  1.or. | f i ’ | <  2 ) THEN Stop 。 IF ( | f i | <  1.or. | f i ’ | <  2 ) THEN Stop 。

43 43 Newton’s methods  Step B Repeat Repeat Calculate V i+1 and f i+1 and f i+1 ’, Calculate V i+1 and f i+1 and f i+1 ’, Until ( | f i | <  1.or. | f i ’ | <  2 ) Until ( | f i | <  1.or. | f i ’ | <  2 )

44 44 Newton’s methods   Formula by Newton’s methods

45 45 ( 二 ) 疊代法求解   疊代計算的邏輯觀念 將體積狀態方程式整理成為體積之自我 函數關係式 疊代計算收斂之判別式

46 46 疊代法求解   vdW 狀態方程式範例 ㄧ、 二、 三、 四、

47 47 您可已曉得!  劇情如何發展!  敬請期待!


Download ppt "1 最小二平方法 與 方程式求解 張基昇製作. 2 目錄   最小二平方法 最小二平方法   方程式求解 方程式範例: van der Waals EOS van der Waals EOS Analysis of the problem 嘗試錯誤法 Bisection methodBisection."

Similar presentations


Ads by Google