Exemplo n.º 1
0
def Somayajulu(T, Tc, A, B, C):
    r'''Calculates air-water surface tension  using the [1]_
    emperical (parameter-regressed) method. Well regressed, no recent data.

    .. math::
        \sigma=aX^{5/4}+bX^{9/4}+cX^{13/4}

    .. math::
        X=(T_c-T)/T_c

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    A : float
        Regression parameter
    B : float
        Regression parameter
    C : float
        Regression parameter

    Returns
    -------
    sigma : float
        Liquid surface tension, N/m

    Notes
    -----
    Presently untested, but matches expected values. Internal units are mN/m.
    Form of function returns imaginary results when T > Tc; None is returned
    if this is the case. Function is claimed valid from the triple to the
    critical point. Results can be evaluated beneath the triple point.

    Examples
    --------
    Water at 300 K

    >>> Somayajulu(300, 647.126, 232.713514, -140.18645, -4.890098)
    0.07166386387996758

    References
    ----------
    .. [1] Somayajulu, G. R. "A Generalized Equation for Surface Tension from
       the Triple Point to the Critical Point." International Journal of
       Thermophysics 9, no. 4 (July 1988): 559-66. doi:10.1007/BF00503154.
    '''
    X = (Tc - T) / Tc
    return X * sqrt(sqrt(X)) * (A + X * (B + C * X)) * 1e-3
Exemplo n.º 2
0
def Psat_IAPWS(T):
    r'''Calculates vapor pressure of water using the IAPWS explicit equation.

    .. math::
        P^{sat} = 10^6 \left[ \frac{2C}{-B + \sqrt{B^2 - 4AC}}  \right]^4

    .. math::
        A = \nu^2 + n_1 \nu + n_2

    .. math::
        B = n_3 \nu^2 + n_4\nu + n_5

    .. math::
        C = n_6\nu^2 + n_7\nu + n_8

    .. math::
        \nu = T + \frac{n_9}{T - n_{10}}

    Parameters
    ----------
    T : float
        Temperature of water, [K]

    Returns
    -------
    Psat : float
        Vapor pressure at T [Pa]

    Notes
    -----
    This formulation is quite efficient, and can also be solved backward.
    The range of validity of this equation is 273.15 K < T < 647.096 K, the
    IAPWS critical point.

    Extrapolation to lower temperatures is very poor. The function continues to
    decrease until a pressure of 5.7 mPa is reached at 159.77353993926621 K;
    under that pressure the vapor pressure increases, which is obviously wrong.

    Examples
    --------
    >>> Psat_IAPWS(300.)
    3536.58941301301

    References
    ----------
    .. [1] Kretzschmar, Hans-Joachim, and Wolfgang Wagner. International Steam
       Tables: Properties of Water and Steam Based on the Industrial
       Formulation IAPWS-IF97. Springer, 2019.
    '''
    v = T - 0.23855557567849 / (T - 0.65017534844798E3)
    v2 = v * v
    A = v2 + 0.11670521452767E4 * v - 0.72421316703206E6
    B = -0.17073846940092E2 * v2 + 0.12020824702470E5 * v - 0.32325550322333E7
    C = 0.14915108613530E2 * v2 - 0.48232657361591E4 * v + 0.40511340542057E6
    x = ((C + C) / (sqrt(B * B - 4.0 * A * C) - B))
    x2 = x * x
    P = 1E6 * x2 * x2
    return P
Exemplo n.º 3
0
def Wagner_original(T, Tc, Pc, a, b, c, d):
    r'''Calculates vapor pressure using the Wagner equation (3, 6 form).

    Requires critical temperature and pressure as well as four coefficients
    specific to each chemical.

    .. math::
        \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^3 + d\tau^6}
        {T_r}
        
    .. math::
        \tau = 1 - \frac{T}{T_c}

    Parameters
    ----------
    T : float
        Temperature of fluid, [K]
    Tc : float
        Critical temperature, [K]
    Pc : float
        Critical pressure, [Pa]
    a, b, c, d : floats
        Parameters for wagner equation. Specific to each chemical. [-]

    Returns
    -------
    Psat : float
        Vapor pressure at T [Pa]

    Notes
    -----
    Warning: Pc is often treated as adjustable constant.

    Examples
    --------
    Methane, coefficients from [2]_, at 100 K.

    >>> Wagner_original(100.0, 190.53, 4596420., a=-6.00435, b=1.1885, 
    ... c=-0.834082, d=-1.22833)
    34520.44601450499

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.
    .. [2] McGarry, Jack. "Correlation and Prediction of the Vapor Pressures of
       Pure Liquids over Large Pressure Ranges." Industrial & Engineering
       Chemistry Process Design and Development 22, no. 2 (April 1, 1983):
       313-22. doi:10.1021/i200021a023.
    '''
    Tr = T / Tc
    tau = 1.0 - Tr
    tau2 = tau * tau
    tau_Tr = tau / Tr
    return Pc * exp(((d * tau2 * tau + c) * tau2 + a + b * sqrt(tau)) * tau_Tr)
