Esempio n. 1
0
def COSTALD_compressed(T, P, Psat, Tc, Pc, omega, Vs):
    r'''Calculates compressed-liquid volume, using the COSTALD [1]_ CSP
    method and a chemical's critical properties.

    The molar volume of a liquid is given by:

    .. math::
        V = V_s\left( 1 - C \ln \frac{B + P}{B + P^{sat}}\right)

    .. math::
        \frac{B}{P_c} = -1 + a\tau^{1/3} + b\tau^{2/3} + d\tau + e\tau^{4/3}

    .. math::
        e = \exp(f + g\omega_{SRK} + h \omega_{SRK}^2)

    .. math::
        C = j + k \omega_{SRK}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    P : float
        Pressure of fluid [Pa]
    Psat : float
        Saturation pressure of the fluid [Pa]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    omega : float
        (ideally SRK) Acentric factor for fluid, [-]
        This parameter is alternatively a fit parameter.
    Vs : float
        Saturation liquid volume, [m^3/mol]

    Returns
    -------
    V_dense : float
        High-pressure liquid volume, [m^3/mol]

    Notes
    -----
    Original equation was in terms of density, but it is converted here.

    The example is from DIPPR, and exactly correct.
    This is DIPPR Procedure 4C: Method for Estimating the Density of Pure
    Organic Liquids under Pressure.

    Examples
    --------
    >>> COSTALD_compressed(303., 9.8E7, 85857.9, 466.7, 3640000.0, 0.281, 0.000105047)
    9.287482879788505e-05

    References
    ----------
    .. [1]  Thomson, G. H., K. R. Brobst, and R. W. Hankinson. "An Improved
       Correlation for Densities of Compressed Liquids and Liquid Mixtures."
       AIChE Journal 28, no. 4 (July 1, 1982): 671-76. doi:10.1002/aic.690280420
    '''
    a = -9.070217
    b = 62.45326
    d = -135.1102
    f = 4.79594
    g = 0.250047
    h = 1.14188
    j = 0.0861488
    k = 0.0344483
    e = exp(f + omega*(g + h*omega))
    C = j + k*omega
    tau = 1.0 - T/Tc
    tau13 = tau**(1.0/3.0)
    B = Pc*(-1.0 + a*tau13 + b*tau13*tau13 + d*tau + e*tau*tau13)
    return Vs*(1.0 - C*log((B + P)/(B + Psat)))
Esempio n. 2
0
def Zuo_Stenby(T, Tc, Pc, omega):
    r'''Calculates air-water surface tension using the reference fluids
    methods of [1]_.

    .. math::
        \sigma^{(1)} = 40.520(1-T_r)^{1.287}

    .. math::
        \sigma^{(2)} = 52.095(1-T_r)^{1.21548}

    .. math::
        \sigma_r = \sigma_r^{(1)}+ \frac{\omega - \omega^{(1)}}
        {\omega^{(2)}-\omega^{(1)}} (\sigma_r^{(2)}-\sigma_r^{(1)})

    .. math::
        \sigma = T_c^{1/3}P_c^{2/3}[\exp{(\sigma_r)} -1]

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    omega : float
        Acentric factor for fluid, [-]

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

    Notes
    -----
    Presently untested. Have not personally checked the sources.
    I strongly believe it is broken.
    The reference values for methane and n-octane are from the DIPPR database.

    Examples
    --------
    Chlorobenzene

    >>> Zuo_Stenby(293., 633.0, 4530000.0, 0.249)
    0.03345569011871088

    References
    ----------
    .. [1] Zuo, You-Xiang, and Erling H. Stenby. "Corresponding-States and
       Parachor Models for the Calculation of Interfacial Tensions." The
       Canadian Journal of Chemical Engineering 75, no. 6 (December 1, 1997):
       1130-37. doi:10.1002/cjce.5450750617
    '''
    Tc_1, Pc_1, omega_1 = 190.56, 4599000.0 * 1e-5, 0.012
    Tc_2, Pc_2, omega_2 = 568.7, 2490000.0 * 1e-5, 0.4
    Pc = Pc * 1e-5
    Tr = T / Tc

    ST_1 = 40.520 * (1.0 - Tr)**1.287  # Methane
    ST_2 = 52.095 * (1.0 - Tr)**1.21548  # n-octane

    ST_r_1 = log(1.0 + 0.013537770442486932 *
                 ST_1)  # Constant from 1/(Tc_1**(1.0/3.0)*Pc_1**(2.0/3.0))
    #    ST_r_1 = log(1.0 + ST_1/(Tc_1**(1.0/3.0)*Pc_1**(2.0/3.0)))
    ST_r_2 = log(1.0 + 0.014154874587259097 *
                 ST_2)  # Constant from /(Tc_2**(1.0/3.0)*Pc_2**(2.0/3.0))
    sigma_r = ST_r_1 + (omega - omega_1) * (ST_r_2 -
                                            ST_r_1) * 2.5773195876288657
    #    sigma_r = ST_r_1 + (omega-omega_1)/(omega_2 - omega_1)*(ST_r_2-ST_r_1)
    sigma = Tc**(1.0 / 3.0) * Pc**(2.0 / 3.0) * (exp(sigma_r) - 1.0)
    sigma = sigma * 1e-3  # N/m, please
    return sigma
Esempio n. 3
0
def Campbell_Thodos(T, Tb, Tc, Pc, MW, dipole=0.0, has_hydroxyl=False):
    r'''Calculate saturation liquid density using the Campbell-Thodos [1]_
    CSP method.

    An old and uncommon estimation method.

    .. math::
        V_s = \frac{RT_c}{P_c}{Z_{RA}}^{[1+(1-T_r)^{2/7}]}

    .. math::
        Z_{RA} = \alpha + \beta(1-T_r)

    .. math::
        \alpha = 0.3883-0.0179s

    .. math::
        s = T_{br} \frac{\ln P_c}{(1-T_{br})}

    .. math::
        \beta = 0.00318s-0.0211+0.625\Lambda^{1.35}

    .. math::
        \Lambda = \frac{P_c^{1/3}} { MW^{1/2} T_c^{5/6}}

    For polar compounds:

    .. math::
        \theta = P_c \mu^2/T_c^2

    .. math::
        \alpha = 0.3883 - 0.0179s - 130540\theta^{2.41}

    .. math::
        \beta = 0.00318s - 0.0211 + 0.625\Lambda^{1.35} + 9.74\times
        10^6 \theta^{3.38}

    Polar Combounds with hydroxyl groups (water, alcohols)

    .. math::
        \alpha = \left[0.690T_{br} -0.3342 + \frac{5.79\times 10^{-10}}
        {T_{br}^{32.75}}\right] P_c^{0.145}

    .. math::
        \beta = 0.00318s - 0.0211 + 0.625 \Lambda^{1.35} + 5.90\Theta^{0.835}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tb : float
        Boiling temperature of the fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    MW : float
        Molecular weight of the fluid [g/mol]
    dipole : float, optional
        Dipole moment of the fluid [debye]
    has_hydroxyl : bool, optional
        Swith to use the hydroxyl variant for polar fluids

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

    Notes
    -----
    If a dipole is provided, the polar chemical method is used.
    The paper is an excellent read.
    Pc is internally converted to atm.

    Examples
    --------
    Ammonia, from [1]_.

    >>> Campbell_Thodos(T=405.45, Tb=239.82, Tc=405.45, Pc=111.7*101325, MW=17.03, dipole=1.47)
    7.347366126245e-05

    References
    ----------
    .. [1] Campbell, Scott W., and George Thodos. "Prediction of Saturated
       Liquid Densities and Critical Volumes for Polar and Nonpolar
       Substances." Journal of Chemical & Engineering Data 30, no. 1
       (January 1, 1985): 102-11. doi:10.1021/je00039a032.
    '''
    Tc_inv = 1.0/Tc
    Tr = T * Tc_inv
    Tbr = Tb * Tc_inv
    Pc = Pc/101325.
    s = Tbr*log(Pc)/(1.0 - Tbr)
    Lambda = Pc**(1.0/3.)/(MW**0.5*Tc**(5/6.))
    beta = 0.00318*s - 0.0211 + 0.625*Lambda**(1.35)
    if dipole is None:
        alpha = 0.3883 - 0.0179*s
    else:
        theta = Pc*dipole*dipole/(Tc*Tc)
        beta += 9.74E6 * theta**3.38
        if has_hydroxyl:
            beta += 5.90*theta**0.835
            alpha = (0.69*Tbr - 0.3342 + 5.79E-10*Tbr**-32.75)*Pc**0.145
        else:
            alpha = 0.3883 - 0.0179*s - 130540 * theta**2.41
    Zra = alpha + beta*(1.0 - Tr)
    p = 1.0 if T == Tc else (1.0 + (1.0 - Tr)**(2.0/7.))
    Vs = R*Tc/(Pc*101325.0)*Zra**p
    return Vs
Esempio n. 4
0
 def interpolation_property(P):
     '''log(P) interpolation transformation by default.
     '''
     return log(P)
