Convergence of a variable in matlab
Afficher commentaires plus anciens
I have a problem that requires convergence of a variable delTa (temp difference in annulus of a wellbore) whose initial value is assumed, with a delTa2 value obtained by using the initial guess delTa value, but through a different route.
Start off with an assumed value of delTa, lets say delTa = 0
while true
Gr = (rci-rins)^3*g*rhoa^2*beta*delTa/mua^2; % calc interim var. RHS vars known
hc = 0.049*(Gr*Pr)^0.333*Pr^0.074*ka/(rins*log(rci/rins)); % RHS vars are known
hc = hc*0.3;
Uto = (rto*(1/(rti*ht)+log(rto/rti)/kt+1/hc(i,j)+log(rco/rci)/kc+...
log(rwb/rco)/kcem))^-1; % RHS vars are known
LR = (2*pi/(cp*w))*(rto*Uto*ke/(ke+rto*Uto*TD)); % using some var calc from above
Q = -LR*w*cp*delTa % Calc Q with var calc from above and using delTa value
delTa2 = -Q/(2*pi*rto*hc); % delTa2 calculated from a similar but diff equation
err = delTa2-delTa; % if assumed value of delTa is right, then err = 0
if abs(err) < 0.0001
break;
else
% modify delTa
end
end
delTa2 is dependent on Q. Q depends on LR. LR depends on Uto. Uto depends on hc which depends on Gr. Gr depends on delTa (initial guess). How do I modify my delTa to a new and more accurate value in the if-else block at the end? What technique can I use here?
Please suggest a way to make these values converge. This is my first short at convergence using MATLAB.
Thanks!
1 commentaire
Torsten
le 9 Déc 2014
Use MATLAB's fzero to determine delTa as a zero of the function
f(x)=x+Q(x)/(2*pi*rto*hc(x))
where Q and hc are calculated as above.
Best wishes
Torsten.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!