Help programing 2D conduction heat transfer in time, using finite diference method (forward euler for time, centered euler for space).
조회 수: 1 (최근 30일)
이전 댓글 표시
25 Points Grid. r = x, z = y.
The formulas are correct, but i don't kwon what i am doing wrong with the matlab programming. Please help >.<
%Body properties
H = 0.3; % Height [m]
D = 0.2; % Diameter [m]
Alpha = 1.5; %Difusion heat transfer coefficient [m^2/s]
% Factores para Diferencia Finita
dr = D/8;
dz = H/8;
dt = 7;
tp = 3600; %Total Process Time. [s]
tc = 2000; %Proces tranfer from heating to cooling. [s]
Ti = 18; %Initial body temperature. [°C]
Tc = 120; %Heating Temperature. [°C]
Tf = 8; %Cooling Temperature. [°C]
%Grid Initialization
T(:,:,1)= Ti*ones(5,5);
time(1) = 0;
time(2) = dt;
t=1;
while time(t+1)<=tp
for i=[5,4,3,2,1]
for j=[5,4,3,2,1]
if i==5&&time(t+1)<=tc
T(i,j,t+1) = Tc;
elseif j==5&&time(t+1)<=tc
T(i,j,t+1) = Tc;
elseif i==5&&time(t+1)>tc
T(i,j,t+1) = Tf;
elseif j==5&&time(t+1)>tc
T(i,j,t+1) = Tf;
elseif i>1&&i<5&&j>1&&j<5
T(i,j,t+1) = Alpha*dt*((T(i+1,j,t)-2*T(i,j,t)+T(i-1,j,t))/(dr)^2 + (1/((i-1)*dr))*((T(i+1,j,t)-T(i,j,t))/(2*dr)) + (T(i,j+1,t)-2*T(i,j,t)+T(i,j-1,t))/(dz)^2) + T(i,j,t);
elseif i==1&&j>1&&j<5
T(i,j,t+1) = Alpha*dt*(4*(T(i+1,j,t)-T(i,j,t))/(dr)^2 + (T(i,j+1,t)-2*T(i,j,t)+T(i,j-1,t))/(dz)^2) + T(i,j,t);
elseif i<1&&i>5&&j==1
T(i,j,t+1) = Alpha*dt*((T(i+1,j,t)-2*T(i,j,t)+T(i-1,j,t))/(dr)^2 + (1/((i-1)*dr))*((T(i+1,j,t)-T(i,j,t))/(2*dr)) + 2*(T(i,j+1,t)-T(i,j,t))/(dz)^2) + T(i,j,t);
elseif i==1&&j==1
T(i,j,t+1) = 2*Alpha*dt*(2*(T(i+1,j,t)-T(i,j,t))/(dr)^2 + (T(i,j+1,t)-T(i,j,t))/(dz)^2) + T(i,j,t);
end
end
end
t = t+1;
time(t+1) = time(t)+dt;
end
댓글 수: 1
Nataly Challapa
2016년 5월 20일
Hello! My question is about the graphic, how can I do a graphic in 3D of this solution? it is possible? because this method would be a solution for the heat equation. Is not it right?
채택된 답변
Dr. Seis
2011년 10월 7일
Do you get any errors... or the result is just incorrect?
One problem: Your second to last "elseif" statement has "i<1&&i>5&&j==1" when I think you meant "i>1&&i<5&&j==1" since "i" can never be both less than 1 and greater than 5.
댓글 수: 0
추가 답변 (2개)
Walter Manns
2011년 10월 7일
참고 항목
카테고리
Help Center 및 File Exchange에서 Thermal Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!