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