Esempio n. 5
0
    def calculate(self, T, method):
        r'''Method to calculate vapor pressure of a fluid at temperature `T`
        with a given method.

        This method has no exception handling; see :obj:`thermo.utils.TDependentProperty.T_dependent_property`
        for that.

        Parameters
        ----------
        T : float
            Temperature at calculate vapor pressure, [K]
        method : str
            Name of the method to use

        Returns
        -------
        Psat : float
            Vapor pressure at T, [Pa]
        '''
        if method == POLY_FIT:
            if T < self.poly_fit_Tmin:
                Psat = (T - self.poly_fit_Tmin
                        ) * self.poly_fit_Tmin_slope + self.poly_fit_Tmin_value
            elif T > self.poly_fit_Tmax:
                Psat = (T - self.poly_fit_Tmax
                        ) * self.poly_fit_Tmax_slope + self.poly_fit_Tmax_value
            else:
                Psat = horner(self.poly_fit_coeffs, T)
            Psat = exp(Psat)
        elif method == BEST_FIT_AB:
            if T < self.poly_fit_Tmax:
                return self.calculate(T, POLY_FIT)
            A, B = self.poly_fit_AB_high_ABC_compat
            return exp(A + B / T)
        elif method == BEST_FIT_ABC:
            if T < self.poly_fit_Tmax:
                return self.calculate(T, POLY_FIT)
            A, B, C = self.DIPPR101_ABC_high
            return exp(A + B / T + C * log(T))
        elif method == WAGNER_MCGARRY:
            Psat = Wagner_original(T, self.WAGNER_MCGARRY_Tc,
                                   self.WAGNER_MCGARRY_Pc,
                                   *self.WAGNER_MCGARRY_coefs)
        elif method == WAGNER_POLING:
            Psat = Wagner(T, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc,
                          *self.WAGNER_POLING_coefs)
        elif method == ANTOINE_EXTENDED_POLING:
            Psat = TRC_Antoine_extended(T, *self.ANTOINE_EXTENDED_POLING_coefs)
        elif method == ANTOINE_POLING:
            A, B, C = self.ANTOINE_POLING_coefs
            Psat = Antoine(T, A, B, C, base=10.0)
        elif method == DIPPR_PERRY_8E:
            Psat = EQ101(T, *self.Perrys2_8_coeffs)
        elif method == VDI_PPDS:
            Psat = Wagner(T, self.VDI_PPDS_Tc, self.VDI_PPDS_Pc,
                          *self.VDI_PPDS_coeffs)
        elif method == COOLPROP:
            Psat = PropsSI('P', 'T', T, 'Q', 0, self.CASRN)
        elif method == BOILING_CRITICAL:
            Psat = boiling_critical_relation(T, self.Tb, self.Tc, self.Pc)
        elif method == LEE_KESLER_PSAT:
            Psat = Lee_Kesler(T, self.Tc, self.Pc, self.omega)
        elif method == AMBROSE_WALTON:
            Psat = Ambrose_Walton(T, self.Tc, self.Pc, self.omega)
        elif method == SANJARI:
            Psat = Sanjari(T, self.Tc, self.Pc, self.omega)
        elif method == EDALAT:
            Psat = Edalat(T, self.Tc, self.Pc, self.omega)
        elif method == EOS:
            Psat = self.eos[0].Psat(T)
        elif method == POLY_FIT:
            Psat = exp(horner(self.poly_fit_coeffs, T))
        else:
            return self._base_calculate(T, method)
        return Psat
Esempio n. 6
0
def EQ100(T, A=0, B=0, C=0, D=0, E=0, F=0, G=0, order=0):
    r'''DIPPR Equation # 100. Used in calculating the molar heat capacities
    of liquids and solids, liquid thermal conductivity, and solid density.
    All parameters default to zero. As this is a straightforward polynomial,
    no restrictions on parameters apply. Note that high-order polynomials like
    this may need large numbers of decimal places to avoid unnecessary error.

    .. math::
        Y = A + BT + CT^2 + DT^3 + ET^4 + FT^5 + GT^6

    Parameters
    ----------
    T : float
        Temperature, [K]
    A-G : 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, integral with respect to T, and integral
    over T with respect to T are computed as follows. All derivatives and
    integrals are easily computed with SymPy.

    .. math::
        \frac{d Y}{dT} = B + 2 C T + 3 D T^{2} + 4 E T^{3} + 5 F T^{4}
        + 6 G T^{5}

    .. math::
        \int Y dT = A T + \frac{B T^{2}}{2} + \frac{C T^{3}}{3} + \frac{D
        T^{4}}{4} + \frac{E T^{5}}{5} + \frac{F T^{6}}{6} + \frac{G T^{7}}{7}

    .. math::
        \int \frac{Y}{T} dT = A \log{\left (T \right )} + B T + \frac{C T^{2}}
        {2} + \frac{D T^{3}}{3} + \frac{E T^{4}}{4} + \frac{F T^{5}}{5}
        + \frac{G T^{6}}{6}

    Examples
    --------
    Water liquid heat capacity; DIPPR coefficients normally listed in J/kmol/K.

    >>> EQ100(300, 276370., -2090.1, 8.125, -0.014116, 0.0000093701)
    75355.81000000003

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    if order == 0:
        return A + T * (B + T * (C + T * (D + T * (E + T * (F + G * T)))))
    elif order == 1:
        return B + T * (2 * C + T * (3 * D + T * (4 * E + T *
                                                  (5 * F + 6 * G * T))))
    elif order == -1:
        return T * (A + T * (B / 2 + T * (C / 3 + T *
                                          (D / 4 + T *
                                           (E / 5 + T *
                                            (F / 6 + G * T / 7))))))
    elif order == -1j:
        return A * log(T) + T * (B + T * (C / 2 + T * (D / 3 + T *
                                                       (E / 4 + T *
                                                        (F / 5 + G * T / 6)))))
    else:
        raise ValueError(order_not_found_msg)
Esempio n. 7
0
def Antoine_coeffs_from_point(T, Psat, dPsat_dT, d2Psat_dT2, base=10.0):
    r'''Calculates the antoine coefficients `A`, `B`, and `C` from a known
    vapor pressure and its first and second temperature derivative.

    Parameters
    ----------
    T : float
        Temperature of fluid, [K]
    Psat : float
        Vapor pressure at specified `T` [Pa]
    dPsat_dT : float
        First temperature derivative of vapor pressure at specified `T` [Pa/K]
    d2Psat_dT2 : float
        Second temperature derivative of vapor pressure at specified `T` [Pa/K^2]
    Base : float, optional
        Base of logarithm; 10 by default

    Returns
    -------
    A : float
        Antoine `A` parameter, [-]
    B : float
        Antoine `B` parameter, [K]
    C : float
        Antoine `C` parameter, [K]

    Notes
    -----
    Coefficients are for calculating vapor pressure in Pascal. This is
    primarily useful for interconverting vapor pressure models, not fitting
    experimental data.

    Derived with SymPy as follows:

    >>> from sympy import * # doctest: +SKIP
    >>> base, A, B, C, T = symbols('base, A, B, C, T') # doctest: +SKIP
    >>> v = base**(A - B/(T + C)) # doctest: +SKIP
    >>> d1, d2 = diff(v, T), diff(v, T, 2) # doctest: +SKIP
    >>> vk, d1k, d2k = symbols('vk, d1k, d2k') # doctest: +SKIP
    >>> solve([Eq(v, vk), Eq(d1, d1k), Eq(d2, d2k)], [A, B, C]) # doctest: +SKIP

    Examples
    --------
    Recalculate some coefficients from a calcualted value and its derivative:


    >>> T = 178.01
    >>> A, B, C = (24.0989474955895, 4346.793091137991, -18.96968471040141)
    >>> Psat = Antoine(T, A, B, C, base=exp(1))
    >>> dPsat_dT, d2Psat_dT2 = (0.006781441203850251, 0.0010801244983894853) # precomputed
    >>> Antoine_coeffs_from_point(T, Psat, dPsat_dT, d2Psat_dT2, base=exp(1))
    (24.098947495155, 4346.793090994, -18.969684713118)

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.
    '''
    x0 = 1.0 / log(base)
    x1 = Psat * d2Psat_dT2
    dPsat_dT_2 = dPsat_dT * dPsat_dT
    x3 = 1.0 / (x1 - dPsat_dT_2)
    x4 = dPsat_dT_2 + dPsat_dT_2
    A = x0 * log(Psat * exp(-x3 * x4))
    B = 4.0 * Psat * dPsat_dT * dPsat_dT_2 * x0 / (
        Psat * Psat * d2Psat_dT2 * d2Psat_dT2 + dPsat_dT_2 * dPsat_dT_2 -
        x1 * x4)
    C = -x3 * (2.0 * Psat * dPsat_dT + T * x1 - T * dPsat_dT_2)
    return (A, B, C)
Esempio n. 8
0
def EQ101(T, A, B, C=0.0, D=0.0, E=0.0, order=0):
    r'''DIPPR Equation # 101. Used in calculating vapor pressure, sublimation
    pressure, and liquid viscosity.
    All 5 parameters are required. E is often an integer. As the model is
    exponential, a sufficiently high temperature will cause an OverflowError.
    A negative temperature (or just low, if fit poorly) may cause a math domain
    error.

    .. math::
        Y = \exp\left(A + \frac{B}{T} + C\cdot \ln T + D \cdot T^E\right)

    Parameters
    ----------
    T : float
        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 `n`, the `nth` derivative of the property 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]

    Notes
    -----
    This function is not integrable for either dT or Y/T dT.

    .. math::
        \frac{d Y}{dT} = \left(- \frac{B}{T^{2}} + \frac{C}{T}
        + \frac{D E T^{E}}{T}\right) e^{A + \frac{B}{T}
        + C \log{\left(T \right)} + D T^{E}}

    .. math::
        \frac{d^2 Y}{dT^2} = \frac{\left(\frac{2 B}{T} - C + D E^{2} T^{E}
        - D E T^{E} + \left(- \frac{B}{T} + C + D E T^{E}\right)^{2}\right)
        e^{A + \frac{B}{T} + C \log{\left(T \right)} + D T^{E}}}{T^{2}}

    .. math::
        \frac{d^3 Y}{dT^3} = \frac{\left(- \frac{6 B}{T} + 2 C + D E^{3} T^{E}
        - 3 D E^{2} T^{E} + 2 D E T^{E} + \left(- \frac{B}{T} + C
        + D E T^{E}\right)^{3} + 3 \left(- \frac{B}{T} + C + D E T^{E}\right)
        \left(\frac{2 B}{T} - C + D E^{2} T^{E} - D E T^{E}\right)\right)
        e^{A + \frac{B}{T} + C \log{\left(T \right)} + D T^{E}}}{T^{3}}

    Examples
    --------
    Water vapor pressure; DIPPR coefficients normally listed in Pa.

    >>> EQ101(300, 73.649, -7258.2, -7.3037, 4.1653E-6, 2)
    3537.44834545549

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    T_inv = 1.0 / T
    T_E = T**E
    expr = trunc_exp(A + B * T_inv + C * log(T) + D * T_E)
    if order == 0:
        return expr
    elif order == 1:
        return T_inv * expr * (-B * T_inv + C + D * E * T_E)
    elif order == 2:
        x0 = (-B * T_inv + C + D * E * T_E)
        return expr * (2.0 * B * T_inv - C + D * E * T_E *
                       (E - 1.0) + x0 * x0) * T_inv * T_inv
    elif order == 3:
        E2 = E * E
        E3 = E2 * E
        x0 = (-B * T_inv + C + D * E * T_E)
        return expr * (-6.0 * B * T_inv + 2.0 * C + D * E3 * T_E - 3 * D * E2 *
                       T_E + 2.0 * D * E * T_E + x0 * x0 * x0 + 3.0 *
                       (-B * T_inv + C + D * E * T_E) *
                       (2.0 * B * T_inv - C + D * E2 * T_E - D * E * T_E)
                       ) * T_inv * T_inv * T_inv
    else:
        raise ValueError(order_not_found_pos_only_msg)
