• No results found

Fortran Programming--Heat Equation 2D SS NoGen (Elliptic PDE)

N/A
N/A
Protected

Academic year: 2021

Share "Fortran Programming--Heat Equation 2D SS NoGen (Elliptic PDE)"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

PROGRAM HeatEquation_2D_SS_NoGen

! This program have been written by Pedram Niakan

!_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-__-_-_-_-_-_-NOMENCLATOR_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

! T[i,j] ---> Temprature @ desired node(i,j)

! i,j ---> Respectively row & column of a node ((n-1)*(m-1)) ---> Number of cells

! m,n ---> Respectively number of rows & columns

! deltaX,deltaY ---> Respectively Length & Height of a cell ! BCS,BCW,BCN,BCS---> Boundry condidtions

! Tinf ---> Temprature of neighbor fluid For convection (@ Boundry) ! qe,qw,qn,qs ---> Heat Flux (@ Boundry) qe,qw,qn,qs<0 represents outgoing of heat from plate &

! cooling and qe,qw,qn,qs>0 represents incoming of heat in to the plate & heating

! k,h ---> Respectively conduction [watt/k-m] & convection [watt/k-m^2] coefficients

! probable ---> Probable values of temperature for solution of discreted equation ! !_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-__-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-__-_-_-_-_-_-_-_-_-_-_-_-_-_ IMPLICIT NONE REAL,ALLOCATABLE :: T(:,:),probable(:,:) INTEGER :: i,j,n,m,q,BCE,BCW,BCN,BCS REAL :: X,deltaX,Y,deltaY,k,h,er !---

DESCRIPTION---WRITE (*,*) "Discrete Equation for 2D,SS,NoGen Heat Transfer @ a rectangle plate:"

WRITE (*,*) ""

WRITE (*,*) " 2 2"

WRITE (*,*) "T[i+1,j]+T[i-1,j] T[i,j+1]+T[i,j-1] (deltaX)+ (deltaY)"

WRITE (*,*) "_________________ + _________________ = 2._________________ * T[i,j]"

WRITE (*,*) " 2 2 2 2"

WRITE (*,*) " (deltaX) (deltaY) (deltaX)*(deltaY)" WRITE (*,*) "" !--- ---OPEN(1,FILE="INPUT(HeatEquation_2D_SS_NoGen).TXT",STATUS="REPLACE") OPEN(2,FILE="OUTPUT(HeatEquation_2D_SS_NoGen).TXT",STATUS="REPLACE")

(2)

READ (*,*) X

WRITE (*,*) "Please enter number of Nodes @ X-Direction:" READ (*,*) n

WRITE (*,*) "Please enter heigth of model @ Y-Direction:" READ (*,*) Y

WRITE (*,*) "Please enter number of Nodes @ Y-Direction:" READ (*,*) m

WRITE (*,*) "Enter thermophysics properties k[watt/kelv-m] & h [watt/kelv-m^2]:"

READ (*,*) k,h deltaX=X/(n-1) deltaY=Y/(m-1)

WRITE (*,*) "Enter allowed value for error:" READ (*,*) er

ALLOCATE (T(1:n,1:m),probable(1:n,1:m))

!Declaration of probable values {0} for nodes DO i=1,n DO j=1,m T(i,j)=0 probable(i,j)=0 END DO END DO

!DECLARATION OF BOUNDRY CONDITIONS q=0

!Declaration of boundry condition @ side E

WRITE (*,*) "Declaration of boundry condition type @ side E:" WRITE (*,*) ""

10 WRITE (*,*)"Select one of below numbers:" WRITE (*,*)" 1 Temperatur"

WRITE (*,*)" 2 Heat Flux" WRITE (*,*)" 3 Convection" READ (*,*) BCE

!Declaration of boundry condition @ side W

WRITE (*,*) "Declaration of boundry condition type @ side W:" WRITE (*,*) ""

20 WRITE (*,*)"Select one of below numbers:" WRITE (*,*)" 1 Temperatur"

WRITE (*,*)" 2 Heat Flux" WRITE (*,*)" 3 Convection" READ (*,*) BCW

!Declaration of boundry condition @ side N

(3)

WRITE (*,*) ""

30 WRITE (*,*)"Select one of below numbers:" WRITE (*,*)" 1 Temperatur"

WRITE (*,*)" 2 Heat Flux" WRITE (*,*)" 3 Convection" READ (*,*) BCN

!Declaration of boundry condition @ side S

