% Guess.m calculates the temperature needed in a wire under free convection 
% for a given amount of heat generation.
%                guess(Btu,Troom(F),Tguess(F))
%  Example:  Temperature=guess(257.8,66,1200)

function Temp=guess(Btuknown,Tinf,Tguess)
diff=3
if (Tguess<=1934) & (Tguess>=Tinf)
while (abs(diff)>0.1),
  Tfilm=(Tguess+Tinf)/2;
  Beta=1/Tfilm;
  [a,k]=data(Tfilm);
  GrxPr=a*(Tguess-Tinf)*(1/12^2)^3;
  x=log10(GrxPr);
  logNu=-5E-5*x^4+0.0003*x^3+0.012*x^2+0.124*x+0.0285;
  Nu=10^(logNu);
  Btu=Nu*k*(Tguess-Tinf)*pi;
  diff=Btuknown-Btu;
  if diff < 0
    Tguess=(1+diff/Btu)*Tguess;
   else
    Tguess=(diff*2+Tguess);
  end 
 end
 Temp=Tguess;
else
   Temp='Guess a temperature between Tinf and 1934 F';
end