Using Explicit Finite Difference Method to Determine the Time at which Unsteady State Ends - 1D Heat transfer

9 次查看(过去 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

回答(1 个)

SALAH ALRABEEI
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.

类别

Help CenterFile Exchange 中查找有关 Power and Energy Systems 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by