Mathematical Physics - Volume II - Numerical Methods

1.1 Finite difference method

21

N = 10 VK = . 001667

N = 10 VK = . 005000

T = . 50 NUMERICKI TACˇ NO

T = . 50 NUMERICKI TACˇ NO

Z = . 0 Z = . 1 Z = . 2 Z = . 3 Z = . 4 Z = . 5 Z = . 6 Z = . 7 Z = . 8 Z = . 9

. 000000 . 222040 . 422346 . 581309 . 683370 . 718537 . 683370 . 581309 . 422346 . 222040

. 000000 . 222022 . 422311 . 581261 . 683314 . 718479 . 683314 . 581261 . 422311 . 222022 . 000000

Z = . 0 Z = . 1 Z = . 2 Z = . 3 Z = . 4 Z = . 5 Z = . 6 Z = . 7 Z = . 8 Z = . 9

. 000000 . 204463 . 388912 . 535292 . 629273 . 661657 . 629273 . 535292 . 388912 . 204463

. 000000 . 222241 . 422728 . 581835 . 683989 . 719188 . 683989 . 581835 . 422728 . 222241 . 000000

Z = 1 . 0 . 000000

Z = 1 . 0 . 000000

PROGRAM e1djd DIMENSION u(0:101) , v(0:101)

OPEN (1,FILE=’ULAZ’) OPEN (2,FILE=’IZLAZ’) pi = 4.*atan(1.) READ (1,99004) n , vk DO 100 i = 0 , n h = 1./n z = i*h

v(i) = 100.*sin(pi*z)

100 CONTINUE 200 DO 300 i = 1 , n - 1

u(i) = v(i) + vk*n*n*(v(i+1)-2*v(i)+v(i-1))

300 CONTINUE

t = t + vk u(0) = 0. u(n) = 0. DO 400 i = 1 , n + 1 v(i-1) = u(i-1)

400 CONTINUE

IF ( abs(0.5-t).GT.vk/2 ) GOTO 200 WRITE (2,99001) n , vk

WRITE (2,99002) t DO 500 i = 0 , n h = 1./n z = i*h WRITE (2,99003) z , u(i) , 100.*exp(-pi*pi*t)*sin(pi*z) 500 CONTINUE STOP 99001 FORMAT (’N=’,I5,T18,’VK=’,F10.6)

Made with FlippingBook flipbook maker