% Forced convection from a bank of tubes. 
function [h, NuD, ReD] = TubeBankNuT(flag,U,D,St,Sl,Nl,mat,Ts,Tm)
  Prs=prop('Pr',mat,Ts); 
  Vmax = St.*U./(St-D);
  switch flag
  case 'inline'
    [ReD,Pr,km] = Re(Vmax,D,mat,Tm);
    Pr_Prs=Pr./Prs;
    j=find(ReD < 100);
    if ~isempty(j)
      NuD(j) = 0.9*ReD(j).^0.4.*Pick(Pr,j).^0.36.*Pick(Pr_Prs,j).^0.25;
    end
    j=find(100 <= ReD & ReD < 1000);
    if ~isempty(j)
      NuD(j) = 0.52*ReD(j).^0.5.*Pick(Pr,j).^0.36.*Pick(Pr_Prs,j).^0.25;
    end
    j=find(1000 <= ReD & ReD < 2e5);
    if ~isempty(j)
      NuD(j) = 0.27*ReD(j).^0.63.*Pick(Pr,j).^0.36.*Pick(Pr_Prs,j).^0.25;
    end
    j=find(2e5 <= ReD);
    if ~isempty(j)
      NuD(j) = 0.033*ReD(j).^0.8.*Pick(Pr,j).^0.4.*Pick(Pr_Prs,j).^0.25;
    end
    Ftable=[0.70,0.80,0.86,0.90,0.93,0.96,0.98,0.99,1];
  case 'staggered'
    Sd = sqrt(Sl.^2+(St/2).^2);
    Vstag = St*U/(Sd-D)/2;
    Vmax = iff(Vstag>Vmax,Vstag,Vmax);
    [ReD,Pr,km] = Re(Vmax,D,mat,Tm);
    Pr_Prs=Pr./Prs;
    St_Sl=St./Sl;
    j=find(ReD < 500);
    if ~isempty(j)
      NuD(j) = 1.04*ReD(j).^0.4.*Pick(Pr,j).^0.36.*Pick(Pr_Prs,j).^0.25;
    end
    j=find(500 <= ReD & ReD < 1000);
    if ~isempty(j)
      NuD(j) = 0.71*ReD(j).^0.5.*Pick(Pr,j).^0.36.*Pick(Pr_Prs,j).^0.25;
    end
    j=find(1000 <= ReD & ReD < 2e5);
    if ~isempty(j)
      NuD(j) = 0.35*Pick(St_Sl,j).^0.2*ReD(j).^0.6 ...
                  .*Pick(Pr,j).^0.36.*Pick(Pr_Prs,j).^0.25;
    end
    j=find(2e5 <= ReD);
    if ~isempty(j)
      NuD(j) = 0.031*Pick(St_Sl,j).^0.2*ReD(j).^0.8 ...
                   .*Pick(Pr,j).^0.36.*Pick(Pr_Prs,j).^0.25;
    end
    Ftable=[0.64,0.76,0.84,0.89,0.93,0.96,0.98,0.99,1];
  otherwise
    error('flag= ''inline'' or ''staggered''');
  end 
  if min(Pr) < 0.6     warning = 'TubeBankNuT: Pr < 0.6'
  elseif max(Pr) > 1e5 warning = 'TubeBankNuT: Pr > 500'
  end
  if max(ReD) > 2e6    warning = 'TubeBankNuT: ReD > 2e6'
  end
  if Nl<16
    Ntable=[1,2,3,4,5,7,10,13,16];
    F = interp1(Ntable,Ftable,Nl);
    NuD=F.*NuD;
    if min(ReD) < 1000 warning = 'TubeBankNuT: Nl < 16 & ReD < 1000'
    end
  end
  h = NuD.*km./D;
end
