Heat transfer Conduction question

5 ビュー (過去 30 日間)
Ahmed Alhezab
Ahmed Alhezab 2017 年 4 月 21 日
編集済み: Sudarshan Kolar 2017 年 4 月 24 日
Can someone help me out in finding the other Temperature values. I am only getting the first two.
I am using Gauss-Siedel Method
tinf=30+273;% deg K
h=100; % W/m^2-K
kcopper= 401;
kbronze= 52; % W/m-k
alpha=14e6; % m^2/s
qdprime= 1e4; % w/m^2
deltax=.02
Nx = 3;
Ny = 9;
% initialize coefficient matrix and constant vector with zeros
A = zeros(Nx*Ny);
C = zeros(1:Nx*Ny,1);
% initial 'guess' for temperature distribution
T(Nx*Ny,1)=100;
% Build coefficient matrix and constant vector
% inner nodes
for n = 2:(Nx-1)
for m = 2:(Ny-1)
i = (n-1)*Ny + m;
A(i,i+Ny) = 1;
A(i,i-Ny) = 1;
A(i,i+1) = 1;
A(i,i-1) = 1;
A(i,i) = -4;
end
end
% Edge nodes
% bottom (Case 6)
for m = 2:(Ny-1)
%n = 1
i = (Nx-1)*Ny + m;
A(i,i-Ny) = 2;
A(i,i+1) = 1;
A(i,i-1) = 1;
A(i,i) = -(2.*(2+((h.*deltax)./kcopper)));
C(i) = -(((2.*h.*deltax)./kcopper).*tinf);
end
%top (Case3)
for m = 2:(Nx-1)
% n = Ny
i = (1 -1)*Ny + m;
A(i,i+Ny) = 2;
A(i,i+1) = 1;
A(i,i-1) = 1;
A(i,i) = -(2.*(2+((h.*deltax)./kcopper)));
C(i) = -(((2.*h.*deltax)./kcopper).*tinf);
end
%left (case 7)
for n=2:(Nx-1)
%m = 1
i = (n-1)*Ny + 1;
A(i,i+Ny) = 1;
A(i,i+1) = 2;
A(i,i-Ny) = 1;
A(i,i) = -4;
C(i) = -((2.*qdprime.*deltax)./kcopper);
end
%right (Case 8)
for n=2:(Nx-1)
%m = Nx
i = (n-1)*Ny + Ny;
A(i,i+Ny) = 1;
A(i,i-1) = 2;
A(i,i-Ny) = 1;
A(i,i) = -(2.*(2+((h.*deltax)./kcopper)));
C(i) = -(((2.*h.*deltax)./kcopper).*tinf);
end
% Corners
%bottom left (Case 4):
i=(Nx-1)*Ny + 1;
A(i,i-Ny) = 1;
A(i,i+1) = 1;
A(i,i) = -(((h.*deltax)./kcopper)+2);
C(i) = -(((h.*deltax)./kcopper).*tinf)+((qdprime.*deltax)./kcopper);
%bottom right (case 5)
i = (Nx)*Ny;
A(i,i-Ny) = 1;
A(i,i-1) = 1;
A(i,i) = -(2.*(1+((h.*deltax)./kcopper)));
C(i) = -(((2.*h.*deltax)./kcopper).*tinf);
%top left (case 1)
i = 1;
A(i,i+1) = 1;
A(i,i) = -(((h.*deltax)./kcopper)+2);
A(i,i+Ny) = 1;
C(i) = -(((h.*deltax)./kcopper).*tinf)+((qdprime.*deltax)./kcopper);
%top right (Case 2)
i = Ny;
A(i,i-1) = 1;
A(i,i) = -(2.*(1+((h.*deltax)./kcopper)));
A(i,i+Ny) = 1;
C(i) = -(((2.*h.*deltax)./kcopper).*tinf);
%Solve using Gauss-Seidel
residual = 100;
iterations = 0;
while (residual > 0.001) % The residual criterion is 0.0001
% different values can be tested
iterations = iterations+1;
%Transfer the previously computed temperatures to an array Told
Told = T;
%Update estimate of the temperature distribution
for n=1:Ny
for m=1:Nx
i = (n-1)*Nx + m;
Told(i) = T(i);
end
end
% iterate through all of the equations
for n=1:Ny
for m=1:Nx
i = (n-1)*Nx + m;
%sum the terms based on updated temperatures
sum1 = 0;
for j=1:i-1
sum1 = sum1 + A(i,j)*T(j);
end
%sum the terms based on temperatures not yet updated
sum2 = 0;
for j=i+1:Nx*Ny
sum2 = sum2 + A(i,j)*Told(j);
end
% update the temperature for the current node
T(i) = (1/A(i,i)) * (C(i) - sum1 - sum2);
end
end
residual = max(T(i) - Told(i));
end
%compute residual
deltaT = abs(T - Told);
residual = max(deltaT);
iterations;
  2 件のコメント
John D'Errico
John D'Errico 2017 年 4 月 21 日
Um, huh? What other temperature values? Be clear about your question.
Ahmed Alhezab
Ahmed Alhezab 2017 年 4 月 21 日
This is output matrix I'm getting. I don't understand why it is only shown the first two.
here is a picture of the problem I am trying to solve.
Im trying to find the temp. at each node

サインインしてコメントする。

回答 (1 件)

Sudarshan Kolar
Sudarshan Kolar 2017 年 4 月 24 日
編集済み: Sudarshan Kolar 2017 年 4 月 24 日
Hello Ahmed,
I understand that you are not able to see certain temperature values in your variable. The best approach here would be to step through your code and observe the values of the variable under consideration as you step through. Following documentations will help you with your debugging:
https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html
https://www.mathworks.com/help/matlab/matlab_prog/examine-values.html

カテゴリ

Help Center および File ExchangeThermal Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by