Finite Differencing Transient Conduction

7 次查看(过去 30 天)
Hello,
I'm attempting to conduct a finite difference approach to a transient conduction problem.
  • Rows are time steps
  • Columns are Length
My initial condition is:
  • At time = 0, Temp Is uniform at 573K (except for at L=0 where it's 673K).
My Boundary Condition is:
  • Temp = 673K at L = 0, constant
  • at L = L, no heat transfer, insulated
My descritization loop appears below.
I can populate T0 with the intial and boundary conditions above, but am running into a problem in the finitie difference for loop.
Any help is appreciated.
clc
clear all
close all
ri = 0.0125;
ro = 0.0375;
R = ro-ri;
t=2000;
k = 50; %W/mK
cp = 1750; %W s /kg K
rho = 1500; %kg/m3
alpha = k /(rho*cp); % m2/s
dr = 50;
dt = 1;
FO = alpha* dt/(dr^2);
T0 = zeros(t+1,51);
T1 = zeros(t+1,51);
for i = 1:t
T0(i,1) = 673;
T0 = T1;
end
for j = 2:t
for i = 1
T0(i,j) = 573;
T0 = T1;
end
end
for j = 3:t
for i = 2:t
T0(i,j) = (dr/R)*FO*T1(i+1,j)-(dr/R)*FO*T1(i,j)+FO*T1(i-1,j)-2*FO*T1(i,j)+FO*T1(i+1,j);
end
T0 = T1;
end
  1 个评论
Torsten
Torsten 2023-5-7
移动:VBBV 2023-5-7
Why do both loops run over t ?
And why do you divide by R = ro-ri and not be r ?
Two of many other errors in your code.
Seems you better stick to the "pdepe" solution.

请先登录,再进行评论。

采纳的回答

VBBV
VBBV 2023-5-7
编辑:VBBV 2023-5-7
May be the central and forward difference schemes are not correct, but the following change will avoid the code errors
clc
clear all
close all
ri = 0.0125;
ro = 0.0375;
R = ro-ri;
t=2000;
k = 50; %W/mK
cp = 1750; %W s /kg K
rho = 1500; %kg/m3
alpha = k /(rho*cp); % m2/s
dr = 50;
dt = 1;
FO = alpha* dt/(dr^2);
T0 = zeros(t+1,51);
T1 = zeros(t+1,51);
for i = 1:t+1
T0(i,1) = 673;
end
for j = 1:t+1
T0(1,j) = 573;
end
T1 = T0;
for j = 2:t
for i = 2:t
% T0(i,j) = FO*((dr/R)*(T1(i+1,j)-T1(i,j))+T1(i-1,j)-(2*T1(i,j)+T1(i+1,j)));
T0(i,j) = T1(i,j)+ (dr/R)*FO*T1(i+1,j)-(dr/R)*FO*T1(i,j)+(FO*T1(i-1,j)-2*FO*T1(i,j)+FO*T1(i+1,j));
end
T1 = T0;
end
T0, T1

更多回答(1 个)

Walter Roberson
Walter Roberson 2023-5-7
T0 = zeros(t+1,51);
T1 = zeros(t+1,51);
Okay, both zeros
for i = 1:t
T0(i,1) = 673;
You replace a particular element of T0 with 673. On the first iteration, T0 will now have 673 in row 1 column 1, and zeros everywhere else.
T0 = T1;
And there you overwrite all of T0 with the zeros stored in T1. If that were your intent then you could be more efficient by just skipping the loop entirely since you already st T0 to all 0.

类别

Help CenterFile Exchange 中查找有关 Heat and Mass Transfer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by