%
%   PIN_FIN_1A.M     Function for Computing DTerr vs Li/L 
%                        (called from PIN_FIN_1.M)
%
%   Given a set of design parameters (Tinfo, ho, Tinfi, hi, k, etc.), this routine
%   computes the measurement error versus immersion length of a pin-shaped probe
%   that is inserted through a wall into a fluid.  The purpose of the probe is to
%   measure the bulk fluid temperature.  However, because of the various heat 
%   transfer mechanisms involved, the probe's tip temperature may be slightly 
%   different from the free stream fluid temperature.  This routine estimates the
%   measurement error for a given set of design parameters.
%
%   Input Variables:
%      Tinfo, ho -- outside temperature and heat transfer coeff
%      Tinfi, hi -- inside temperature and heat transfer coeff
%      k         -- probe material thermal conductivity
%      L, D      -- probe's total length and diameter
%
%   Output Variables:
%      LiL       -- values of Li/L
%      DTerr     -- difference between the inside tip temperature and the fluid 
%                   temperature for each value of LiL
%
%   File prepared by J. R. White, UMass-Lowell (last update: Sept. 2017)
%

      function [LiL,DTerr] = pin_fin_1a(Tinfo,ho,Tinfi,hi,k,L,D)
      Ac = pi*D^2/4;   P = pi*D;
      mo = sqrt(ho*P/(k*Ac));   mi = sqrt(hi*P/(k*Ac)); 
      Li = 0.1*L:0.025*L:0.9*L; 
      Lo = L-Li;   LiL = Li/L;
      co1 = sinh(mo*Lo) + (ho/(mo*k))*cosh(mo*Lo);
      co2 = cosh(mo*Lo) + (ho/(mo*k))*sinh(mo*Lo);
      co = co1./co2;
      ci1 = sinh(mi*Li) + (hi/(mi*k))*cosh(mi*Li);
      ci2 = cosh(mi*Li) + (hi/(mi*k))*sinh(mi*Li);
      ci = ci1./ci2;
      Tb1 = Tinfo*sqrt(ho)*co + Tinfi*sqrt(hi)*ci;
      Tb2 = sqrt(ho)*co + sqrt(hi)*ci;
      Tb = Tb1./Tb2;
      DTerr = (Tb - Tinfi)./ci2;
%
%   end of function
