Click here to load reader
Upload
mohammad-afeef
View
37
Download
0
Embed Size (px)
DESCRIPTION
fortran code for laplace eq
Citation preview
!---------1000K---------! !! !! !!!200k 500K !! !! !! !--------100 K -----------!
program heat_conductionimplicit none
!************** VARIABLES USED ********************
real, dimension(:,:), allocatable:: Tinteger i,j,k,iter,nx,ny,nreal dx,dyreal lb, rb ,tb ,bb,inireal a
!**************************************************
!************* USER INPUT *************************
print*, "enter the totoal number of nodes in x"read*, nx
print*, "enter the totoal number of nodes in y"read*, ny
print*, "enter dx"read*, dx
print*, "enter dy"read*, dy
print*, "enter left boundary condition"read*, lb
print*, "enter right boundary condition"read*, rb
print*, "enter the to boundary condition"read*, tb
print*, "enter the bottom boundary condition"read*, bb
print*, "enter the total number of iterations"read*, iter
!*************************************************
allocate(T(ny,nx))
!***************** INITIALIZING *******************
do i= 1,nyT(i,1) = lbT(i,nx) = rbend do
do i=1,nxT(1,i) = tbT(ny,i) = bbend do
ini = (0.25)*(lb+rb+tb+bb)
do i=2,ny-1do j=2,nx-1
T(1,i) =ini
end do end do
!**************************************************
a=( ((dx**2)*(dy**2))/(2*(dx**2 + dy**2)) )
!*************** SOLVING *************************
do n = 2,iterdo i = 2,ny-1do j = 2,nx-1
T(i,j) = a * (((T(i+1,j) + T(i-1,j) )/dx**2) + ((T(i,j-1) + T(i,j+1) )/dy**2))print*, i, j, n, T(i,j)
end do end do end do
read*, k
end program heat_conduction