Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

A) Program Description:

The MATLAB function Gauss- Siedel. m is written to solve a set of linear algebraic equations
by the Gauss- Siedel iterative method. Inputs to the function are the coefficient matrix, the
vector of constants, and the vector of initial guesses for all the unknowns (T11 to T25). The
default convergence criterion is absolute of [(T (i) – T (i-1))/T (i)] < 10-4.

The next step in the program is to build the modified coefficient matrix and the modified
vector of constants. The function then starts the substitution procedure according to Eq. (7),
which continues until the convergence criterion is reached for all of the unknowns.

Then it calls the function Gauss Siedel. m to solve the set of equations. Finally, the program
shows the final results of calculation.

Program

% Solve the system of linear equation using Gauss-Seidel method:


% 5.56T11-1.78T12-T21= 178
% -1.78T11+5.56T12-1.78T13-T22= 0
% -1.78T12+5.56T13-1.78T14-T23= 0
% -1.78T13+5.56T14-1.78T15-T24= 0
% -1.78T14+5.56T15-T25= 178
% -T11+5.56T21-1.78T22= 178
% -T12-1.78T21+5.56T22-1.78T23= 0
% -T13-1.78T22+5.56T23-1.78T24= 0
% -T14-1.78T23+5.56T24-1.78T25= 0
% -T15-1.78T24+5.56T25= 178
% Initial values: T12=0, T13=0, T14=0, T15=0, T21=0, T22=0,
T23=0,
% T24=0, T25=0
% Iterate until the value of error for T11 is less than 0.01%
% Solution:
% T11=(178+1.78T12+T21)/5.56
% T12=(1.78T11+1.78T13+T22)/5.56
% T13=(1.78T12+1.78T14+T23)/5.56
% T14=(1.78T13+1.78T15+T24)/5.56
% T15=(178+1.78T14+T25)/5.56
% T21=(178+T11+1.78T22)/5.56
% T22=(T12+1.78T21+1.78T23)/5.56
% T23=(T13+1.78T22+1.78T24)/5.56
% T24=(T14+1.78T23+1.78T25)/5.56
% T25=(178+T15+1.78T24)/5.56

clear;clc;format('long','g');
i=1;
T12(i)=0;T13(i)=0;T14(i)=0;T15(i)=0;T21(i)=0;T22(i)=0;T23(i)=0;T24(i
)=0;T25(i)=0;
error_T11(i)=9999;

while error_T11(i)>=0.01
T11(i+1)=(178+1.78*T12(i)+T21(i))/5.56;
T12(i+1)=(1.78*T11(i+1)+1.78*T13(i)+T22(i))/5.56;
T13(i+1)=(1.78*T12(i+1)+1.78*T14(i)+T23(i))/5.56;
T14(i+1)=(1.78*T13(i+1)+1.78*T15(i)+T24(i))/5.56;
T15(i+1)=(178+1.78*T14(i+1)+T25(i))/5.56;
T21(i+1)=(178+T11(i+1)+1.78*T22(i))/5.56;
T22(i+1)=(T12(i+1)+1.78*T23(i))/5.56;
T23(i+1)=(T13(i+1)+1.78*T22(i+1)+1.78*T24(i))/5.56;
T24(i+1)=(T14(i+1)+1.78*T23(i+1)+1.78*T25(i))/5.56;
T25(i+1)=(178+T15(i+1)+1.78*T24(i+1))/5.56;

error_T11(i+1)=abs((T11(i+1)-T11(i))/T11(i+1))*100;
error_T12(i+1)=abs((T12(i+1)-T12(i))/T12(i+1))*100;
error_T13(i+1)=abs((T13(i+1)-T13(i))/T13(i+1))*100;
error_T14(i+1)=abs((T14(i+1)-T14(i))/T14(i+1))*100;
error_T15(i+1)=abs((T15(i+1)-T15(i))/T15(i+1))*100;
error_T21(i+1)=abs((T21(i+1)-T21(i))/T21(i+1))*100;
error_T22(i+1)=abs((T22(i+1)-T22(i))/T22(i+1))*100;
error_T23(i+1)=abs((T23(i+1)-T23(i))/T23(i+1))*100;
error_T24(i+1)=abs((T24(i+1)-T24(i))/T24(i+1))*100;
error_T25(i+1)=abs((T25(i+1)-T25(i))/T25(i+1))*100;

