# Path: ht/conv_internal.py
# def laminar_entry_Seider_Tate(Re, Pr, L, Di, mu=None, mu_w=None):
#     r'''Calculates average internal convection Nusselt number for laminar flows
#     in pipe during the thermal entry region as developed in [1]_, also
#     shown in [2]_.
# 
#     .. math::
#         Nu_D=1.86\left(\frac{D}{L}Re_DPr\right)^{1/3}\left(\frac{\mu_b}
#         {\mu_s}\right)^{0.14}
# 
#     Parameters
#     ----------
#     Re : float
#         Reynolds number, [-]
#     Pr : float
#         Prandtl number, [-]
#     L : float
#         Length of pipe [m]
#     Di : float
#         Diameter of pipe [m]
#     mu : float, optional
#         Viscosity of fluid, [Pa*s]
#     mu_w : float, optional
#         Viscosity of fluid at wall temperature, [Pa*s]
# 
#     Returns
#     -------
#     Nu : float
#         Nusselt number, [-]
# 
#     Notes
#     -----
#     Reynolds number should be less than 10000. This should be calculated
#     using pipe diameter.
#     Prandlt number should be no less than air and no more than liquid metals;
#     0.7 < Pr <  16700
#     Viscosities should be the bulk and surface properties; they are optional.
#     Outside the boundaries, this equation is provides very false results.
# 
#     Examples
#     --------
#     >>> laminar_entry_Seider_Tate(Re=100000, Pr=1.1, L=5, Di=.5)
#     41.366029684589265
# 
#     References
#     ----------
#     .. [1] Sieder, E. N., and G. E. Tate. "Heat Transfer and Pressure Drop of
#        Liquids in Tubes." Industrial & Engineering Chemistry 28, no. 12
#        (December 1, 1936): 1429-35. doi:10.1021/ie50324a027.
#     .. [2] Serth, R. W., Process Heat Transfer: Principles,
#        Applications and Rules of Thumb. 2E. Amsterdam: Academic Press, 2014.
#     '''
#     Nu = 1.86*(Di/L*Re*Pr)**(1/3.0)
#     if mu_w is not None and mu is not None:
#         Nu *= (mu/mu_w)**0.14
#     return Nu


