Iteration loop for a function to reach a certain value.

3 ビュー (過去 30 日間)
Fabian
Fabian 2024 年 3 月 9 日
コメント済み: Fabian 2024 年 3 月 11 日
Hello, I want to write an iteration loop for a function that needs an innitial guess. The equations work off of each other and thus a first guess is needed to find an answer, the method is as follows: Tc is the first guess, then 3 seperate values are found using the initial guess of Tc, and finally a new Tc is found utilizing the previous 3 values found. The final Tc value must be close to the initial guess for the answer to be correct and that is why I want the iteration loop to occur. Thank you in advance!
%the "+273.15" serves to convert celcius to kelvin
g=9.81;
NU=2.52;
k=.0293;%from book
L=.025;%plate to cover spacing m
sigma=5.6697e-8;
epsilonp=0.95;%plate emittance
epsilonc=0.88;%glass emittance
Ts=10+273.15;%ambient sky temp K
Tp=60+273.15;%mean plate temp K
Tc=35+273.156;%assumed collector temp K, this is the desired iterated value
hcpc=NU*(k/L);%conv. heat trans coeff
hw=10;
hrpc=((sigma*(Tp^2+Tc^2)*(Tp+Tc))/((1/epsilonp)+(1/epsilonc)-1));%rad conv
%between plate and collector
hrca=epsilonc*sigma*(Tc^2+Ts^2)*(Tc+Ts);%rad. coeff for cover to air
Ut=((1/(hcpc+hrpc))+(1/(hw+hrpc)))^-1;%top loss coeff from collector to ambient
Tc=Tp-((Ut*(Tp-Ts)/(hcpc+hrpc)));%this value must get close to value of original guess

採用された回答

Torsten
Torsten 2024 年 3 月 9 日
g=9.81;
NU=2.52;
k=.0293;%from book
L=.025;%plate to cover spacing m
sigma=5.6697e-8;
epsilonp=0.95;%plate emittance
epsilonc=0.88;%glass emittance
Ts=10+273.15;%ambient sky temp K
Tp=60+273.15;%mean plate temp K
Tc=35+273.156;%assumed collector temp K, this is the desired iterated value
Tcnew = Inf;
hcpc=NU*(k/L);%conv. heat trans coeff
hw=10;
tol = 1e-6;
format long
while abs(Tc-Tcnew) > tol
Tcnew = Tc;
hrpc=((sigma*(Tp^2+Tc^2)*(Tp+Tc))/((1/epsilonp)+(1/epsilonc)-1));%rad conv
%between plate and collector
hrca=epsilonc*sigma*(Tc^2+Ts^2)*(Tc+Ts);%rad. coeff for cover to air
Ut=((1/(hcpc+hrpc))+(1/(hw+hrpc)))^-1;%top loss coeff from collector to ambient
Tc=Tp-((Ut*(Tp-Ts)/(hcpc+hrpc)));%this value must get close to value of original guess
Tc
end
Tc =
3.012549948434458e+02
Tc =
3.011481167433821e+02
Tc =
3.011464601619294e+02
Tc =
3.011464344851034e+02
Tc =
3.011464340871154e+02
  1 件のコメント
Fabian
Fabian 2024 年 3 月 11 日
This worked perfectly, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeneral Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by