Problem Statement. Perform the same computation as in Example 1.1 but use Eq. (1.12)

to compute the velocity. Employ a step size of 2 s for the calculation.

– – – – – (1.12)

New value = old value + slope × step size

Note that this approach is formally called Euler’s method.

Refer to the numerical solution , we can write the Fortran code as follow,

program Euler ! Euler’s merhod (Numerical method)

IMPLICIT NONE

REAL*8 m,g,c,v1,v2,T1,T2 ! 宣告4個雙精準數變數, m為質量, g為重力加速度, c為空氣阻力的拖曳係數

Integer*4 t, tlast ! 宣告t為長整數,使用4 bytes, t為時間, tlast為上一次的時間

m = 68.1 ! 體重68.1 kg

g = 9.8 ! 重力加速度9.8 m/s^2

c = 12.5 ! 風阻係數12.5 kg/s

v1 = 0 ! 初始速度為 0 m/s

!tlast = 0 ! 紀錄上一次結束的時間

T1 = 0

T2 = 0

OPEN (6, FILE = “Euler_2sec_50.txt”, STATUS = ‘UNKNOWN’)

Do t = 0, 50, 2

T1 = 1.0 * t ;

v2 = v1 + ( g – ( c / m ) * v1 ) * (T1 – T2)

write (*, *) T1, V2

v1 = v2

T2 = T1

END Do

pause

stop

end

We can copy the results form Euler_2sec_50.txt to Excel, and present them to graphic diagram.

Reference:

Numerical Methods for Engineers 6th P16-P17, Steven C. Chapra Raymond P. Canale

### Like this:

Like Loading...

*Related*

Pingback: Comparison of the numerical and analytical solutions | furtherstep