Exemplo n.º 4
0
def dPsat_IAPWS_dT(T):
    r'''Calculates the first temperature dervative of vapor pressure of water 
    using the IAPWS explicit equation. This was derived with SymPy, using the
    CSE method.


    Parameters
    ----------
    T : float
        Temperature of water, [K]

    Returns
    -------
    dPsat_dT : float
        Temperature dervative of vapor pressure at T [Pa/K]

    Notes
    -----
    The derivative of this is useful when solving for water dew point.

    Examples
    --------
    >>> dPsat_IAPWS_dT(300.)
    207.88388134164282

    References
    ----------
    .. [1] Kretzschmar, Hans-Joachim, and Wolfgang Wagner. International Steam
       Tables: Properties of Water and Steam Based on the Industrial
       Formulation IAPWS-IF97. Springer, 2019.
    '''
    # 1 power, four divisions
    x0 = 1.0/(T - 650.175348447980014)
    x1 = T - 0.238555575678490006*x0
    x2 = x1*x1
    x3 = -0.0119059642846224972*T + 0.00284023416392566131*x0 + 0.0000368171193891888733*x2 + 1.0
    x4 = 0.00371867596455583913*T
    x5 = 0.000887110885486382334*x0
    x6 = 5.28184261979789455e-6*x2
    x7 = x4 - x5 - x6 - 1.0
    x8 = 4668.20858110680001*T - 1113.62718545319967*x0 + 4.0*x2 - 2896852.66812823992
    x9 = sqrt(x7*x7 - 9.56991643658934639e-14*x8*(-4823.26573615910002*T + 1150.61693433977007*x0 + 14.9151086135300002*x2 + 405113.405420569994))
    x10 = -x4 + x5 + x6 + x9 + 1.0
    x10_inv = 1.0/x10
    x11 = 0.00153804662447919488*T - 1.0
    x11 = 1.0/(x11*x11)
    x12 = x1*(1.12864813714895499e-6*x11 + 2.0)
    x20 = x10_inv*x10_inv*x10_inv*x10_inv
    return (-3946.77829948379076*x3*x3*x3*(2.68752888216023447e-8*x11 - 0.000147268477556755493*x12 
                + 0.0476238571384899889 + x3*(-8.39415340011308276e-9*x11 + 0.0000211273704791915782*x12
                - 0.0148747038582233565 + 2.0*(x7*(4.19707670005654138e-9*x11 
            - 0.0000105636852395957891*x12 + 0.00743735192911167825) + x8*(2.60482114645230015e-16*x11 
            - 1.42736343074136086e-12*x12 + 4.6158250046507185e-10) + (0.00263438245944447809*x11 
            + 4.0*x12 + 4668.20858110680001)*(4.6158250046507185e-10*T - 1.10113079121562103e-10*x0 
            - 1.42736343074136086e-12*x2 - 3.8769014372169964e-8))/x9)*x10_inv)*x20)
