1st Project-2D HT in SQR Plate With MATLAB PDF
1st Project-2D HT in SQR Plate With MATLAB PDF
1st Project-2D HT in SQR Plate With MATLAB PDF
Problem Description:
Simulation of 2D Heat Transfer in a Square Plate with MATLAB. In different
conditions. The conditions in this homework are as to be:
1. An square plate with insulation in 3 sides, with 5-elemented meshing pattern,
heat input of 100C, and 20C of steady temperature in 3 other walls;
2. The square plate remains the same as (1), but with 2 sides of insulation at 20C,
and heat input of 100 and 250C in two other walls, and 10-elemented meshing
pattern;
3. Same square plate as (1), but with no insulated wall. Heat inputs are represented
as 100, 250, 400, and 500C, for top, left, right, and bottom respectively, and the
meshing pattern is considered as 20-element style.
All the elements assumed as quadratic shape, and heat transfer regime is steady state.
Page 1 of 11
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
1. The square plate with 3 insulated walls and 5-elemented meshing pattern:
Heat input of 100C acting on top wall, and 3 remaining sides are insulated at 20C.
Square plate to be assumed 1m long and 1m wide. Step determined as 5, then
1000
200
So, in overall, there are 25 meshes generated and the temperature for 36 nodes1 must
be determined (Fig.2).
The partial differential equation for problem conditions mentioned earlier can be
expressed as below:
So, for horizontal step=vertical step=5, no. of the nodes determined as 36.
Page 2 of 11
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
When there is no heat generation in the medium, the finite difference equation for an
interior node further simplifies to:
1
[1]
Taking a volume element for a general interior node, with (m,n) coordination, as stated
in Fig.3, we have T(m,n) address for an example interior node.
Fig.3: The volume element of a general interior node (m, n) for two dimensional conduction in rectangular
coordinates [1]
Page 3 of 11
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
So, as for programming in MATLAB, the equation above can be expressed as:
,
In order to writing a code in MATLAB, we have to use a preliminary value for all of
the nodes consisting the [T] matrix. As an example, and just for start, the temperature
of 20C has been chosen.
The MATLAB code generated as below:
m=6; n=6;
T(1:m,1:n)=20; %Preliminary Values of 36 Points%
T(1,2:n-1)=100; %Boundary Condition of Top Side Heating%
for k=1:1:inf
T0=T;
for i=2:m-1
for j=2:n-1
T(i,j)=(1/4)*(T(i-1,j)+T(i+1,j)+T(i,j-1)+T(i,j+1));
end
end
error=max(max(abs(T0-T)));
if error<1e-2
break
end
end
T
iteration=k
subplot(2,1,1),contour(T),title('Thermal Distribution in Steady
State'),xlabel('x'),ylabel('y'),colorbar
subplot(2,1,2),pcolor(T),shading interp,title('Thermal Distribution
(SS)'),xlabel('x'),ylabel('y'),colorbar
The first FOR loop is used to permit MATLAB calculator to select the right iteration
value (named as k), resulting in [T] matrix and iteration value as below:
T =
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
iteration =
18
Page 4 of 11
100.0000
56.3557
37.8684
28.7795
23.6322
20.0000
100.0000
67.5654
46.3501
33.6254
25.7521
20.0000
100.0000
67.5674
46.3527
33.6275
25.7531
20.0000
100.0000
56.3594
37.8733
28.7834
23.6341
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
2. The square plate with 2 insulated walls and 10-elemented meshing pattern:
Heat input of 100C remains acting on top wall, but 250C of temperature is feeding
from left side of the square plate. The 2 remaining sides (right and bottom) are insulated
at 20C. Square plate to be assumed 1m long and 1m wide. Step determined as 10, then
1000
10
100
So, in overall, there are 100 meshes generated and the temperature for 121 nodes2 must
be determined.
As the strategy for problem solving remains the same, the MATLAB code presented as
below:
So, for horizontal step=vertical step=10, no. of the nodes determined as 121.
Page 5 of 11
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
m=11; n=11;
T(1:m,1:n)=20; %Preliminary Values of 121 Points%
T(1,2:n-1)=100; %Boundary Condition of Top Side Heating%
T(1:m-1,1)=250; %Boundary Condition of Left Side Heating%
for k=1:1:inf
T0=T;
for i=2:m-1
for j=2:n-1
T(i,j)=(1/4)*(T(i-1,j)+T(i+1,j)+T(i,j-1)+T(i,j+1));
end
end
error=max(max(abs(T0-T)));
if error<1e-2
break
end
end
T
iteration=k
subplot(2,1,1),contour(T),title('Thermal Distribution in Steady
State'),xlabel('x'),ylabel('y'),colorbar
subplot(2,1,2),pcolor(T),shading interp,title('Thermal Distribution
(SS)'),xlabel('x'),ylabel('y'),colorbar
T =
Columns 1 through 8
250.0000
100.0000
250.0000
89.0695
250.0000
80.7654
250.0000
74.6369
250.0000
69.4464
250.0000
64.1107
250.0000
57.8813
250.0000
50.3254
250.0000
41.3119
250.0000
31.0311
20.0000
20.0000
Page 6 of 11
100.0000
100.0000
100.0000
100.0000
100.0000
100.0000
171.5535
138.5685
121.4501
110.7594
102.9345
96.1934
197.6507
161.2784
136.4820
118.6634
104.7953
92.7783
207.7786
172.4242
144.5508
122.6323
104.8199
89.3720
211.0491
176.1036
146.6823
122.5135
102.4975
85.2680
210.3246
174.2743
143.5798
118.2616
97.4073
79.7722
205.9848
167.1041
135.1187
109.5643
89.1157
72.3180
196.5195
153.0512
120.2418
95.7774
77.1883
62.5157
177.0486
128.3494
97.0313
76.1275
61.3556
50.2408
133.3299
86.2727
63.4136
50.3529
41.8730
35.7858
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
Columns 9 through 11
100.0000
79.3260
66.5865
58.9756
53.7819
49.3544
44.7808
39.6000
33.6547
27.0281
20.0000
100.0000
61.6524
47.2853
40.9043
37.3587
34.7510
32.2933
29.6433
26.6812
23.4273
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
20.0000
iteration =
70
Page 7 of 11
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
3. The square plate with no insulated walls and 20-elemented meshing pattern:
Heat input values are of 100, 250, 400, and 500C for top, left, right, and bottom sides,
respectively. Preliminary temperature of all nodes remains at 20C. Square plate to be
assumed 1m long and 1m wide. Step determined as 20, then
1000
20
50
So, in overall, there are 400 meshes generated and the temperature for 441 nodes3 must
be determined.
As the strategy for problem solving remains the same, the MATLAB code presented as
below:
m=21; n=21;
T(1:m,1:n)=20; %Preliminary Values of 121 Points%
T(1,1:n)=100; %Boundary Condition of Top Side Heating%
T(2:m-1,1)=250; %Boundary Condition of Left Side Heating%
T(m,1:n)=500; %Boundary Condition of Bottom Side Heating%
T(2:m-1,n)=400; %Boundary Condition of Right Side Heating%
for k=1:1:inf
T0=T;
for i=2:m-1
for j=2:n-1
T(i,j)=(1/4)*(T(i-1,j)+T(i+1,j)+T(i,j-1)+T(i,j+1));
end
end
error=max(max(abs(T0-T)));
if error<1e-2
break
end
end
T
iteration=k
subplot(2,1,1),contour(T),title('Thermal Distribution in Steady
State'),xlabel('x'),ylabel('y'),colorbar
subplot(2,1,2),pcolor(T),shading interp,title('Thermal Distribution
(SS)'),xlabel('x'),ylabel('y'),colorbar
After 289 iteration of solving, the [T] matrix resulted provided as below:
So, for horizontal step=vertical step=20, no. of the nodes determined as 441.
Page 8 of 11
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
T =
Columns 1 through 8
100.0000
100.0000
250.0000
124.2785
250.0000
147.9173
250.0000
170.4348
250.0000
191.5708
250.0000
211.2674
250.0000
229.6166
250.0000
246.8097
250.0000
263.0991
250.0000
278.7752
250.0000
294.1528
250.0000
309.5651
250.0000
325.3601
250.0000
341.8964
250.0000
359.5347
250.0000
378.6181
250.0000
399.4357
250.0000
422.1610
250.0000
446.7665
250.0000
472.9317
500.0000
500.0000
100.0000
100.0000
100.0000
100.0000
100.0000
100.0000
176.4973
148.3465
135.9009
129.7696
126.5794
124.9566
207.6437
180.9900
165.4903
156.6013
151.5955
148.9728
223.0895
202.4828
188.4734
179.5555
174.2351
171.4289
232.2342
217.3828
206.3713
198.9196
194.3693
192.0826
238.4680
228.4487
220.7169
215.3917
212.2509
210.9734
243.1930
237.2334
232.6648
229.6901
228.2818
228.3067
247.0750
244.6345
243.0284
242.4343
242.8932
244.3705
250.4774
251.2090
252.3905
254.1383
256.5014
259.4889
253.6305
257.3417
261.1971
265.2405
269.5005
274.0018
256.7081
263.3382
269.8270
276.1396
282.2742
288.2599
259.8689
269.4841
278.6439
287.2304
295.2122
302.6281
263.2882
276.0932
288.0446
298.9389
308.7310
317.4918
267.1952
283.5635
298.5122
311.7617
323.2954
333.2636
271.9332
292.4602
310.6881
326.3115
339.4380
350.3850
278.0813
303.6620
325.4765
343.3680
357.7714
369.3162
286.7329
318.6352
344.1947
363.9209
378.9731
390.5007
300.2178
339.9552
368.7515
389.1546
403.7069
414.2865
324.1851
372.2192
401.7053
420.2439
432.4191
440.7833
374.3044
423.0330
445.6092
457.6994
464.9455
469.6648
500.0000
500.0000
500.0000
500.0000
500.0000
500.0000
Columns 9 through 16
100.0000
100.0000
124.2450
141.4381
147.9911
179.8078
Page 9 of 11
100.0000
100.0000
100.0000
100.0000
100.0000
100.0000
124.7152
125.6434
127.0556
129.0510
131.8264
135.7376
148.9775
150.8079
153.5330
157.3266
162.5212
169.6895
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
170.8326
213.5306
192.5113
242.3740
212.9236
266.8372
232.0992
287.6785
250.1702
305.6696
267.3411
321.4999
283.8657
335.7567
300.0294
348.9369
316.1373
361.4676
332.5037
373.7279
349.4425
386.0694
367.2527
398.8320
386.1972
412.3547
406.4718
426.9748
428.1619
442.9997
451.1941
460.6293
475.2968
479.8031
500.0000
500.0000
172.4041
175.0858
178.9496
184.2086
191.2492
200.6973
194.7316
198.1926
202.9816
209.3188
217.5788
228.3280
215.8320
219.9848
225.4784
232.5184
241.4303
252.6717
235.7037
240.4519
246.4437
253.8601
262.9653
274.1027
254.4491
259.6926
266.0009
273.5287
282.4822
293.1079
272.2486
277.8871
284.3563
291.7883
300.3420
310.1906
289.3364
295.2700
301.7672
308.9436
316.9229
325.8263
305.9811
312.1086
318.5177
325.3135
332.5955
340.4492
322.4692
328.6850
334.8998
341.2147
347.7122
354.4519
339.0923
345.2807
351.1995
356.9501
362.6018
368.1920
356.1331
362.1633
367.6842
372.7998
377.5672
381.9989
373.8502
379.5710
384.5894
389.0121
392.8813
396.1785
392.4581
397.6950
402.1036
405.7904
408.7788
411.0118
412.1018
416.6591
420.3509
423.2777
425.4414
426.7434
432.8275
436.4980
439.3722
441.5364
442.9734
443.5525
454.5551
457.1401
459.1100
460.5285
461.3689
461.4981
477.0629
478.4012
479.4030
480.1023
480.4787
480.4447
500.0000
500.0000
500.0000
500.0000
500.0000
500.0000
100.0000
250.6764
310.6540
339.2343
355.2133
365.3617
372.4659
377.8279
382.1302
385.7695
389.0008
392.0075
394.9403
397.9471
401.2050
404.9738
409.7108
416.3616
427.1946
100.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
400.0000
Columns 17 through 21
100.0000
150.2103
194.5782
231.2498
260.8086
284.6342
304.1151
320.4034
334.3943
346.7757
358.0860
368.7648
379.1933
389.7286
400.7337
412.6075
425.8070
440.8462
458.2187
Page 10 of 11
100.0000
164.8274
217.0490
256.0872
284.9832
306.7833
323.7528
337.4436
348.9078
358.8752
367.8758
376.3212
384.5604
392.9253
401.7736
411.5402
422.8039
436.3628
453.2621
100.0000
192.0522
252.7061
291.0709
316.2583
333.7688
346.6751
356.7168
364.9247
371.9483
378.2277
384.0901
389.8079
395.6443
401.9000
408.9800
417.5086
428.5414
443.9338
Homework
Course: CFD (Computational Fluid Dynamics)
Student Name: Ahmadreza Aminian
478.1389
500.0000
474.5346
500.0000
466.7378
500.0000
448.4831
500.0000
iteration =
289
References:
1. Y.A. engel, Heat and Mass Transfer; a Practical Approach, 2nd ed., McGraw-Hill, 2002, pp
301-302.
Page 11 of 11