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]_. Has complicated rules regarding where  
    properties should be evaluated.
        
    .. math::
        Nu_m = 0.0169Re_b^{0.8356} Pr_{sel}^{0.432}\omega

    Parameters
    ----------
    Re : float
        Reynolds number as explained below, [-]
    Pr : float
        Prandtl number as explained below, [-]
    H : float, optional
        Enthalpy of water (if the fluid is water), [J/kg]

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

    Notes
    -----
    w is calculated as follows, for water only, with a reference point from
    the 1967-IFC formulation. It is set to 1 if H is not provided:
    if Hb < 1.54E6 J/kg, w = 0.82; if Hb > 1.74E6 J/kg, w = 1; otherwise 
    w = 0.82 + 9E-7*(Hb-1.54E6). 
    
    To determine heat capacity to be used, Cp should be calculated at 5 points, 
    and the lowest three points should be averaged.
    The five points are: Tw, (Tw+Tf)/2, Tf, (Tb+Tf)/2, Tb.
    
    Viscosity should be the bulk viscosity.
    Thermal conductivity should be the average of the bulk and wall values.
    Density should be the bulk density. 
    
    [2]_ states this correlation was developed with D = 10, 14, and 20 mm,
    P from 22 to 27 MPa, G from 300 to 2500 kg/m^2/s, and q from 
    200 to 700 kW/m^2. It was ranked 6th among the 14 correlations reviewed for
    enhanced heat transfer, with a MAD of 13.8%, and 6th overall for the three
    heat transfer conditions with a overall MAD of 14.8%. [3]_ ranked it 8th
    of 14 correlations for the three heat transfer conditions.
    
    [2]_ has an almost complete description of the model; both [3]_ and [4]_
    simplify it.

    Examples
    --------
    >>> Nu_Griem(1E5, 1.2)
    275.4818576600527

    References
    ----------
    .. [1] Griem, H. "A New Procedure for the Prediction of Forced Convection 
       Heat Transfer at near- and Supercritical Pressure." Heat and Mass 
       Transfer 31, no. 5 (1996): 301-5. doi:10.1007/BF02184042.
    .. [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_Griem(Re, Pr, H=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]_. Has complicated rules regarding where  
    properties should be evaluated.
        
    .. math::
        Nu_m = 0.0169Re_b^{0.8356} Pr_{sel}^{0.432}\omega

    Parameters
    ----------
    Re : float
        Reynolds number as explained below, [-]
    Pr : float
        Prandtl number as explained below, [-]
    H : float, optional
        Enthalpy of water (if the fluid is water), [J/kg]

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

    Notes
    -----
    w is calculated as follows, for water only, with a reference point from
    the 1967-IFC formulation. It is set to 1 if H is not provided:
    if Hb < 1.54E6 J/kg, w = 0.82; if Hb > 1.74E6 J/kg, w = 1; otherwise 
    w = 0.82 + 9E-7*(Hb-1.54E6). 
    
    To determine heat capacity to be used, Cp should be calculated at 5 points, 
    and the lowest three points should be averaged.
    The five points are: Tw, (Tw+Tf)/2, Tf, (Tb+Tf)/2, Tb.
    
    Viscosity should be the bulk viscosity.
    Thermal conductivity should be the average of the bulk and wall values.
    Density should be the bulk density. 
    
    [2]_ states this correlation was developed with D = 10, 14, and 20 mm,
    P from 22 to 27 MPa, G from 300 to 2500 kg/m^2/s, and q from 
    200 to 700 kW/m^2. It was ranked 6th among the 14 correlations reviewed for
    enhanced heat transfer, with a MAD of 13.8%, and 6th overall for the three
    heat transfer conditions with a overall MAD of 14.8%. [3]_ ranked it 8th
    of 14 correlations for the three heat transfer conditions.
    
    [2]_ has an almost complete description of the model; both [3]_ and [4]_
    simplify it.

    Examples
    --------
    >>> Nu_Griem(1E5, 1.2)
    275.4818576600527

    References
    ----------
    .. [1] Griem, H. "A New Procedure for the Prediction of Forced Convection 
       Heat Transfer at near- and Supercritical Pressure." Heat and Mass 
       Transfer 31, no. 5 (1996): 301-5. doi:10.1007/BF02184042.
    .. [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:
        if H < 1.54E6:
            w = 0.82
        elif H > 1.74E6:
            w = 1
        else:
            w = 0.82 + 9E-7*(H - 1.54E6)
    else:
        w = 1
    Nu = 0.0169*Re**0.8356*Pr**0.432*w
    return Nu