r'''Calculates heat transfer coefficient for condensation
    of a fluid inside a tube, as presented in
    [1]_, also given in [2]_ and [3]_.

    .. math::
        Nu = \frac{hD_i}{k_l} = 0.05 Re_e^{0.8} Pr_l^{0.33}
        
        Re_{eq} = Re_g(\mu_g/\mu_l)(\rho_l/\rho_g)^{0.5} + Re_l

        v_{gs} = \frac{mx}{\rho_g \frac{\pi}{4}D^2}

        v_{ls} = \frac{m(1-x)}{\rho_l \frac{\pi}{4}D^2}

    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific interval [-]
    D : float
        Diameter of the channel [m]
    rhol : float
        Density of the liquid [kg/m^3]
    rhog : float
        Density of the gas [kg/m^3]
    mul : float
        Viscosity of liquid [Pa*s]
    mug : float
        Viscosity of gas [Pa*s]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]

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

    Notes
    -----

    Examples
    --------
    >>> Cavallini_Smith_Zecchin(m=1, x=0.4, D=.3, rhol=800, rhog=2.5, mul=1E-5, mug=1E-3, kl=0.6, Cpl=2300)
    5578.218369177804
    
    References
    ----------
    .. [1] A. Cavallini, J. R. Smith and R. Zecchin, A dimensionless correlation
       for heat transfer in forced convection condensation, 6th International 
       Heat Transfer Conference., Tokyo, Japan (1974) 309-313. 
    .. [2] Kakaç, Sadik, ed. Boilers, Evaporators, and Condensers. 1st. 
       Wiley-Interscience, 1991.
    .. [3] Balcılar, Muhammet, Ahmet Selim Dalkılıç, Berna Bolat, and Somchai 
       Wongwises. "Investigation of Empirical Correlations on the Determination
       of Condensation Heat Transfer Characteristics during Downward Annular 
       Flow of R134a inside a Vertical Smooth Tube Using Artificial 
       Intelligence Algorithms." Journal of Mechanical Science and Technology 
       25, no. 10 (October 12, 2011): 2683-2701. doi:10.1007/s12206-011-0618-2.

def Cavallini_Smith_Zecchin(m, x, D, rhol, rhog, mul, mug, kl, Cpl):
    r'''Calculates heat transfer coefficient for condensation
    of a fluid inside a tube, as presented in
    [1]_, also given in [2]_ and [3]_.

    .. math::
        Nu = \frac{hD_i}{k_l} = 0.05 Re_e^{0.8} Pr_l^{0.33}
        
        Re_{eq} = Re_g(\mu_g/\mu_l)(\rho_l/\rho_g)^{0.5} + Re_l

        v_{gs} = \frac{mx}{\rho_g \frac{\pi}{4}D^2}

        v_{ls} = \frac{m(1-x)}{\rho_l \frac{\pi}{4}D^2}

    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific interval [-]
    D : float
        Diameter of the channel [m]
    rhol : float
        Density of the liquid [kg/m^3]
    rhog : float
        Density of the gas [kg/m^3]
    mul : float
        Viscosity of liquid [Pa*s]
    mug : float
        Viscosity of gas [Pa*s]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]

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

    Notes
    -----

    Examples
    --------
    >>> Cavallini_Smith_Zecchin(m=1, x=0.4, D=.3, rhol=800, rhog=2.5, mul=1E-5, mug=1E-3, kl=0.6, Cpl=2300)
    5578.218369177804
    
    References
    ----------
    .. [1] A. Cavallini, J. R. Smith and R. Zecchin, A dimensionless correlation
       for heat transfer in forced convection condensation, 6th International 
       Heat Transfer Conference., Tokyo, Japan (1974) 309-313. 
    .. [2] Kakaç, Sadik, ed. Boilers, Evaporators, and Condensers. 1st. 
       Wiley-Interscience, 1991.
    .. [3] Balcılar, Muhammet, Ahmet Selim Dalkılıç, Berna Bolat, and Somchai 
       Wongwises. "Investigation of Empirical Correlations on the Determination
       of Condensation Heat Transfer Characteristics during Downward Annular 
       Flow of R134a inside a Vertical Smooth Tube Using Artificial 
       Intelligence Algorithms." Journal of Mechanical Science and Technology 
       25, no. 10 (October 12, 2011): 2683-2701. doi:10.1007/s12206-011-0618-2.
    '''
    Prl = Prandtl(Cp=Cpl, mu=mul, k=kl)
    Vl = m*(1-x)/(rhol*pi/4*D**2)
    Vg = m*x/(rhog*pi/4*D**2)
    Rel = Reynolds(V=Vl, D=D, rho=rhol, mu=mul)    
    Reg = Reynolds(V=Vg, D=D, rho=rhog, mu=mug)
    '''The following was coded, and may be used instead of the above lines,
    to check that the definitions of parameters here provide the same results
    as those defined in [1]_.
    G = m/(pi/4*D**2)
    Re = G*D/mul
    Rel = Re*(1-x)
    Reg = Re*x/(mug/mul)'''
    Reeq = Reg*(mug/mul)*(rhol/rhog)**0.5 + Rel
    Nul = 0.05*Reeq**0.8*Prl**0.33
    return Nul*kl/D