r'''Calculates internal convection Nusselt number for turbulent vertical
    upward flow in a pipe under supercritical conditions according to [1]_.
        
    .. math::
        Nu_b = 0.02269 Re_b^{0.8079} \bar{Pr}_b^{0.9213}
        \left(\frac{\rho_w}{\rho_b}\right)^{0.6638}
        \left(\frac{\mu_w}{\mu_b}\right)^{0.8687}
        
        \bar{Cp} = \frac{H_w-H_b}{T_w-T_b}
        
    Parameters
    ----------
    Re : float
        Reynolds number with bulk fluid properties, [-]
    Pr : float
        Prandtl number with bulk fluid properties and an average heat capacity
        between the wall and bulk temperatures [-]
    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 data used to develop the correlation, P varied from 23 to 30 MPa,
    and D was 12 mm. G varied from 600-1200 kg/m^2/s and q varied from 100 to 
    600 kW/m^2.
    
    Cp used in the calculation of Prandtl number should be the average value
    of those at the wall and the bulk temperatures.

    For deteriorated heat transfer, this was the third most accurate  
    correlation in [2]_ with a MAD of 20.5%.
    
    If the extra density and viscosity information is not provided, it will 
    not be used.

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

    References
    ----------
    .. [1] Xu, F., Guo, L.J., Mao, Y.F., Jiang, X.E., 2005. "Experimental 
       investigation to the heat transfer characteristics of water in vertical 
       pipes under supercritical pressure". J. Xi'an Jiaotong University 39, 
       468-471.
    .. [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_Xu(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 = 0.02269 Re_b^{0.8079} \bar{Pr}_b^{0.9213}
        \left(\frac{\rho_w}{\rho_b}\right)^{0.6638}
        \left(\frac{\mu_w}{\mu_b}\right)^{0.8687}
        
        \bar{Cp} = \frac{H_w-H_b}{T_w-T_b}
        
    Parameters
    ----------
    Re : float
        Reynolds number with bulk fluid properties, [-]
    Pr : float
        Prandtl number with bulk fluid properties and an average heat capacity
        between the wall and bulk temperatures [-]
    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 data used to develop the correlation, P varied from 23 to 30 MPa,
    and D was 12 mm. G varied from 600-1200 kg/m^2/s and q varied from 100 to 
    600 kW/m^2.
    
    Cp used in the calculation of Prandtl number should be the average value
    of those at the wall and the bulk temperatures.

    For deteriorated heat transfer, this was the third most accurate  
    correlation in [2]_ with a MAD of 20.5%.
    
    If the extra density and viscosity information is not provided, it will 
    not be used.

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

    References
    ----------
    .. [1] Xu, F., Guo, L.J., Mao, Y.F., Jiang, X.E., 2005. "Experimental 
       investigation to the heat transfer characteristics of water in vertical 
       pipes under supercritical pressure". J. Xi'an Jiaotong University 39, 
       468-471.
    .. [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.
    '''
    Nu = 0.02269*Re**0.8079*Pr**0.9213
    if rho_w and rho_b:
        Nu *= (rho_w/rho_b)**0.6638
    if mu_w and mu_b:
        Nu *= (mu_w/mu_b)**0.8687
    return Nu