Help programing 2D conduction heat transfer in time, using finite diference method (forward euler for time, centered euler for space).
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Walter Manns
el 6 de Oct. de 2011
Comentada: Nataly Challapa
el 20 de Mayo de 2016
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 comentario
Nataly Challapa
el 20 de Mayo de 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?
Respuesta aceptada
Dr. Seis
el 7 de Oct. de 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 comentarios
Más respuestas (2)
Walter Manns
el 7 de Oct. de 2011
2 comentarios
Dr. Seis
el 7 de Oct. de 2011
Let's start with your value at val(4,4,3)... I assume this value should actually be somewhere between 18 and 120 after 1 time step, right?
Dr. Seis
el 7 de Oct. de 2011
Can you provide the non-code version of the equation that you based your "i>1&&i<5&&j>1&&j<5" case?
Ver también
Categorías
Más información sobre Thermal Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!