r'''Calculates heat transfer coefficient for condensation
    of a pure chemical inside a vertical tube or tube bundle, as presented in
    [2]_ according to [1]_.

    .. math::
        Nu = \frac{hD_i}{k_l} = C Re_e^n Pr_l^{1/3}
        
        C = 0.0265, n=0.8 \text{ for } Re_e > 5\times10^4
        
        C = 5.03, n=\frac{1}{3} \text{ for } Re_e < 5\times10^4

        Re_e = \frac{D_i G_e}{\mu_l}
        
        G_e = G\left[(1-x)+x(\rho_l/\rho_g)^{0.5}\right]
        
    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    rhog : float
        Density of the gas [kg/m^3]
    rhol : float
        Density of the liquid [kg/m^3]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    mul : float
        Viscosity of liquid [Pa*s]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]
    D : float
        Diameter of the tubing [m]
    x : float
        Quality at the specific interval [-]

    Returns
    -------
    h : float
        Heat transfer coefficient [W/m^2/K]

    Notes
    -----

    Examples
    --------
    >>> Akers_Deans_Crosser(m=0.35, rhog=6.36, rhol=582.9, kl=0.098, 
    ... mul=159E-6, Cpl=2520., D=0.03, x=0.85)
    7117.24177265201

    References
    ----------
    .. [1] Akers, W. W., H. A. Deans, and O. K. Crosser. "Condensing Heat 
       Transfer Within Horizontal Tubes." Chem. Eng. Progr. Vol: 55, Symposium 
       Ser. No. 29 (January 1, 1959).
    .. [2] Kakaç, Sadik, ed. Boilers, Evaporators, and Condensers. 1st. 
       Wiley-Interscience, 1991.

def Akers_Deans_Crosser(m, rhog, rhol, kl, mul, Cpl, D, x):
    r'''Calculates heat transfer coefficient for condensation
    of a pure chemical inside a vertical tube or tube bundle, as presented in
    [2]_ according to [1]_.

    .. math::
        Nu = \frac{hD_i}{k_l} = C Re_e^n Pr_l^{1/3}
        
        C = 0.0265, n=0.8 \text{ for } Re_e > 5\times10^4
        
        C = 5.03, n=\frac{1}{3} \text{ for } Re_e < 5\times10^4

        Re_e = \frac{D_i G_e}{\mu_l}
        
        G_e = G\left[(1-x)+x(\rho_l/\rho_g)^{0.5}\right]
        
    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    rhog : float
        Density of the gas [kg/m^3]
    rhol : float
        Density of the liquid [kg/m^3]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    mul : float
        Viscosity of liquid [Pa*s]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]
    D : float
        Diameter of the tubing [m]
    x : float
        Quality at the specific interval [-]

    Returns
    -------
    h : float
        Heat transfer coefficient [W/m^2/K]

    Notes
    -----

    Examples
    --------
    >>> Akers_Deans_Crosser(m=0.35, rhog=6.36, rhol=582.9, kl=0.098, 
    ... mul=159E-6, Cpl=2520., D=0.03, x=0.85)
    7117.24177265201

    References
    ----------
    .. [1] Akers, W. W., H. A. Deans, and O. K. Crosser. "Condensing Heat 
       Transfer Within Horizontal Tubes." Chem. Eng. Progr. Vol: 55, Symposium 
       Ser. No. 29 (January 1, 1959).
    .. [2] Kakaç, Sadik, ed. Boilers, Evaporators, and Condensers. 1st. 
       Wiley-Interscience, 1991.
    '''
    G = m/(pi/4*D**2)
    Ge = G*((1-x) + x*(rhol/rhog)**0.5)
    Ree = D*Ge/mul
    Prl = mul*Cpl/kl
    if Ree > 5E4:
        C, n = 0.0265, 0.8
    else:
        C, n = 5.03, 1/3.
    Nu = C*Ree**n*Prl**(1/3.)
    return Nu*kl/D