Esempio n. 9
0
def EQ105(T, A, B, C, D, order=0):
    r'''DIPPR Equation #105. Often used in calculating liquid molar density.
    All 4 parameters are required. C is sometimes the fluid's critical
    temperature.

    .. math::
        Y = \frac{A}{B^{1 + \left(1-\frac{T}{C}\right)^D}}

    Parameters
    ----------
    T : float
        Temperature, [K]
    A-D : 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, 2, and 3, that derivative of the property 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]

    Notes
    -----
    This expression can be integrated in terms of the incomplete gamma function
    for dT, however nans are the only output from that function.
    For Y/T dT no integral could be found.

    .. math::
        \frac{d Y}{dT} = \frac{A B^{- \left(1 - \frac{T}{C}\right)^{D} - 1} D
        \left(1 - \frac{T}{C}\right)^{D} \log{\left(B \right)}}{C \left(1
        - \frac{T}{C}\right)}

    .. math::
        \frac{d^2 Y}{dT^2} = \frac{A B^{- \left(1 - \frac{T}{C}\right)^{D} - 1}
        D \left(1 - \frac{T}{C}\right)^{D} \left(D \left(1 - \frac{T}{C}
        \right)^{D} \log{\left(B \right)} - D + 1\right) \log{\left(B \right)}}
        {C^{2} \left(1 - \frac{T}{C}\right)^{2}}

    .. math::
        \frac{d^3 Y}{dT^3} = \frac{A B^{- \left(1 - \frac{T}{C}\right)^{D} - 1}
        D \left(1 - \frac{T}{C}\right)^{D} \left(D^{2} \left(1 - \frac{T}{C}
        \right)^{2 D} \log{\left(B \right)}^{2} - 3 D^{2} \left(1 - \frac{T}{C}
        \right)^{D} \log{\left(B \right)} + D^{2} + 3 D \left(1 - \frac{T}{C}
        \right)^{D} \log{\left(B \right)} - 3 D + 2\right) \log{\left(B
        \right)}}{C^{3} \left(1 - \frac{T}{C}\right)^{3}}

    Examples
    --------
    Hexane molar density; DIPPR coefficients normally in kmol/m^3.

    >>> EQ105(300., 0.70824, 0.26411, 507.6, 0.27537)
    7.593170096339237

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    if order == 0:
        return A * B**(-(1. + (1. - T / C)**D))
    elif order == 1:
        x0 = 1.0 / C
        x1 = 1.0 - T * x0
        x2 = x1**D
        return A * B**(-x2 - 1.0) * D * x0 * x2 * log(B) / x1
    elif order == 2:
        x0 = 1.0 - T / C
        x1 = x0**D
        x2 = D * x1 * log(B)
        den = 1.0 / (C * x0)
        return A * B**(-x1 - 1.0) * x2 * (1.0 - D + x2) * den * den
    elif order == 3:
        x0 = 1.0 - T / C
        x1 = x0**D
        x2 = 3.0 * D
        x3 = D * D
        x4 = log(B)
        x5 = x1 * x4
        den = 1.0 / (C * x0)
        return A * B**(-x1 - 1.0) * D * x5 * (x0**(2.0 * D) * x3 * x4 * x4 +
                                              x2 * x5 - x2 - 3.0 * x3 * x5 +
                                              x3 + 2.0) * den * den * den
    else:
        raise ValueError(order_not_found_msg)
Esempio n. 10
0
    def calculate(self, T, method):
        r'''Method to calculate heat of vaporization of a liquid at
        temperature `T` with a given method.

        This method has no exception handling; see :obj:`T_dependent_property <thermo.utils.TDependentProperty.T_dependent_property>`
        for that.

        Parameters
        ----------
        T : float
            Temperature at which to calculate heat of vaporization, [K]
        method : str
            Name of the method to use

        Returns
        -------
        Hvap : float
            Heat of vaporization of the liquid at T, [J/mol]
        '''
        if method == BESTFIT:
            if T > self.poly_fit_Tc:
                Hvap = 0
            else:
                Hvap = horner(self.poly_fit_coeffs,
                              log(1.0 - T / self.poly_fit_Tc))

        elif method == COOLPROP:
            Hvap = PropsSI('HMOLAR', 'T', T, 'Q', 1, self.CASRN) - PropsSI(
                'HMOLAR', 'T', T, 'Q', 0, self.CASRN)
        elif method == DIPPR_PERRY_8E:
            Hvap = EQ106(T, *self.Perrys2_150_coeffs)
        # CSP methods
        elif method == VDI_PPDS:
            Hvap = PPDS12(T, self.VDI_PPDS_Tc, *self.VDI_PPDS_coeffs)
        elif method == ALIBAKHSHI:
            Hvap = Alibakhshi(T=T, Tc=self.Tc, C=self.Alibakhshi_C)
        elif method == MORGAN_KOBAYASHI:
            Hvap = MK(T, self.Tc, self.omega)
        elif method == SIVARAMAN_MAGEE_KOBAYASHI:
            Hvap = SMK(T, self.Tc, self.omega)
        elif method == VELASCO:
            Hvap = Velasco(T, self.Tc, self.omega)
        elif method == PITZER:
            Hvap = Pitzer(T, self.Tc, self.omega)
        elif method == CLAPEYRON:
            Zg = self.Zg(T) if hasattr(self.Zg, '__call__') else self.Zg
            Zl = self.Zl(T) if hasattr(self.Zl, '__call__') else self.Zl
            Psat = self.Psat(T) if hasattr(self.Psat,
                                           '__call__') else self.Psat
            if Zg:
                if Zl:
                    dZ = Zg - Zl
                else:
                    dZ = Zg
            Hvap = Clapeyron(T, self.Tc, self.Pc, dZ=dZ, Psat=Psat)
        # CSP methods at Tb only
        elif method == RIEDEL:
            Hvap = Riedel(self.Tb, self.Tc, self.Pc)
        elif method == CHEN:
            Hvap = Chen(self.Tb, self.Tc, self.Pc)
        elif method == VETERE:
            Hvap = Vetere(self.Tb, self.Tc, self.Pc)
        elif method == LIU:
            Hvap = Liu(self.Tb, self.Tc, self.Pc)
        # Individual data point methods
        elif method == CRC_HVAP_TB:
            Hvap = self.CRC_HVAP_TB_Hvap
        elif method == CRC_HVAP_298:
            Hvap = self.CRC_HVAP_298
        elif method == GHARAGHEIZI_HVAP_298:
            Hvap = self.GHARAGHEIZI_HVAP_298_Hvap
        elif method in self.tabular_data:
            Hvap = self.interpolate(T, method)
        # Adjust with the watson equation if estimated at Tb or Tc only
        if method in self.boiling_methods or (self.Tc and method in [
                CRC_HVAP_TB, CRC_HVAP_298, GHARAGHEIZI_HVAP_298
        ]):
            if method in self.boiling_methods:
                Tref = self.Tb
            elif method == CRC_HVAP_TB:
                Tref = self.CRC_HVAP_TB_Tb
            elif method in [CRC_HVAP_298, GHARAGHEIZI_HVAP_298]:
                Tref = 298.15
            Hvap = Watson(T, Hvap, Tref, self.Tc, self.Watson_exponent)
        return Hvap
Esempio n. 11
0
def EQ127(T, A, B, C, D, E, F, G, order=0):
    r'''DIPPR Equation #127. Rarely used, and then only in calculating
    ideal-gas heat capacity. All 7 parameters are required.

    .. math::
        Y = A+B\left[\frac{\left(\frac{C}{T}\right)^2\exp\left(\frac{C}{T}
        \right)}{\left(\exp\frac{C}{T}-1 \right)^2}\right]
        +D\left[\frac{\left(\frac{E}{T}\right)^2\exp\left(\frac{E}{T}\right)}
        {\left(\exp\frac{E}{T}-1 \right)^2}\right]
        +F\left[\frac{\left(\frac{G}{T}\right)^2\exp\left(\frac{G}{T}\right)}
        {\left(\exp\frac{G}{T}-1 \right)^2}\right]

    Parameters
    ----------
    T : float
        Temperature, [K]
    A-G : 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, integral with respect to T, and integral
    over T with respect to T are computed as follows. All expressions can be
    obtained with SymPy readily.

    .. math::
        \frac{d Y}{dT} = - \frac{B C^{3} e^{\frac{C}{T}}}{T^{4}
        \left(e^{\frac{C}{T}} - 1\right)^{2}} + \frac{2 B C^{3}
        e^{\frac{2 C}{T}}}{T^{4} \left(e^{\frac{C}{T}} - 1\right)^{3}}
        - \frac{2 B C^{2} e^{\frac{C}{T}}}{T^{3} \left(e^{\frac{C}{T}}
        - 1\right)^{2}} - \frac{D E^{3} e^{\frac{E}{T}}}{T^{4}
        \left(e^{\frac{E}{T}} - 1\right)^{2}} + \frac{2 D E^{3}
        e^{\frac{2 E}{T}}}{T^{4} \left(e^{\frac{E}{T}} - 1\right)^{3}}
        - \frac{2 D E^{2} e^{\frac{E}{T}}}{T^{3} \left(e^{\frac{E}{T}}
        - 1\right)^{2}} - \frac{F G^{3} e^{\frac{G}{T}}}{T^{4}
        \left(e^{\frac{G}{T}} - 1\right)^{2}} + \frac{2 F G^{3}
        e^{\frac{2 G}{T}}}{T^{4} \left(e^{\frac{G}{T}} - 1\right)^{3}}
        - \frac{2 F G^{2} e^{\frac{G}{T}}}{T^{3} \left(e^{\frac{G}{T}}
        - 1\right)^{2}}

    .. math::
        \int Y dT = A T + \frac{B C^{2}}{C e^{\frac{C}{T}} - C}
        + \frac{D E^{2}}{E e^{\frac{E}{T}} - E}
        + \frac{F G^{2}}{G e^{\frac{G}{T}} - G}

    .. math::
        \int \frac{Y}{T} dT = A \ln{\left (T \right )} + B C^{2} \left(
        \frac{1}{C T e^{\frac{C}{T}} - C T} + \frac{1}{C T} - \frac{1}{C^{2}}
        \ln{\left (e^{\frac{C}{T}} - 1 \right )}\right) + D E^{2} \left(
        \frac{1}{E T e^{\frac{E}{T}} - E T} + \frac{1}{E T} - \frac{1}{E^{2}}
        \ln{\left (e^{\frac{E}{T}} - 1 \right )}\right) + F G^{2} \left(
        \frac{1}{G T e^{\frac{G}{T}} - G T} + \frac{1}{G T} - \frac{1}{G^{2}}
        \ln{\left (e^{\frac{G}{T}} - 1 \right )}\right)

    Examples
    --------
    Ideal gas heat capacity of methanol; DIPPR coefficients normally in
    J/kmol/K

    >>> EQ127(20., 3.3258E4, 3.6199E4, 1.2057E3, 1.5373E7, 3.2122E3, -1.5318E7, 3.2122E3)
    33258.0

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    if order == 0:
        return (A + B * ((C / T)**2 * exp(C / T) / (exp(C / T) - 1)**2) + D *
                ((E / T)**2 * exp(E / T) / (exp(E / T) - 1)**2) + F *
                ((G / T)**2 * exp(G / T) / (exp(G / T) - 1)**2))
    elif order == 1:
        return (-B * C**3 * exp(C / T) / (T**4 * (exp(C / T) - 1)**2) +
                2 * B * C**3 * exp(2 * C / T) / (T**4 * (exp(C / T) - 1)**3) -
                2 * B * C**2 * exp(C / T) / (T**3 * (exp(C / T) - 1)**2) -
                D * E**3 * exp(E / T) / (T**4 * (exp(E / T) - 1)**2) +
                2 * D * E**3 * exp(2 * E / T) / (T**4 * (exp(E / T) - 1)**3) -
                2 * D * E**2 * exp(E / T) / (T**3 * (exp(E / T) - 1)**2) -
                F * G**3 * exp(G / T) / (T**4 * (exp(G / T) - 1)**2) +
                2 * F * G**3 * exp(2 * G / T) / (T**4 * (exp(G / T) - 1)**3) -
                2 * F * G**2 * exp(G / T) / (T**3 * (exp(G / T) - 1)**2))
    elif order == -1:
        return (A * T + B * C**2 / (C * exp(C / T) - C) + D * E**2 /
                (E * exp(E / T) - E) + F * G**2 / (G * exp(G / T) - G))
    elif order == -1j:
        return (A * log(T) + B * C**2 *
                (1 / (C * T * exp(C / T) - C * T) + 1 /
                 (C * T) - log(exp(C / T) - 1) / C**2) + D * E**2 *
                (1 / (E * T * exp(E / T) - E * T) + 1 /
                 (E * T) - log(exp(E / T) - 1) / E**2) + F * G**2 *
                (1 / (G * T * exp(G / T) - G * T) + 1 /
                 (G * T) - log(exp(G / T) - 1) / G**2))
    else:
        raise ValueError(order_not_found_msg)
Esempio n. 12
0
def BVirial_Tsonopoulos_extended(T, Tc, Pc, omega, a=0, b=0, species_type='',
                                 dipole=0, order=0):
    r'''Calculates the second virial coefficient using the
    comprehensive model in [1]_. See the notes for the calculation of `a` and
    `b`.

    .. math::
        \frac{BP_c}{RT_c} = B^{(0)} + \omega B^{(1)} + a B^{(2)} + b B^{(3)}

    .. math::
        B^{(0)}=0.1445-0.33/T_r-0.1385/T_r^2-0.0121/T_r^3

    .. math::
        B^{(1)} = 0.0637+0.331/T_r^2-0.423/T_r^3 -0.423/T_r^3 - 0.008/T_r^8

    .. math::
        B^{(2)} = 1/T_r^6

    .. math::
        B^{(3)} = -1/T_r^8

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    omega : float
        Acentric factor for fluid, [-]
    a : float, optional
        Fit parameter, calculated based on species_type if a is not given and
        species_type matches on of the supported chemical classes.
    b : float, optional
        Fit parameter, calculated based on species_type if a is not given and
        species_type matches on of the supported chemical classes.
    species_type : str, optional
        One of .
    dipole : float
        dipole moment, optional, [Debye]
    order : int, optional
        Order of the calculation. 0 for the calculation of B itself; for 1/2/3,
        the first/second/third derivative of B with respect to temperature; and
        for -1/-2, the first/second indefinite integral of B with respect to
        temperature. No other integrals or derivatives are implemented, and an
        exception will be raised if any other order is given.

    Returns
    -------
    B : float
        Second virial coefficient in density form or its integral/derivative if
        specified, [m^3/mol or m^3/mol/K^order]

    Notes
    -----
    Analytical models for derivatives and integrals are available for orders
    -2, -1, 1, 2, and 3, all obtained with SymPy.


    To calculate `a` or `b`, the following rules are used:

    For 'simple' or 'normal' fluids:

    .. math::
        a = 0

    .. math::
        b = 0

    For 'ketone', 'aldehyde', 'alkyl nitrile', 'ether', 'carboxylic acid',
    or 'ester' types of chemicals:

    .. math::
        a = -2.14\times 10^{-4} \mu_r - 4.308 \times 10^{-21} (\mu_r)^8

    .. math::
        b = 0

    For 'alkyl halide', 'mercaptan', 'sulfide', or 'disulfide' types of
    chemicals:

    .. math::
        a = -2.188\times 10^{-4} (\mu_r)^4 - 7.831 \times 10^{-21} (\mu_r)^8

    .. math::
        b = 0

    For 'alkanol' types of chemicals (except methanol):

    .. math::
        a = 0.0878

    .. math::
        b = 0.00908 + 0.0006957 \mu_r

    For methanol:

    .. math::
        a = 0.0878

    .. math::
        b = 0.0525

    For water:

    .. math::
        a = -0.0109

    .. math::
        b = 0

    If required, the form of dipole moment used in the calculation of some
    types of `a` and `b` values is as follows:

    .. math::
        \mu_r = 100000\frac{\mu^2(Pc/101325.0)}{Tc^2}


    For first temperature derivative of B:

    .. math::
        \frac{d B^{(0)}}{dT} = \frac{33 Tc}{100 T^{2}} + \frac{277 Tc^{2}}{1000 T^{3}} + \frac{363 Tc^{3}}{10000 T^{4}} + \frac{607 Tc^{8}}{125000 T^{9}}

    .. math::
        \frac{d B^{(1)}}{dT} = - \frac{331 Tc^{2}}{500 T^{3}} + \frac{1269 Tc^{3}}{1000 T^{4}} + \frac{8 Tc^{8}}{125 T^{9}}

    .. math::
        \frac{d B^{(2)}}{dT} = - \frac{6 Tc^{6}}{T^{7}}

    .. math::
        \frac{d B^{(3)}}{dT} = \frac{8 Tc^{8}}{T^{9}}

    For the second temperature derivative of B:

    .. math::
        \frac{d^2 B^{(0)}}{dT^2} = - \frac{3 Tc}{125000 T^{3}} \left(27500 + \frac{34625 Tc}{T} + \frac{6050 Tc^{2}}{T^{2}} + \frac{1821 Tc^{7}}{T^{7}}\right)

    .. math::
        \frac{d^2 B^{(1)}}{dT^2} = \frac{3 Tc^{2}}{500 T^{4}} \left(331 - \frac{846 Tc}{T} - \frac{96 Tc^{6}}{T^{6}}\right)

    .. math::
        \frac{d^2 B^{(2)}}{dT^2} = \frac{42 Tc^{6}}{T^{8}}

    .. math::
        \frac{d^2 B^{(3)}}{dT^2} = - \frac{72 Tc^{8}}{T^{10}}

    For the third temperature derivative of B:

    .. math::
        \frac{d^3 B^{(0)}}{dT^3} = \frac{3 Tc}{12500 T^{4}} \left(8250 + \frac{13850 Tc}{T} + \frac{3025 Tc^{2}}{T^{2}} + \frac{1821 Tc^{7}}{T^{7}}\right)

    .. math::
        \frac{d^3 B^{(1)}}{dT^3} = \frac{3 Tc^{2}}{250 T^{5}} \left(-662 + \frac{2115 Tc}{T} + \frac{480 Tc^{6}}{T^{6}}\right)

    .. math::
        \frac{d^3 B^{(2)}}{dT^3} = - \frac{336 Tc^{6}}{T^{9}}

    .. math::
        \frac{d^3 B^{(3)}}{dT^3} = \frac{720 Tc^{8}}{T^{11}}

    For the first indefinite integral of B:

    .. math::
        \int{B^{(0)}} dT = \frac{289 T}{2000} - \frac{33 Tc}{100} \ln{\left (T \right )} + \frac{1}{7000000 T^{7}} \left(969500 T^{6} Tc^{2} + 42350 T^{5} Tc^{3} + 607 Tc^{8}\right)

    .. math::
        \int{B^{(1)}} dT = \frac{637 T}{10000} - \frac{1}{70000 T^{7}} \left(23170 T^{6} Tc^{2} - 14805 T^{5} Tc^{3} - 80 Tc^{8}\right)

    .. math::
        \int{B^{(2)}} dT = - \frac{Tc^{6}}{5 T^{5}}

    .. math::
        \int{B^{(3)}} dT = \frac{Tc^{8}}{7 T^{7}}

    For the second indefinite integral of B:

    .. math::
        \int\int B^{(0)} dT dT = \frac{289 T^{2}}{4000} - \frac{33 T}{100} Tc \ln{\left (T \right )} + \frac{33 T}{100} Tc + \frac{277 Tc^{2}}{2000} \ln{\left (T \right )} - \frac{1}{42000000 T^{6}} \left(254100 T^{5} Tc^{3} + 607 Tc^{8}\right)

    .. math::
        \int\int B^{(1)} dT dT = \frac{637 T^{2}}{20000} - \frac{331 Tc^{2}}{1000} \ln{\left (T \right )} - \frac{1}{210000 T^{6}} \left(44415 T^{5} Tc^{3} + 40 Tc^{8}\right)

    .. math::
        \int\int B^{(2)} dT dT = \frac{Tc^{6}}{20 T^{4}}

    .. math::
        \int\int B^{(3)} dT dT = - \frac{Tc^{8}}{42 T^{6}}

    Examples
    --------
    Example from Perry's Handbook, 8E, p2-499. Matches to a decimal place.

    >>> BVirial_Tsonopoulos_extended(430., 405.65, 11.28E6, 0.252608, a=0, b=0, species_type='ketone', dipole=1.469)
    -9.679718337596426e-05

    References
    ----------
    .. [1] Tsonopoulos, C., and J. L. Heidman. "From the Virial to the Cubic
       Equation of State." Fluid Phase Equilibria 57, no. 3 (1990): 261-76.
       doi:10.1016/0378-3812(90)85126-U
    .. [2] Tsonopoulos, Constantine, and John H. Dymond. "Second Virial
       Coefficients of Normal Alkanes, Linear 1-Alkanols (and Water), Alkyl
       Ethers, and Their Mixtures." Fluid Phase Equilibria, International
       Workshop on Vapour-Liquid Equilibria and Related Properties in Binary
       and Ternary Mixtures of Ethers, Alkanes and Alkanols, 133, no. 1-2
       (June 1997): 11-34. doi:10.1016/S0378-3812(97)00058-7.
    '''
    Tr = T/Tc
    if order == 0:
        B0 = 0.1445 - 0.33/Tr - 0.1385/Tr**2 - 0.0121/Tr**3 - 0.000607/Tr**8
        B1 = 0.0637 + 0.331/Tr**2 - 0.423/Tr**3 - 0.008/Tr**8
        B2 = 1./Tr**6
        B3 = -1./Tr**8
    elif order == 1:
        B0 = 33*Tc/(100*T**2) + 277*Tc**2/(1000*T**3) + 363*Tc**3/(10000*T**4) + 607*Tc**8/(125000*T**9)
        B1 = -331*Tc**2/(500*T**3) + 1269*Tc**3/(1000*T**4) + 8*Tc**8/(125*T**9)
        B2 = -6.0*Tc**6/T**7
        B3 = 8.0*Tc**8/T**9
    elif order == 2:
        B0 = -3*Tc*(27500 + 34625*Tc/T + 6050*Tc**2/T**2 + 1821*Tc**7/T**7)/(125000*T**3)
        B1 = 3*Tc**2*(331 - 846*Tc/T - 96*Tc**6/T**6)/(500*T**4)
        B2 = 42.0*Tc**6/T**8
        B3 = -72.0*Tc**8/T**10
    elif order == 3:
        B0 = 3*Tc*(8250 + 13850*Tc/T + 3025*Tc**2/T**2 + 1821*Tc**7/T**7)/(12500*T**4)
        B1 = 3*Tc**2*(-662 + 2115*Tc/T + 480*Tc**6/T**6)/(250*T**5)
        B2 = -336.0*Tc**6/T**9
        B3 = 720.0*Tc**8/T**11
    elif order == -1:
        B0 = 289*T/2000. - 33*Tc*log(T)/100. + (969500*T**6*Tc**2 + 42350*T**5*Tc**3 + 607*Tc**8)/(7000000.*T**7)
        B1 = 637*T/10000. - (23170*T**6*Tc**2 - 14805*T**5*Tc**3 - 80*Tc**8)/(70000.*T**7)
        B2 = -Tc**6/(5*T**5)
        B3 = Tc**8/(7*T**7)
    elif order == -2:
        B0 = 289*T**2/4000. - 33*T*Tc*log(T)/100. + 33*T*Tc/100. + 277*Tc**2*log(T)/2000. - (254100*T**5*Tc**3 + 607*Tc**8)/(42000000.*T**6)
        B1 = 637*T**2/20000. - 331*Tc**2*log(T)/1000. - (44415*T**5*Tc**3 + 40*Tc**8)/(210000.*T**6)
        B2 = Tc**6/(20*T**4)
        B3 = -Tc**8/(42*T**6)
    else:
        raise ValueError('Only orders -2, -1, 0, 1, 2 and 3 are supported.')
    if a == 0 and b == 0 and species_type != '':
        if species_type == 'simple' or species_type == 'normal':
            a, b = 0, 0
        elif species_type == 'methyl alcohol':
            a, b = 0.0878, 0.0525
        elif species_type == 'water':
            a, b = -0.0109, 0
        elif dipole != 0 and Tc != 0 and Pc != 0:
            dipole_r = 1E5*dipole**2*(Pc/101325.0)/Tc**2

            if (species_type == 'ketone' or species_type == 'aldehyde'
            or species_type == 'alkyl nitrile' or species_type == 'ether'
            or species_type == 'carboxylic acid' or species_type == 'ester'):
                a, b = -2.14E-4*dipole_r-4.308E-21*dipole_r**8, 0
            elif (species_type == 'alkyl halide' or species_type == 'mercaptan'
            or species_type == 'sulfide' or species_type == 'disulfide'):
                a, b = -2.188E-4*dipole_r**4-7.831E-21*dipole_r**8, 0

            elif species_type == 'alkanol':
                a, b = 0.0878, 0.00908+0.0006957*dipole_r
    Br = B0 + omega*B1 + a*B2 + b*B3
    return Br*R*Tc/Pc
Esempio n. 13
0
def BVirial_Tsonopoulos(T, Tc, Pc, omega, order=0):
    r'''Calculates the second virial coefficient using the model in [1]_.

    .. math::
        B_r=B^{(0)}+\omega B^{(1)}

    .. math::
        B^{(0)}= 0.1445-0.330/T_r - 0.1385/T_r^2 - 0.0121/T_r^3 - 0.000607/T_r^8

    .. math::
        B^{(1)} = 0.0637+0.331/T_r^2-0.423/T_r^3 -0.423/T_r^3 - 0.008/T_r^8

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    omega : float
        Acentric factor for fluid, [-]
    order : int, optional
        Order of the calculation. 0 for the calculation of B itself; for 1/2/3,
        the first/second/third derivative of B with respect to temperature; and
        for -1/-2, the first/second indefinite integral of B with respect to
        temperature. No other integrals or derivatives are implemented, and an
        exception will be raised if any other order is given.

    Returns
    -------
    B : float
        Second virial coefficient in density form or its integral/derivative if
        specified, [m^3/mol or m^3/mol/K^order]

    Notes
    -----
    A more complete expression is also available, in
    BVirial_Tsonopoulos_extended.

    Analytical models for derivatives and integrals are available for orders
    -2, -1, 1, 2, and 3, all obtained with SymPy.

    For first temperature derivative of B:

    .. math::
        \frac{d B^{(0)}}{dT} = \frac{33 Tc}{100 T^{2}} + \frac{277 Tc^{2}}{1000 T^{3}} + \frac{363 Tc^{3}}{10000 T^{4}} + \frac{607 Tc^{8}}{125000 T^{9}}

    .. math::
        \frac{d B^{(1)}}{dT} = - \frac{331 Tc^{2}}{500 T^{3}} + \frac{1269 Tc^{3}}{1000 T^{4}} + \frac{8 Tc^{8}}{125 T^{9}}

    For the second temperature derivative of B:

    .. math::
        \frac{d^2 B^{(0)}}{dT^2} = - \frac{3 Tc}{125000 T^{3}} \left(27500 + \frac{34625 Tc}{T} + \frac{6050 Tc^{2}}{T^{2}} + \frac{1821 Tc^{7}}{T^{7}}\right)

    .. math::
        \frac{d^2 B^{(1)}}{dT^2} = \frac{3 Tc^{2}}{500 T^{4}} \left(331 - \frac{846 Tc}{T} - \frac{96 Tc^{6}}{T^{6}}\right)

    For the third temperature derivative of B:

    .. math::
        \frac{d^3 B^{(0)}}{dT^3} = \frac{3 Tc}{12500 T^{4}} \left(8250 + \frac{13850 Tc}{T} + \frac{3025 Tc^{2}}{T^{2}} + \frac{1821 Tc^{7}}{T^{7}}\right)

    .. math::
        \frac{d^3 B^{(1)}}{dT^3} = \frac{3 Tc^{2}}{250 T^{5}} \left(-662 + \frac{2115 Tc}{T} + \frac{480 Tc^{6}}{T^{6}}\right)

    For the first indefinite integral of B:

    .. math::
        \int{B^{(0)}} dT = \frac{289 T}{2000} - \frac{33 Tc}{100} \ln{\left (T \right )} + \frac{1}{7000000 T^{7}} \left(969500 T^{6} Tc^{2} + 42350 T^{5} Tc^{3} + 607 Tc^{8}\right)

    .. math::
        \int{B^{(1)}} dT = \frac{637 T}{10000} - \frac{1}{70000 T^{7}} \left(23170 T^{6} Tc^{2} - 14805 T^{5} Tc^{3} - 80 Tc^{8}\right)

    For the second indefinite integral of B:

    .. math::
        \int\int B^{(0)} dT dT = \frac{289 T^{2}}{4000} - \frac{33 T}{100} Tc \ln{\left (T \right )} + \frac{33 T}{100} Tc + \frac{277 Tc^{2}}{2000} \ln{\left (T \right )} - \frac{1}{42000000 T^{6}} \left(254100 T^{5} Tc^{3} + 607 Tc^{8}\right)

    .. math::
        \int\int B^{(1)} dT dT = \frac{637 T^{2}}{20000} - \frac{331 Tc^{2}}{1000} \ln{\left (T \right )} - \frac{1}{210000 T^{6}} \left(44415 T^{5} Tc^{3} + 40 Tc^{8}\right)

    Examples
    --------
    Example matching that in BVirial_Abbott, for isobutane.

    >>> BVirial_Tsonopoulos(510., 425.2, 38E5, 0.193)
    -0.00020935295404416802

    References
    ----------
    .. [1] Tsonopoulos, Constantine. "An Empirical Correlation of Second Virial
       Coefficients." AIChE Journal 20, no. 2 (March 1, 1974): 263-72.
       doi:10.1002/aic.690200209.
    '''
    Tr = T/Tc
    if order == 0:
        B0 = 0.1445 - 0.33/Tr - 0.1385/Tr**2 - 0.0121/Tr**3 - 0.000607/Tr**8
        B1 = 0.0637 + 0.331/Tr**2 - 0.423/Tr**3 - 0.008/Tr**8
    elif order == 1:
        B0 = 33*Tc/(100*T**2) + 277*Tc**2/(1000*T**3) + 363*Tc**3/(10000*T**4) + 607*Tc**8/(125000*T**9)
        B1 = -331*Tc**2/(500*T**3) + 1269*Tc**3/(1000*T**4) + 8*Tc**8/(125*T**9)
    elif order == 2:
        B0 = -3*Tc*(27500 + 34625*Tc/T + 6050*Tc**2/T**2 + 1821*Tc**7/T**7)/(125000*T**3)
        B1 = 3*Tc**2*(331 - 846*Tc/T - 96*Tc**6/T**6)/(500*T**4)
    elif order == 3:
        B0 = 3*Tc*(8250 + 13850*Tc/T + 3025*Tc**2/T**2 + 1821*Tc**7/T**7)/(12500*T**4)
        B1 = 3*Tc**2*(-662 + 2115*Tc/T + 480*Tc**6/T**6)/(250*T**5)
    elif order == -1:
        B0 = 289*T/2000. - 33*Tc*log(T)/100. + (969500*T**6*Tc**2 + 42350*T**5*Tc**3 + 607*Tc**8)/(7000000.*T**7)
        B1 = 637*T/10000. - (23170*T**6*Tc**2 - 14805*T**5*Tc**3 - 80*Tc**8)/(70000.*T**7)
    elif order == -2:
        B0 = 289*T**2/4000. - 33*T*Tc*log(T)/100. + 33*T*Tc/100. + 277*Tc**2*log(T)/2000. - (254100*T**5*Tc**3 + 607*Tc**8)/(42000000.*T**6)
        B1 = 637*T**2/20000. - 331*Tc**2*log(T)/1000. - (44415*T**5*Tc**3 + 40*Tc**8)/(210000.*T**6)
    else:
        raise ValueError('Only orders -2, -1, 0, 1, 2 and 3 are supported.')
    Br = (B0+omega*B1)
    return Br*R*Tc/Pc
Esempio n. 14
0
def BVirial_Pitzer_Curl(T, Tc, Pc, omega, order=0):
    r'''Calculates the second virial coefficient using the model in [1]_.
    Designed for simple calculations.

    .. math::
        B_r=B^{(0)}+\omega B^{(1)}

    .. math::
        B^{(0)}=0.1445-0.33/T_r-0.1385/T_r^2-0.0121/T_r^3

    .. math::
        B^{(1)} = 0.073+0.46/T_r-0.5/T_r^2 -0.097/T_r^3 - 0.0073/T_r^8

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    omega : float
        Acentric factor for fluid, [-]
    order : int, optional
        Order of the calculation. 0 for the calculation of B itself; for 1/2/3,
        the first/second/third derivative of B with respect to temperature; and
        for -1/-2, the first/second indefinite integral of B with respect to
        temperature. No other integrals or derivatives are implemented, and an
        exception will be raised if any other order is given.

    Returns
    -------
    B : float
        Second virial coefficient in density form or its integral/derivative if
        specified, [m^3/mol or m^3/mol/K^order]

    Notes
    -----
    Analytical models for derivatives and integrals are available for orders
    -2, -1, 1, 2, and 3, all obtained with SymPy.

    For first temperature derivative of B:

    .. math::
        \frac{d B^{(0)}}{dT} = \frac{33 Tc}{100 T^{2}} + \frac{277 Tc^{2}}{1000 T^{3}} + \frac{363 Tc^{3}}{10000 T^{4}}

    .. math::
        \frac{d B^{(1)}}{dT} = - \frac{23 Tc}{50 T^{2}} + \frac{Tc^{2}}{T^{3}} + \frac{291 Tc^{3}}{1000 T^{4}} + \frac{73 Tc^{8}}{1250 T^{9}}

    For the second temperature derivative of B:

    .. math::
        \frac{d^2 B^{(0)}}{dT^2} = - \frac{3 Tc}{5000 T^{3}} \left(1100 + \frac{1385 Tc}{T} + \frac{242 Tc^{2}}{T^{2}}\right)

    .. math::
        \frac{d^2 B^{(1)}}{dT^2} = \frac{Tc}{T^{3}} \left(\frac{23}{25} - \frac{3 Tc}{T} - \frac{291 Tc^{2}}{250 T^{2}} - \frac{657 Tc^{7}}{1250 T^{7}}\right)

    For the third temperature derivative of B:

    .. math::
        \frac{d^3 B^{(0)}}{dT^3} = \frac{3 Tc}{500 T^{4}} \left(330 + \frac{554 Tc}{T} + \frac{121 Tc^{2}}{T^{2}}\right)

    .. math::
        \frac{d^3 B^{(1)}}{dT^3} = \frac{3 Tc}{T^{4}} \left(- \frac{23}{25} + \frac{4 Tc}{T} + \frac{97 Tc^{2}}{50 T^{2}} + \frac{219 Tc^{7}}{125 T^{7}}\right)

    For the first indefinite integral of B:

    .. math::
        \int{B^{(0)}} dT = \frac{289 T}{2000} - \frac{33 Tc}{100} \ln{\left (T \right )} + \frac{1}{20000 T^{2}} \left(2770 T Tc^{2} + 121 Tc^{3}\right)

    .. math::
        \int{B^{(1)}} dT = \frac{73 T}{1000} + \frac{23 Tc}{50} \ln{\left (T \right )} + \frac{1}{70000 T^{7}} \left(35000 T^{6} Tc^{2} + 3395 T^{5} Tc^{3} + 73 Tc^{8}\right)

    For the second indefinite integral of B:

    .. math::
        \int\int B^{(0)} dT dT = \frac{289 T^{2}}{4000} - \frac{33 T}{100} Tc \ln{\left (T \right )} + \frac{33 T}{100} Tc + \frac{277 Tc^{2}}{2000} \ln{\left (T \right )} - \frac{121 Tc^{3}}{20000 T}

    .. math::
        \int\int B^{(1)} dT dT = \frac{73 T^{2}}{2000} + \frac{23 T}{50} Tc \ln{\left (T \right )} - \frac{23 T}{50} Tc + \frac{Tc^{2}}{2} \ln{\left (T \right )} - \frac{1}{420000 T^{6}} \left(20370 T^{5} Tc^{3} + 73 Tc^{8}\right)

    Examples
    --------
    Example matching that in BVirial_Abbott, for isobutane.

    >>> BVirial_Pitzer_Curl(510., 425.2, 38E5, 0.193)
    -0.00020845362479301725

    References
    ----------
    .. [1] Pitzer, Kenneth S., and R. F. Curl. "The Volumetric and
       Thermodynamic Properties of Fluids. III. Empirical Equation for the
       Second Virial Coefficient1." Journal of the American Chemical Society
       79, no. 10 (May 1, 1957): 2369-70. doi:10.1021/ja01567a007.
    '''
    Tr = T/Tc
    if order == 0:
        B0 = 0.1445 - 0.33/Tr - 0.1385/Tr**2 - 0.0121/Tr**3
        B1 = 0.073 + 0.46/Tr - 0.5/Tr**2 - 0.097/Tr**3 - 0.0073/Tr**8
    elif order == 1:
        B0 = Tc*(3300*T**2 + 2770*T*Tc + 363*Tc**2)/(10000*T**4)
        B1 = Tc*(-2300*T**7 + 5000*T**6*Tc + 1455*T**5*Tc**2 + 292*Tc**7)/(5000*T**9)
    elif order == 2:
        B0 = -3*Tc*(1100*T**2 + 1385*T*Tc + 242*Tc**2)/(5000*T**5)
        B1 = Tc*(1150*T**7 - 3750*T**6*Tc - 1455*T**5*Tc**2 - 657*Tc**7)/(1250*T**10)
    elif order == 3:
        B0 = 3*Tc*(330*T**2 + 554*T*Tc + 121*Tc**2)/(500*T**6)
        B1 = 3*Tc*(-230*T**7 + 1000*T**6*Tc + 485*T**5*Tc**2 + 438*Tc**7)/(250*T**11)
    elif order == -1:
        B0 = 289*T/2000 - 33*Tc*log(T)/100 + (2770*T*Tc**2 + 121*Tc**3)/(20000*T**2)
        B1 = 73*T/1000 + 23*Tc*log(T)/50 + (35000*T**6*Tc**2 + 3395*T**5*Tc**3 + 73*Tc**8)/(70000*T**7)
    elif order == -2:
        B0 = 289*T**2/4000 - 33*T*Tc*log(T)/100 + 33*T*Tc/100 + 277*Tc**2*log(T)/2000 - 121*Tc**3/(20000*T)
        B1 = 73*T**2/2000 + 23*T*Tc*log(T)/50 - 23*T*Tc/50 + Tc**2*log(T)/2 - (20370*T**5*Tc**3 + 73*Tc**8)/(420000*T**6)
    else:
        raise ValueError('Only orders -2, -1, 0, 1, 2 and 3 are supported.')
    Br = B0 + omega*B1
    return Br*R*Tc/Pc
