Help programing 2D conduction heat transfer in time, using finite diference method (forward euler for time, centered euler for space).
6 views (last 30 days)
Show older comments
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 Comment
Nataly Challapa
on 20 May 2016
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?
Accepted Answer
Dr. Seis
on 7 Oct 2011
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 Comments
More Answers (2)
Walter Manns
on 7 Oct 2011
See Also
Categories
Find more on Thermal Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!