Borrar filtros
Borrar filtros

Iteration loop for a function to reach a certain value.

3 visualizaciones (últimos 30 días)
Fabian
Fabian el 9 de Mzo. de 2024
Comentada: Fabian el 11 de Mzo. de 2024
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

Respuesta aceptada

Torsten
Torsten el 9 de Mzo. de 2024
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

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by