i=i+1;
end

disp(' T11 error(%)');


disp([T11',error_T11'])
disp(' T12 error(%)');
disp([T12',error_T12'])
disp(' T13 error(%)');
disp([T13',error_T13'])
disp(' T14 error(%)');
disp([T14',error_T14'])
disp(' T15 error(%)');
disp([T15',error_T15'])
disp(' T21 error(%)');
disp([T21',error_T21'])
disp(' T22 error(%)');
disp([T22',error_T22'])
disp(' T23 error(%)');
disp([T23',error_T23'])
disp(' T24 error(%)');
disp([T24',error_T24'])
disp(' T25 error(%)');
disp([T25',error_T25'])

DISPLAIED RESULT
Using Gauss - Siedel Iterative Method
>>

Result

Discussion of Results: In this case we use the value of 0 as the initial guess for the values of the
unknowns T11 to T25. The Gauss- Siedel method converges to the solution in 15 iterations. The
convergence criterion, which is satisfied by all the unknowns, is 0.001.
B. In case with insulated bottom edge

i. Using Gauss – Siedel iteration method

The program description is similar to the previous one, however there will be 2 additional unknowns
found at the bottom interior edge (i.e. T01 and T02) and also we should have to include an initial
guess for these unknown terms in addition to the previous unknowns.

Program

% Solve the system of linear equation using Gauss-Seidel method:


% 5.56T10-3.56T11-T20= 0
% -1.78T10+5.56T11-1.78T12-T21= 0
% -1.78T11+5.56T12-1.78T13-T22= 0
% -1.78T12+5.56T13-1.78T14-T23= 0
% -1.78T13+5.56T14-1.78T15-T24= 0
% -1.78T14+5.56T15-T25= 178
% -T10+5.56T20-3.56T21= 0
% -T11-1.78T20+5.56T21-1.78T22= 0
% -T12-1.78T21+5.56T22-1.78T23= 0
% -T13-1.78T22+5.56T23-1.78T24= 0
% -T14-1.78T23+5.56T24-1.78T25= 0
% -T15-1.78T24+5.56T25= 178
% Initial values: T11=0, T12=0, T13=0, T14=0, T15=0, T20=0,
T21=0,
% T22=0, T23=0, T24=0, T25=0
% Iterate until the value of error for T11 is less than 0.01%
% Solution:
% T10=( T20+3.56T11)/5.56
% T11=(1.78T10+1.78T12+T21)/5.56
% T12=(1.78T11+1.78T13+T22)/5.56
% T13=(1.78T12+1.78T14+T23)/5.56
% T14=(1.78T13+1.78T15+T24)/5.56
% T15=(178+1.78T14+T25)/5.56
% T20=(T10+3.56T21)/5.56
% T21=(T11+1.78T20+1.78T22)/5.56
% T22=(T12+1.78T21+1.78T23)/5.56
% T23=(T13+1.78T22+1.78T24)/5.56
% T24=(T14+1.78T23+1.78T25)/5.56
% T25=(178+T15+1.78T24)/5.56

clear;clc;format('long','g');
i=1;

