Heat Transfer Interations with while loops
15 次查看(过去 30 天)
显示 更早的评论
I've been working on this code for the past couple days. I'm tyring to get the interations to run and get a time for how long it will take for T(1,p) to get to 200 degrees. Everytime I run the code to that, it runs for more than 10 minutes.
%%
%Steady Temperature at each node
clc
clear
L=.25; h=4000; Tinf=40; den=7850;
Cp=650;k=27.3; dx=5E-3;
diff=k/(den*Cp); Bi=(h*dx)/k;
Fo=(1/2)/(1+Bi);
dt_i=(Fo*dx^2)/diff;dt=1.3;
Ti=1200;
Ts=Tinf;
T_goal=200;
for i=1:51
x=(i-1)*dx;
T(i,1)=Ti;
end
nodes=1:51;
table=[nodes; T'];
fprintf('Node Initial Temperature\n')
fprintf(' %i %5.3f\n',table);
%%
p=1;
while T_goal<T(1,p)
p=p+1;
t=dt*(p-1);
for i=1:51
%for Cp
if 900<=T(i,p-1)
Cp=650;
elseif 745<=T(i,p-1)
Cp=545+(17820/(T(i,p-1)-731));
elseif 600<=T(i,p-1)
Cp=666+(13002/(738-T(i,p-1)));
else 20<=T(i,p-1)
Cp=(425+7.73*10^-1*T(i,p-1))-(1.69*(10^-3)*(T(i,p-1)^2))+(2.22*(10^-6)*(T(i,p-1)^3));
end
%For k
if 800<=T(i,p-1)
k=27.3;
else T(i,p-1)
k=54-3.33*(10^-2)*T(i,p-1);
end
diff=k/(den*Cp);
Bi=h*L/k;
Fo=(diff*dt)/L^2;
if i==1
T(i,p)= Fo*(2*T(i+1,p-1))+(1-2*Fo)*T(i,p-1);
elseif i==51
T(i,p)=2*Fo*(T(i-1,p-1)+Bi*Tinf)+(1-2*Fo-2*Bi*Fo)*T(i,p-1);
else
T(i,p)=Fo*(T(i-1,p-1)+T(i+1,p-1))+(1-2*Fo)*T(i,p-1);
end
end
end
T_i=T';
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!