WRITE (*,*) "Declaration of boundry condition type @ side S:" WRITE (*,*) ""

40 WRITE (*,*)"Select one of below numbers:" WRITE (*,*)" 1 Temperatur"

WRITE (*,*)" 2 Heat Flux" WRITE (*,*)" 3 Convection" READ (*,*) BCS

50 IF (BCE==1) THEN

CALL Temperatur (q,n,m,BCE,BCW,BCN,BCS,T) ELSE IF (BCE==2) THEN

CALL HeatFlux (q,n,deltaX,m,deltaY,k,BCE,BCW,BCN,BCS,T) ELSE IF (BCE==3) THEN

CALL Convection (q,n,deltaX,m,deltaY,k,h,BCE,BCW,BCN,BCS,T) ELSE

WRITE (*,*)"Enter a correct number for EAST!" GO TO 10

END IF

60 IF (BCW==1) THEN

CALL Temperatur (q,n,m,BCE,BCW,BCN,BCS,T) ELSE IF (BCW==2) THEN

CALL HeatFlux (q,n,deltaX,m,deltaY,k,BCE,BCW,BCN,BCS,T) ELSE IF (BCW==3) THEN

CALL Convection (q,n,deltaX,m,deltaY,k,h,BCE,BCW,BCN,BCS,T) ELSE

WRITE (*,*)"Enter a correct number for WEST!" GO TO 20

END IF

70 IF (BCN==1) THEN

CALL Temperatur (q,n,m,BCE,BCW,BCN,BCS,T) ELSE IF (BCN==2) THEN

CALL HeatFlux (q,n,deltaX,m,deltaY,k,BCE,BCW,BCN,BCS,T) ELSE IF (BCN==3) THEN

CALL Convection (q,n,deltaX,m,deltaY,k,h,BCE,BCW,BCN,BCS,T) ELSE

WRITE (*,*)"Enter a correct number for NORTH!" GO TO 30

END IF

80 IF (BCS==1) THEN

CALL Temperatur (q,n,m,BCE,BCW,BCN,BCS,T) ELSE IF (BCS==2) THEN

(4)

ELSE IF (BCS==3) THEN

CALL Convection (q,n,deltaX,m,deltaY,k,h,BCE,BCW,BCN,BCS,T) ELSE

WRITE (*,*)"Enter a correct number for SOUTH!" GO TO 40

END IF

!Using Try & Error method 90 DO i=2,n-1 DO j=2,m-1 T(i,j)=(((T(i+1,j)+T(i-1,j))/(deltaX**2))+((T(i,j+1)+T(i,j-1))/ (deltaY**2)))*(.5*(deltaX**2)*(deltaY**2)/(deltaX**2+deltaY**2)) WRITE (*,*) "T(",i,",",j,")=",T(i,j) q=1 END DO END DO DO i=2,n-1 DO j=2,m-1 IF (ABS(T(i,j)-probable(i,j))>er) THEN probable(i,j)=T(i,j) GO TO 50 END IF END DO END DO WRITE (2,*)"varibles:x,y"

WRITE (2,*)"zone f=point,i=",n,",j=",m DO j=1,m

DO i=1,n

WRITE (*,*)"T(",i,",",j,")= ",T(i,j) WRITE (2,100)i,j,T(i,j)

100 FORMAT (15x,I10,I10,f20.6) END DO

END DO PAUSE

END PROGRAM HeatEquation_2D_SS_NoGen

!

CONTAINS !---

---SUBROUTINE Temperatur (q,n,m,BCE,BCW,BCN,BCS,T) INTEGER,INTENT(IN):: q,n,m,BCE,BCW,BCN,BCS REAL :: Te,Tw,Tn,Ts INTEGER :: i,j REAL,DIMENSION(1:n,1:m),INTENT(INOUT) :: T IF (BCE==1) THEN IF (q==0) THEN

(5)

READ (*,*) Te END IF DO j=1,m T(n,j)=Te END DO END IF IF (BCW==1) THEN IF (q==0) THEN

WRITE (*,*) "Enter the Temperatur @ WEST SIDE:" READ (*,*) Tw END IF DO j=1,m T(1,j)=Tw END DO END IF IF (BCN==1) THEN IF (q==0) THEN

WRITE (*,*) "Enter the Temperatur @ NORTH SIDE:" READ (*,*) Tn END IF DO i=1,n T(i,m)=Tn END DO END IF IF (BCS==1) THEN IF (q==0) THEN