T11(i)=0;T12(i)=0;T13(i)=0;T14(i)=0;T15(i)=0;T20(i)=0;T21(i)=0;T22(i
)=0;T23(i)=0;T24(i)=0;T25(i)=0;
error_T11(i)=9999;
while error_T11(i)>=0.01
T10(i+1)=(T20(i)+3.56*T11(i))/5.56;
T11(i+1)=(1.78*T10(i+1)+1.78*T12(i)+T21(i))/5.56;
T12(i+1)=(1.78*T11(i+1)+1.78*T13(i)+T22(i))/5.56;
T13(i+1)=(1.78*T12(i+1)+1.78*T14(i)+T23(i))/5.56;
T14(i+1)=(1.78*T13(i+1)+1.78*T15(i)+T24(i))/5.56;
T15(i+1)=(178+1.78*T14(i+1)+T25(i))/5.56;
T20(i+1)=(T10(i+1)+3.56*T21(i))/5.56;
T21(i+1)=(T11(i+1)+1.78*T20(i+1)+1.78*T22(i))/5.56;
T22(i+1)=(T12(i+1)+1.78*T21(i+1)+1.78*T23(i))/5.56;
T23(i+1)=(T13(i+1)+1.78*T22(i+1)+1.78*T24(i))/5.56;
T24(i+1)=(T14(i+1)+1.78*T23(i+1)+1.78*T25(i))/5.56;
T25(i+1)=(178+T15(i+1)+1.78*T24(i+1))/5.56;
error_T10(i+1)=abs((T10(i+1)-T10(i))/T10(i+1));
error_T11(i+1)=abs((T11(i+1)-T11(i))/T11(i+1));
error_T12(i+1)=abs((T12(i+1)-T12(i))/T12(i+1));
error_T13(i+1)=abs((T13(i+1)-T13(i))/T13(i+1));
error_T14(i+1)=abs((T14(i+1)-T14(i))/T14(i+1));
error_T15(i+1)=abs((T15(i+1)-T15(i))/T15(i+1));
error_T20(i+1)=abs((T20(i+1)-T20(i))/T20(i+1));
error_T21(i+1)=abs((T21(i+1)-T21(i))/T21(i+1));
error_T22(i+1)=abs((T22(i+1)-T22(i))/T22(i+1));
error_T23(i+1)=abs((T23(i+1)-T23(i))/T23(i+1));
error_T24(i+1)=abs((T24(i+1)-T24(i))/T24(i+1));
error_T25(i+1)=abs((T25(i+1)-T25(i))/T25(i+1));

i=i+1;
end

disp(' T10 error');


disp([T10',error_T10'])
disp(' T11 error');
disp([T11',error_T11'])
disp(' T12 error');
disp([T12',error_T12'])
disp(' T13 error');
disp([T13',error_T13'])
disp(' T14 error');
disp([T14',error_T14'])
disp(' T15 error');
disp([T15',error_T15'])
disp(' T20 error');
disp([T20',error_T20'])
disp(' T21 error');
disp([T21',error_T21'])
disp(' T22 error');
disp([T22',error_T22'])
disp(' T23 error');
disp([T23',error_T23'])
disp(' T24 error');
disp([T24',error_T24'])
disp(' T25 error');
disp([T25',error_T25'])

Displayed result after running the program

T10 error (%) T20 error (%)

0 9999 0 0
0 NaN
0 NaN
T11 error
T21 error (%)
0 0
0 0
0 NaN
0 NaN
T12 error (%)
T22 error (%)
0 0
0 0
0 NaN
0 NaN
T13 error (%)
T23 error (%)
0 0
0 0
0 NaN
0 NaN
T14 error (%)
T24 error (%)
0 0
0 0
0 NaN 1 NaN

T25 error (%)

T15 error (%) 0 0

0 0 37.7723720304332 1

32.0143884892086 1
Answer /Results

Discussion of Results: In the second case we use the value of 0 as the initial guess for the values of
the unknowns T01, T02, T11 to T25. The Gauss- Siedel method converges to the solution in 2
iterations. The convergence criterion, which is satisfied by all the unknowns, is 0.001. Here as you
observe from the computed results, the temperature values at interior nodes are zero except the two
upper interior nodes of T15 and T25.

You might also like