r'''Calculates the two-phase non-boiling laminar heat transfer coefficient  
    of a liquid and gas flowing inside a tube of any inclination, as in [1]_  
    and reviewed in [2]_.

    Laminar for Rel <= 2000:

    .. math::
        h_{TP} = 1.615\frac{k_l}{D}\left(\frac{Re_l Pr_l D}{L}\right)^{1/3}
        \left(\frac{\mu_b}{\mu_w}\right)^{0.14}
    
    Turbulent for Rel > 2000:
    
    .. math::
        h_{TP} = 0.0155\frac{k_l}{D} Pr_l^{0.5} Re_l^{0.83}
    
        Re_l = \frac{\rho_l v_l D}{\mu_l}
        
        V_l = \frac{V_{ls}}{1-\alpha}

    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific tube interval [-]
    alpha : float
        Void fraction in the tube, [-]
    D : float
        Diameter of the tube [m]
    rhol : float
        Density of the liquid [kg/m^3]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    mu_b : float
        Viscosity of liquid at bulk conditions (average of inlet/outlet 
        temperature) [Pa*s]
    mu_w : float, optional
        Viscosity of liquid at wall temperature [Pa*s]
    L : float, optional
        Length of the tube, [m]
    turbulent : bool or None, optional
        Whether or not to force the correlation to return the turbulent
        result; will return the laminar regime if False

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

    Notes
    -----
    Developed with mixtures of air-water, helium-water, and freon-12-water and 
    vertical tests. Studied flow patterns were bubbly, slug, annular, 
    bubbly-slug, and slug-annular regimes. Superficial velocity ratios ranged 
    from 0.02 to 470.

    A viscosity correction is only suggested for the laminar regime. 
    If the viscosity at the wall temperature is not given, the liquid viscosity
    correction is not applied.

    Examples
    --------
    >>> Aggour(m=1, x=.9, D=.3, alpha=.9, rhol=1000, Cpl=2300, kl=.6, mu_b=1E-3)
    420.9347146885667

    References
    ----------
    .. [1] Aggour, Mohamed A. Hydrodynamics and Heat Transfer in Two-Phase 
       Two-Component Flows, Ph.D. Thesis, University of Manutoba, Canada 
       (1978). http://mspace.lib.umanitoba.ca/xmlui/handle/1993/14171.
    .. [2] Dongwoo Kim, Venkata K. Ryali, Afshin J. Ghajar, Ronald L. 
       Dougherty. "Comparison of 20 Two-Phase Heat Transfer Correlations with 
       Seven Sets of Experimental Data, Including Flow Pattern and Tube 
       Inclination Effects." Heat Transfer Engineering 20, no. 1 (February 1, 
       1999): 15-40. doi:10.1080/014576399271691.

def Aggour(m, x, alpha, D, rhol, Cpl, kl, mu_b, mu_w=None, L=None, 
           turbulent=None):
    r'''Calculates the two-phase non-boiling laminar heat transfer coefficient  
    of a liquid and gas flowing inside a tube of any inclination, as in [1]_  
    and reviewed in [2]_.

    Laminar for Rel <= 2000:

    .. math::
        h_{TP} = 1.615\frac{k_l}{D}\left(\frac{Re_l Pr_l D}{L}\right)^{1/3}
        \left(\frac{\mu_b}{\mu_w}\right)^{0.14}
    
    Turbulent for Rel > 2000:
    
    .. math::
        h_{TP} = 0.0155\frac{k_l}{D} Pr_l^{0.5} Re_l^{0.83}
    
        Re_l = \frac{\rho_l v_l D}{\mu_l}
        
        V_l = \frac{V_{ls}}{1-\alpha}

    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific tube interval [-]
    alpha : float
        Void fraction in the tube, [-]
    D : float
        Diameter of the tube [m]
    rhol : float
        Density of the liquid [kg/m^3]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    mu_b : float
        Viscosity of liquid at bulk conditions (average of inlet/outlet 
        temperature) [Pa*s]
    mu_w : float, optional
        Viscosity of liquid at wall temperature [Pa*s]
    L : float, optional
        Length of the tube, [m]
    turbulent : bool or None, optional
        Whether or not to force the correlation to return the turbulent
        result; will return the laminar regime if False

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

    Notes
    -----
    Developed with mixtures of air-water, helium-water, and freon-12-water and 
    vertical tests. Studied flow patterns were bubbly, slug, annular, 
    bubbly-slug, and slug-annular regimes. Superficial velocity ratios ranged 
    from 0.02 to 470.

    A viscosity correction is only suggested for the laminar regime. 
    If the viscosity at the wall temperature is not given, the liquid viscosity
    correction is not applied.

    Examples
    --------
    >>> Aggour(m=1, x=.9, D=.3, alpha=.9, rhol=1000, Cpl=2300, kl=.6, mu_b=1E-3)
    420.9347146885667

    References
    ----------
    .. [1] Aggour, Mohamed A. Hydrodynamics and Heat Transfer in Two-Phase 
       Two-Component Flows, Ph.D. Thesis, University of Manutoba, Canada 
       (1978). http://mspace.lib.umanitoba.ca/xmlui/handle/1993/14171.
    .. [2] Dongwoo Kim, Venkata K. Ryali, Afshin J. Ghajar, Ronald L. 
       Dougherty. "Comparison of 20 Two-Phase Heat Transfer Correlations with 
       Seven Sets of Experimental Data, Including Flow Pattern and Tube 
       Inclination Effects." Heat Transfer Engineering 20, no. 1 (February 1, 
       1999): 15-40. doi:10.1080/014576399271691.
    '''
    Vls = m*(1-x)/(rhol*pi/4*D**2)
    Vl = Vls/(1.-alpha)
    
    Prl = Prandtl(Cp=Cpl, k=kl, mu=mu_b)
    Rel = Reynolds(V=Vl, D=D, rho=rhol, mu=mu_b)

    if turbulent or (Rel > 2000 and turbulent is None):
        hl = 0.0155*(kl/D)*Rel**0.83*Prl**0.5
        return hl*(1-alpha)**-0.83
    else:
        hl = 1.615*(kl/D)*(Rel*Prl*D/L)**(1/3.)
        if mu_w:
            hl *= (mu_b/mu_w)**0.14
        return hl*(1-alpha)**(-1/3.)