Exemplo n.º 5
0
def Meybodi_Daryasafar_Karimi(rho_water, rho_oil, T, Tc):
    r'''Calculates the interfacial tension between water and a hydrocabon
    liquid according to the correlation of [1]_.

    .. math::
        \gamma_{hw} = \left(\frac{A_1 + A_2 \Delta \rho + A_3\Delta\rho^2
        + A_4\Delta\rho^3} {A_5 + A_6\frac{T^{A_7}}{T_{c,h}} + A_8T^{A_9}}
        \right)^{A_{10}}

    Parameters
    ----------
    rho_water : float
        The density of the aqueous phase, [kg/m^3]
    rho_oil : float
        The density of the hydrocarbon phase, [kg/m^3]
    T : float
        Temperature of the fluid, [K]
    Tc : float
        Critical temperature of the hydrocarbon mixture, [K]

    Returns
    -------
    sigma : float
        Hydrocarbon-water surface tension [N/m]

    Notes
    -----
    Internal units of the equation are g/mL and mN/m.

    Examples
    --------
    >>> Meybodi_Daryasafar_Karimi(980, 760, 580, 914)
    0.02893598143089256

    References
    ----------
    .. [1] Kalantari Meybodi, Mahdi, Amin Daryasafar, and Masoud Karimi.
       "Determination of Hydrocarbon-Water Interfacial Tension Using a New
       Empirical Correlation."  Fluid Phase Equilibria 415 (May 15, 2016):
       42-50. doi:10.1016/j.fluid.2016.01.037.
    '''
    A1 = -1.3687340042E-1
    A2 = -3.0391828884E-1
    A3 = 5.6225871072E-1
    A4 = -3.3074367079E-1
    A5 = -3.0050179309E0
    A6 = 5.8914210205E-5
    A7 = -4.1388901263E0
    A8 = 3.0084299030E0
    A9 = -3.8203072876E-3
    #    A10 = 3.5000000000E0
    drho = abs(rho_water - rho_oil) * 1e-3  # Correlation in units of g/mL
    sigma = ((A1 + drho * (A2 + drho * (A3 + A4 * drho))) /
             (A5 + A6 * T**A7 / Tc + A8 * T**A9))
    return sigma * sigma * sigma * sqrt(sigma) * 1e-3  # mN/m to N/m
Exemplo n.º 6
0
def Miqueu(T, Tc, Vc, omega):
    r'''Calculates air-water surface tension using the methods of [1]_.

    .. math::
        \sigma = k T_c \left( \frac{N_a}{V_c}\right)^{2/3}
        (4.35 + 4.14 \omega)t^{1.26}(1+0.19t^{0.5} - 0.487t)

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Vc : float
        Critical volume of fluid [m^3/mol]
    omega : float
        Acentric factor for fluid, [-]

    Returns
    -------
    sigma : float
        Liquid surface tension, N/m

    Notes
    -----
    Uses Avogadro's constant and the Boltsman constant.
    Internal units of volume are mL/mol and mN/m. However, either a typo
    is in the article or author's work, or my value of k is off by 10; this is
    corrected nonetheless.
    Created with 31 normal fluids, none polar or hydrogen bonded. Has an
    AARD of 3.5%.

    Examples
    --------
    Bromotrifluoromethane, 2.45 mN/m

    >>> Miqueu(300., 340.1, 0.000199, 0.1687)
    0.003474100774091376

    References
    ----------
    .. [1] Miqueu, C, D Broseta, J Satherley, B Mendiboure, J Lachaise, and
       A Graciaa. "An Extended Scaled Equation for the Temperature Dependence
       of the Surface Tension of Pure Compounds Inferred from an Analysis of
       Experimental Data." Fluid Phase Equilibria 172, no. 2 (July 5, 2000):
       169-82. doi:10.1016/S0378-3812(00)00384-8.
    '''
    Vc = Vc * 1E6
    t = 1. - T / Tc
    sigma = k * Tc * (N_A / Vc)**(2.0 / 3.0) * (
        4.35 + 4.14 * omega) * t**1.26 * (1.0 + 0.19 * sqrt(t) -
                                          0.25 * t) * 10000.0
    return sigma
Exemplo n.º 7
0
def solubility_parameter(T, Hvapm, Vml):
    r'''This function handles the calculation of a chemical's solubility
    parameter. Calculation is a function of temperature, but is not always
    presented as such. `Hvapm`, `Vml`, `T` are required.

    .. math::
        \delta = \sqrt{\frac{\Delta H_{vap} - RT}{V_m}}

    Parameters
    ----------
    T : float
        Temperature of the fluid [k]
    Hvapm : float
        Heat of vaporization [J/mol/K]
    Vml : float
        Specific volume of the liquid [m^3/mol]

    Returns
    -------
    delta : float
        Solubility parameter, [Pa^0.5]

    Notes
    -----
    Undefined past the critical point. For convenience, if Hvap is not defined,
    an error is not raised; None is returned instead. Also for convenience,
    if Hvapm is less than RT, None is returned to avoid taking the root of a
    negative number.

    This parameter is often given in units of cal/ml, which is 2045.48 times
    smaller than the value returned here.

    Examples
    --------
    Pentane at STP

    >>> solubility_parameter(T=298.2, Hvapm=26403.3, Vml=0.000116055)
    14357.68128600315

    References
    ----------
    .. [1] Barton, Allan F. M. CRC Handbook of Solubility Parameters and Other
       Cohesion Parameters, Second Edition. CRC Press, 1991.
    '''
    # Prevent taking the root of a negative number
    return None if (Hvapm < R * T or Vml < 0.0) else sqrt(
        (Hvapm - R * T) / Vml)
