r'''Calculates internal convection Nusselt number for turbulent vertical
    upward flow in a pipe under supercritical conditions according to [1]_.
        
    .. math::
        Nu_w = 0.004 Re_w^{0.923} \bar{Pr}_w^{0.773}
        \left(\frac{\rho_w}{\rho_b}\right)^{0.186}
        \left(\frac{\mu_w}{\mu_b}\right)^{0.366}
        
        \bar{Cp} = \frac{H_w-H_b}{T_w-T_b}
        
    Parameters
    ----------
    Re : float
        Reynolds number with wall fluid properties, [-]
    Pr : float
        Prandtl number with wall 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 wall fluid properties, [-]

    Notes
    -----
    For the data used to develop the correlation, P was set at 24 MPa, and D 
    was 10 mm. G varied from 200-1500 kg/m^2/s and q varied from 0 to 1250 
    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 most accurate correlation in 
    [2]_ with a MAD of 18.1%.
    
    If the extra density and viscosity information is not provided, it will 
    not be used.

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

    References
    ----------
    .. [1] Gupta, Sahil, Amjad Farah, Krysten King, Sarah Mokry, and Igor 
       Pioro. "Developing New Heat-Transfer Correlation for SuperCritical-Water
       Flow in Vertical Bare Tubes," January 1, 2010, 809-17. 
       doi:10.1115/ICONE18-30024.
    .. [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_Gupta(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_w = 0.004 Re_w^{0.923} \bar{Pr}_w^{0.773}
        \left(\frac{\rho_w}{\rho_b}\right)^{0.186}
        \left(\frac{\mu_w}{\mu_b}\right)^{0.366}
        
        \bar{Cp} = \frac{H_w-H_b}{T_w-T_b}
        
    Parameters
    ----------
    Re : float
        Reynolds number with wall fluid properties, [-]
    Pr : float
        Prandtl number with wall 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 wall fluid properties, [-]

    Notes
    -----
    For the data used to develop the correlation, P was set at 24 MPa, and D 
    was 10 mm. G varied from 200-1500 kg/m^2/s and q varied from 0 to 1250 
    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 most accurate correlation in 
    [2]_ with a MAD of 18.1%.
    
    If the extra density and viscosity information is not provided, it will 
    not be used.

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

    References
    ----------
    .. [1] Gupta, Sahil, Amjad Farah, Krysten King, Sarah Mokry, and Igor 
       Pioro. "Developing New Heat-Transfer Correlation for SuperCritical-Water
       Flow in Vertical Bare Tubes," January 1, 2010, 809-17. 
       doi:10.1115/ICONE18-30024.
    .. [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.004*Re**0.923*Pr**0.773
    if rho_w and rho_b:
        Nu *= (rho_w/rho_b)**0.186
    if mu_w and mu_b:
        Nu *= (mu_w/mu_b)**0.366
    return Nu