필터 지우기
필터 지우기

Finite Differencing Transient Conduction

조회 수: 3 (최근 30일)
Tony Stianchie
Tony Stianchie 2023년 5월 7일
이동: VBBV 2023년 5월 7일
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에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by