r'''Calculates internal convection Nusselt number for turbulent vertical
    upward flow in a pipe under supercritical conditions according to [1]_, 
    also shown in [2]_, [3]_ and [4]_. Depends on fluid enthalpy, mass flux,
    and heat flux.
        
    .. math::
        Nu_b = 0.015Re_b^{0.85} Pr_b^m
        
        m = 0.69 - \frac{81000}{q_{dht}} + f_cq
        
        q_{dht} = 200 G^{1.2}
        
        f_c = 2.9\times10^{-8} + \frac{0.11}{q_{dht}} \text{ for } 
        H_b < 1500 \text{ kJ/kg}
        
        f_c = -8.7\times10^{-8} - \frac{0.65}{q_{dht}} \text{ for } 
        1500 \text{ kJ/kg} < H_b < 3300 \text{ kJ/kg}
        
        f_c = -9.7\times10^{-7} + \frac{1.3}{q_{dht}} \text{ for } 
        H_b > 3300 \text{ kJ/kg}

    Parameters
    ----------
    Re : float
        Reynolds number with bulk fluid properties, [-]
    Pr : float
        Prandtl number with bulk fluid properties, [-]
    H : float, optional
        Enthalpy of water (if the fluid is water), [J/kg]
    G : float, optional
        Mass flux of the fluid, [kg/m^2/s]
    q : float, optional
        Heat flux to wall, [W/m^2]

    Returns
    -------
    Nu : float
        Nusselt number as explained below, [-]

    Notes
    -----
    The reference point for the enthalpy values is not stated in [1]_. The 
    upper and lower enthalpy limits for this correlation are 4000 kJ/kg and 
    0 kJ/kg, but these are not enforced in this function.
    
    If not all of H, G, and q are provided, the correlation is used without
    the correction.
    
    This correlation was ranked 6th best in [3]_, and found 4th best for 
    enhanced heat transfer in [2]_ with a MAD of 12.3%.
    
    For the data used to develop the correlation, G varied from 100-1750 
    kg/m^2/s, q varied from 0 to 1800 kW/m^2, and bulk temperature varied from 
    20 to 550 decrees Celsius. 

    This correlation does not have realistic behavior for values outside those
    used in the study, and should not be used.

    Examples
    --------
    >>> Nu_Kitoh(1E5, 1.2, 1.3E6, 1500, 5E6)
    331.80234139591306
    
    References
    ----------
    .. [1] Kitoh, Kazuaki, Seiichi Koshizuka, and Yoshiaki Oka. "Refinement of 
       Transient Criteria and Safety Analysis for a High-Temperature Reactor 
       Cooled by Supercritical Water." Nuclear Technology 135, no. 3 
       (September 1, 2001): 252-64.
    .. [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.
    .. [3] Yu, Jiyang, Baoshan Jia, Dan Wu, and Daling Wang. "Optimization of 
       Heat Transfer Coefficient Correlation at Supercritical Pressure Using 
       Genetic Algorithms." Heat and Mass Transfer 45, no. 6 (January 8, 2009): 
       757-66. doi:10.1007/s00231-008-0475-4.
    .. [4] Jäger, Wadim, Victor Hugo Sánchez Espinoza, and Antonio Hurtado. 
       "Review and Proposal for Heat Transfer Predictions at Supercritical 
       Water Conditions Using Existing Correlations and Experiments." Nuclear 
       Engineering and Design, (W3MDM) University of Leeds International 
       Symposium: What Where When? Multi-dimensional Advances for Industrial 
       Process Monitoring, 241, no. 6 (June 2011): 2184-2203. 
       doi:10.1016/j.nucengdes.2011.03.022.

def Nu_Kitoh(Re, Pr, H=None, G=None, q=None):
    r'''Calculates internal convection Nusselt number for turbulent vertical
    upward flow in a pipe under supercritical conditions according to [1]_, 
    also shown in [2]_, [3]_ and [4]_. Depends on fluid enthalpy, mass flux,
    and heat flux.
        
    .. math::
        Nu_b = 0.015Re_b^{0.85} Pr_b^m
        
        m = 0.69 - \frac{81000}{q_{dht}} + f_cq
        
        q_{dht} = 200 G^{1.2}
        
        f_c = 2.9\times10^{-8} + \frac{0.11}{q_{dht}} \text{ for } 
        H_b < 1500 \text{ kJ/kg}
        
        f_c = -8.7\times10^{-8} - \frac{0.65}{q_{dht}} \text{ for } 
        1500 \text{ kJ/kg} < H_b < 3300 \text{ kJ/kg}
        
        f_c = -9.7\times10^{-7} + \frac{1.3}{q_{dht}} \text{ for } 
        H_b > 3300 \text{ kJ/kg}

    Parameters
    ----------
    Re : float
        Reynolds number with bulk fluid properties, [-]
    Pr : float
        Prandtl number with bulk fluid properties, [-]
    H : float, optional
        Enthalpy of water (if the fluid is water), [J/kg]
    G : float, optional
        Mass flux of the fluid, [kg/m^2/s]
    q : float, optional
        Heat flux to wall, [W/m^2]

    Returns
    -------
    Nu : float
        Nusselt number as explained below, [-]

    Notes
    -----
    The reference point for the enthalpy values is not stated in [1]_. The 
    upper and lower enthalpy limits for this correlation are 4000 kJ/kg and 
    0 kJ/kg, but these are not enforced in this function.
    
    If not all of H, G, and q are provided, the correlation is used without
    the correction.
    
    This correlation was ranked 6th best in [3]_, and found 4th best for 
    enhanced heat transfer in [2]_ with a MAD of 12.3%.
    
    For the data used to develop the correlation, G varied from 100-1750 
    kg/m^2/s, q varied from 0 to 1800 kW/m^2, and bulk temperature varied from 
    20 to 550 decrees Celsius. 

    This correlation does not have realistic behavior for values outside those
    used in the study, and should not be used.

    Examples
    --------
    >>> Nu_Kitoh(1E5, 1.2, 1.3E6, 1500, 5E6)
    331.80234139591306
    
    References
    ----------
    .. [1] Kitoh, Kazuaki, Seiichi Koshizuka, and Yoshiaki Oka. "Refinement of 
       Transient Criteria and Safety Analysis for a High-Temperature Reactor 
       Cooled by Supercritical Water." Nuclear Technology 135, no. 3 
       (September 1, 2001): 252-64.
    .. [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.
    .. [3] Yu, Jiyang, Baoshan Jia, Dan Wu, and Daling Wang. "Optimization of 
       Heat Transfer Coefficient Correlation at Supercritical Pressure Using 
       Genetic Algorithms." Heat and Mass Transfer 45, no. 6 (January 8, 2009): 
       757-66. doi:10.1007/s00231-008-0475-4.
    .. [4] Jäger, Wadim, Victor Hugo Sánchez Espinoza, and Antonio Hurtado. 
       "Review and Proposal for Heat Transfer Predictions at Supercritical 
       Water Conditions Using Existing Correlations and Experiments." Nuclear 
       Engineering and Design, (W3MDM) University of Leeds International 
       Symposium: What Where When? Multi-dimensional Advances for Industrial 
       Process Monitoring, 241, no. 6 (June 2011): 2184-2203. 
       doi:10.1016/j.nucengdes.2011.03.022. 
    '''
    if H and G and q:
        qht = 200.*G**1.2
        if H < 1.5E6:
            fc = 2.9E-8 + 0.11/qht
        elif 1.5E6 <= H <= 3.3E6:
            fc = -8.7E-8 - 0.65/qht
        else:
            fc = -9.7E-7 + 1.3/qht
        m = 0.69 - 81000./qht + fc*q
    else:
        m = 0.69
    return 0.015*Re**0.85*Pr**m