Documente Academic
Documente Profesional
Documente Cultură
Name
: Nadya Amalia
Student ID
: 20213042
Subject
Lecturer
25 oC
T1,4
T2,4
T3,4
T1,3
T1,3
T2,3
T3,3
T4,3
T1,2
T1,1
T2,2
T3,2
T4,2
T1,1
T1,1
T2,1
T3,1
T4,1
T2,0
T3,0
T1,0
50 oC
0 oC
1, 2, + +1, ,1 2, + ,+1
+
=0
()2
()2
The Laplaces molecule distribution:
j+1
j
j-1
i-1
i+1
4, + , + 2, = 25
4 1
0
1
0
0
0
0
0 ,
25
1 4 1
0
1
0
0
0
0 1, 25
0
1 4 0
0
1
0
0
0 , 175
0
0 4 1
0
1
0
0 , 0
1
1
0
1 4 1
0
1
0 , = 0
0
0
1
0
1 4 0
0
1 , 150
0
0
0
0
1
0
0 4 1
0 3, 50
0
0
0
1
0
0
1 4 1 3, 50
0
0
0
0
0
1
0
1 4 200
,
After , is obtained, the overrelaxation step is applied to improve convergence. = 1.2 is used
, = , + (1 ),
, ,
, =
100%
The distributed temperature , will keep being updated as long as , is greater than or .
Heat flux:
, ,
'
2
, ,
= '
'
2
= '
with = 0.49 /. .
= +
= +
with in radians.
> 0
> 0
=
=
=
=
=
=
% Define
nx
=
ny
=
nx_int =
ny_int =
0.0;
25.0;
150.0;
50.0;
1.2;
0.49;
%
%
%
%
%
%
mesh
5.0;
5.0;
nx-1;
ny-1;
%
%
%
%
number
number
number
number
% Calculate intervals
xo
= 0.0;
xf
= 1.0;
yo
= 0.0;
yf
= 1.0;
dx
= (xf - xo)/nx_int;
dy
= (yf - yo)/ny_int;
xgrid = [xo:dx:xf];
ygrid = [yo:dy:yf];
of
of
of
of
for x = x0 (i = 0)
for x = xf (i = 4)
for x = x0 (i = 0)
for y = yf (i = 4)
% Told(i,j) = 0.0
Told(i,j) = (left + right + bottom + top) / 4.0;
end
end
fprintf('2D Heat Distribution (Liebmanns method)\n');
fprintf('==================================================================\n\
n');
fprintf('Boundary and initial conditions');
T = Told;
Temperatures = rot90(T)
% Tolerance and maximum number of Liebmann's iterations
itermax = 200.0;
% maximum number of iterations
tol
= 1.0 ;
% the absolute tolerance to check for convergance, 1%
fprintf('Maximum iteration
= %4.0d\n', itermax);
fprintf('Maximum error tolerance in percent = %7.4f\n', tol);
% Iteration loop
for iter = 1:itermax
Told = T;
% store values from previous iteration
for i = 2:(nx-1)
for j = 2:(ny-1)
% Apply Liebmann's method
T(i,j) = (T(i+1,j) + T(i-1,j) + T(i,j+1) + T(i,j-1)) / 4.0;
T(i,j) = lambda*T(i,j) + (1-lambda)*Told(i,j);
end
end
% Check for convergence using tolerance
for i = 2:(nx-1)
for j = 2:(ny-1)
err = (max(max(abs(T - Told))))*100;
end
end
fprintf('\nIteration = %4.0f, \t Error in percent = %4.4f', iter, err)
if err < tol
break
end
end
% Print out results to screen
fprintf('\n\nNumber of iterations = %2.0f\n\n',iter)
temp = fliplr(T);
disp('Temperatures in sheet in deg C = ')
for j = 1:ny
fprintf('%10.4f',temp(:,j))
fprintf('\n')
end
% Calculate temperature gradients
dTdx = zeros(nx,ny);
% deg C/cm - temperature gradient in x-direction
dTdy = zeros(nx,ny);
% deg C/cm - temperature gradient in y-direction
for j = 2:ny-1
% middle rows and columns
for i = 2:nx-1
dTdx(i,j) = (T(i+1,j) - T(i-1,j)) / (2*dx);
dTdy(i,j) = (T(i,j+1) - T(i,j-1)) / (2*dy);
end
end
for i = 2:nx-1
dTdx(i,1)
dTdx(i,ny)
dTdy(i,1)
dTdy(i,ny)
end
for j = 2:ny-1
dTdx(1,j)
dTdx(nx,j)
dTdy(1,j)
dTdy(nx,j)
/ (2*dy);
/ (2*dy);
end
% Corner nodes
dTdx(1,1)
= (-3*T(1,1)
dTdy(1,1)
= (-3*T(1,1)
+ 4*T(2,1)
+ 4*T(1,2)
- T(3,1))
- T(1,3))
/ (2*dx);
/ (2*dy);
dTdx(1,ny)
dTdy(1,ny)
= (-3*T(1,ny)
= ( 3*T(1,ny)
+ 4*T(2,ny)
- 4*T(1,ny-1)
- T(3,ny))
+ T(1,ny-2))
/ (2*dx);
/ (2*dy);
dTdx(nx,1)
dTdy(nx,1)
= ( 3*T(nx,1)
= (-3*T(nx,1)
- 4*T(nx-1,1)
+ 4*T(nx,2)
+ T(nx-2,1))
- T(nx,3))
/ (2*dx);
/ (2*dy);
Computation Results
2D Heat Distribution (Liebmanns method)
==================================================================
Boundary and initial conditions
Temperatures =
25.0000
25.0000
25.0000
25.0000
0
150.0000
56.2500
56.2500
56.2500
0
150.0000
56.2500
56.2500
56.2500
0
150.0000
56.2500
56.2500
56.2500
0
Maximum iteration
=
Maximum error tolerance in percent =
Iteration
Iteration
Iteration
Iteration
Iteration
Iteration
Iteration
Iteration
=
=
=
=
=
=
=
=
1,
2,
3,
4,
5,
6,
7,
8,
Error
Error
Error
Error
Error
Error
Error
Error
Number of iterations =
in
in
in
in
in
in
in
in
percent
percent
percent
percent
percent
percent
percent
percent
150.0000
50.0000
50.0000
50.0000
0
200
1.0000
=
=
=
=
=
=
=
=
3072.3000
1290.9750
657.2160
346.6755
141.9222
11.0987
3.2435
0.3362
150.0000
50.0000
50.0000
50.0000
0.0000
0.2940
0.1435
0.0210
0.0647
0.1470
Temperature (deg C)
1
150
0.9
0.8
0.7
100
0.6
0.5
0.4
50
0.3
0.2
0.1
0
0.2
0.4
0.6
0.8