r'''Calculates heat transfer coefficient for condensation
    of a fluid inside a tube, as presented in [1]_ and again by the same 
    author in [2]_; also given in [3]_. Requires no properties of the gas.
    Uses the Dittus-Boelter correlation for single phase heat transfer 
    coefficient, with a Reynolds number assuming all the flow is liquid.

    .. math::
        h_{TP} = h_L\left[(1-x)^{0.8} +\frac{3.8x^{0.76}(1-x)^{0.04}}
        {P_r^{0.38}}\right]
    
    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific interval [-]
    D : float
        Diameter of the channel [m]
    rhol : float
        Density of the liquid [kg/m^3]
    mul : float
        Viscosity of liquid [Pa*s]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]
    P : float
        Pressure of the fluid, [Pa]
    Pc : float
        Critical pressure of the fluid, [Pa]

    Returns
    -------
    h : float
        Heat transfer coefficient [W/m^2/K]

    Notes
    -----
    [1]_ is well written an unambiguous as to how to apply this equation.

    Examples
    --------
    >>> Shah(m=1, x=0.4, D=.3, rhol=800, mul=1E-5, kl=0.6, Cpl=2300, P=1E6, Pc=2E7)
    2561.2593415479214

    References
    ----------
    .. [1] Shah, M. M. "A General Correlation for Heat Transfer during Film 
       Condensation inside Pipes." International Journal of Heat and Mass 
       Transfer 22, no. 4 (April 1, 1979): 547-56. 
       doi:10.1016/0017-9310(79)90058-9. 
    .. [2] Shah, M. M., Heat Transfer During Film Condensation in Tubes and 
       Annuli: A Review of the Literature, ASHRAE Transactions, vol. 87, no. 
       3, pp. 1086-1100, 1981.
    .. [3] Kakaç, Sadik, ed. Boilers, Evaporators, and Condensers. 1st. 
       Wiley-Interscience, 1991.

def Shah(m, x, D, rhol, mul, kl, Cpl, P, Pc):
    r'''Calculates heat transfer coefficient for condensation
    of a fluid inside a tube, as presented in [1]_ and again by the same 
    author in [2]_; also given in [3]_. Requires no properties of the gas.
    Uses the Dittus-Boelter correlation for single phase heat transfer 
    coefficient, with a Reynolds number assuming all the flow is liquid.

    .. math::
        h_{TP} = h_L\left[(1-x)^{0.8} +\frac{3.8x^{0.76}(1-x)^{0.04}}
        {P_r^{0.38}}\right]
    
    Parameters
    ----------
    m : float
        Mass flow rate [kg/s]
    x : float
        Quality at the specific interval [-]
    D : float
        Diameter of the channel [m]
    rhol : float
        Density of the liquid [kg/m^3]
    mul : float
        Viscosity of liquid [Pa*s]
    kl : float
        Thermal conductivity of liquid [W/m/K]
    Cpl : float
        Constant-pressure heat capacity of liquid [J/kg/K]
    P : float
        Pressure of the fluid, [Pa]
    Pc : float
        Critical pressure of the fluid, [Pa]

    Returns
    -------
    h : float
        Heat transfer coefficient [W/m^2/K]

    Notes
    -----
    [1]_ is well written an unambiguous as to how to apply this equation.

    Examples
    --------
    >>> Shah(m=1, x=0.4, D=.3, rhol=800, mul=1E-5, kl=0.6, Cpl=2300, P=1E6, Pc=2E7)
    2561.2593415479214

    References
    ----------
    .. [1] Shah, M. M. "A General Correlation for Heat Transfer during Film 
       Condensation inside Pipes." International Journal of Heat and Mass 
       Transfer 22, no. 4 (April 1, 1979): 547-56. 
       doi:10.1016/0017-9310(79)90058-9. 
    .. [2] Shah, M. M., Heat Transfer During Film Condensation in Tubes and 
       Annuli: A Review of the Literature, ASHRAE Transactions, vol. 87, no. 
       3, pp. 1086-1100, 1981.
    .. [3] Kakaç, Sadik, ed. Boilers, Evaporators, and Condensers. 1st. 
       Wiley-Interscience, 1991.
    '''
    VL = m/(rhol*pi/4*D**2)
    ReL = Reynolds(V=VL, D=D, rho=rhol, mu=mul)
    Prl = Prandtl(Cp=Cpl, k=kl, mu=mul)
    hL = turbulent_Dittus_Boelter(ReL, Prl)*kl/D
    Pr = P/Pc
    return hL*((1-x)**0.8 + 3.8*x**0.76*(1-x)**0.04/Pr**0.38)