Mathematical Physics - Volume II - Numerical Methods
20 Chapter 1. Finite difference method and Finite element method
c(i) = -w*vk*n*n d(i) = u(i) + (1-w)*vk*n*n*(u(i+1)-2*u(i)+u(i-1))
300 CONTINUE
CALL tridi(a,b,c,d,l) t = t + vk DO 400 i = 1 , n - 1 u(i) = d(i)
400 CONTINUE u(0) = 0. u(n) = 0.
IF ( abs(0.5-t).GT.vk/2 ) GOTO 200 WRITE (2,99001) w WRITE (2,99002) n , vk
WRITE (2,99003) t DO 500 i = 0 , n h = 1./n z = i*h WRITE (2,99004) z , u(i) , 100.*exp(-pi*pi*t)*sin(pi*z) 500 CONTINUE STOP 99001 FORMAT (’W=’,F5.2) 99002 FORMAT (’N=’,I5,T18,’VK=’,F10.6) 99003 FORMAT (’T=’,F5.2,T18,’NUMERICKI’,T35,’TACNO’,) 99004 FORMAT (’Z=’,F4.1,T13,F13.6,T30,F13.6) 99005 FORMAT (I5,F15.6,F5.2) END
SUBROUTINE tridi(a,b,c,d,l) DIMENSION a(101) , b(101) , c(101) , d(101) DO 100 i = 2 , l rt = -a(i)/b(i-1)
b(i) = b(i) + rt*c(i-1) d(i) = d(i) + rt*d(i-1)
100 CONTINUE
d(l) = d(l)/b(l) DO 200 i = l - 1 , 1 , -1 d(i) = (d(i)-c(i)*d(i+1))/b(i)
200 CONTINUE RETURN END
Made with FlippingBook flipbook maker