PROGRAM Heat_conduction_with_FTCS_Scheme
!defining kx=x position, ky=time, k=conductivity
!dx,dt=step size
parameter(kx=10,ky=100)
real::T(kx,ky),dt,dx,k,c
integer::n,i
open(1,file='heat_FTCS.out')
!assuming the temperature of the two outer faces are 100K
do i=1,ky
T(1,i)=100.0
T(kx,i)=100.0
enddo
!defining parameters
dt=1;dx=0.01;k=.004
c=k*dt/dx
!to satisfy CFL criteria
if(c>0.5) stop
!assuming the temperature of the inner points are 27K
do j=1,ky
do i=2,kx-1
T(i,j)=27.0
enddo
enddo
do j=1,ky-1
do i=2,kx-1
T(i,j+1)=T(i,j)+c*(T(i+1,j)-2*T(i,j)+T(i-1,j))
enddo
write(1,2)(T(i,j+1),i=1,kx)
enddo
2 format(10(f5.1,2x))
END PROGRAM
!defining kx=x position, ky=time, k=conductivity
!dx,dt=step size
parameter(kx=10,ky=100)
real::T(kx,ky),dt,dx,k,c
integer::n,i
open(1,file='heat_FTCS.out')
!assuming the temperature of the two outer faces are 100K
do i=1,ky
T(1,i)=100.0
T(kx,i)=100.0
enddo
!defining parameters
dt=1;dx=0.01;k=.004
c=k*dt/dx
!to satisfy CFL criteria
if(c>0.5) stop
!assuming the temperature of the inner points are 27K
do j=1,ky
do i=2,kx-1
T(i,j)=27.0
enddo
enddo
do j=1,ky-1
do i=2,kx-1
T(i,j+1)=T(i,j)+c*(T(i+1,j)-2*T(i,j)+T(i-1,j))
enddo
write(1,2)(T(i,j+1),i=1,kx)
enddo
2 format(10(f5.1,2x))
END PROGRAM
Comments
Post a Comment