r'''Calculates internal convection Nusselt number for turbulent vertical
    upward flow in a pipe under supercritical conditions according to [1]_.
        
    .. math::
        Nu_b = \frac{(f/8)Re_b \bar Pr_b}{1+900/Re_b+12.7(f/8)^{1/2}
        (\bar Pr_b)^{2/3}-1)}
        
        f = f_d\left(\frac{\rho_w}{\rho_b}\right)^{0.4}
        \left(\frac{\mu_w}{\mu_b}\right)^{0.2}

        f_d = [1.82\log_{10}(Re_b) - 1.64]^{-2}
        
    Parameters
    ----------
    Re : float
        Reynolds number with bulk fluid properties, [-]
    Pr : float
        Prandtl number with bulk fluid properties [-]
    rho_w : float, optional
        Density at the wall temperature, [kg/m^3]
    rho_b : float, optional
        Density at the bulk temperature, [kg/m^3]
    mu_w : float, optional
        Viscosity at the wall temperature, [Pa*s]
    mu_b : float, optional
        Viscosity at the bulk temperature, [Pa*s]

    Returns
    -------
    Nu : float
        Nusselt number with bulk fluid properties, [-]

    Notes
    -----    
    For the heat transfer database in [2]_, this correlation was 5th most
    accurate in the enhanced heat transfer category, and second in the normal
    heat transfer category with MADs of 13.8% and 12.0% respectively.
    
    If the extra viscosity and density information is not provided, it will not
    be used.

    Examples
    --------
    >>> Nu_Petukhov(1E5, 1.2, 330, 290., 8e-4, 9e-4)
    254.8258598466738

    References
    ----------
    .. [1] Petukhov, B.S., V.A. Kurganov, and V.B. Ankudinov. "HEAT TRANSFER 
       AND FLOW RESISTANCE IN THE TURBULENT PIPE FLOW OF A FLUID WITH 
       NEAR-CRITICAL STATE PARAMETERS." High Temperature 21, no. 1 (1983): 
       81-89.
    .. [2] Chen, Weiwei, Xiande Fang, Yu Xu, and Xianghui Su. "An Assessment of
       Correlations of Forced Convection Heat Transfer to Water at 
       Supercritical Pressure." Annals of Nuclear Energy 76 (February 2015): 
       451-60. doi:10.1016/j.anucene.2014.10.027.

def Nu_Petukhov(Re, Pr, rho_w=None, rho_b=None, mu_w=None, mu_b=None):
    r'''Calculates internal convection Nusselt number for turbulent vertical
    upward flow in a pipe under supercritical conditions according to [1]_.
        
    .. math::
        Nu_b = \frac{(f/8)Re_b \bar Pr_b}{1+900/Re_b+12.7(f/8)^{1/2}
        (\bar Pr_b)^{2/3}-1)}
        
        f = f_d\left(\frac{\rho_w}{\rho_b}\right)^{0.4}
        \left(\frac{\mu_w}{\mu_b}\right)^{0.2}

        f_d = [1.82\log_{10}(Re_b) - 1.64]^{-2}
        
    Parameters
    ----------
    Re : float
        Reynolds number with bulk fluid properties, [-]
    Pr : float
        Prandtl number with bulk fluid properties [-]
    rho_w : float, optional
        Density at the wall temperature, [kg/m^3]
    rho_b : float, optional
        Density at the bulk temperature, [kg/m^3]
    mu_w : float, optional
        Viscosity at the wall temperature, [Pa*s]
    mu_b : float, optional
        Viscosity at the bulk temperature, [Pa*s]

    Returns
    -------
    Nu : float
        Nusselt number with bulk fluid properties, [-]

    Notes
    -----    
    For the heat transfer database in [2]_, this correlation was 5th most
    accurate in the enhanced heat transfer category, and second in the normal
    heat transfer category with MADs of 13.8% and 12.0% respectively.
    
    If the extra viscosity and density information is not provided, it will not
    be used.

    Examples
    --------
    >>> Nu_Petukhov(1E5, 1.2, 330, 290., 8e-4, 9e-4)
    254.8258598466738

    References
    ----------
    .. [1] Petukhov, B.S., V.A. Kurganov, and V.B. Ankudinov. "HEAT TRANSFER 
       AND FLOW RESISTANCE IN THE TURBULENT PIPE FLOW OF A FLUID WITH 
       NEAR-CRITICAL STATE PARAMETERS." High Temperature 21, no. 1 (1983): 
       81-89.
    .. [2] Chen, Weiwei, Xiande Fang, Yu Xu, and Xianghui Su. "An Assessment of
       Correlations of Forced Convection Heat Transfer to Water at 
       Supercritical Pressure." Annals of Nuclear Energy 76 (February 2015): 
       451-60. doi:10.1016/j.anucene.2014.10.027.
    '''
    fd = (1.82*log10(Re) - 1.64)**-2
    if rho_w and rho_b:
        fd *= (rho_w/rho_b)**0.4
    if mu_w and mu_b:
        fd *= (mu_w/mu_b)**0.2
    return (fd/8.)*Re*Pr/(1 + 900./Re + 12.7*(fd/8.)**0.5*(Pr**(2/3.)-1))