from math import pi
from fluids.core import Reynolds, Prandtl
from ht.conv_internal import laminar_entry_Seider_Tate
    No specific suggestion for how to calculate the liquid-phase heat transfer
    coefficient is given in [1]_; [2]_ suggests to use the same procedure as
    in `Knott`.

    Examples
    --------
    >>> Martin_Sims(m=1, x=.9, D=.3, rhol=1000, rhog=2.5, hl=141.2)
    5563.280000000001
    >>> Martin_Sims(m=1, x=.9, D=.3, rhol=1000, rhog=2.5, Cpl=2300, kl=.6,
    ... mu_b=1E-3, mu_w=1.2E-3, L=24)
    5977.505465781747

    References
    ----------
    .. [1] Martin, B. W, and G. E Sims. "Forced Convection Heat Transfer to
       Water with Air Injection in a Rectangular Duct." International Journal
       of Heat and Mass Transfer 14, no. 8 (August 1, 1971): 1115-34.
       doi:10.1016/0017-9310(71)90208-0.
    .. [2] Dongwoo Kim, Venkata K. Ryali, Afshin J. Ghajar, Ronald L.
       Dougherty. "Comparison of 20 Two-Phase Heat Transfer Correlations with
       Seven Sets of Experimental Data, Including Flow Pattern and Tube
       Inclination Effects." Heat Transfer Engineering 20, no. 1 (February 1,
       1999): 15-40. doi:10.1080/014576399271691.
    '''
    Vgs = m*x/(rhog*pi/4*D**2)
    Vls = m*(1-x)/(rhol*pi/4*D**2)
    if hl is None:
        V = Vgs + Vls # Net velocity
        Re = Reynolds(V=V, D=D, rho=rhol, mu=mu_b)
        Pr = Prandtl(Cp=Cpl, k=kl, mu=mu_b)

# Path: ht/conv_internal.py
# def laminar_entry_Seider_Tate(Re, Pr, L, Di, mu=None, mu_w=None):
#     r'''Calculates average internal convection Nusselt number for laminar flows
#     in pipe during the thermal entry region as developed in [1]_, also
#     shown in [2]_.
# 
#     .. math::
#         Nu_D=1.86\left(\frac{D}{L}Re_DPr\right)^{1/3}\left(\frac{\mu_b}
#         {\mu_s}\right)^{0.14}
# 
#     Parameters
#     ----------
#     Re : float
#         Reynolds number, [-]
#     Pr : float
#         Prandtl number, [-]
#     L : float
#         Length of pipe [m]
#     Di : float
#         Diameter of pipe [m]
#     mu : float, optional
#         Viscosity of fluid, [Pa*s]
#     mu_w : float, optional
#         Viscosity of fluid at wall temperature, [Pa*s]
# 
#     Returns
#     -------
#     Nu : float
#         Nusselt number, [-]
# 
#     Notes
#     -----
#     Reynolds number should be less than 10000. This should be calculated
#     using pipe diameter.
#     Prandlt number should be no less than air and no more than liquid metals;
#     0.7 < Pr <  16700
#     Viscosities should be the bulk and surface properties; they are optional.
#     Outside the boundaries, this equation is provides very false results.
# 
#     Examples
#     --------
#     >>> laminar_entry_Seider_Tate(Re=100000, Pr=1.1, L=5, Di=.5)
#     41.366029684589265
# 
#     References
#     ----------
#     .. [1] Sieder, E. N., and G. E. Tate. "Heat Transfer and Pressure Drop of
#        Liquids in Tubes." Industrial & Engineering Chemistry 28, no. 12
#        (December 1, 1936): 1429-35. doi:10.1021/ie50324a027.
#     .. [2] Serth, R. W., Process Heat Transfer: Principles,
#        Applications and Rules of Thumb. 2E. Amsterdam: Academic Press, 2014.
#     '''
#     Nu = 1.86*(Di/L*Re*Pr)**(1/3.0)
#     if mu_w is not None and mu is not None:
#         Nu *= (mu/mu_w)**0.14
#     return Nu


# Path: ht/conv_two_phase.py
from math import pi
from fluids.core import Reynolds, Prandtl
from ht.conv_internal import laminar_entry_Seider_Tate

    No specific suggestion for how to calculate the liquid-phase heat transfer
    coefficient is given in [1]_; [2]_ suggests to use the same procedure as
    in `Knott`.

    Examples
    --------
    >>> Martin_Sims(m=1, x=.9, D=.3, rhol=1000, rhog=2.5, hl=141.2)
    5563.280000000001
    >>> Martin_Sims(m=1, x=.9, D=.3, rhol=1000, rhog=2.5, Cpl=2300, kl=.6,
    ... mu_b=1E-3, mu_w=1.2E-3, L=24)
    5977.505465781747

    References
    ----------
    .. [1] Martin, B. W, and G. E Sims. "Forced Convection Heat Transfer to
       Water with Air Injection in a Rectangular Duct." International Journal
       of Heat and Mass Transfer 14, no. 8 (August 1, 1971): 1115-34.
       doi:10.1016/0017-9310(71)90208-0.
    .. [2] Dongwoo Kim, Venkata K. Ryali, Afshin J. Ghajar, Ronald L.
       Dougherty. "Comparison of 20 Two-Phase Heat Transfer Correlations with
       Seven Sets of Experimental Data, Including Flow Pattern and Tube
       Inclination Effects." Heat Transfer Engineering 20, no. 1 (February 1,
       1999): 15-40. doi:10.1080/014576399271691.
    '''
    Vgs = m*x/(rhog*pi/4*D**2)
    Vls = m*(1-x)/(rhol*pi/4*D**2)
    if hl is None:
        V = Vgs + Vls # Net velocity
        Re = Reynolds(V=V, D=D, rho=rhol, mu=mu_b)
        Pr = Prandtl(Cp=Cpl, k=kl, mu=mu_b)

        Nul = laminar_entry_Seider_Tate(Re=Re, Pr=Pr, L=L, Di=D, mu=mu_b, mu_w=mu_w)