Sunteți pe pagina 1din 6

Homework 5

Name

: Nadya Amalia

Student ID

: 20213042

Subject

: Computation of Physical Systems (FI5005)

Lecturer

: Dr.rer.nat. Linus Ampang Pasasa

SOLVING LAPLACES EQUATION USING LIEBMANNS METHOD


Consider a rectangle conductor plate is divided into 55 grids with the following boundary
conditions.
150 oC

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 and = 1%. ( = 0.49 /. . )


Solution

The Laplaces equation for 2D heat distribution:


2 (, )2 (, )
+
=0
2
2

1, 2, + +1, ,1 2, + ,+1
+
=0
()2
()2
The Laplaces molecule distribution:

j+1
j
j-1
i-1

i+1

If = then 1, + ,1 + ,+1 + +1, 4, = 0

25 + 0 + 1,2 + 2,1 41,1 = 0

For point (1,1):

0,1 + 1,0 + 1,2 + 2,1 41,1 = 0

4, + , + 2, = 25

For point (1,2):

For point (2,3):

0,2 + 1,1 + 1,3 + 2,2 41,2 = 0

1,3 + 2,2 + 2,4 + 3,3 42,3 = 0

1,1 41,2 + 1,3 + 2,2 = 25


For point (1,3):

1,3 + 2,2 42,3 + 3,3 = 150

0,3 + 1,2 + 1,4 + 2,3 41,3 = 0

2,1 + 3,0 + 3,2 + 4,1 43,1 = 0

1,2 41,3 + 2,3 = 175


For point (2,1):

2,1 43,1 + 3,2 = 50

1,1 + 2,0 + 2,2 + 3,1 42,1 = 0

2,2 + 3,1 + 3,3 + 4,2 43,2 = 0

1,1 42,1 + 2,2 + 3,1 = 0


For point (2,2):

2,2 + 3,1 43,2 + 3,3 = 50

1,2 + 2,1 + 2,3 + 3,2 42,2 = 0

2,3 + 3,2 + 3,4 + 4,3 43,3 = 0

25 + 1,1 + 1,3 + 2,2 41,2 = 0

1,3 + 2,2 + 150 + 3,3 42,3 = 0


For point (3,1):

25 + 1,2 + 150 + 2,3 41,3 = 0

2,1 + 0 + 3,2 + 50 43,1 = 0


For point (3,2):

1,1 + 0 + 2,2 + 3,1 42,1 = 0

2,2 + 3,1 + 3,3 + 50 43,2 = 0


For point (3,3):

1,2 + 2,1 42,2 + 2,3 + 3,2 = 0

2,3 + 3,2 43,3 = 200

Thus, we obtain the following system of the equations:

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 ),

with maximum tolerance = 1%, where

, ,
, =
100%

The distributed temperature , will keep being updated as long as , is greater than or .
Heat flux:

, ,

'

2
, ,

= '
'

2
= '

with = 0.49 /. .

Resultant flux and the direction:

= +

= +

with in radians.

> 0

> 0

MATLAB Source Code


% Solving Laplace's equation using Liebmann's method
% 2D Heat Distribution in Metal Sheet
clc, clear all;
% Author: Nadya Amalia (20213042)
% Department of Physics
% Bandung Institute of Technology, Bandung
bottom
left
top
right
lambda
k

=
=
=
=
=
=

% Define
nx
=
ny
=
nx_int =
ny_int =

0.0;
25.0;
150.0;
50.0;
1.2;
0.49;

%
%
%
%
%
%

deg C - bottom edge boundary value


deg C - left edge boundary value
deg C - top edge boundary value
deg C - right edge boundary value
relaxation value in Liebmann's method
Cal/cm.?)

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

grid points in the x-direction


grid points in the y-direction
intervals in the x-direction
intervals in the y-direction

% cm - grid spacing in x-direction


% cm - grid spacing in x-direction

% Initialize T and Told


T
= zeros(nx,ny);
Told = zeros(nx,ny);
% Boundary Conditions
for i = 1:nx
% boundary condition
Told(1,i) = left;
% boundary condition
Told(nx,i) = right;
% boundary condition
Told(i,1) = bottom;
% boundary condition
Told(i,ny) = top;
end

for x = x0 (i = 0)
for x = xf (i = 4)
for x = x0 (i = 0)
for y = yf (i = 4)

% Set initial guess at the interior nodes of Told


for i = 2:nx_int
for j = 2:ny_int
3

% 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)

% bottom and top rows


= ( T(i+1,1) - T(i-1,1))
/ (2*dx);
= ( T(i+1,ny) - T(i-1,ny)) / (2*dx);
= (-3*T(i,1) + 4*T(i,2)
- T(i,3))
/ (2*dy);
= ( 3*T(i,ny) - 4*T(i,ny-1) + T(i,ny-2)) / (2*dy);
4

end
for j = 2:ny-1
dTdx(1,j)
dTdx(nx,j)
dTdy(1,j)
dTdy(nx,j)

% left and right sides


= (-3*T(1,j) + 4*T(2,j)
- T(3,j))
/ (2*dx);
= ( 3*T(nx,j) - 4*T(nx-1,j) + T(nx-2,j)) / (2*dx);
= ( T(1,j+1) - T(1,j-1))
= ( T(nx,j+1) - T(nx,j-1))

/ (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);

dTdx(nx,ny) = ( 3*T(nx,ny) - 4*T(nx,ny-1) + T(nx,ny-2)) / (2*dx);


dTdy(nx,ny) = ( 3*T(nx,ny) - 4*T(nx-1,ny) + T(nx-2,ny)) /(2*dy);
% Calculate heat fluxes
qflux_x = -k*dTdx;
direction
qflux_y = -k*dTdy;
direction
qflux
= sqrt(qflux_x.^2

% Cal/cm^2 - heat flux in x% Cal/cm^2 - heat flux in y+ qflux_y.^2);

% Cal/cm^2 - heat flux magnitude

% Display results to screen


fprintf('\n')
disp('Heat flux in sheet in kCal/cm^2 = ')
for j=ny:-1:1
fprintf('%10.4f', qflux(:,j)*1e-3)
fprintf('\n')
end
% Contour plot showing isotherms in the sheet
v = top:(bottom-top)/22:bottom;
% deg C - magnitudes for contours
colormap(jet)
% set color scheme for contour plot
contourf(xgrid, ygrid, T', v);
% contour plot of T versus (x, y)
colorbar
% add colorbar to contour plot
caxis([bottom top]);
% set colorbar to range from top to
bottom
axis equal tight
% make axis to scale
title('Temperature (deg C)')
xlabel('x')
ylabel('y')
% Vector plot showning heat flux vectors
hold on
quiver(xgrid, ygrid, qflux_x, qflux_y,2)
hold off

% vector plot of heat flux

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

Temperatures in sheet in deg C =


25.0000 150.0000 150.0000 150.0000
25.0000
78.5717
93.0805
87.5000
25.0000
46.2062
56.2504
56.9198
25.0000
25.0015
28.7954
33.9287
0.0000
0.0000
0.0000
0.0000

150.0000
50.0000
50.0000
50.0000
0.0000

Heat flux in sheet in kCal/cm^2 =


0.3675
0.2163
0.1312
0.1538
0.1433
0.1216
0.0923
0.1005
0.0525
0.0608
0.0639
0.0529
0.0248
0.0454
0.0558
0.0595
0.0735
0.0527
0.0578
0.0772
>>

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

Figure 1. 2D heat distribution in metal sheet

S-ar putea să vă placă și