Exemplo n.º 8
0
def Tsat_IAPWS(P):
    r'''Calculates the saturation temperature of water using the IAPWS explicit
    equation.
    
    .. math::
        T_s = \frac{n_{10} + D - \left[(n_{10}+D)^2 - 4(n_9 + n_{10}D) \right]^{0.5}}{2}

    .. math:
        D = \frac{2G}{-F - (F^2 - 4EG)^{0.5}}
    
    .. math::
        E = \beta^2 + n_3 \beta + n_6
    
    .. math::
        F = n_1 \beta^2 + n_4\beta + n_7
    
    .. math::
        G = n_2\beta^2 + n_5\beta + n_8
    
    .. math::
        \beta = \left(P_{sat} \right)^{0.25}
        

    Parameters
    ----------
    Psat : float
        Vapor pressure at T [Pa]

    Returns
    -------
    T : float
        Temperature of water along the saturation curve at `Psat`, [K]

    Notes
    -----
    The range of validity of this equation is 273.15 K < T < 647.096 K, the 
    IAPWS critical point.
    
    The coefficients `n1` to `n10` are (0.11670521452767E4, -0.72421316703206E6, 
    -0.17073846940092E2, 0.12020824702470E5, -0.32325550322333E7, 0.14915108613530E2,
    -0.48232657361591E4, 0.40511340542057E6, -0.23855557567849, 0.65017534844798E3)

    Examples
    --------
    >>> Tsat_IAPWS(1E5)
    372.75591861133773

    References
    ----------
    .. [1] Kretzschmar, Hans-Joachim, and Wolfgang Wagner. International Steam
       Tables: Properties of Water and Steam Based on the Industrial
       Formulation IAPWS-IF97. Springer, 2019.
    '''
    B = sqrt(sqrt(P * 1E-6))
    E = B * (B + -0.17073846940092E2) + 0.14915108613530E2
    F = B * (0.11670521452767E4 * B + 0.12020824702470E5) + -0.48232657361591E4
    G = B * (-0.72421316703206E6 * B +
             -0.32325550322333E7) + 0.40511340542057E6
    D = 2.0 * G / (-F - sqrt(F * F - 4.0 * E * G))
    n10 = 0.65017534844798E3
    x0 = (n10 + D)
    T = (n10 + D - sqrt(x0 * x0 - 4.0 * (-0.23855557567849 + n10 * D))) * 0.5
    return T
Exemplo n.º 9
0
def permittivity_IAPWS(T, rho):
    r'''Calculate the relative permittivity of pure water as a function of.
    temperature and density. Assumes the 1997 IAPWS [1]_ formulation.

    .. math::
        \epsilon(\rho, T) =\frac{1 + A + 5B + (9 + 2A + 18B + A^2 + 10AB + 
        9B^2)^{0.5}}{4(1-B)}
        
    .. math::
        A(\rho, T) = \frac{N_A\mu^2\rho g}{M\epsilon_0 kT}
        
    .. math::
        B(\rho) = \frac{N_A\alpha\rho}{3M\epsilon_0}
        
    .. math::
        g(\delta,\tau) = 1 + \sum_{i=1}^{11}n_i\delta^{I_i}\tau^{J_i} 
        + n_{12}\delta\left(\frac{647.096}{228}\tau^{-1} - 1\right)^{-1.2}

    .. math::
        \delta = \rho/(322 \text{ kg/m}^3)
        
    .. math::
        \tau = T/647.096\text{K}

    Parameters
    ----------
    T : float
        Temperature of water [K]
    rho : float
        Mass density of water at T and P [kg/m^3]

    Returns
    -------
    epsilon : float
        Relative permittivity of water at T and rho, [-]

    Notes
    -----
    Validity:
    
    273.15 < T < 323.15 K for 0 < P < iceVI melting pressure at T or 1000 MPa,
    whichever is smaller.
    
    323.15 < T < 873.15 K 0 < p < 600 MPa.
    
    Coefficients and constants (they are optimized away in the function itself):
    
    ih = [1, 1, 1, 2, 3, 3, 4, 5, 6, 7, 10]
    
    jh = [0.25, 1, 2.5, 1.5, 1.5, 2.5, 2, 2, 5, 0.5, 10]
    
    Nh = [0.978224486826, -0.957771379375, 0.237511794148, 0.714692244396,
          -0.298217036956, -0.108863472196, 0.949327488264E-1, 
          -.980469816509E-2, 0.165167634970E-4, 0.937359795772E-4, 
          -0.12317921872E-9]
    
    polarizability = 1.636E-40
    
    dipole = 6.138E-30
    
    Examples
    --------
    >>> permittivity_IAPWS(373., 958.46)
    55.565841872697234
    
    >>> permittivity_IAPWS(650., 40.31090)
    1.2659205723606064

    References
    ----------
    .. [1] IAPWS. 1997. Release on the Static Dielectric Constant of Ordinary 
       Water Substance for Temperatures from 238 K to 873 K and Pressures up 
       to 1000 MPa.
    '''
    #    k = 1.38064852e-23
    # actual molecular dipole moment of water, in C*m
    #    dipole2 = 3.7675044000000003e-59 # dipole = 6.138E-30 # but we square it
    #    polarizability = 1.636E-40 # actual mean molecular polarizability of water, C^2/J*m^2
    #    MW = 0.018015268 # molecular weight of water, kg/mol
    #    N_A = 6.0221367e23
    delta = rho * 0.003105590062111801  # 1/322.0
    #    delta = rho/322.
    T_inv = 1.0 / T
    tau = 647.096 * T_inv

    g = 1.0 + 0.196096504426E-2 * delta * (T * 0.0043859649122807015 -
                                           1.0)**-1.2  # 0.00438.. == 1/228.0
    #    g = 1.0  + 0.196096504426E-2*delta*(T/228. - 1.0)**-1.2
    #    ih = [1, 1, 1, 2, 3, 3, 4, 5, 6, 7, 10]
    #    jh = [0.25, 1, 2.5, 1.5, 1.5, 2.5, 2, 2, 5, 0.5, 10]
    #    Nh = [0.978224486826, -0.957771379375, 0.237511794148, 0.714692244396,
    #          -0.298217036956, -0.108863472196, 0.949327488264E-1,
    #          -.980469816509E-2, 0.165167634970E-4, 0.937359795772E-4,
    #          -0.12317921872E-9]
    #
    #    for h in range(11):
    #        g += Nh[h]*delta**ih[h]*tau**jh[h]
    tau_rt = sqrt(tau)
    tau_15 = tau * tau_rt
    tau_25 = tau_15 * tau
    tau_2 = tau * tau
    tau_5 = tau_25 * tau_25

    g += delta * (
        -delta *
        (delta *
         (-delta *
          (delta *
           (delta *
            (delta *
             (-1.2317921872000001181e-10 * delta * delta * delta * tau_5 *
              tau_5 + 0.000093735979577200004786 * tau_rt) +
             0.000016516763497000000026 * tau_5) - 0.0098046981650899995425 *
            tau_2) + 0.094932748826400001341 * tau_2) +
          0.10886347219599999681 * tau_25 + 0.29821703695599999229 * tau_15) -
         0.71469224439599998711 * tau_15) +
        0.97822448682600005032 * sqrt(tau_rt) - 0.9577713793750000093 * tau +
        0.23751179414799999945 * tau_25)

    A = rho * g * T_inv * 10.302249930663786  #N_A*dipole2/(epsilon_0*k*MW)
    B = rho * 0.00020588442304500529  #Na*polarizability/1(3.*epsilon_0*MW) simplifies to the constant
    epsilon = (1. + A + 5. * B + sqrt(9. + A * (2.0 + A) + B *
                                      (18. + 10. * A + 9. * B))) / (4. -
                                                                    4. * B)
    return epsilon
Exemplo n.º 10
0
def RI_IAPWS(T, rho, wavelength=0.5893):
    r'''Calculates the refractive index of water at a given temperature,
    density, and wavelength.

    .. math::
        n(\rho, T, \lambda) = \left(\frac{2A + 1}{1-A}\right)^{0.5}

    .. math::
        A(\delta, \theta, \Lambda) = \delta\left(a_0 + a_1\delta +
        a_2\theta + a_3\Lambda^2\theta + a_4\Lambda^{-2}
        \frac{a_5}{\Lambda^2-\Lambda_{UV}^2} + \frac{a_6}
        {\Lambda^2 - \Lambda_{IR}^2} + a_7\delta^2\right)

    .. math::
        \delta = \rho/(1000 \text{ kg/m}^3)

    .. math::
        \theta = T/273.15\text{K}

    .. math::
        \Lambda = \lambda/0.589 \mu m

    .. math::
        \Lambda_{IR} = 5.432937

    .. math::
        \Lambda_{UV} = 0.229202

    Parameters
    ----------
    T : float
        Temperature of the water [K]
    rho : float
        Density of the water [kg/m^3]
    wavelength : float
        Wavelength of fluid [micrometers]

    Returns
    -------
    RI : float
        Refractive index of the water, [-]

    Notes
    -----
    This function is valid in the following range:
    261.15 K < T < 773.15 K
    0 < rho < 1060 kg/m^3
    0.2 < wavelength < 1.1 micrometers

    Test values are from IAPWS 2010 book.

    Examples
    --------
    >>> RI_IAPWS(298.15, 997.047435, 0.5893)
    1.3328581926471605

    References
    ----------
    .. [1] IAPWS, 1997. Release on the Refractive Index of Ordinary Water
       Substance as a Function of Wavelength, Temperature and Pressure.
    '''
    delta = rho * 1e-3
    theta = T * (1.0 / 273.15)
    Lambda = wavelength * (1.0 / 0.589)

    LambdaIR = 5.432937
    LambdaUV = 0.229202

    Lambda2 = Lambda * Lambda

    A = delta * (0.244257733 + 0.0097463448 * delta + -0.00373235 * theta +
                 0.0002686785 * Lambda2 * theta + 0.0015892057 / Lambda2 +
                 0.0024593426 / (Lambda2 - LambdaUV * LambdaUV) + 0.90070492 /
                 (Lambda2 - LambdaIR * LambdaIR) -
                 0.0166626219 * delta * delta)
    n = sqrt((2.0 * A + 1.) / (1. - A))
    return n
Exemplo n.º 11
0
def EQ116(T, Tc, A, B, C, D, E, order=0):
    r'''DIPPR Equation #116. Used to describe the molar density of water fairly
    precisely; no other uses listed. All 5 parameters are needed, as well as
    the critical temperature.

    .. math::
        Y = A + B\tau^{0.35} + C\tau^{2/3} + D\tau + E\tau^{4/3}

        \tau = 1 - \frac{T}{T_c}

    Parameters
    ----------
    T : float
        Temperature, [K]
    Tc : float
        Critical temperature, [K]
    A-E : float
        Parameter for the equation; chemical and property specific [-]
    order : int, optional
        Order of the calculation. 0 for the calculation of the result itself;
        for 1, the first derivative of the property is returned, for
        -1, the indefinite integral of the property with respect to temperature
        is returned; and for -1j, the indefinite integral of the property
        divided by temperature with respect to temperature is returned. No 
        other integrals or derivatives are implemented, and an exception will 
        be raised if any other order is given.

    Returns
    -------
    Y : float
        Property [constant-specific; if order == 1, property/K; if order == -1,
                  property*K; if order == -1j, unchanged from default]

    Notes
    -----
    The derivative with respect to T and integral with respect to T are 
    computed as follows. The integral divided by T with respect to T has an
    extremely complicated (but still elementary) integral which can be read 
    from the source. It was computed with Rubi; the other expressions can 
    readily be obtained with SymPy.

    .. math::
        \frac{d Y}{dT} = - \frac{7 B}{20 T_c \left(- \frac{T}{T_c} + 1\right)^{
        \frac{13}{20}}} - \frac{2 C}{3 T_c \sqrt[3]{- \frac{T}{T_c} + 1}} 
        - \frac{D}{T_c} - \frac{4 E}{3 T_c} \sqrt[3]{- \frac{T}{T_c} + 1}

    .. math::
        \int Y dT = A T - \frac{20 B}{27} T_c \left(- \frac{T}{T_c} + 1\right)^{
        \frac{27}{20}} - \frac{3 C}{5} T_c \left(- \frac{T}{T_c} + 1\right)^{
        \frac{5}{3}} + D \left(- \frac{T^{2}}{2 T_c} + T\right) - \frac{3 E}{7} 
        T_c \left(- \frac{T}{T_c} + 1\right)^{\frac{7}{3}}
                
    Examples
    --------
    Water liquid molar density; DIPPR coefficients normally in kmol/m^3.

    >>> EQ116(300., 647.096, 17.863, 58.606, -95.396, 213.89, -141.26)
    55.17615446406527

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    if order == 0:
        tau = 1 - T / Tc
        return A + B * tau**0.35 + C * tau**(2 / 3.) + D * tau + E * tau**(4 /
                                                                           3.)
    elif order == 1:
        return (-7 * B / (20 * Tc * (-T / Tc + 1)**(13 / 20)) - 2 * C /
                (3 * Tc * (-T / Tc + 1)**(1 / 3)) - D / Tc - 4 * E *
                (-T / Tc + 1)**(1 / 3) / (3 * Tc))
    elif order == -1:
        return (A * T - 20 * B * Tc * (-T / Tc + 1)**(27 / 20) / 27 -
                3 * C * Tc * (-T / Tc + 1)**(5 / 3) / 5 + D * (-T**2 /
                                                               (2 * Tc) + T) -
                3 * E * Tc * (-T / Tc + 1)**(7 / 3) / 7)
    elif order == -1j:
        # 3x increase in speed - cse via sympy
        x0 = log(T)
        x1 = 0.5 * x0
        x2 = 1 / Tc
        x3 = T * x2
        x4 = -x3 + 1
        x5 = 1.5 * C
        x6 = x4**0.333333333333333
        x7 = 2 * B
        x8 = x4**0.05
        x9 = log(-x6 + 1)
        x10 = sqrt(3)
        x11 = x10 * atan(x10 * (2 * x6 + 1) / 3)
        x12 = sqrt(5)
        x13 = 0.5 * x12
        x14 = x13 + 0.5
        x15 = B * x14
        x16 = sqrt(x13 + 2.5)
        x17 = 2 * x8
        x18 = -x17
        x19 = -x13
        x20 = x19 + 0.5
        x21 = B * x20
        x22 = sqrt(x19 + 2.5)
        x23 = B * x16
        x24 = 0.5 * sqrt(0.1 * x12 + 0.5)
        x25 = x12 + 1
        x26 = 4 * x8
        x27 = -x26
        x28 = sqrt(10) * B / sqrt(x12 + 5)
        x29 = 2 * x12
        x30 = sqrt(x29 + 10)
        x31 = 1 / x30
        x32 = -x12 + 1
        x33 = 0.5 * B * x22
        x34 = -x2 * (T - Tc)
        x35 = 2 * x34**0.1
        x36 = x35 + 2
        x37 = x34**0.05
        x38 = x30 * x37
        x39 = 0.5 * B * x16
        x40 = x37 * sqrt(-x29 + 10)
        x41 = 0.25 * x12
        x42 = B * (-x41 + 0.25)
        x43 = x12 * x37
        x44 = x35 + x37 + 2
        x45 = B * (x41 + 0.25)
        x46 = -x43
        x47 = x35 - x37 + 2
        return A * x0 + 2.85714285714286 * B * x4**0.35 - C * x1 + C * x11 + D * x0 - D * x3 - E * x1 - E * x11 + 0.75 * E * x4**1.33333333333333 + 3 * E * x6 + 1.5 * E * x9 - x15 * atan(
            x14 * (x16 + x17)) + x15 * atan(x14 * (x16 + x18)) - x21 * atan(
                x20 *
                (x17 + x22)) + x21 * atan(x20 * (x18 + x22)) + x23 * atan(
                    x24 *
                    (x25 + x26)) - x23 * atan(x24 * (x25 + x27)) - x28 * atan(
                        x31 * (x26 + x32)) + x28 * atan(
                            x31 * (x27 + x32)
                        ) - x33 * log(x36 - x38) + x33 * log(
                            x36 + x38) + x39 * log(x36 - x40) - x39 * log(
                                x36 + x40
                            ) + x4**0.666666666666667 * x5 - x42 * log(
                                x43 + x44) + x42 * log(x46 + x47) + x45 * log(
                                    x43 + x47) - x45 * log(
                                        x44 + x46) + x5 * x9 + x7 * atan(
                                            x8) - x7 * atanh(x8)
    else:
        raise ValueError(order_not_found_msg)
Exemplo n.º 12
0
def Winterfeld_Scriven_Davis(xs, sigmas, rhoms):
    r'''Calculates surface tension of a liquid mixture according to
    mixing rules in [1]_ and also in [2]_.

    .. math::
        \sigma_M = \sum_i \sum_j \frac{1}{V_L^{L2}}\left(x_i V_i \right)
        \left( x_jV_j\right)\sqrt{\sigma_i\cdot \sigma_j}

    Parameters
    ----------
    xs : array-like
        Mole fractions of all components, [-]
    sigmas : array-like
        Surface tensions of all components, [N/m]
    rhoms : array-like
        Molar densities of all components, [mol/m^3]

    Returns
    -------
    sigma : float
        Air-liquid surface tension of mixture, [N/m]

    Notes
    -----
    DIPPR Procedure 7C: Method for the Surface Tension of Nonaqueous Liquid
    Mixtures

    Becomes less accurate as liquid-liquid critical solution temperature is
    approached. DIPPR Evaluation:  3-4% AARD, from 107 nonaqueous binary
    systems, 1284 points. Internally, densities are converted to kmol/m^3. The
    Amgat function is used to obtain liquid mixture density in this equation.

    Raises a ZeroDivisionError if either molar volume are zero, and a
    ValueError if a surface tensions of a pure component is negative.

    Examples
    --------
    >>> Winterfeld_Scriven_Davis([0.1606, 0.8394], [0.01547, 0.02877],
    ... [8610., 15530.])
    0.02496738845043982

    References
    ----------
    .. [1] Winterfeld, P. H., L. E. Scriven, and H. T. Davis. "An Approximate
       Theory of Interfacial Tensions of Multicomponent Systems: Applications
       to Binary Liquid-Vapor Tensions." AIChE Journal 24, no. 6
       (November 1, 1978): 1010-14. doi:10.1002/aic.690240610.
    .. [2] Danner, Ronald P, and Design Institute for Physical Property Data.
       Manual for Predicting Chemical Process Design Data. New York, N.Y, 1982.
    '''
    N = len(xs)
    Vms = [0.0]*N
    rho = 0.0
    for i in range(N):
        Vms[i] = 1e3/rhoms[i]
        rho += xs[i]*Vms[i]
#    rho = 1./rho
    rho = 1.4142135623730951/rho # factor out rt2
    # For speed, transform the Vms array to contain
#    xs[i]*Vms[i]*sigmas_05[i]*rho
    tot = 0.0
    for i in range(N):
        val = sqrt(sigmas[i])*xs[i]*rho*Vms[i]
        Vms[i] = val
        tot += val*val
    tot *= 0.5
    for i in range(N):
        # Symmetric - can be slightly optimized
        for j in range(i):
            tot += Vms[i]*Vms[j]
    return tot
Exemplo n.º 13
0
def SNM0(T, Tc, Vc, omega, delta_SRK=None):
    r'''Calculates saturated liquid density using the Mchaweh, Moshfeghian
    model [1]_. Designed for simple calculations.

    .. math::
        V_s = V_c/(1+1.169\tau^{1/3}+1.818\tau^{2/3}-2.658\tau+2.161\tau^{4/3}

    .. math::
        \tau = 1-\frac{(T/T_c)}{\alpha_{SRK}}

    .. math::
        \alpha_{SRK} = [1 + m(1-\sqrt{T/T_C}]^2

    .. math::
        m = 0.480+1.574\omega-0.176\omega^2

    If the fit parameter `delta_SRK` is provided, the following is used:

    .. math::
        V_s = V_C/(1+1.169\tau^{1/3}+1.818\tau^{2/3}-2.658\tau+2.161\tau^{4/3})
        /\left[1+\delta_{SRK}(\alpha_{SRK}-1)^{1/3}\right]

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Vc : float
        Critical volume of fluid [m^3/mol]
    omega : float
        Acentric factor for fluid, [-]
    delta_SRK : float, optional
        Fitting parameter [-]

    Returns
    -------
    Vs : float
        Saturation liquid volume, [m^3/mol]

    Notes
    -----
    73 fit parameters have been gathered from the article.

    Examples
    --------
    Argon, without the fit parameter and with it. Tabulated result in Perry's
    is 3.4613e-05. The fit increases the error on this occasion.

    >>> SNM0(121, 150.8, 7.49e-05, -0.004)
    3.440225640273e-05
    >>> SNM0(121, 150.8, 7.49e-05, -0.004, -0.03259620)
    3.493288100008e-05

    References
    ----------
    .. [1] Mchaweh, A., A. Alsaygh, Kh. Nasrifar, and M. Moshfeghian.
       "A Simplified Method for Calculating Saturated Liquid Densities."
       Fluid Phase Equilibria 224, no. 2 (October 1, 2004): 157-67.
       doi:10.1016/j.fluid.2004.06.054
    '''
    Tr = T / Tc
    m = 0.480 + 1.574 * omega - 0.176 * omega * omega
    x0 = (1.0 + m * (1.0 - sqrt(Tr)))
    alpha_SRK = x0 * x0
    tau = 1. - Tr / alpha_SRK

    tau_cbrt = tau**(1 / 3.)
    rho0 = 1. + tau_cbrt * (
        1.169 + 1.818 * tau_cbrt) - 2.658 * tau + 2.161 * tau * tau_cbrt
    V0 = 1. / rho0

    if delta_SRK is None:
        return Vc * V0
    else:
        return Vc * V0 / (1. + delta_SRK * (alpha_SRK - 1.0)**(1.0 / 3.0))