Professional Documents
Culture Documents
MATLAB Exercise On Conduction
MATLAB Exercise On Conduction
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
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
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
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
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
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
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.