Using Explicit Finite Difference Method to Determine the Time at which Unsteady State Ends - 1D Heat transfer
8 ビュー (過去 30 日間)
古いコメントを表示
I need to find the time at which unsteady state ends and steady state begins by using explicit finite difference method. I tried modifying the fde code by adding a while loop and if statement inside the loop as below but the code keeps running forever. What should I do?
%% Expilict Finite Difference Method 1D Transiet Heat System
%defining parameters:
k = 28; %W/mC
qG = 6*10^5; %W/m^3
h = 60; %W/m^2C
Tair = 30; %C
Ti = 100; %C
alpha = 12.5*10^-6; %m^2/s
th = 1000; %hour
ts = 300; %second
%dicretization:
a=0;
b=5; %cm
n=6; %number of nodes
dx1 = (b-a)/(n-1);
dx = dx1/100; %m
x = (a/100):dx:(b/100);
%calculating dt
dt1 = (dx^2)/(2*alpha*(1+((h*dx)/k)));
dt = 100;
%calculating r
r = alpha*dt/dx;
% Initial temperature
for i = 1:n
T(i,1) =Ti ;
end
while 1
for t=1:ts/dt %end of time will be found but how :/
% Temperature at the boundary
T(1,t+1) = ((1-2*r)*T(1,t))+(2*r*T(2,t))+(r*qG*(dx^2)/k);
T(n,t+1) = ((1-(2*r)-(2*r*h*dx/k))*T(n,t))+(2*r*T(n-1,t))+(2*r*h*dx*Tair/k) +(r*qG*(dx^2)/k);
% Implementation of the explicit method to interior nodes
for i=2:n-1 % Space Loop
T(i,t+1) =T(i,t) + r*(T(i-1,t)+T(i+1,t)-2.*T(i,t)) + r*qG*(dx^2)/k;
end
end
if T(n,t)==T(n,t+1)
t_final=ts/3600;
break
else
ts=ts+dt;
end
end
0 件のコメント
回答 (1 件)
SALAH ALRABEEI
2021 年 6 月 10 日
Your dicretization much satisfy the stability condition since the explicit scheme is conditionally stable. Moreover, The error might not be less than 1e-7 which still not 0. Therefore, your breaking condition might to get satisfied.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Power and Energy Systems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!