WRITE (*,*) "Enter the Temperatur @ SOUTH SIDE:" READ (*,*) Ts END IF DO i=1,n T(i,1)=Ts END DO END IF RETURN

END SUBROUTINE Temperatur

SUBROUTINE HeatFlux (q,n,deltaX,m,deltaY,k,BCE,BCW,BCN,BCS,T) INTEGER,INTENT(IN) :: q,n,m,BCE,BCW,BCN,BCS REAL,INTENT(IN) :: deltaX,deltaY,k INTEGER :: i,j REAL :: qe,qw,qn,qs REAL,DIMENSION(1:n,1:m),INTENT(INOUT) :: T IF (BCE==2) THEN IF (q==0) THEN

(6)

READ (*,*) qe END IF DO j=1,m T(n,j)=qe*deltaX/k+T(n-1,j) END DO END IF IF (BCW==2) THEN IF (q==0) THEN

WRITE (*,*) "Enter the HeatFlux @ WEST SIDE:" READ (*,*) qw END IF DO j=1,m T(1,j)=qw*deltaX/k+T(2,j) END DO END IF IF (BCN==2) THEN IF (q==0) THEN

WRITE (*,*) "Enter the HeatFlux @ NORTH SIDE:" READ (*,*) qn END IF DO i=1,n T(i,m)=qn*deltaY/k+T(i,m-1) END DO END IF IF (BCS==2) THEN IF (q==0) THEN

WRITE (*,*) "Enter the HeatFlux @ SOUTH SIDE:" READ (*,*) qs END IF DO i=1,n T(i,1)=qs*deltaY/k+T(i,2) END DO END IF RETURN

END SUBROUTINE HeatFlux

SUBROUTINE Convection (q,n,deltaX,m,deltaY,k,h,BCE,BCW,BCN,BCS,T) INTEGER,INTENT(IN):: q,n,m,BCE,BCW,BCN,BCS REAL,INTENT(IN) :: deltaX,deltaY,k,h INTEGER :: i,j REAL :: Tinf_e,Tinf_w,Tinf_n,Tinf_s REAL,DIMENSION(1:n,1:m),INTENT(INOUT) :: T IF (BCE==3) THEN IF (q==0) THEN

(7)

READ (*,*) Tinf_e END IF DO j=1,m T(n,j)=(T(n-1,j)+(h*deltaX/k)*Tinf_e)/(h*deltaX/k+1) END DO END IF IF (BCW==3) THEN IF (q==0) THEN

WRITE (*,*) "Enter the Tinf_w @ WEST SIDE:" READ (*,*) Tinf_w END IF DO j=1,m T(1,j)=(T(2,j)+(h*deltaX/k)*Tinf_w)/(h*deltaX/k+1) END DO END IF IF (BCN==3) THEN IF (q==0) THEN

WRITE (*,*) "Enter the Tinf_n @ NORTH SIDE:" READ (*,*) Tinf_n END IF DO i=1,n T(i,m)=(T(i,m-1)+(h*deltaX/k)*Tinf_n)/(h*deltaY/k+1) END DO END IF IF (BCS==3) THEN IF (q==0) THEN

WRITE (*,*) "Enter the Tinf_s @ SOUTH SIDE:" READ (*,*) Tinf_s END IF DO i=1,n T(i,1)=(T(i,2)+(h*deltaX/k)*Tinf_s)/(h*deltaY/k+1) END DO END IF RETURN

References

Related documents

We reach this conclusion with the help of a large randomized field experiment that provided Finnish high school students accurate information about the earnings

As noted above, European banks funded purchases of U.S. assets through various forms of short-term dollar borrowing, making them highly vulnerable to any reduced availability of

This paper examines which strategy a firm will use to enter a foreign market: exporting, merger and acquisition (M&amp;A), or greenfield investment (through either a wholly

In the current research, the researcher started collecting the key secondary research materials with a direct relation to Saudi women’s fashion consumption, the market

I also understand that I am responsible for payment of the services or items I request and receive if these services or items are determined not to be reasonable and

In this paper, which builds upon the analysis in Drèze (2002), we derive the optimal insurance policy in a general model with a discrete number of states of health and we show

He said about banks website to be an important factor of trust and he feels that it has good amount of information about their services and activities. He perceives no problem

The current study aimed to establish a computational approach for modeling the magnetic resonance imaging (MRI)-based structural complexity of the brain using the framework of