Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. module hei
  2.  
  3. use sub_solver
  4.  
  5. implicit none
  6. contains
  7.  
  8.  
  9.  
  10. subroutine heis(f,T,n)
  11.  
  12. integer, intent(in) :: n
  13.  
  14. double precision, intent(in) :: f
  15.  
  16. double precision, dimension(:,:), allocatable :: T
  17.  
  18. double precision pi,re,L2norm
  19.  
  20. integer i
  21. pi=3.14159265359
  22.  
  23. do i=1,50
  24.  
  25.  
  26. call BC(n,T)
  27.  
  28.  
  29.  
  30. call gauss_seidel(n,T)
  31.  
  32. call L2normsolver(n,T,L2norm)
  33.  
  34.  
  35.  
  36. if (abs(L2old-L2norm) .LE. 0.0000001) then
  37.  
  38. exit
  39.  
  40. end if
  41.  
  42.  
  43. end do
  44.  
  45. write(*,*)'iteration count',i
  46.  
  47.  
  48.  
  49.  
  50.  
  51. end subroutine heis
  52.  
  53.  
  54.  
  55.  
  56. end module hei
  57.  
  58.  
  59. subroutine L2normsolver(n,T,L2norm)
  60.  
  61. integer, intent(in) :: n
  62. double precision, dimension(:,:), allocatable :: T
  63.  
  64. integer i,j
  65. double precision errorsum,L2norm,pi,h,x,y
  66.  
  67. pi=3.14159265359
  68.  
  69. h=1/n
  70.  
  71. errorsum=0
  72.  
  73. !Sums up all the errors
  74.  
  75. do i=2,n+1
  76. do j=2,n+1
  77.  
  78. x=(j-1.5)*1/n
  79. y=(i-1.5)*1/n
  80.  
  81.  
  82.  
  83. errorsum=errorsum+(T(i,j)-(cos(pi*x)*sinh(pi*y))/sinh(pi))**2
  84.  
  85.  
  86. end do
  87. end do
  88.  
  89.  
  90. !L2 norm
  91. L2norm=sqrt(errorsum/(n**2))
  92.  
  93.  
  94.  
  95.  
  96. end subroutine L2normsolver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement