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

    Either a specified `hl` is required, or `Cpl`, `kl`, `mu_b`, `mu_w` and 
    `L` are required to calculate `hl`.

    .. math::
        \frac{h_{TP}}{h_l} = \left(1 + \frac{V_{gs}}{V_{ls}}\right)^{1/3}
            
    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific tube interval [-]
    D : float
        Diameter of the tube [m]
    rhol : float
        Density of the liquid [kg/m^3]
    rhog : float
        Density of the gas [kg/m^3]
    Cpl : float, optional
        Constant-pressure heat capacity of liquid [J/kg/K]
    kl : float, optional
        Thermal conductivity of liquid [W/m/K]
    mu_b : float, optional
        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]
    hl : float, optional
        Liquid-phase heat transfer coefficient as described below, [W/m^2/K]

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

    Notes
    -----
    The liquid-only heat transfer coefficient will be calculated with the 
    `laminar_entry_Seider_Tate` correlation, should it not be provided as an
    input. Many of the arguments to this function are optional and are only
    used if `hl` is not provided. 
    
    `hl` should be calculated with a velocity equal to that determined with 
    a combined volumetric flow of both the liquid and the gas. All other 
    parameters used in calculating the heat transfer coefficient are those
    of the liquid. If the viscosity at the wall temperature is not given, the 
    liquid viscosity correction in `laminar_entry_Seider_Tate` is not applied.
    
    Examples
    --------
    >>> Knott(m=1, x=.9, D=.3, rhol=1000, rhog=2.5, Cpl=2300, kl=.6, mu_b=1E-3, 
    ... mu_w=1.2E-3, L=4)
    4225.536758045839

    References
    ----------
    .. [1] Knott, R. F., R. N. Anderson, Andreas. Acrivos, and E. E. Petersen. 
       "An Experimental Study of Heat Transfer to Nitrogen-Oil Mixtures." 
       Industrial & Engineering Chemistry 51, no. 11 (November 1, 1959): 
       1369-72. doi:10.1021/ie50599a032. 
    .. [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 Knott(m, x, D, rhol, rhog, Cpl=None, kl=None, mu_b=None, mu_w=None, L=None,
          hl=None):
    r'''Calculates the two-phase non-boiling heat transfer coefficient of a 
    liquid and gas flowing inside a tube of any inclination, as in [1]_ and 
    reviewed in [2]_.

    Either a specified `hl` is required, or `Cpl`, `kl`, `mu_b`, `mu_w` and 
    `L` are required to calculate `hl`.

    .. math::
        \frac{h_{TP}}{h_l} = \left(1 + \frac{V_{gs}}{V_{ls}}\right)^{1/3}
            
    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific tube interval [-]
    D : float
        Diameter of the tube [m]
    rhol : float
        Density of the liquid [kg/m^3]
    rhog : float
        Density of the gas [kg/m^3]
    Cpl : float, optional
        Constant-pressure heat capacity of liquid [J/kg/K]
    kl : float, optional
        Thermal conductivity of liquid [W/m/K]
    mu_b : float, optional
        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]
    hl : float, optional
        Liquid-phase heat transfer coefficient as described below, [W/m^2/K]

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

    Notes
    -----
    The liquid-only heat transfer coefficient will be calculated with the 
    `laminar_entry_Seider_Tate` correlation, should it not be provided as an
    input. Many of the arguments to this function are optional and are only
    used if `hl` is not provided. 
    
    `hl` should be calculated with a velocity equal to that determined with 
    a combined volumetric flow of both the liquid and the gas. All other 
    parameters used in calculating the heat transfer coefficient are those
    of the liquid. If the viscosity at the wall temperature is not given, the 
    liquid viscosity correction in `laminar_entry_Seider_Tate` is not applied.
    
    Examples
    --------
    >>> Knott(m=1, x=.9, D=.3, rhol=1000, rhog=2.5, Cpl=2300, kl=.6, mu_b=1E-3, 
    ... mu_w=1.2E-3, L=4)
    4225.536758045839

    References
    ----------
    .. [1] Knott, R. F., R. N. Anderson, Andreas. Acrivos, and E. E. Petersen. 
       "An Experimental Study of Heat Transfer to Nitrogen-Oil Mixtures." 
       Industrial & Engineering Chemistry 51, no. 11 (November 1, 1959): 
       1369-72. doi:10.1021/ie50599a032. 
    .. [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.
    '''
    Vgs = m*x/(rhog*pi/4*D**2)
    Vls = m*(1-x)/(rhol*pi/4*D**2)
    if not hl:
        V = Vgs + Vls # Net velocity
        Re = Reynolds(V=V, D=D, rho=rhol, mu=mu_b)
        Pr = Prandtl(Cp=Cpl, k=kl, mu=mu_b)
        Nul = laminar_entry_Seider_Tate(Re=Re, Pr=Pr, L=L, Di=D, mu=mu_b, mu_w=mu_w)
        hl = Nul*kl/D
    return hl*(1 + Vgs/Vls)**(1/3.)