Sie sind auf Seite 1von 4

heat.

for
1
C****************************************************************
2
C PROGRAM FOR HEAT CONDUCTION WITH IMPLICIT METHOD
*
3
C****************************************************************
4
C
5
PROGRAM MAIN
6
PARAMETER (N=101)
7
COMMON
8
&/VAR/TEMP(NX)
9
&/ALL/NI,NIM1,F,DTIME
10
&/GEOM/X(NX),DXEP(NX),DXPW(NX),SEW(NX)
11
&/COEF/AP(NX),AE(NX),AW(NX),SU(NX),SP(NX)
12
OPEN (10,FILE='HEAT.DAT',STATUS='UNKNOWN')
13
C--INITIAL PARAMETER
14
NI = 21
15
NIM1 = NI-1
16
XMAX = 1.0
17
TMAX = 0.5
18
DX = XMAX/FLOAT(NIM1)
19
WRITE(6.*)'LOCAL FOURIER NUMBER R= '
20
READ(5,*)R
21
DTIME = R*DX*DX
22
F
= 0.5
23
CALL INIT
24
WRITE(6,1000)NI,XMAX,TMAX,DTIME
25
WRITE(6,1010)(X(I),I=1,NI)
26
NITER = 0
27
TIME = 0.
28
WRITE(6,1020)NITER,TIME
29
WRITE(6,1010)(TEMP(I),I=1,NI)
30
WRITE(10,1010)(TEMP(I),I=1,NI)
31
C--CALCULATE TEMPERATURE WITH TIME MARCHING
32
10 NITER = NITER+1
33
TIME = TIME+DTIME
34
CALL CALCOE
35
CALL TDMA(NI,TEMP)
36
WRITE(6,1020)NITER,TIME
37
WRITE(6,1010)(TEMP(I),I=1,NI)
38
WRITE(10,1010)(TEMP(I),I=1,NI)
39
IF(TIME.LT.TMAX)GO TO 10
40
WRITE(6,1030)
41
CLOSE (10)
42
STOP
43
1000 FORMAT(1H ,'NUMBER OF GRID= ',I3,' XMAX= ',F8.3,
44
&
' TMAX= ',F8.3,' DTIME= ',F8.3/
45
&
'GRID POINT LOCATIONS')
46
1010 FORMAT(1H ,10F8.3)
47
1020 FORMAT(1H ,'NITER= ',I4,5X,'TIME= ',F10.4)
48
1030 FORMAT(//1H ,'CALCULATION END')
49
END
50
C
51
SUBROUTINE INIT
52
PARAMETER (NX=101)
53
COMMON
54
&/VAR/TEMP(NX)
55
&/ALL/NI,NIM1,F,DTIME
56
&/GEOM/X(NX),DXEP(NX),DXPW(NX),SEW(NX)
57
&/COEF/AP(NX),AE(NX),AW(NX),SU(NX),SP(NX)
58
C--PARAMETERS FOR METRICS
59
DX = 1./FLOAT(NIM1)

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119

X(1) = 0.
DO 10 I=2,NI
X(I) = X(I-1)+DX
10 CONTINUE
C--DXPW : DISTANCE BETWEEN POINTS P AND W
C--DXEP : DISTANCE BETWEEN POINTS E AND P
DXPW(1) = 0.0
DXEP(NI) = 0.0
DO 101 I=1,NIM1
DXEP(I) = X(I+1)-X(I)
DXPW(I+1) = DXEP(I)
101 CONTINUE
C--SEW : SPACING BETWEEN POINTS E AND W
SEW(1) = 0.0
SEW(NI) = 0.0
DO 103 I=2,NIM1
SEW(I) = 0.5*(DXEP(I)+DXPW(I))
103 CONTINUE
C--INITIAL VALUES FOR TEMPERATURE
DO 200 I=1,NI
TEMP(I) = 1.
C IF YOU USE THE TRIANGLE DISTRIBUTION AS AN INITIAL CONDITION
C
IF(X(I).LE.0.5)THEN
C
TEMP(I)=2.*X(I)
C
ELSE
C
TEMP(I)=2.*(1-X(I))
C
ENDIF
200 CONTINUE
RETURN
END
C
C--CALCULATION OF COEFFICIENTS IN ALGEBRAIC EQUATIONS
C
FOR TEMPERATURE
SUBROUTINE CALCOE
PARAMETER (NX=101)
COMMON
&/VAR/TEMP(NX)
&/ALL/NI,NIM1,F,DTIME
&/GEOM/X(NX),DXEP(NX),DXPW(NX),SEW(NX)
&/COEF/AP(NX),AE(NX),AW(NX),SU(NX),SP(NX)
C--BOUNDARY VALUES FOR TEMPERATURE
TEMP(1) = O.
TEMP(NI) = O.
AP(1)
= 1.
AE(1)
= O.
SU(1)
= TEMP(1)
AP(NI) = 1.
AW(NI) = O.
SU(NI) = TEMP(NI)
C--PARAMETER FOR IMPLICIT ALGORITHM
F1= 1.-F
C--CALCULATION OF COEFFICIENTS
DO 100 I=2,NIM1
AEOR = 1./DXEP(I)
AWOR = 1./DXPW(I)
APO = SEW(I)/DTIME
AP(I) = F*AEOR+F*AWOR+APO
AE(I) = AEOR*F
AW(I) = AWOR*F
SU(I) = AEOR*F1*TEMP(I+1)+AWOR*F1*TEMP(I-1)

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

&

+(APO-F1*AEOR-Fl*AWOR)*TEMP(I)
SP(I) = O.
100 CONTINUE
RETURN
END

C
C--SOLVE TRI-DIAGONAL MATRIX
SUBROUTINE TDMA(NI,PHI)
PARAMETER (NX=101)
DIMENSION PHI(NI),P(NX),Q(NX)
COMMON
&/COEF/AP(NX),AE(NX),AW(NX),SU(NX),SP(NX)
NIM1 = NI-1
P(1) = AE(1)/AP(1)
Q(1) = SU(1)/AP(1)
DO 100 I=2,NI
C--CALCULATE COEFFICIENTS OF RECURRENCE FORMULA
TERM = 1./(AP(I)-AW(I)*P(I-1))
P(I) = AE(I)*TERM
Q(I) = (SU(I)+AW(I)*Q(I-1))*TERM
100 CONTINUE
PHI(NI) = Q(NI)
C--OBTAIN NEW PHI'S
DO 110 II=2,NIM1
I
= NI+1-II
PHI(I) = P(I)*PHI(I+1)+Q(I)
110 CONTINUE
RETURN
END

graph2.for
1 C***********************************************************
2 C
GRAPHICS PROGRAM FOR HEAT CONDUCTION EQUATION
*
3 C***********************************************************
4
PROGRAM HEATGRAPH
5
REAL X(0:20),T(0:20),XX,YY,X1,X2,Y1,Y2
6
INTEGER I,ITIME,IEND
7 C--GPSL INITIAL
8
CALL PLOTS
9
CALL CLSX
10
CALL CLSC
11
CALL WINDOW(-0.1,-0.1,1.1,1.1)
12
CALL VPORT(0.0,0.0,1.6,0.9)
13 C--TRUNCATION OF COORDINATE VALUES
14
DO 10 1=0,20
15
X(I)=0.05*I
16
10 CONTINUE
17 C--PLOT OF X-Y AXIS
18
CALL PLINE(0.0,0.0,1.05,0.0)
19
CALL-PLINE(0.0,0.0,0.0,1.05)
20
DO 20 1=1,20
21
XX=1./20.*FLOAT(I)
22
YY=1./20.*FLOAT(I)
23
CALL PLINE(XX,0.0,XX,0.02)
24
CALL PLINE(0.0,YY,0.015,YY)
25
20 CONTINUE
26
OPEN(10,FILE='HEAT.DAT',STATUS='UNKNOWN')
27
DO 30 ITIME=1,100
28 C--READ THE TEMPERATURE FROM THE FILE
29
READ(10,*,END=50)(T(I),I=0,20)

30 C--PLOT THE DISTRIBUTION OF THE TEMPERATURE


31
DO 40 1=1,20
32
CALL PLINE(X(J-1),T(I-1),X(I),T(I))
33
40 CONTINUE
34
30 CONTINUE
35
50 CONTINUE
36
CLOSE(10)
37
WRITE(6.*)'1-D HEAT CONDUCTION ANALYSYS. END=0 HOLD=999'
38
READ(5,*)IEND
39
IF(IEND.NE.999)THEN
40 C--GPSL END
41
CALL CLSX
42
CALL CLSC
43
ENDIF
44
STOP
45
END
46
47
SUBROUTINE PLINE(X1,Y1,X2,Y2)
48
REAL X1,Y1,X2,Y2
49 C--DRAW THE LINE BETWEEN TWO POINTS
50
CALL PLOT(X1,Y1,3)
51
CALL PLOT(X2,Y2,2)
52
RETURN
53
END