Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module hei
- use sub_solver
- implicit none
- contains
- subroutine heis(f,T,n)
- integer, intent(in) :: n
- double precision, intent(in) :: f
- double precision, dimension(:,:), allocatable :: T
- double precision pi,re,L2norm
- integer i
- pi=3.14159265359
- do i=1,50
- call BC(n,T)
- call gauss_seidel(n,T)
- call L2normsolver(n,T,L2norm)
- if (abs(L2old-L2norm) .LE. 0.0000001) then
- exit
- end if
- end do
- write(*,*)'iteration count',i
- end subroutine heis
- end module hei
- subroutine L2normsolver(n,T,L2norm)
- integer, intent(in) :: n
- double precision, dimension(:,:), allocatable :: T
- integer i,j
- double precision errorsum,L2norm,pi,h,x,y
- pi=3.14159265359
- h=1/n
- errorsum=0
- !Sums up all the errors
- do i=2,n+1
- do j=2,n+1
- x=(j-1.5)*1/n
- y=(i-1.5)*1/n
- errorsum=errorsum+(T(i,j)-(cos(pi*x)*sinh(pi*y))/sinh(pi))**2
- end do
- end do
- !L2 norm
- L2norm=sqrt(errorsum/(n**2))
- end subroutine L2normsolver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement