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 件のコメント
採用された回答
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
0 件のコメント
その他の回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Heat and Mass Transfer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!