Esempio n. 15
0
def EQ104(T, A, B, C, D, E, order=0):
    r'''DIPPR Equation #104. Often used in calculating second virial
    coefficients of gases. All 5 parameters are required.
    C, D, and E are normally large values.

    .. math::
        Y = A + \frac{B}{T} + \frac{C}{T^3} + \frac{D}{T^8} + \frac{E}{T^9}

    Parameters
    ----------
    T : float
        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, integral with respect to T, and integral
    over T with respect to T are computed as follows. All expressions can be
    obtained with SymPy readily.

    .. math::
        \frac{d Y}{dT} = - \frac{B}{T^{2}} - \frac{3 C}{T^{4}}
        - \frac{8 D}{T^{9}} - \frac{9 E}{T^{10}}

    .. math::
        \int Y dT = A T + B \log{\left (T \right )} - \frac{1}{56 T^{8}}
        \left(28 C T^{6} + 8 D T + 7 E\right)

    .. math::
        \int \frac{Y}{T} dT = A \log{\left (T \right )} - \frac{1}{72 T^{9}}
        \left(72 B T^{8} + 24 C T^{6} + 9 D T + 8 E\right)

    Examples
    --------
    Water second virial coefficient; DIPPR coefficients normally dimensionless.

    >>> EQ104(300, 0.02222, -26.38, -16750000, -3.894E19, 3.133E21)
    -1.1204179007265156

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    if order == 0:
        T2 = T * T
        return A + (B + (C + (D + E / T) / (T2 * T2 * T)) / T2) / T
    elif order == 1:
        T2 = T * T
        T4 = T2 * T2
        return (-B + (-3 * C + (-8 * D - 9 * E / T) / (T4 * T)) / T2) / T2
    elif order == -1:
        return A * T + B * log(T) - (28 * C * T**6 + 8 * D * T +
                                     7 * E) / (56 * T**8)
    elif order == -1j:
        return A * log(T) - (72 * B * T**8 + 24 * C * T**6 + 9 * D * T +
                             8 * E) / (72 * T**9)
    else:
        raise ValueError(order_not_found_msg)
Esempio n. 16
0
def EQ106(T, Tc, A, B, C=0.0, D=0.0, E=0.0, order=0):
    r'''DIPPR Equation #106. Often used in calculating liquid surface tension,
    and heat of vaporization.
    Only parameters A and B parameters are required; many fits include no
    further parameters. Critical temperature is also required.

    .. math::
        Y = A(1-T_r)^{B + C T_r + D T_r^2 + E T_r^3}

    .. math::
        Tr = \frac{T}{Tc}

    Parameters
    ----------
    T : float
        Temperature, [K]
    Tc : float
        Critical temperature, [K]
    A-D : 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, 2, and 3, that derivative of the property 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]

    Notes
    -----
    This form is used by Yaws with only the parameters `A` and `B`.

    The integral could not be found, but the integral over T actually could,
    again in terms of hypergeometric functions.

    .. math::
        \frac{d Y}{dT} = A \left(- \frac{T}{T_{c}} + 1\right)^{B + \frac{C T}
        {T_{c}} + \frac{D T^{2}}{T_{c}^{2}} + \frac{e T^{3}}{T_{c}^{3}}} \left(
        \left(\frac{C}{T_{c}} + \frac{2 D T}{T_{c}^{2}} + \frac{3 e T^{2}}
        {T_{c}^{3}}\right) \log{\left(- \frac{T}{T_{c}} + 1 \right)} - \frac{B
        + \frac{C T}{T_{c}} + \frac{D T^{2}}{T_{c}^{2}} + \frac{e T^{3}}
        {T_{c}^{3}}}{T_{c} \left(- \frac{T}{T_{c}} + 1\right)}\right)

    .. math::
        \frac{d^2 Y}{dT^2} = \frac{A \left(- \frac{T}{T_{c}} + 1\right)^{B
        + \frac{C T}{T_{c}} + \frac{D T^{2}}{T_{c}^{2}} + \frac{e T^{3}}
        {T_{c}^{3}}} \left(2 \left(D + \frac{3 e T}{T_{c}}\right) \log{\left(
        - \frac{T}{T_{c}} + 1 \right)} + \left(\left(C + \frac{2 D T}{T_{c}}
        + \frac{3 e T^{2}}{T_{c}^{2}}\right) \log{\left(- \frac{T}{T_{c}}
        + 1 \right)} + \frac{B + \frac{C T}{T_{c}} + \frac{D T^{2}}{T_{c}^{2}}
        + \frac{e T^{3}}{T_{c}^{3}}}{\frac{T}{T_{c}} - 1}\right)^{2}
        + \frac{2 \left(C + \frac{2 D T}{T_{c}} + \frac{3 e T^{2}}{T_{c}^{2}}
        \right)}{\frac{T}{T_{c}} - 1} - \frac{B + \frac{C T}{T_{c}} + \frac{D
        T^{2}}{T_{c}^{2}} + \frac{e T^{3}}{T_{c}^{3}}}{\left(\frac{T}{T_{c}}
        - 1\right)^{2}}\right)}{T_{c}^{2}}

    .. math::
        \frac{d^3 Y}{dT^3} = \frac{A \left(- \frac{T}{T_{c}} + 1\right)^{B
        + \frac{C T}{T_{c}} + \frac{D T^{2}}{T_{c}^{2}} + \frac{e T^{3}}
        {T_{c}^{3}}} \left(\frac{6 \left(D + \frac{3 e T}{T_{c}}\right)}
        {\frac{T}{T_{c}} - 1} + \left(\left(C + \frac{2 D T}{T_{c}}
        + \frac{3 e T^{2}}{T_{c}^{2}}\right) \log{\left(- \frac{T}{T_{c}}
        + 1 \right)} + \frac{B + \frac{C T}{T_{c}} + \frac{D T^{2}}{T_{c}^{2}}
        + \frac{e T^{3}}{T_{c}^{3}}}{\frac{T}{T_{c}} - 1}\right)^{3}
        + 3 \left(\left(C + \frac{2 D T}{T_{c}} + \frac{3 e T^{2}}{T_{c}^{2}}
        \right) \log{\left(- \frac{T}{T_{c}} + 1 \right)} + \frac{B
        + \frac{C T}{T_{c}} + \frac{D T^{2}}{T_{c}^{2}} + \frac{e T^{3}}
        {T_{c}^{3}}}{\frac{T}{T_{c}} - 1}\right) \left(2 \left(D + \frac{3 e T}
        {T_{c}}\right) \log{\left(- \frac{T}{T_{c}} + 1 \right)} + \frac{2
        \left(C + \frac{2 D T}{T_{c}} + \frac{3 e T^{2}}{T_{c}^{2}}\right)}
        {\frac{T}{T_{c}} - 1} - \frac{B + \frac{C T}{T_{c}} + \frac{D T^{2}}
        {T_{c}^{2}} + \frac{e T^{3}}{T_{c}^{3}}}{\left(\frac{T}{T_{c}}
        - 1\right)^{2}}\right) + 6 e \log{\left(- \frac{T}{T_{c}} + 1 \right)}
        - \frac{3 \left(C + \frac{2 D T}{T_{c}} + \frac{3 e T^{2}}{T_{c}^{2}}
        \right)}{\left(\frac{T}{T_{c}} - 1\right)^{2}} + \frac{2 \left(B
        + \frac{C T}{T_{c}} + \frac{D T^{2}}{T_{c}^{2}} + \frac{e T^{3}}
        {T_{c}^{3}}\right)}{\left(\frac{T}{T_{c}} - 1\right)^{3}}\right)}
        {T_{c}^{3}}

    Examples
    --------
    Water surface tension; DIPPR coefficients normally in Pa*s.

    >>> EQ106(300, 647.096, 0.17766, 2.567, -3.3377, 1.9699)
    0.07231499373541

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    if order == 0:
        Tr = T / Tc
        return A * (1. - Tr)**(B + Tr * (C + Tr * (D + E * Tr)))
    elif order == 1:
        x0 = 1.0 / Tc
        x1 = T * x0
        x2 = 1.0 - x1
        x3 = E * x1
        x4 = C + x1 * (D + x3)
        x5 = B + x1 * x4
        return A * x0 * x2**x5 * (x5 / (x1 - 1.0) +
                                  (x1 * (D + 2.0 * x3) + x4) * log(x2))
    elif order == 2:
        x0 = T / Tc
        x1 = 1.0 - x0
        x2 = E * x0
        x3 = C + x0 * (D + x2)
        x4 = B + x0 * x3
        x5 = log(x1)
        x6 = x0 - 1.0
        x7 = 1.0 / x6
        x8 = x0 * (D + 2.0 * x2) + x3
        return (A * x1**x4 *
                (-x4 / x6**2 + 2 * x5 * (D + 3.0 * x2) + 2.0 * x7 * x8 +
                 (x4 * x7 + x5 * x8)**2) / Tc**2)
    elif order == 3:
        x0 = T / Tc
        x1 = 1.0 - x0
        x2 = E * x0
        x3 = C + x0 * (D + x2)
        x4 = B + x0 * x3
        x5 = log(x1)
        x6 = D + 3.0 * x2
        x7 = x0 - 1.0
        x8 = 1 / x7
        x9 = x7**(-2)
        x10 = x0 * (D + 2.0 * x2) + x3
        x11 = x10 * x5 + x4 * x8
        return (A * x1**x4 * (-3 * x10 * x9 + x11**3 + 3 * x11 *
                              (2 * x10 * x8 - x4 * x9 + 2 * x5 * x6) +
                              2 * x4 / x7**3 + 6 * E * x5 + 6 * x6 * x8) /
                Tc**3)
    else:
        raise ValueError(order_not_found_msg)
Esempio n. 17
0
def EQ107(T, A=0, B=0, C=0, D=0, E=0, order=0):
    r'''DIPPR Equation #107. Often used in calculating ideal-gas heat capacity.
    All 5 parameters are required.
    Also called the Aly-Lee equation.

    .. math::
        Y = A + B\left[\frac{C/T}{\sinh(C/T)}\right]^2 + D\left[\frac{E/T}{
        \cosh(E/T)}\right]^2

    Parameters
    ----------
    T : float
        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, integral with respect to T, and integral
    over T with respect to T are computed as follows. The derivative is
    obtained via SymPy; the integrals from Wolfram Alpha.

    .. math::
        \frac{d Y}{dT} = \frac{2 B C^{3} \cosh{\left (\frac{C}{T} \right )}}
        {T^{4} \sinh^{3}{\left (\frac{C}{T} \right )}} - \frac{2 B C^{2}}{T^{3}
        \sinh^{2}{\left (\frac{C}{T} \right )}} + \frac{2 D E^{3} \sinh{\left
        (\frac{E}{T} \right )}}{T^{4} \cosh^{3}{\left (\frac{E}{T} \right )}}
        - \frac{2 D E^{2}}{T^{3} \cosh^{2}{\left (\frac{E}{T} \right )}}

    .. math::
        \int Y dT = A T + \frac{B C}{\tanh{\left (\frac{C}{T} \right )}}
        - D E \tanh{\left (\frac{E}{T} \right )}

    .. math::
        \int \frac{Y}{T} dT = A \log{\left (T \right )} + \frac{B C}{T \tanh{
        \left (\frac{C}{T} \right )}} - B \log{\left (\sinh{\left (\frac{C}{T}
        \right )} \right )} - \frac{D E}{T} \tanh{\left (\frac{E}{T} \right )}
        + D \log{\left (\cosh{\left (\frac{E}{T} \right )} \right )}

    Examples
    --------
    Water ideal gas molar heat capacity; DIPPR coefficients normally in
    J/kmol/K

    >>> EQ107(300., 33363., 26790., 2610.5, 8896., 1169.)
    33585.90452768923

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    .. [2] Aly, Fouad A., and Lloyd L. Lee. "Self-Consistent Equations for
       Calculating the Ideal Gas Heat Capacity, Enthalpy, and Entropy." Fluid
       Phase Equilibria 6, no. 3 (January 1, 1981): 169-79.
       doi:10.1016/0378-3812(81)85002-9.
    '''
    if order == 0:
        return A + B * ((C / T) / sinh(C / T))**2 + D * (
            (E / T) / cosh(E / T))**2
    elif order == 1:
        return (2 * B * C**3 * cosh(C / T) / (T**4 * sinh(C / T)**3) -
                2 * B * C**2 / (T**3 * sinh(C / T)**2) +
                2 * D * E**3 * sinh(E / T) / (T**4 * cosh(E / T)**3) -
                2 * D * E**2 / (T**3 * cosh(E / T)**2))
    elif order == -1:
        return A * T + B * C / tanh(C / T) - D * E * tanh(E / T)
    elif order == -1j:
        return (A * log(T) + B * C / tanh(C / T) / T - B * log(sinh(C / T)) -
                D * E * tanh(E / T) / T + D * log(cosh(E / T)))
    else:
        raise ValueError(order_not_found_msg)
Esempio n. 18
0
def EQ115(T, A, B, C=0, D=0, E=0, order=0):
    r'''DIPPR Equation #115. No major uses; has been used as an alternate
    liquid viscosity expression, and as a model for vapor pressure.
    Only parameters A and B are required.

    .. math::
        Y = \exp\left(A + \frac{B}{T} + C\ln T + D T^2 + \frac{E}{T^2}\right)

    Parameters
    ----------
    T : float
        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, 2, and 3, that derivative of the property 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]

    Notes
    -----
    No coefficients found for this expression.
    This function is not integrable for either dT or Y/T dT.

    .. math::
        \frac{d Y}{dT} = \left(- \frac{B}{T^{2}} + \frac{C}{T} + 2 D T
        - \frac{2 E}{T^{3}}\right) e^{A + \frac{B}{T} + C \log{\left(T \right)}
        + D T^{2} + \frac{E}{T^{2}}}

    .. math::
        \frac{d^2 Y}{dT^2} = \left(\frac{2 B}{T^{3}} - \frac{C}{T^{2}} + 2 D
        + \frac{6 E}{T^{4}} + \left(\frac{B}{T^{2}} - \frac{C}{T} - 2 D T
        + \frac{2 E}{T^{3}}\right)^{2}\right) e^{A + \frac{B}{T}
        + C \log{\left(T \right)} + D T^{2} + \frac{E}{T^{2}}}

    .. math::
        \frac{d^3 Y}{dT^3} =- \left(3 \left(\frac{2 B}{T^{3}} - \frac{C}{T^{2}}
        + 2 D + \frac{6 E}{T^{4}}\right) \left(\frac{B}{T^{2}} - \frac{C}{T}
        - 2 D T + \frac{2 E}{T^{3}}\right) + \left(\frac{B}{T^{2}}
        - \frac{C}{T} - 2 D T + \frac{2 E}{T^{3}}\right)^{3} + \frac{2 \left(
        \frac{3 B}{T} - C + \frac{12 E}{T^{2}}\right)}{T^{3}}\right)
        e^{A + \frac{B}{T} + C \log{\left(T \right)} + D T^{2} + \frac{E}{T^{2}}}

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE
    '''
    if order == 0:
        return exp(A + B / T + C * log(T) + D * T**2 + E / T**2)
    elif order == 1:
        x0 = T**2
        x1 = 1 / x0
        x2 = 1 / T
        return (-(B * x1 - C * x2 - 2 * D * T + 2 * E / T**3) *
                exp(A + B * x2 + C * log(T) + D * x0 + E * x1))
    elif order == 2:
        x0 = 1 / T
        x1 = T**2
        x2 = 1 / x1
        x3 = 2 * D
        x4 = 2 / T**3
        return (B * x4 - C * x2 + 6 * E / T**4 + x3 +
                (B * x2 - C * x0 + E * x4 - T * x3)**
                2) * exp(A + B * x0 + C * log(T) + D * x1 + E * x2)
    elif order == 3:
        x0 = 1 / T
        x1 = B * x0
        x2 = T**2
        x3 = 1 / x2
        x4 = E * x3
        x5 = 2 / T**3
        x6 = 2 * D
        x7 = B * x3 - C * x0 + E * x5 - T * x6
        return (-(x5 * (-C + 3 * x1 + 12 * x4) + x7**3 + 3 * x7 *
                  (B * x5 - C * x3 + 6 * E / T**4 + x6)) *
                exp(A + C * log(T) + D * x2 + x1 + x4))
    else:
        raise ValueError(order_not_found_msg)
Esempio n. 19
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)
Esempio n. 20
0
def Sanjari(T, Tc, Pc, omega):
    r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a
    CSP relationship by [1]_. Requires a chemical's critical temperature,
    pressure, and acentric factor. Although developed for refrigerants,
    this model should have some general predictive ability.

    The vapor pressure of a chemical at `T` is given by:

    .. math::
        P^{sat} = P_c\exp(f^{(0)} + \omega f^{(1)} + \omega^2 f^{(2)})

    .. math::
        f^{(0)} = a_1 + \frac{a_2}{T_r} + a_3\ln T_r + a_4 T_r^{1.9}

    .. math::
        f^{(1)} = a_5 + \frac{a_6}{T_r} + a_7\ln T_r + a_8 T_r^{1.9}

    .. math::
        f^{(2)} = a_9 + \frac{a_{10}}{T_r} + a_{11}\ln T_r + a_{12} T_r^{1.9}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    omega : float
        Acentric factor [-]

    Returns
    -------
    Psat : float
        Vapor pressure, [Pa]

    Notes
    -----
    a[1-12] are as follows:
    6.83377, -5.76051, 0.90654, -1.16906,
    5.32034, -28.1460, -58.0352, 23.57466,
    18.19967, 16.33839, 65.6995, -35.9739.

    For a claimed fluid not included in the regression, R128, the claimed AARD
    was 0.428%. A re-calculation using 200 data points from 125.45 K to
    343.90225 K evenly spaced by 1.09775 K as generated by NIST Webbook April
    2016 produced an AARD of 0.644%. It is likely that the author's regression
    used more precision in its coefficients than was shown here. Nevertheless,
    the function is reproduced as shown in [1]_.

    For Tc=808 K, Pc=1100000 Pa, omega=1.1571, this function actually declines
    after 770 K.

    Examples
    --------
    >>> Sanjari(347.2, 617.1, 36E5, 0.299)
    13651.916109552523

    References
    ----------
    .. [1] Sanjari, Ehsan, Mehrdad Honarmand, Hamidreza Badihi, and Ali
       Ghaheri. "An Accurate Generalized Model for Predict Vapor Pressure of
       Refrigerants." International Journal of Refrigeration 36, no. 4
       (June 2013): 1327-32. doi:10.1016/j.ijrefrig.2013.01.007.
    '''
    Tr = T / Tc
    Tr_inv = 1.0 / Tr
    log_Tr = log(Tr)
    Tr_19 = Tr**1.9
    f0 = 6.83377 + -5.76051 * Tr_inv + 0.90654 * log_Tr + -1.16906 * Tr_19
    f1 = 5.32034 + -28.1460 * Tr_inv + -58.0352 * log_Tr + 23.57466 * Tr_19
    f2 = 18.19967 + 16.33839 * Tr_inv + 65.6995 * log_Tr + -35.9739 * Tr_19
    return Pc * exp(f0 + omega * f1 + omega * omega * f2)