r'''Calculates internal convection Nusselt number for turbulent vertical
    upward flow in a pipe under supercritical conditions according to [1]_.
        
    .. math::
        Nu_b = 0.0183 Re_b^{0.82} Pr^{0.5}
        \left(\frac{\rho_w}{\rho_b}\right)^{0.3}
        \left(\frac{\bar C_p}{C_{p,b}}\right)^n
        
        n = 0.4 \text{ for } T_b < T_w < T_{pc} \text{ or } 1.2T_{pc} < T_b < T_w
        
        n = 0.4 + 0.2(T_w/T_{pc} - 1) \text{ for } T_b < T_{pc} <T_w
        
        n = 0.4 + 0.2(T_w/T_{pc} - 1)[1 - 5(T_b/T_{pc}-1)]
        \text{ for } T_{pc} < T_b < 1.2T_{pc} \text{ and } T_b < T_w

        \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, [-]
    rho_w : float, optional
        Density at the wall temperature, [kg/m^3]
    rho_b : float, optional
        Density at the bulk temperature, [kg/m^3]
    Cp_avg : float, optional
        Average heat capacity between the wall and bulk temperatures, [J/kg/K]
    Cp_b : float, optional
        Heat capacity at the bulk temperature, [J/kg/K]
    T_b : float
        Bulk temperature, [K]
    T_w : float
        Wall temperature, [K]
    T_pc : float
        Pseudocritical temperature, i.e. temperature at P where Cp is at a 
        maximum, [K]

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

    Notes
    -----
    The range of examined parameters is as follows: 
    P from 23.4 to 29.3 MPa; G from 700-3600 kg/m^2/s; 
    q from 46 to 2600 kW/m^2; Re from 8E4 to 5E5; D from 1.6 to 20 mm.
    
    For enhanced heat transfer database in [2]_, this correlation was the
    second best with a MAD of 11.5%. In the database in [3]_, the correlation
    was the second best as well.
    
    This is sometimes called the Jackson-Hall correlation.
    If the extra information is not provided, the correlation will be used
    without the corrections.

    Examples
    --------
    >>> Nu_Jackson(1E5, 1.2)
    252.37231572974918

    References
    ----------
    .. [1] Jackson, J. D. "Consideration of the Heat Transfer Properties of 
       Supercritical Pressure Water in Connection with the Cooling of Advanced 
       Nuclear Reactors", 2002.
    .. [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_Jackson(Re, Pr, rho_w=None, rho_b=None, Cp_avg=None, Cp_b=None, T_b=None,
               T_w=None, T_pc=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.0183 Re_b^{0.82} Pr^{0.5}
        \left(\frac{\rho_w}{\rho_b}\right)^{0.3}
        \left(\frac{\bar C_p}{C_{p,b}}\right)^n
        
        n = 0.4 \text{ for } T_b < T_w < T_{pc} \text{ or } 1.2T_{pc} < T_b < T_w
        
        n = 0.4 + 0.2(T_w/T_{pc} - 1) \text{ for } T_b < T_{pc} <T_w
        
        n = 0.4 + 0.2(T_w/T_{pc} - 1)[1 - 5(T_b/T_{pc}-1)]
        \text{ for } T_{pc} < T_b < 1.2T_{pc} \text{ and } T_b < T_w

        \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, [-]
    rho_w : float, optional
        Density at the wall temperature, [kg/m^3]
    rho_b : float, optional
        Density at the bulk temperature, [kg/m^3]
    Cp_avg : float, optional
        Average heat capacity between the wall and bulk temperatures, [J/kg/K]
    Cp_b : float, optional
        Heat capacity at the bulk temperature, [J/kg/K]
    T_b : float
        Bulk temperature, [K]
    T_w : float
        Wall temperature, [K]
    T_pc : float
        Pseudocritical temperature, i.e. temperature at P where Cp is at a 
        maximum, [K]

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

    Notes
    -----
    The range of examined parameters is as follows: 
    P from 23.4 to 29.3 MPa; G from 700-3600 kg/m^2/s; 
    q from 46 to 2600 kW/m^2; Re from 8E4 to 5E5; D from 1.6 to 20 mm.
    
    For enhanced heat transfer database in [2]_, this correlation was the
    second best with a MAD of 11.5%. In the database in [3]_, the correlation
    was the second best as well.
    
    This is sometimes called the Jackson-Hall correlation.
    If the extra information is not provided, the correlation will be used
    without the corrections.

    Examples
    --------
    >>> Nu_Jackson(1E5, 1.2)
    252.37231572974918

    References
    ----------
    .. [1] Jackson, J. D. "Consideration of the Heat Transfer Properties of 
       Supercritical Pressure Water in Connection with the Cooling of Advanced 
       Nuclear Reactors", 2002.
    .. [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 all([T_b, T_w, T_pc]):
        if T_b < T_w < T_pc or 1.2*T_pc < T_b < T_w:      
            n = 0.4
        elif T_b < T_pc < T_w:
            n = 0.4 + 0.2*(T_w/T_pc - 1)
        else:
            n = 0.4 + 0.2*(T_w/T_pc - 1)*(1 - 5*(T_b/T_pc - 1))
    else:
        n = 0.4
    Nu = 0.0183*Re**0.82*Pr**0.5
    if rho_w and rho_b:
        Nu *= (rho_w/rho_b)**0.3
    if Cp_avg and Cp_b:
        Nu *= (Cp_avg/Cp_b)**n
    return Nu