% Heat exchanger NTU relations
function NTU = HeatExNTU(Flag,Cr,Eff)
  switch Flag
  case 'CountFlow'
    if Cr==1 NTU = Eff./(1-Eff);
    else NTU = log((1-Cr.*Eff)./(1-Eff))./(1-Cr);
    end
  case 'ParalFlow'
    NTU = -log(1-Eff.*(1+Cr))./(1+Cr);
  case 'ShellTube'
    SqrtTerm=sqrt(1+Cr.^2);
    NTU=log((2./Eff-1-Cr+SqrtTerm)./(2./Eff-1-Cr-SqrtTerm))./SqrtTerm;
  otherwise
    Flag=Flag
    error('HeatExNTU: Unknown Flag');
  end
end
