def viscosity_index(nu_40, nu_100, rounding=False):

nu_40, nu_100 = nu_40*<NUM_LIT>, nu_100*<NUM_LIT>  <EOL>if nu_100 < <NUM_LIT:2>:<EOL><INDENT>return None  <EOL><DEDENT>elif nu_100 < <NUM_LIT>:<EOL><INDENT>L = np.interp(nu_100, VI_nus, VI_Ls)<EOL>H = np.interp(nu_100, VI_nus, VI_Hs)<EOL><DEDENT>else:<EOL><INDENT>L = <NUM_LIT>*nu_100**<NUM_LIT:2> + <NUM_LIT>*nu_100 - <NUM_LIT><EOL>H = <NUM_LIT>*nu_100**<NUM_LIT:2> + <NUM_LIT>*nu_100 - <NUM_LIT><EOL><DEDENT>if nu_40 > H:<EOL><INDENT>VI = (L-nu_40)/(L-H)*<NUM_LIT:100><EOL><DEDENT>else:<EOL><INDENT>N = (log(H) - log(nu_40))/log(nu_100)<EOL>VI = (<NUM_LIT:10>**N-<NUM_LIT:1>)/<NUM_LIT> + <NUM_LIT:100><EOL><DEDENT>if rounding:<EOL><INDENT>VI = _round_whole_even(VI)<EOL><DEDENT>return VI<EOL>

r'''Calculates the viscosity index of a liquid. Requires dynamic viscosity
    of a liquid at 40°C and 100°C. Value may either be returned with or
    without rounding. Rounding is performed per the standard.

    if nu_100 < 70:

    .. math::
        L, H = interp(nu_100)

    else:

    .. math::
        L = 0.8353\nu_{100}^2 + 14.67\nu_{100} - 216

        H = 0.1684\nu_{100}^2 + 11.85\nu_{100} - 97

    if nu_40 > H:

    .. math::
        VI = \frac{L-nu_{40}}{L-H}\cdot 100

    else:

    .. math::
        N = \frac{\log(H) - \log(\nu_{40})}{\log (\nu_{100})}

         VI = \frac{10^N-1}{0.00715} + 100

    Parameters
    ----------
    nu_40 : float
        Dynamic viscosity of fluid at 40°C, [m^2/s]
    nu_100 : float
        Dynamic viscosity of fluid at 100°C, [m^2/s]
    rounding : bool, optional
        Whether to round the value or not.

    Returns
    -------
    VI: float
        Viscosity index [-]

    Notes
    -----
    VI is undefined for nu_100 under 2 mm^2/s. None is returned if this is the
    case. Internal units are mm^2/s. Higher values of viscosity index suggest
    a lesser decrease in kinematic viscosity as temperature increases.

    Note that viscosity is a pressure-dependent property, and that the
    viscosity index is defined for a fluid at whatever pressure it is at.
    The viscosity index is thus also a function of pressure.

    Examples
    --------
    >>> viscosity_index(73.3E-6, 8.86E-6, rounding=True)
    92

    References
    ----------
    .. [1] ASTM D2270-10(2016) Standard Practice for Calculating Viscosity
       Index from Kinematic Viscosity at 40 °C and 100 °C, ASTM International,
       West Conshohocken, PA, 2016, http://dx.doi.org/10.1520/D2270-10R16


def Przedziecki_Sridhar(T, Tm, Tc, Pc, Vc, Vm, omega, MW):

Pc = Pc/<NUM_LIT>  <EOL>Vm, Vc = Vm*<NUM_LIT>, Vc*<NUM_LIT>  <EOL>Tr = T/Tc<EOL>Gamma = <NUM_LIT> - <NUM_LIT>*Tr - <NUM_LIT>*Tr**<NUM_LIT:2><EOL>VrT = <NUM_LIT>-<NUM_LIT>*Tr + <NUM_LIT>*Tr**<NUM_LIT:2> - <NUM_LIT>*Tr**<NUM_LIT:3> + <NUM_LIT>*Tr**<NUM_LIT:4><EOL>V = VrT*(<NUM_LIT:1>-omega*Gamma)*Vc<EOL>Vo = <NUM_LIT>*omega*Tc - <NUM_LIT> + Vm/(<NUM_LIT>*(Tm/Tc) + <NUM_LIT>)  <EOL>E = -<NUM_LIT> + Vc/(<NUM_LIT> + <NUM_LIT:0.1>*MW - <NUM_LIT>*Pc + <NUM_LIT>*Tm - <NUM_LIT>*(Tm/Tc))<EOL>return Vo/(E*(V-Vo))/<NUM_LIT><EOL>

r'''Calculates the viscosity of a liquid using an emperical formula
    developed in [1]_.

    .. math::
        \mu=\frac{V_o}{E(V-V_o)}

        E=-1.12+\frac{V_c}{12.94+0.10MW-0.23P_c+0.0424T_{m}-11.58(T_{m}/T_c)}

        V_o = 0.0085\omega T_c-2.02+\frac{V_{m}}{0.342(T_m/T_c)+0.894}

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    Tm : float
        Melting point of fluid [K]
    Tc : float
        Critical temperature of the fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    Vc : float
        Critical volume of the fluid [m^3/mol]
    Vm : float
        Molar volume of the fluid at temperature [K]
    omega : float
        Acentric factor of compound
    MW : float
        Molwcular weight of fluid [g/mol]

    Returns
    -------
    mu_l : float
        Viscosity of liquid, [Pa*S]

    Notes
    -----
    A test by Reid (1983) is used, but only mostly correct.
    This function is not recommended. Its use has been removed from the Liquid Viscosity function.
    Internal units are bar and mL/mol.
    TODO: Test again with data from 5th ed table.

    Examples
    --------
    >>> Przedziecki_Sridhar(383., 178., 591.8, 41E5, 316E-6, 95E-6, .263, 92.14)
    0.0002198147995603383

    References
    ----------
    .. [1] Przedziecki, J. W., and T. Sridhar. "Prediction of Liquid
       Viscosities." AIChE Journal 31, no. 2 (February 1, 1985): 333-35.
       doi:10.1002/aic.690310225.


def calculate(self, T, P, zs, ws, method):

if method == SIMPLE:<EOL><INDENT>mus = [i(T, P) for i in self.ViscosityGases]<EOL>return mixing_simple(zs, mus)<EOL><DEDENT>elif method == HERNING_ZIPPERER:<EOL><INDENT>mus = [i(T, P) for i in self.ViscosityGases]<EOL>return Herning_Zipperer(zs, mus, self.MWs)<EOL><DEDENT>elif method == WILKE:<EOL><INDENT>mus = [i(T, P) for i in self.ViscosityGases]<EOL>return Wilke(zs, mus, self.MWs)<EOL><DEDENT>elif method == BROKAW:<EOL><INDENT>mus = [i(T, P) for i in self.ViscosityGases]<EOL>return Brokaw(T, zs, mus, self.MWs, self.molecular_diameters, self.Stockmayers)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Method to calculate viscosity of a gas mixture at
        temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
        `ws` with a given method.

        This method has no exception handling; see `mixture_property`
        for that.

        Parameters
        ----------
        T : float
            Temperature at which to calculate the property, [K]
        P : float
            Pressure at which to calculate the property, [Pa]
        zs : list[float]
            Mole fractions of all species in the mixture, [-]
        ws : list[float]
            Weight fractions of all species in the mixture, [-]
        method : str
            Name of the method to use

        Returns
        -------
        mu : float
            Viscosity of gas mixture, [Pa*s]


Tr = T/Tc<EOL>xi = <NUM_LIT>*Tc**(<NUM_LIT:1>/<NUM_LIT>)/(MW**<NUM_LIT:0.5>*Pc**(<NUM_LIT:2>/<NUM_LIT>))<EOL>a = <NUM_LIT><EOL>b = <NUM_LIT><EOL>c = <NUM_LIT><EOL>d = -<NUM_LIT><EOL>e = <NUM_LIT><EOL>f = -<NUM_LIT><EOL>return (<NUM_LIT:1.> + a*Tr**b - c * exp(d*Tr) + e*exp(f*Tr))/(<NUM_LIT>*xi)<EOL>

r'''Calculates the viscosity of a gas using an emperical formula
    developed in [1]_.

    .. math::
        \eta \xi \times 10^8 = 46.10 T_r^{0.618} - 20.40 \exp(-0.449T_r) + 1
        9.40\exp(-4.058T_r)+1

        \xi = 2173.424 T_c^{1/6} MW^{-1/2} P_c^{-2/3}

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    Tc : float
        Critical temperature of the fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    MW : float
        Molwcular weight of fluid [g/mol]

    Returns
    -------
    mu_g : float
        Viscosity of gas, [Pa*S]

    Notes
    -----
    This equation has been tested. The equation uses SI units only internally.
    The constant 2173.424 is an adjustment factor for units.
    Average deviation within 3% for most compounds.
    Greatest accuracy with dipole moments close to 0.
    Hydrogen and helium have different coefficients, not implemented.
    This is DIPPR Procedure 8B: Method for the Viscosity of Pure,
    non hydrocarbon, nonpolar gases at low pressures

    Examples
    --------
    >>> Yoon_Thodos(300., 556.35, 4.5596E6, 153.8)
    1.0194885727776819e-05

    References
    ----------
    .. [1]  Yoon, Poong, and George Thodos. "Viscosity of Nonpolar Gaseous
       Mixtures at Normal Pressures." AIChE Journal 16, no. 2 (1970): 300-304.
       doi:10.1002/aic.690160225.


methods, methods_P = [], []<EOL>Tmins, Tmaxs = [], []<EOL>if has_CoolProp and self.CASRN in coolprop_dict:<EOL><INDENT>methods.append(COOLPROP); methods_P.append(COOLPROP)<EOL>self.CP_f = coolprop_fluids[self.CASRN]<EOL>Tmins.append(self.CP_f.Tmin); Tmaxs.append(self.CP_f.Tc)<EOL><DEDENT>if self.CASRN in _VDISaturationDict:<EOL><INDENT>methods.append(VDI_TABULAR)<EOL>Ts, props = VDI_tabular_data(self.CASRN, '<STR_LIT>')<EOL>self.VDI_Tmin = Ts[<NUM_LIT:0>]<EOL>self.VDI_Tmax = Ts[-<NUM_LIT:1>]<EOL>self.tabular_data[VDI_TABULAR] = (Ts, props)<EOL>Tmins.append(self.VDI_Tmin); Tmaxs.append(self.VDI_Tmax)<EOL><DEDENT>if self.CASRN in Dutt_Prasad.index:<EOL><INDENT>methods.append(DUTT_PRASAD)<EOL>_, A, B, C, self.DUTT_PRASAD_Tmin, self.DUTT_PRASAD_Tmax = _Dutt_Prasad_values[Dutt_Prasad.index.get_loc(self.CASRN)].tolist()<EOL>self.DUTT_PRASAD_coeffs = [A, B, C]<EOL>Tmins.append(self.DUTT_PRASAD_Tmin); Tmaxs.append(self.DUTT_PRASAD_Tmax)<EOL><DEDENT>if self.CASRN in VN3_data.index:<EOL><INDENT>methods.append(VISWANATH_NATARAJAN_3)<EOL>_, _, A, B, C, self.VISWANATH_NATARAJAN_3_Tmin, self.VISWANATH_NATARAJAN_3_Tmax = _VN3_data_values[VN3_data.index.get_loc(self.CASRN)].tolist()<EOL>self.VISWANATH_NATARAJAN_3_coeffs = [A, B, C]<EOL>Tmins.append(self.VISWANATH_NATARAJAN_3_Tmin); Tmaxs.append(self.VISWANATH_NATARAJAN_3_Tmax)<EOL><DEDENT>if self.CASRN in VN2_data.index:<EOL><INDENT>methods.append(VISWANATH_NATARAJAN_2)<EOL>_, _, A, B, self.VISWANATH_NATARAJAN_2_Tmin, self.VISWANATH_NATARAJAN_2_Tmax = _VN2_data_values[VN2_data.index.get_loc(self.CASRN)].tolist()<EOL>self.VISWANATH_NATARAJAN_2_coeffs = [A, B]<EOL>Tmins.append(self.VISWANATH_NATARAJAN_2_Tmin); Tmaxs.append(self.VISWANATH_NATARAJAN_2_Tmax)<EOL><DEDENT>if self.CASRN in VN2E_data.index:<EOL><INDENT>methods.append(VISWANATH_NATARAJAN_2E)<EOL>_, _, C, D, self.VISWANATH_NATARAJAN_2E_Tmin, self.VISWANATH_NATARAJAN_2E_Tmax = _VN2E_data_values[VN2E_data.index.get_loc(self.CASRN)].tolist()<EOL>self.VISWANATH_NATARAJAN_2E_coeffs = [C, D]<EOL>Tmins.append(self.VISWANATH_NATARAJAN_2E_Tmin); Tmaxs.append(self.VISWANATH_NATARAJAN_2E_Tmax)<EOL><DEDENT>if self.CASRN in Perrys2_313.index:<EOL><INDENT>methods.append(DIPPR_PERRY_8E)<EOL>_, C1, C2, C3, C4, C5, self.Perrys2_313_Tmin, self.Perrys2_313_Tmax = _Perrys2_313_values[Perrys2_313.index.get_loc(self.CASRN)].tolist()<EOL>self.Perrys2_313_coeffs = [C1, C2, C3, C4, C5]<EOL>Tmins.append(self.Perrys2_313_Tmin); Tmaxs.append(self.Perrys2_313_Tmax)<EOL><DEDENT>if self.CASRN in VDI_PPDS_7.index:<EOL><INDENT>methods.append(VDI_PPDS)<EOL>self.VDI_PPDS_coeffs = _VDI_PPDS_7_values[VDI_PPDS_7.index.get_loc(self.CASRN)].tolist()[<NUM_LIT:2>:]<EOL><DEDENT>if all((self.MW, self.Tc, self.Pc, self.omega)):<EOL><INDENT>methods.append(LETSOU_STIEL)<EOL>Tmins.append(self.Tc/<NUM_LIT:4>); Tmaxs.append(self.Tc) <EOL><DEDENT>if all((self.MW, self.Tm, self.Tc, self.Pc, self.Vc, self.omega, self.Vml)):<EOL><INDENT>methods.append(PRZEDZIECKI_SRIDHAR)<EOL>Tmins.append(self.Tm); Tmaxs.append(self.Tc) <EOL><DEDENT>if all([self.Tc, self.Pc, self.omega]):<EOL><INDENT>methods_P.append(LUCAS)<EOL><DEDENT>self.all_methods = set(methods)<EOL>self.all_methods_P = set(methods_P)<EOL>if Tmins and Tmaxs:<EOL><INDENT>self.Tmin, self.Tmax = min(Tmins), max(Tmaxs)<EOL><DEDENT>

r'''Method which picks out coefficients for the specified chemical
        from the various dictionaries and DataFrames storing it. All data is
        stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`,
        :obj:`all_methods` and obj:`all_methods_P` as a set of methods for
        which the data exists for.

        Called on initialization only. See the source code for the variables at
        which the coefficients are stored. The coefficients can safely be
        altered once the class is initialized. This method can be called again
        to reset the parameters.


if method == COOLPROP:<EOL><INDENT>mu = PropsSI('<STR_LIT>', '<STR_LIT:T>', T, '<STR_LIT:P>', P, self.CASRN)<EOL><DEDENT>elif method in self.tabular_data:<EOL><INDENT>mu = self.interpolate_P(T, P, method)<EOL><DEDENT>return mu<EOL>

r'''Method to calculate pressure-dependent gas viscosity
        at temperature `T` and pressure `P` with a given method.

        This method has no exception handling; see `TP_dependent_property`
        for that.

        Parameters
        ----------
        T : float
            Temperature at which to calculate gas viscosity, [K]
        P : float
            Pressure at which to calculate gas viscosity, [K]
        method : str
            Name of the method to use

        Returns
        -------
        mu : float
            Viscosity of the gas at T and P, [Pa*]


mu = <NUM_LIT:10>**(A + B/(C - T))<EOL>return mu/<NUM_LIT><EOL>

r'''Calculate the viscosity of a liquid using the 3-term Antoine form
    representation developed in [1]_. Requires input coefficients. The `A`
    coefficient is assumed to yield coefficients in centipoise, as all
    coefficients found so far have been.

    .. math::
        \log_{10} \mu = A + B/(T + C)

    Parameters
    ----------
    T : float
        Temperature of fluid [K]

    Returns
    -------
    mu : float
        Liquid viscosity, [Pa*s]

    Notes
    -----
    No other source for these coefficients has been found.

    Examples
    --------
    >>> ViswanathNatarajan3(298.15, -2.7173, -1071.18, -129.51)
    0.0006129806445142112

    References
    ----------
    .. [1] Viswanath, Dabir S., and G. Natarajan. Databook On The Viscosity Of
       Liquids. New York: Taylor & Francis, 1989


def Brokaw(T, ys, mus, MWs, molecular_diameters, Stockmayers):

cmps = range(len(ys))<EOL>MDs = molecular_diameters<EOL>if not none_and_length_check([ys, mus, MWs, molecular_diameters, Stockmayers]): <EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>Tsts = [T/Stockmayer_i for Stockmayer_i in Stockmayers]<EOL>Sij = [[<NUM_LIT:0> for i in cmps] for j in cmps]<EOL>Mij = [[<NUM_LIT:0> for i in cmps] for j in cmps]<EOL>mij = [[<NUM_LIT:0> for i in cmps] for j in cmps]<EOL>Aij = [[<NUM_LIT:0> for i in cmps] for j in cmps]<EOL>phiij =[[<NUM_LIT:0> for i in cmps] for j in cmps]<EOL>for i in cmps:<EOL><INDENT>for j in cmps:<EOL><INDENT>Sij[i][j] = (<NUM_LIT:1>+(Tsts[i]*Tsts[j])**<NUM_LIT:0.5> + (MDs[i]*MDs[j])/<NUM_LIT>)/(<NUM_LIT:1> + Tsts[i] + (MDs[i]**<NUM_LIT:2>/<NUM_LIT>))**<NUM_LIT:0.5>/(<NUM_LIT:1> + Tsts[j] + (MDs[j]**<NUM_LIT:2>/<NUM_LIT>))**<NUM_LIT:0.5><EOL>if MDs[i] <= <NUM_LIT:0.1> and MDs[j] <= <NUM_LIT:0.1>:<EOL><INDENT>Sij[i][j] = <NUM_LIT:1><EOL><DEDENT>Mij[i][j] = MWs[i]/MWs[j]<EOL>mij[i][j] = (<NUM_LIT>/(<NUM_LIT:1>+Mij[i][j]**-<NUM_LIT:1>)/(<NUM_LIT:1>+Mij[i][j]))**<NUM_LIT><EOL>Aij[i][j] = mij[i][j]*Mij[i][j]**-<NUM_LIT:0.5>*(<NUM_LIT:1> + (Mij[i][j]-Mij[i][j]**<NUM_LIT>)/(<NUM_LIT:2>*(<NUM_LIT:1>+Mij[i][j]) + (<NUM_LIT:1>+Mij[i][j]**<NUM_LIT>)*mij[i][j]**-<NUM_LIT:0.5>/(<NUM_LIT:1>+mij[i][j])))<EOL>phiij[i][j] = (mus[i]/mus[j])**<NUM_LIT:0.5>*Sij[i][j]*Aij[i][j]<EOL><DEDENT><DEDENT>return sum([ys[i]*mus[i]/sum([ys[j]*phiij[i][j] for j in cmps]) for i in cmps])<EOL>

r'''Calculates viscosity of a gas mixture according to
    mixing rules in [1]_.

    .. math::
        \eta_{mix} = \sum_{i=1}^n \frac{y_i \eta_i}{\sum_{j=1}^n y_j \phi_{ij}}

        \phi_{ij} = \left( \frac{\eta_i}{\eta_j} \right)^{0.5} S_{ij} A_{ij}

        A_{ij} = m_{ij} M_{ij}^{-0.5} \left[1 +
        \frac{M_{ij} - M_{ij}^{0.45}}
        {2(1+M_{ij}) + \frac{(1 + M_{ij}^{0.45}) m_{ij}^{-0.5}}{1 + m_{ij}}} \right]

        m_{ij} = \left[ \frac{4}{(1+M_{ij}^{-1})(1+M_{ij})}\right]^{0.25}

        M_{ij} = \frac{M_i}{M_j}

        S_{ij} = \frac{1 + (T_i^* T_j^*)^{0.5} + (\delta_i \delta_j/4)}
        {[1+T_i^* + (\delta_i^2/4)]^{0.5}[1+T_j^*+(\delta_j^2/4)]^{0.5}}

        T^* = kT/\epsilon

    Parameters
    ----------
    T : float
        Temperature of fluid, [K]
    ys : float
        Mole fractions of gas components
    mus : float
        Gas viscosities of all components, [Pa*S]
    MWs : float
        Molecular weights of all components, [g/mol]
    molecular_diameters : float
        L-J molecular diameter  of all components, [angstroms]
    Stockmayers : float
        L-J Stockmayer energy parameters of all components, []

    Returns
    -------
    mug : float
        Viscosity of gas mixture, [Pa*S]

    Notes
    -----
    This equation is entirely dimensionless; all dimensions cancel.
    The original source has not been reviewed.

    This is DIPPR Procedure 8D: Method for the Viscosity of Nonhydrocarbon
    Vapor Mixtures at Low Pressure (Polar and Nonpolar)

    Examples
    --------
    >>> Brokaw(308.2, [0.05, 0.95], [1.34E-5, 9.5029E-6], [64.06, 46.07], [0.42, 0.19], [347, 432])
    9.699085099801568e-06

    References
    ----------
    .. [1] Brokaw, R. S. "Predicting Transport Properties of Dilute Gases."
       Industrial & Engineering Chemistry Process Design and Development
       8, no. 2 (April 1, 1969): 240-53. doi:10.1021/i260030a015.
    .. [2] Brokaw, R. S. Viscosity of Gas Mixtures, NASA-TN-D-4496, 1968.
    .. [3] Danner, Ronald P, and Design Institute for Physical Property Data.
       Manual for Predicting Chemical Process Design Data. New York, N.Y, 1982.


if T == self.T_cached:<EOL><INDENT>return self.prop_cached<EOL><DEDENT>else:<EOL><INDENT>self.prop_cached = self.T_dependent_property(T)<EOL>self.T_cached = T<EOL>return self.prop_cached<EOL><DEDENT>

r'''Convenience method to calculate the property; calls
        :obj:`T_dependent_property`. Caches previously calculated value,
        which is an overhead when calculating many different values of
        a property. See :obj:`T_dependent_property` for more details as to the
        calculation procedure.

        Parameters
        ----------
        T : float
            Temperature at which to calculate the property, [K]

        Returns
        -------
        prop : float
            Calculated property, [`units`]


if (T, P) == self.TP_cached:<EOL><INDENT>return self.prop_cached<EOL><DEDENT>else:<EOL><INDENT>self.prop_cached = self.TP_or_T_dependent_property(T, P)<EOL>self.TP_cached = (T, P)<EOL>return self.prop_cached<EOL><DEDENT>

r'''Convenience method to calculate the property; calls
        :obj:`TP_dependent_property`. Caches previously calculated value,
        which is an overhead when calculating many different values of
        a property. See :obj:`TP_dependent_property` for more details as to the
        calculation procedure.

        Parameters
        ----------
        T : float
            Temperature at which to calculate the property, [K]
        P : float
            Pressure at which to calculate the property, [Pa]

        Returns
        -------
        prop : float
            Calculated property, [`units`]


def T_dependent_property_integral_over_T(self, T1, T2):

Tavg = <NUM_LIT:0.5>*(T1+T2)<EOL>if self.method:<EOL><INDENT>if self.test_method_validity(Tavg, self.method):<EOL><INDENT>try:<EOL><INDENT>return self.calculate_integral_over_T(T1, T2, self.method)<EOL><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>sorted_valid_methods = self.select_valid_methods(Tavg)<EOL>for method in sorted_valid_methods:<EOL><INDENT>try:<EOL><INDENT>return self.calculate_integral_over_T(T1, T2, method)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to calculate the integral of a property over temperature
        with respect to temperature, using a specified method. Methods found
        valid by `select_valid_methods` are attempted until a method succeeds.
        If no methods are valid and succeed, None is returned.

        Calls `calculate_integral_over_T` internally to perform the actual
        calculation.

        .. math::
            \text{integral} = \int_{T_1}^{T_2} \frac{\text{property}}{T} \; dT

        Parameters
        ----------
        T1 : float
            Lower limit of integration, [K]
        T2 : float
            Upper limit of integration, [K]
        method : str
            Method for which to find the integral

        Returns
        -------
        integral : float
            Calculated integral of the property over the given range,
            [`units`]


if not none_and_length_check([fracs, props]):<EOL><INDENT>return None<EOL><DEDENT>result = sum(frac*prop for frac, prop in zip(fracs, props))<EOL>return result<EOL>

r'''Simple function calculates a property based on weighted averages of
    properties. Weights could be mole fractions, volume fractions, mass
    fractions, or anything else.

    .. math::
        y = \sum_i \text{frac}_i \cdot \text{prop}_i

    Parameters
    ----------
    fracs : array-like
        Fractions of a mixture
    props: array-like
        Properties

    Returns
    -------
    prop : value
        Calculated property

    Notes
    -----
    Returns None if any fractions or properties are missing or are not of the
    same length.

    Examples
    --------
    >>> mixing_simple([0.1, 0.9], [0.01, 0.02])
    0.019000000000000003


def calculate_derivative_P(self, P, T, zs, ws, method, order=<NUM_LIT:1>):

f = lambda P: self.calculate(T, P, zs, ws, method)<EOL>return derivative(f, P, dx=<NUM_LIT>, n=order, order=<NUM_LIT:1>+order*<NUM_LIT:2>)<EOL>

r'''Method to calculate a derivative of a mixture property with respect
        to pressure at constant temperature and composition
        of a given order using a specified method. Uses SciPy's derivative
        function, with a delta of 0.01 Pa and a number of points equal to
        2*order + 1.

        This method can be overwritten by subclasses who may perfer to add
        analytical methods for some or all methods as this is much faster.

        If the calculation does not succeed, returns the actual error
        encountered.

        Parameters
        ----------
        P : float
            Pressure at which to calculate the derivative, [Pa]
        T : float
            Temperature at which to calculate the derivative, [K]
        zs : list[float]
            Mole fractions of all species in the mixture, [-]
        ws : list[float]
            Weight fractions of all species in the mixture, [-]
        method : str
            Method for which to find the derivative
        order : int
            Order of the derivative, >= 1

        Returns
        -------
        d_prop_d_P_at_T : float
            Calculated derivative property at constant temperature,
            [`units/Pa^order`]


def TP_dependent_property_derivative_P(self, T, P, order=<NUM_LIT:1>):

sorted_valid_methods_P = self.select_valid_methods_P(T, P)<EOL>for method in sorted_valid_methods_P:<EOL><INDENT>try:<EOL><INDENT>return self.calculate_derivative_P(P, T, method, order)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to calculate a derivative of a temperature and pressure
        dependent property with respect to pressure at constant temperature,
        of a given order. Methods found valid by `select_valid_methods_P` are
        attempted until a method succeeds. If no methods are valid and succeed,
        None is returned.

        Calls `calculate_derivative_P` internally to perform the actual
        calculation.

        .. math::
            \text{derivative} = \frac{d (\text{property})}{d P}|_{T}

        Parameters
        ----------
        T : float
            Temperature at which to calculate the derivative, [K]
        P : float
            Pressure at which to calculate the derivative, [Pa]
        order : int
            Order of the derivative, >= 1

        Returns
        -------
        d_prop_d_P_at_T : float
            Calculated derivative property, [`units/Pa^order`]


tot = sum(values)<EOL>return [i/tot for i in values]<EOL>

r'''Simple function which normalizes a series of values to be from 0 to 1,
    and for their sum to add to 1.

    .. math::
        x = \frac{x}{sum_i x_i}

    Parameters
    ----------
    values : array-like
        array of values

    Returns
    -------
    fractions : array-like
        Array of values from 0 to 1

    Notes
    -----
    Does not work on negative values.

    Examples
    --------
    >>> normalize([3, 2, 1])
    [0.5, 0.3333333333333333, 0.16666666666666666]


def Joule_Thomson(T, V, Cp, dV_dT=None, beta=None):

if dV_dT:<EOL><INDENT>return (T*dV_dT - V)/Cp<EOL><DEDENT>elif beta:<EOL><INDENT>return V/Cp*(beta*T - <NUM_LIT:1.>)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Calculate a real fluid's Joule Thomson coefficient. The required
    derivative should be calculated with an equation of state, and `Cp` is the
    real fluid versions. This can either be calculated with `dV_dT` directly,
    or with `beta` if it is already known.

    .. math::
        \mu_{JT} = \left(\frac{\partial T}{\partial P}\right)_H = \frac{1}{C_p}
        \left[T \left(\frac{\partial V}{\partial T}\right)_P - V\right]
        = \frac{V}{C_p}\left(\beta T-1\right)

    Parameters
    ----------
    T : float
        Temperature of fluid, [K]
    V : float
        Molar volume of fluid, [m^3/mol]
    Cp : float
        Real fluid heat capacity at constant pressure, [J/mol/K]
    dV_dT : float, optional
        Derivative of `V` with respect to `T`, [m^3/mol/K]
    beta : float, optional
        Isobaric coefficient of a thermal expansion, [1/K]

    Returns
    -------
    mu_JT : float
        Joule-Thomson coefficient [K/Pa]

    Examples
    --------
    Example from [2]_:

    >>> Joule_Thomson(T=390, V=0.00229754, Cp=153.235, dV_dT=1.226396e-05)
    1.621956080529905e-05

    References
    ----------
    .. [1] Walas, Stanley M. Phase Equilibria in Chemical Engineering.
       Butterworth-Heinemann, 1985.
    .. [2] Pratt, R. M. "Thermodynamic Properties Involving Derivatives: Using
       the Peng-Robinson Equation of State." Chemical Engineering Education 35,
       no. 2 (March 1, 2001): 112-115.


def T_dependent_property_derivative(self, T, order=<NUM_LIT:1>):

if self.method:<EOL><INDENT>if self.test_method_validity(T, self.method):<EOL><INDENT>try:<EOL><INDENT>return self.calculate_derivative(T, self.method, order)<EOL><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>sorted_valid_methods = self.select_valid_methods(T)<EOL>for method in sorted_valid_methods:<EOL><INDENT>try:<EOL><INDENT>return self.calculate_derivative(T, method, order)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to obtain a derivative of a property with respect to
        temperature, of a given order. Methods found valid by
        `select_valid_methods` are attempted until a method succeeds. If no
        methods are valid and succeed, None is returned.

        Calls `calculate_derivative` internally to perform the actual
        calculation.

        .. math::
            \text{derivative} = \frac{d (\text{property})}{d T}

        Parameters
        ----------
        T : float
            Temperature at which to calculate the derivative, [K]
        order : int
            Order of the derivative, >= 1

        Returns
        -------
        derivative : float
            Calculated derivative property, [`units/K^order`]


def plot_TP_dependent_property(self, Tmin=None, Tmax=None, Pmin=None,<EOL>Pmax=None,  methods_P=[], pts=<NUM_LIT:15>, <EOL>only_valid=True):

if not has_matplotlib:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>from mpl_toolkits.mplot3d import axes3d<EOL>from matplotlib.ticker import FormatStrFormatter<EOL>import numpy.ma as ma<EOL>if Pmin is None:<EOL><INDENT>if self.Pmin is not None:<EOL><INDENT>Pmin = self.Pmin<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if Pmax is None:<EOL><INDENT>if self.Pmax is not None:<EOL><INDENT>Pmax = self.Pmax<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if Tmin is None:<EOL><INDENT>if self.Tmin is not None:<EOL><INDENT>Tmin = self.Tmin<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if Tmax is None:<EOL><INDENT>if self.Tmax is not None:<EOL><INDENT>Tmax = self.Tmax<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if not methods_P:<EOL><INDENT>methods_P = self.user_methods_P if self.user_methods_P else self.all_methods_P<EOL><DEDENT>Ps = np.linspace(Pmin, Pmax, pts)<EOL>Ts = np.linspace(Tmin, Tmax, pts)<EOL>Ts_mesh, Ps_mesh = np.meshgrid(Ts, Ps)<EOL>fig = plt.figure()<EOL>ax = fig.gca(projection='<STR_LIT>')<EOL>handles = []<EOL>for method_P in methods_P:<EOL><INDENT>if only_valid:<EOL><INDENT>properties = []<EOL>for T in Ts:<EOL><INDENT>T_props = []<EOL>for P in Ps:<EOL><INDENT>if self.test_method_validity_P(T, P, method_P):<EOL><INDENT>try:<EOL><INDENT>p = self.calculate_P(T, P, method_P)<EOL>if self.test_property_validity(p):<EOL><INDENT>T_props.append(p)<EOL><DEDENT>else:<EOL><INDENT>T_props.append(None)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>T_props.append(None)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>T_props.append(None)<EOL><DEDENT><DEDENT>properties.append(T_props)<EOL><DEDENT>properties = ma.masked_invalid(np.array(properties, dtype=np.float).T)<EOL>handles.append(ax.plot_surface(Ts_mesh, Ps_mesh, properties, cstride=<NUM_LIT:1>, rstride=<NUM_LIT:1>, alpha=<NUM_LIT:0.5>))<EOL><DEDENT>else:<EOL><INDENT>properties = [[self.calculate_P(T, P, method_P) for P in Ps] for T in Ts]<EOL>handles.append(ax.plot_surface(Ts_mesh, Ps_mesh, properties, cstride=<NUM_LIT:1>, rstride=<NUM_LIT:1>, alpha=<NUM_LIT:0.5>))<EOL><DEDENT><DEDENT>ax.yaxis.set_major_formatter(FormatStrFormatter('<STR_LIT>'))<EOL>ax.zaxis.set_major_formatter(FormatStrFormatter('<STR_LIT>'))<EOL>ax.xaxis.set_major_formatter(FormatStrFormatter('<STR_LIT>'))<EOL>ax.set_xlabel('<STR_LIT>')<EOL>ax.set_ylabel('<STR_LIT>')<EOL>ax.set_zlabel(self.name + '<STR_LIT:U+002CU+0020>' + self.units)<EOL>plt.title(self.name + '<STR_LIT>' + self.CASRN)<EOL>plt.show(block=False)<EOL>ax.legend(handles, methods_P)<EOL>plt.show(block=False)<EOL>

r'''Method to create a plot of the property vs temperature and pressure
        according to either a specified list of methods, or user methods (if
        set), or all methods. User-selectable number of points for each
        variable. If only_valid is set,`test_method_validity_P` will be used to
        check if each condition in the specified range is valid, and
        `test_property_validity` will be used to test the answer, and the
        method is allowed to fail; only the valid points will be plotted.
        Otherwise, the result will be calculated and displayed as-is. This will
        not suceed if the any method fails for any point.

        Parameters
        ----------
        Tmin : float
            Minimum temperature, to begin calculating the property, [K]
        Tmax : float
            Maximum temperature, to stop calculating the property, [K]
        Pmin : float
            Minimum pressure, to begin calculating the property, [Pa]
        Pmax : float
            Maximum pressure, to stop calculating the property, [Pa]
        methods_P : list, optional
            List of methods to consider
        pts : int, optional
            A list of points to calculate the property at for both temperature
            and pressure; pts^2 points will be calculated.
        only_valid : bool
            If True, only plot successful methods and calculated properties,
            and handle errors; if False, attempt calculation without any
            checking and use methods outside their bounds


def plot_property(self, zs, ws, Tmin=None, Tmax=None, Pmin=<NUM_LIT>, Pmax=<NUM_LIT>, <EOL>methods=[], pts=<NUM_LIT:15>, only_valid=True):

if not has_matplotlib:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>from mpl_toolkits.mplot3d import axes3d<EOL>from matplotlib.ticker import FormatStrFormatter<EOL>import numpy.ma as ma<EOL>if Pmin is None:<EOL><INDENT>if self.Pmin is not None:<EOL><INDENT>Pmin = self.Pmin<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if Pmax is None:<EOL><INDENT>if self.Pmax is not None:<EOL><INDENT>Pmax = self.Pmax<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if Tmin is None:<EOL><INDENT>if self.Tmin is not None:<EOL><INDENT>Tmin = self.Tmin<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if Tmax is None:<EOL><INDENT>if self.Tmax is not None:<EOL><INDENT>Tmax = self.Tmax<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if not methods:<EOL><INDENT>methods = self.user_methods if self.user_methods else self.all_methods<EOL><DEDENT>Ps = np.linspace(Pmin, Pmax, pts)<EOL>Ts = np.linspace(Tmin, Tmax, pts)<EOL>Ts_mesh, Ps_mesh = np.meshgrid(Ts, Ps)<EOL>fig = plt.figure()<EOL>ax = fig.gca(projection='<STR_LIT>')<EOL>handles = []<EOL>for method in methods:<EOL><INDENT>if only_valid:<EOL><INDENT>properties = []<EOL>for T in Ts:<EOL><INDENT>T_props = []<EOL>for P in Ps:<EOL><INDENT>if self.test_method_validity(T, P, zs, ws, method):<EOL><INDENT>try:<EOL><INDENT>p = self.calculate(T, P, zs, ws, method)<EOL>if self.test_property_validity(p):<EOL><INDENT>T_props.append(p)<EOL><DEDENT>else:<EOL><INDENT>T_props.append(None)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>T_props.append(None)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>T_props.append(None)<EOL><DEDENT><DEDENT>properties.append(T_props)<EOL><DEDENT>properties = ma.masked_invalid(np.array(properties, dtype=np.float).T)<EOL>handles.append(ax.plot_surface(Ts_mesh, Ps_mesh, properties, cstride=<NUM_LIT:1>, rstride=<NUM_LIT:1>, alpha=<NUM_LIT:0.5>))<EOL><DEDENT>else:<EOL><INDENT>properties = [[self.calculate(T, P, zs, ws, method) for P in Ps] for T in Ts]<EOL>handles.append(ax.plot_surface(Ts_mesh, Ps_mesh, properties, cstride=<NUM_LIT:1>, rstride=<NUM_LIT:1>, alpha=<NUM_LIT:0.5>))<EOL><DEDENT><DEDENT>ax.yaxis.set_major_formatter(FormatStrFormatter('<STR_LIT>'))<EOL>ax.zaxis.set_major_formatter(FormatStrFormatter('<STR_LIT>'))<EOL>ax.xaxis.set_major_formatter(FormatStrFormatter('<STR_LIT>'))<EOL>ax.set_xlabel('<STR_LIT>')<EOL>ax.set_ylabel('<STR_LIT>')<EOL>ax.set_zlabel(self.name + '<STR_LIT:U+002CU+0020>' + self.units)<EOL>plt.title(self.name + '<STR_LIT>' + '<STR_LIT:U+002CU+0020>'.join(self.CASs) <EOL>+ '<STR_LIT>' + '<STR_LIT:U+002CU+0020>'.join(str(round(i, <NUM_LIT:4>)) for i in zs) + '<STR_LIT:.>')<EOL>plt.show(block=False)<EOL>ax.legend(handles, methods)<EOL>plt.show(block=False)<EOL>

r'''Method to create a plot of the property vs temperature and pressure
        according to either a specified list of methods, or user methods (if
        set), or all methods. User-selectable number of points for each
        variable. If only_valid is set,`test_method_validity` will be used to
        check if each condition in the specified range is valid, and
        `test_property_validity` will be used to test the answer, and the
        method is allowed to fail; only the valid points will be plotted.
        Otherwise, the result will be calculated and displayed as-is. This will
        not suceed if the any method fails for any point.

        Parameters
        ----------
        Tmin : float
            Minimum temperature, to begin calculating the property, [K]
        Tmax : float
            Maximum temperature, to stop calculating the property, [K]
        Pmin : float
            Minimum pressure, to begin calculating the property, [Pa]
        Pmax : float
            Maximum pressure, to stop calculating the property, [Pa]
        methods : list, optional
            List of methods to consider
        pts : int, optional
            A list of points to calculate the property at for both temperature
            and pressure; pts^2 points will be calculated.
        only_valid : bool
            If True, only plot successful methods and calculated properties,
            and handle errors; if False, attempt calculation without any
            checking and use methods outside their bounds


return -dV_dP/V<EOL>

r'''Calculate the isothermal coefficient of a compressibility, given its
    molar volume at a certain `T` and `P`, and its derivative of molar volume
    with respect to `P`.

    .. math::
        \kappa = -\frac{1}{V}\left(\frac{\partial V}{\partial P} \right)_T

    Parameters
    ----------
    V : float
        Molar volume at `T` and `P`, [m^3/mol]
    dV_dP : float
        Derivative of molar volume with respect to `P`, [m^3/mol/Pa]

    Returns
    -------
    kappa : float
        Isothermal coefficient of a compressibility, [1/Pa]

    Notes
    -----
    For an ideal gas, this expression simplified to:

    .. math::
        \kappa = \frac{1}{P}

    Examples
    --------
    Calculated for hexane from the PR EOS at 299 K and 1 MPa (liquid):

    >>> isothermal_compressibility(0.000130229900873546, -2.72902118209903e-13)
    2.095541165119158e-09

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.


tot = <NUM_LIT:0><EOL>for c in coeffs:<EOL><INDENT>tot = tot * x + c<EOL><DEDENT>return tot<EOL>

r'''Simple function to calculate the value of a polynomial at a specific
    value of `x`, using the Horner evaluation scheme

    Parameters
    ----------
    coeffs : array-like
        Coefficients, where coeffs[0] is multiplied by the largest power of x,
        and coeffs[-1] is added to the sum with no multiplication.
    x : float
        Value to evaluate the polynomial at

    Returns
    -------
    y : float
        Evaluated result

    Notes
    -----
    Efficient. Faster than numpy.polyval.

    Examples
    --------
    >>> horner([1,2,3], 3)
    18


def mixture_property(self, T, P, zs, ws):

<EOL>if self.method:<EOL><INDENT>if self.test_method_validity(T, P, zs, ws, self.method):<EOL><INDENT>try:<EOL><INDENT>prop = self.calculate(T, P, zs, ws, self.method)<EOL>if self.test_property_validity(prop):<EOL><INDENT>return prop<EOL><DEDENT><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>self.sorted_valid_methods = self.select_valid_methods(T, P, zs, ws)<EOL>for method in self.sorted_valid_methods:<EOL><INDENT>try:<EOL><INDENT>prop = self.calculate(T, P, zs, ws, method)<EOL>if self.test_property_validity(prop):<EOL><INDENT>self.method = method<EOL>return prop<EOL><DEDENT><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to calculate the property with sanity checking and without
        specifying a specific method. `select_valid_methods` is used to obtain
        a sorted list of methods to try. Methods are then tried in order until
        one succeeds. The methods are allowed to fail, and their results are
        checked with `test_property_validity`. On success, the used method
        is stored in the variable `method`.

        If `method` is set, this method is first checked for validity with
        `test_method_validity` for the specified temperature, and if it is
        valid, it is then used to calculate the property. The result is checked
        for validity, and returned if it is valid. If either of the checks fail,
        the function retrieves a full list of valid methods with
        `select_valid_methods` and attempts them as described above.

        If no methods are found which succeed, returns None.

        Parameters
        ----------
        T : float
            Temperature at which to calculate the property, [K]
        P : float
            Pressure at which to calculate the property, [Pa]
        zs : list[float]
            Mole fractions of all species in the mixture, [-]
        ws : list[float]
            Weight fractions of all species in the mixture, [-]

        Returns
        -------
        prop : float
            Calculated property, [`units`]


def set_tabular_data(self, Ts, properties, name=None, check_properties=True):

<EOL>if check_properties:<EOL><INDENT>for p in properties:<EOL><INDENT>if not self.test_property_validity(p):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>if not all(b > a for a, b in zip(Ts, Ts[<NUM_LIT:1>:])):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if name is None:<EOL><INDENT>name = '<STR_LIT>' + str(len(self.tabular_data))  <EOL><DEDENT>self.tabular_data[name] = (Ts, properties)<EOL>self.method = None<EOL>self.user_methods.insert(<NUM_LIT:0>, name)<EOL>self.all_methods.add(name)<EOL>self.set_user_methods(user_methods=self.user_methods, forced=self.forced)<EOL>

r'''Method to set tabular data to be used for interpolation.
        Ts must be in increasing order. If no name is given, data will be
        assigned the name 'Tabular data series #x', where x is the number of
        previously added tabular data series. The name is added to all
        methods and iserted at the start of user methods,

        Parameters
        ----------
        Ts : array-like
            Increasing array of temperatures at which properties are specified, [K]
        properties : array-like
            List of properties at Ts, [`units`]
        name : str, optional
            Name assigned to the data
        check_properties : bool
            If True, the properties will be checked for validity with
            `test_property_validity` and raise an exception if any are not
            valid


def phase_identification_parameter(V, dP_dT, dP_dV, d2P_dV2, d2P_dVdT):

return V*(d2P_dVdT/dP_dT - d2P_dV2/dP_dV)<EOL>

r'''Calculate the Phase Identification Parameter developed in [1]_ for
    the accurate and efficient determination of whether a fluid is a liquid or
    a gas based on the results of an equation of state. For supercritical
    conditions, this provides a good method for choosing which property
    correlations to use.

    .. math::
        \Pi = V \left[\frac{\frac{\partial^2 P}{\partial V \partial T}}
        {\frac{\partial P }{\partial T}}- \frac{\frac{\partial^2 P}{\partial
        V^2}}{\frac{\partial P}{\partial V}} \right]

    Parameters
    ----------
    V : float
        Molar volume at `T` and `P`, [m^3/mol]
    dP_dT : float
        Derivative of `P` with respect to `T`, [Pa/K]
    dP_dV : float
        Derivative of `P` with respect to `V`, [Pa*mol/m^3]
    d2P_dV2 : float
        Second derivative of `P` with respect to `V`, [Pa*mol^2/m^6]
    d2P_dVdT : float
        Second derivative of `P` with respect to both `V` and `T`, [Pa*mol/m^3/K]

    Returns
    -------
    PIP : float
        Phase Identification Parameter, [-]

    Notes
    -----
    Heuristics were used by process simulators before the invent of this
    parameter.

    The criteria for liquid is Pi > 1; for vapor, Pi <= 1.

    There is also a solid phase mechanism available. For solids, the Solid
    Phase Identification Parameter is greater than 1, like liquids; however,
    unlike liquids, d2P_dVdT is always >0; it is < 0 for liquids and gases.

    Examples
    --------
    Calculated for hexane from the PR EOS at 299 K and 1 MPa (liquid):

    >>> phase_identification_parameter(0.000130229900874, 582169.397484,
    ... -3.66431747236e+12, 4.48067893805e+17, -20518995218.2)
    11.33428990564796

    References
    ----------
    .. [1] Venkatarathnam, G., and L. R. Oellrich. "Identification of the Phase
       of a Fluid Using Partial Derivatives of Pressure, Volume, and
       Temperature without Reference to Saturation Properties: Applications in
       Phase Equilibria Calculations." Fluid Phase Equilibria 301, no. 2
       (February 25, 2011): 225-33. doi:10.1016/j.fluid.2010.12.001.
    .. [2] Jayanti, Pranava Chaitanya, and G. Venkatarathnam. "Identification
       of the Phase of a Substance from the Derivatives of Pressure, Volume and
       Temperature, without Prior Knowledge of Saturation Properties: Extension
       to Solid Phase." Fluid Phase Equilibria 425 (October 15, 2016): 269-277.
       doi:10.1016/j.fluid.2016.06.001.


def set_user_methods(self, user_methods, forced=False):

<EOL>if isinstance(user_methods, str):<EOL><INDENT>user_methods = [user_methods]<EOL><DEDENT>self.user_methods = user_methods<EOL>self.forced = forced<EOL>if set(self.user_methods).difference(self.all_methods):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if not self.user_methods and self.forced:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>self.method = None<EOL>self.sorted_valid_methods = []<EOL>self.T_cached = None<EOL>

r'''Method used to select certain property methods as having a higher
        priority than were set by default. If `forced` is true, then methods
        which were not specified are excluded from consideration.

        As a side effect, `method` is removed to ensure than the new methods
        will be used in calculations afterwards.

        An exception is raised if any of the methods specified aren't available
        for the chemical. An exception is raised if no methods are provided.

        Parameters
        ----------
        user_methods : str or list
            Methods by name to be considered or prefered
        forced : bool, optional
            If True, only the user specified methods will ever be considered;
            if False other methods will be considered if no user methods
            suceed


return rho/rho_ref<EOL>

r'''Calculates the specific gravity of a substance with respect to another
    substance; by default, this is water at 15.6 °C (60 °F). For gases,
    normally the reference density is 1.2 kg/m^3, that of dry air. However, in
    general specific gravity should always be specified with respect to the
    temperature and pressure of its reference fluid. This can vary widely.

    .. math::
        SG = \frac{\rho}{\rho_{ref}}

    Parameters
    ----------
    rho : float
        Density of the substance, [kg/m^3]
    rho_ref : float, optional
        Density of the reference substance, [kg/m^3]

    Returns
    -------
    SG : float
        Specific gravity of the substance with respect to the reference
        density, [-]

    Notes
    -----
    Another common reference point is water at 4°C (rho_ref=999.9748691393087).
    Specific gravity is often used by consumers instead of density.
    The reference for solids is normally the same as for liquids - water.

    Examples
    --------
    >>> SG(860)
    0.8608461408159591


key = (name, self.interpolation_T, self.interpolation_property, self.interpolation_property_inv)<EOL><INDENT>if isinstance(self.tabular_data_interpolators, dict) and key in self.tabular_data_interpolators:<EOL><INDENT>extrapolator, spline = self.tabular_data_interpolators[key]<EOL><DEDENT><DEDENT>if key in self.tabular_data_interpolators:<EOL><INDENT>extrapolator, spline = self.tabular_data_interpolators[key]<EOL><DEDENT>else:<EOL><INDENT>Ts, properties = self.tabular_data[name]<EOL>if self.interpolation_T:  <EOL><INDENT>Ts2 = [self.interpolation_T(T2) for T2 in Ts]<EOL><DEDENT>else:<EOL><INDENT>Ts2 = Ts<EOL><DEDENT>if self.interpolation_property:  <EOL><INDENT>properties2 = [self.interpolation_property(p) for p in properties]<EOL><DEDENT>else:<EOL><INDENT>properties2 = properties<EOL><DEDENT>extrapolator = interp1d(Ts2, properties2, fill_value='<STR_LIT>')<EOL>if len(properties) >= <NUM_LIT:5>:<EOL><INDENT>spline = interp1d(Ts2, properties2, kind='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>spline = None<EOL>

r'''Method to perform interpolation on a given tabular data set
        previously added via :obj:`set_tabular_data`. This method will create the
        interpolators the first time it is used on a property set, and store
        them for quick future use.

        Interpolation is cubic-spline based if 5 or more points are available,
        and linearly interpolated if not. Extrapolation is always performed
        linearly. This function uses the transforms `interpolation_T`,
        `interpolation_property`, and `interpolation_property_inv` if set. If
        any of these are changed after the interpolators were first created,
        new interpolators are created with the new transforms.
        All interpolation is performed via the `interp1d` function.

        Parameters
        ----------
        T : float
            Temperature at which to interpolate the property, [K]
        name : str
            The name assigned to the tabular data set

        Returns
        -------
        prop : float
            Calculated property, [`units`]


for i in range(len(values)):<EOL><INDENT>try:<EOL><INDENT>values[i] = float(values[i])<EOL><DEDENT>except:<EOL><INDENT>if values[i] == '<STR_LIT>':<EOL><INDENT>values[i] = None<EOL><DEDENT>else:<EOL><INDENT>values[i] = values[i].strip()<EOL>pass<EOL><DEDENT><DEDENT><DEDENT>return values<EOL>

r'''Legacy function to turn a list of strings into either floats
    (if numeric), stripped strings (if not) or None if the string is empty.
    Accepts any numeric formatting the float function does.

    Parameters
    ----------
    values : list
        list of strings

    Returns
    -------
    values : list
        list of floats, strings, and None values [-]

    Examples
    --------
    >>> to_num(['1', '1.1', '1E5', '0xB4', ''])
    [1.0, 1.1, 100000.0, '0xB4', None]


<EOL>if self.method:<EOL><INDENT>if self.test_method_validity(T, self.method):<EOL><INDENT>try:<EOL><INDENT>prop = self.calculate(T, self.method)<EOL>if self.test_property_validity(prop):<EOL><INDENT>return prop<EOL><DEDENT><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>self.sorted_valid_methods = self.select_valid_methods(T)<EOL>for method in self.sorted_valid_methods:<EOL><INDENT>try:<EOL><INDENT>prop = self.calculate(T, method)<EOL>if self.test_property_validity(prop):<EOL><INDENT>self.method = method<EOL>return prop<EOL><DEDENT><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to calculate the property with sanity checking and without
        specifying a specific method. `select_valid_methods` is used to obtain
        a sorted list of methods to try. Methods are then tried in order until
        one succeeds. The methods are allowed to fail, and their results are
        checked with `test_property_validity`. On success, the used method
        is stored in the variable `method`.

        If `method` is set, this method is first checked for validity with
        `test_method_validity` for the specified temperature, and if it is
        valid, it is then used to calculate the property. The result is checked
        for validity, and returned if it is valid. If either of the checks fail,
        the function retrieves a full list of valid methods with
        `select_valid_methods` and attempts them as described above.

        If no methods are found which succeed, returns None.

        Parameters
        ----------
        T : float
            Temperature at which to calculate the property, [K]

        Returns
        -------
        prop : float
            Calculated property, [`units`]


def property_derivative_P(self, T, P, zs, ws, order=<NUM_LIT:1>):

sorted_valid_methods = self.select_valid_methods(T, P, zs, ws)<EOL>for method in sorted_valid_methods:<EOL><INDENT>try:<EOL><INDENT>return self.calculate_derivative_P(P, T, zs, ws, method, order)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to calculate a derivative of a mixture property with respect
        to pressure at constant temperature and composition,
        of a given order. Methods found valid by `select_valid_methods` are
        attempted until a method succeeds. If no methods are valid and succeed,
        None is returned.

        Calls `calculate_derivative_P` internally to perform the actual
        calculation.

        .. math::
            \text{derivative} = \frac{d (\text{property})}{d P}|_{T, z}

        Parameters
        ----------
        T : float
            Temperature at which to calculate the derivative, [K]
        P : float
            Pressure at which to calculate the derivative, [Pa]
        zs : list[float]
            Mole fractions of all species in the mixture, [-]
        ws : list[float]
            Weight fractions of all species in the mixture, [-]
        order : int
            Order of the derivative, >= 1

        Returns
        -------
        d_prop_d_P_at_T : float
            Calculated derivative property, [`units/Pa^order`]


def property_derivative_T(self, T, P, zs, ws, order=<NUM_LIT:1>):

sorted_valid_methods = self.select_valid_methods(T, P, zs, ws)<EOL>for method in sorted_valid_methods:<EOL><INDENT>try:<EOL><INDENT>return self.calculate_derivative_T(T, P, zs, ws, method, order)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to calculate a derivative of a mixture property with respect
        to temperature at constant pressure and composition,
        of a given order. Methods found valid by `select_valid_methods` are
        attempted until a method succeeds. If no methods are valid and succeed,
        None is returned.

        Calls `calculate_derivative_T` internally to perform the actual
        calculation.

        .. math::
            \text{derivative} = \frac{d (\text{property})}{d T}|_{P, z}

        Parameters
        ----------
        T : float
            Temperature at which to calculate the derivative, [K]
        P : float
            Pressure at which to calculate the derivative, [Pa]
        zs : list[float]
            Mole fractions of all species in the mixture, [-]
        ws : list[float]
            Weight fractions of all species in the mixture, [-]
        order : int
            Order of the derivative, >= 1

        Returns
        -------
        d_prop_d_T_at_P : float
            Calculated derivative property, [`units/K^order`]


mols_i = [Vfi/Vmi for Vfi, Vmi in zip(Vfs, Vms)]<EOL>mols = sum(mols_i)<EOL>return [mol_i/mols for mol_i in mols_i]<EOL>

r'''Converts a list of mass fractions to mole fractions. Requires molecular
    weights for all species.

    .. math::
        z_i = \frac{\frac{\text{Vf}_i}{V_{m,i}}}{\sum_i
        \frac{\text{Vf}_i}{V_{m,i}}}

    Parameters
    ----------
    Vfs : iterable
        Molar volume fractions [-]
    VMs : iterable
        Molar volumes of species [m^3/mol]

    Returns
    -------
    zs : list
        Mole fractions [-]

    Notes
    -----
    Does not check that the sums add to one. Does not check that inputs are of
    the same length.

    Molar volumes are specified in terms of pure components only. Function
    works with any phase.

    Examples
    --------
    Acetone and benzene example

    >>> Vfs_to_zs([0.596, 0.404], [8.0234e-05, 9.543e-05])
    [0.6369779395901142, 0.3630220604098858]


if <NUM_LIT:0> <= x <= <NUM_LIT>:<EOL><INDENT>p = [<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>q = [-<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT:1.0>]<EOL>offset = <NUM_LIT><EOL><DEDENT>elif <NUM_LIT> < x <= <NUM_LIT>:<EOL><INDENT>p = [<NUM_LIT>, -<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>]<EOL>q = [-<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT:1.0>]<EOL>offset = <NUM_LIT><EOL><DEDENT>elif <NUM_LIT> < x <= <NUM_LIT:1>:<EOL><INDENT>p = [<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>]<EOL>q = [-<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, <NUM_LIT:1.0>]<EOL>offset = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>x = x - offset<EOL>return horner(p, x)/horner(q, x)<EOL>

r'''Simple function to calculate PolyLog(2, x) from ranges 0 <= x <= 1,
    with relative error guaranteed to be < 1E-7 from 0 to 0.99999. This
    is a Pade approximation, with three coefficient sets with splits at 0.7
    and 0.99. An exception is raised if x is under 0 or above 1.

    Parameters
    ----------
    x : float
        Value to evaluate PolyLog(2, x) T

    Returns
    -------
    y : float
        Evaluated result

    Notes
    -----
    Efficient (2-4 microseconds). No implementation of this function exists in
    SciPy. Derived with mpmath's pade approximation.
    Required for the entropy integral of
    :obj:`thermo.heat_capacity.Zabransky_quasi_polynomial`.

    Examples
    --------
    >>> polylog2(0.5)
    0.5822405264516294


return (Vm)**-<NUM_LIT:1>*MW/<NUM_LIT><EOL>

r'''Calculate the density of a chemical, given its molar volume and
    molecular weight.

    .. math::
        \rho = \frac{MW}{1000\cdot VM}

    Parameters
    ----------
    Vm : float
        Molar volume, [m^3/mol]
    MW : float
        Molecular weight, [g/mol]

    Returns
    -------
    rho : float
        Density, [kg/m^3]

    Examples
    --------
    >>> Vm_to_rho(0.000132, 86.18)
    652.8787878787879

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.


tot = sum(w/MW for w, MW in zip(ws, MWs))<EOL>zs = [w/MW/tot for w, MW in zip(ws, MWs)]<EOL>return zs<EOL>

r'''Converts a list of mass fractions to mole fractions. Requires molecular
    weights for all species.

    .. math::
        z_i = \frac{\frac{w_i}{MW_i}}{\sum_i \frac{w_i}{MW_i}}

    Parameters
    ----------
    ws : iterable
        Mass fractions [-]
    MWs : iterable
        Molecular weights [g/mol]

    Returns
    -------
    zs : iterable
        Mole fractions [-]

    Notes
    -----
    Does not check that the sums add to one. Does not check that inputs are of
    the same length.

    Examples
    --------
    >>> ws_to_zs([0.3333333333333333, 0.6666666666666666], [10, 20])
    [0.5, 0.5]


def TP_dependent_property_derivative_T(self, T, P, order=<NUM_LIT:1>):

sorted_valid_methods_P = self.select_valid_methods_P(T, P)<EOL>for method in sorted_valid_methods_P:<EOL><INDENT>try:<EOL><INDENT>return self.calculate_derivative_T(T, P, method, order)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return None<EOL>

r'''Method to calculate a derivative of a temperature and pressure
        dependent property with respect to temperature at constant pressure,
        of a given order. Methods found valid by `select_valid_methods_P` are
        attempted until a method succeeds. If no methods are valid and succeed,
        None is returned.

        Calls `calculate_derivative_T` internally to perform the actual
        calculation.

        .. math::
            \text{derivative} = \frac{d (\text{property})}{d T}|_{P}

        Parameters
        ----------
        T : float
            Temperature at which to calculate the derivative, [K]
        P : float
            Pressure at which to calculate the derivative, [Pa]
        order : int
            Order of the derivative, >= 1

        Returns
        -------
        d_prop_d_T_at_P : float
            Calculated derivative property, [`units/K^order`]


return V*P/T/R<EOL>

r'''Calculates the compressibility factor of a gas, given its
    temperature, pressure, and molar volume.

    .. math::
        Z = \frac{PV}{RT}

    Parameters
    ----------
    T : float
        Temperature, [K]
    P : float
        Pressure [Pa]
    V : float
        Molar volume, [m^3/mol]

    Returns
    -------
    Z : float
        Compressibility factor, [-]

    Examples
    --------
    >>> Z(600, P=1E6, V=0.00463)
    0.9281019876560912

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.


def plot_isobar(self, P, Tmin=None, Tmax=None, methods_P=[], pts=<NUM_LIT:50>,<EOL>only_valid=True):

if not has_matplotlib:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if Tmin is None:<EOL><INDENT>if self.Tmin is not None:<EOL><INDENT>Tmin = self.Tmin<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if Tmax is None:<EOL><INDENT>if self.Tmax is not None:<EOL><INDENT>Tmax = self.Tmax<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if not methods_P:<EOL><INDENT>if self.user_methods_P:<EOL><INDENT>methods_P = self.user_methods_P<EOL><DEDENT>else:<EOL><INDENT>methods_P = self.all_methods_P<EOL><DEDENT><DEDENT>Ts = np.linspace(Tmin, Tmax, pts)<EOL>for method_P in methods_P:<EOL><INDENT>if only_valid:<EOL><INDENT>properties, Ts2 = [], []<EOL>for T in Ts:<EOL><INDENT>if self.test_method_validity_P(T, P, method_P):<EOL><INDENT>try:<EOL><INDENT>p = self.calculate_P(T, P, method_P)<EOL>if self.test_property_validity(p):<EOL><INDENT>properties.append(p)<EOL>Ts2.append(T)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>plt.plot(Ts2, properties, label=method_P)<EOL><DEDENT>else:<EOL><INDENT>properties = [self.calculate_P(T, P, method_P) for T in Ts]<EOL>plt.plot(Ts, properties, label=method_P)<EOL><DEDENT><DEDENT>plt.legend(loc='<STR_LIT>')<EOL>plt.ylabel(self.name + '<STR_LIT:U+002CU+0020>' + self.units)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.title(self.name + '<STR_LIT>' + self.CASRN)<EOL>plt.show()<EOL>

r'''Method to create a plot of the property vs temperature at a
        specific pressure according to
        either a specified list of methods, or user methods (if set), or all
        methods. User-selectable number of points, and temperature range. If
        only_valid is set,`test_method_validity_P` will be used to check if
        each condition in the specified range is valid, and
        `test_property_validity` will be used to test the answer, and the
        method is allowed to fail; only the valid points will be plotted.
        Otherwise, the result will be calculated and displayed as-is. This will
        not suceed if the method fails.

        Parameters
        ----------
        P : float
            Pressure for the isobar, [Pa]
        Tmin : float
            Minimum temperature, to begin calculating the property, [K]
        Tmax : float
            Maximum temperature, to stop calculating the property, [K]
        methods_P : list, optional
            List of methods to consider
        pts : int, optional
            A list of points to calculate the property at; if Tmin to Tmax
            covers a wide range of method validities, only a few points may end
            up calculated for a given method so this may need to be large
        only_valid : bool
            If True, only plot successful methods and calculated properties,
            and handle errors; if False, attempt calculation without any
            checking and use methods outside their bounds


Tbr = Tb/Tc<EOL>Tr = T/Tc<EOL>Pc = Pc/<NUM_LIT>  <EOL>Q = <NUM_LIT>*(<NUM_LIT:1> + Tbr*log(Pc/<NUM_LIT>)/(<NUM_LIT:1>-Tbr))-<NUM_LIT><EOL>sigma = (Pc)**(<NUM_LIT:2>/<NUM_LIT>)*Tc**(<NUM_LIT:1>/<NUM_LIT>)*Q*(<NUM_LIT:1>-Tr)**(<NUM_LIT:11>/<NUM_LIT>)<EOL>sigma = sigma/<NUM_LIT:1000>  <EOL>return sigma<EOL>

r'''Calculates air-water surface tension  using the [1]_
    emperical method. Old and tested.

    .. math::
        \sigma = P_c^{2/3}T_c^{1/3}Q(1-T_r)^{11/9}

        Q = 0.1196 \left[ 1 + \frac{T_{br}\ln (P_c/1.01325)}{1-T_{br}}\right]-0.279

    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]

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

    Notes
    -----
    Numerous arrangements of this equation are available.
    This is DIPPR Procedure 7A: Method for the Surface Tension of Pure,
    Nonpolar, Nonhydrocarbon Liquids
    The exact equation is not in the original paper.
    If the equation yields a negative result, return None.

    Examples
    --------
    p-dichloribenzene at 412.15 K, from DIPPR; value differs due to a slight
    difference in method.

    >>> Brock_Bird(412.15, 447.3, 685, 3.952E6)
    0.02208448325192495

    Chlorobenzene from Poling, as compared with a % error value at 293 K.

    >>> Brock_Bird(293.15, 404.75, 633.0, 4530000.0)
    0.032985686413713036

    References
    ----------
    .. [1] Brock, James R., and R. Byron Bird. "Surface Tension and the
       Principle of Corresponding States." AIChE Journal 1, no. 2
       (June 1, 1955): 174-77. doi:10.1002/aic.690010208


def Hakim_Steinberg_Stiel(T, Tc, Pc, omega, StielPolar=<NUM_LIT:0>):

Q = (<NUM_LIT> + <NUM_LIT>*omega - <NUM_LIT>*StielPolar - <NUM_LIT>*StielPolar**<NUM_LIT:2><EOL>- <NUM_LIT>*omega**<NUM_LIT:2> + <NUM_LIT>*StielPolar*omega)<EOL>m = (<NUM_LIT> + <NUM_LIT>*omega - <NUM_LIT>*StielPolar - <NUM_LIT>*StielPolar**<NUM_LIT:2><EOL>- <NUM_LIT>*omega**<NUM_LIT:2> + <NUM_LIT>*StielPolar*omega)<EOL>Tr = T/Tc<EOL>Pc = Pc/<NUM_LIT><EOL>sigma = Pc**(<NUM_LIT:2>/<NUM_LIT>)*Tc**(<NUM_LIT:1>/<NUM_LIT>)*Q*((<NUM_LIT:1> - Tr)/<NUM_LIT>)**m<EOL>sigma = sigma/<NUM_LIT>  <EOL>return sigma<EOL>

r'''Calculates air-water surface tension using the reference fluids methods
    of [1]_.

    .. math::
        \sigma = 4.60104\times 10^{-7} P_c^{2/3}T_c^{1/3}Q_p \left(\frac{1-T_r}{0.4}\right)^m

        Q_p = 0.1574+0.359\omega-1.769\chi-13.69\chi^2-0.51\omega^2+1.298\omega\chi

        m = 1.21+0.5385\omega-14.61\chi-32.07\chi^2-1.65\omega^2+22.03\omega\chi

    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, [-]
    StielPolar : float, optional
        Stiel Polar Factor, [-]

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

    Notes
    -----
    Original equation for m and Q are used. Internal units are atm and mN/m.

    Examples
    --------
    1-butanol, as compared to value in CRC Handbook of 0.02493.

    >>> Hakim_Steinberg_Stiel(298.15, 563.0, 4414000.0, 0.59, StielPolar=-0.07872)
    0.021907902575190447

    References
    ----------
    .. [1] Hakim, D. I., David Steinberg, and L. I. Stiel. "Generalized
       Relationship for the Surface Tension of Polar Fluids." Industrial &
       Engineering Chemistry Fundamentals 10, no. 1 (February 1, 1971): 174-75.
       doi:10.1021/i160037a032.


sigma = (a - b*(T-<NUM_LIT>))/<NUM_LIT:1000><EOL>return sigma<EOL>

r'''Calculates surface tension of a fluid given two parameters, a linear
    fit in Celcius from [1]_ with data reprinted in [2]_.

    .. math::
        \sigma = a - bT

    Parameters
    ----------
    T : float
        Temperature of fluid, [K]
    a : float
        Parameter for equation. Chemical specific.
    b : float
        Parameter for equation. Chemical specific.

    Returns
    -------
    sigma: float
        Surface tension [N/m]

    Notes
    -----
    Internal units are mN/m, and degrees Celcius.
    This function has been checked against several references.

    Examples
    --------
    >>> Jasper(298.15, 24, 0.0773)
    0.0220675

    References
    ----------
    .. [1] Jasper, Joseph J. "The Surface Tension of Pure Liquid Compounds."
       Journal of Physical and Chemical Reference Data 1, no. 4
       (October 1, 1972): 841-1010. doi:10.1063/1.3253106.
    .. [2] Speight, James. Lange's Handbook of Chemistry. 16 edition.
       McGraw-Hill Professional, 2005.


def Aleem(T, MW, Tb, rhol, Hvap_Tb, Cpl):

MW = MW/<NUM_LIT> <EOL>sphericity = <NUM_LIT:1.> - <NUM_LIT>*MW + <NUM_LIT>*MW*MW<EOL>return sphericity*MW**(<NUM_LIT:1>/<NUM_LIT>)/(<NUM_LIT>*N_A**(<NUM_LIT:1>/<NUM_LIT>))*rhol**(<NUM_LIT:2>/<NUM_LIT>)*(Hvap_Tb + Cpl*(Tb-T))<EOL>

r'''Calculates vapor-liquid surface tension using the correlation derived by
    [1]_ based on critical property CSP methods.

    .. math::
        \sigma = \phi \frac{MW^{1/3}} {6N_A^{1/3}}\rho_l^{2/3}\left[H_{vap}
        + C_{p,l}(T_b-T)\right]

        \phi = 1 - 0.0047MW + 6.8\times 10^{-6} MW^2

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    MW : float
        Molecular weight [g/mol]
    Tb : float
        Boiling temperature of the fluid [K]
    rhol : float
        Liquid density at T and P [kg/m^3]
    Hvap_Tb : float
        Mass enthalpy of vaporization at the normal boiling point [kg/m^3]
    Cpl : float
        Liquid heat capacity of the chemical at T [J/kg/K]

    Returns
    -------
    sigma : float
        Liquid-vapor surface tension [N/m]

    Notes
    -----
    Internal units of molecuar weight are kg/mol. This model is dimensionally
    consistent.

    This model does not use the critical temperature. After it predicts a
    surface tension of 0 at a sufficiently high temperature, it returns
    negative results. The temperature at which this occurs (the "predicted"
    critical temperature) can be calculated as follows:

    .. math::
        \sigma = 0 \to T_{c,predicted} \text{ at } T_b + \frac{H_{vap}}{Cp_l}

    Because of its dependence on density, it has the potential to model the
    effect of pressure on surface tension.

    Claims AAD of 4.3%. Developed for normal alkanes. Total of 472 data points.
    Behaves worse for higher alkanes. Behaves very poorly overall.

    Examples
    --------
    Methane at 90 K

    >>> Aleem(T=90, MW=16.04246, Tb=111.6, rhol=458.7, Hvap_Tb=510870.,
    ... Cpl=2465.)
    0.01669970221165325

    References
    ----------
    .. [1] Aleem, W., N. Mellon, S. Sufian, M. I. A. Mutalib, and D. Subbarao.
       "A Model for the Estimation of Surface Tension of Pure Hydrocarbon
       Liquids." Petroleum Science and Technology 33, no. 23-24 (December 17,
       2015): 1908-15. doi:10.1080/10916466.2015.1110593.


Vc = Vc*<NUM_LIT><EOL>t = <NUM_LIT:1.>-T/Tc<EOL>sigma = k*Tc*(N_A/Vc)**(<NUM_LIT:2>/<NUM_LIT>)*(<NUM_LIT> + <NUM_LIT>*omega)*t**<NUM_LIT>*(<NUM_LIT:1>+<NUM_LIT>*t**<NUM_LIT:0.5> - <NUM_LIT>*t)*<NUM_LIT><EOL>return sigma<EOL>

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.003474099603581931

    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.


Tr = T/Tc<EOL>Pc = Pc/<NUM_LIT>  <EOL>sigma = Pc**(<NUM_LIT:2>/<NUM_LIT>)*Tc**(<NUM_LIT:1>/<NUM_LIT>)*(<NUM_LIT>+<NUM_LIT>*omega)/<NUM_LIT> * (<EOL>(<NUM_LIT>+<NUM_LIT>*omega)/(<NUM_LIT>-<NUM_LIT>*omega))**(<NUM_LIT:2>/<NUM_LIT>)*(<NUM_LIT:1>-Tr)**(<NUM_LIT:11>/<NUM_LIT>)<EOL>sigma = sigma/<NUM_LIT:1000>  <EOL>return sigma<EOL>

r'''Calculates air-water surface tension using the correlation derived
    by [1]_ from the works of [2]_ and [3]_. Based on critical property CSP
    methods.

    .. math::
        \sigma = P_c^{2/3}T_c^{1/3}\frac{1.86 + 1.18\omega}{19.05}
        \left[ \frac{3.75 + 0.91 \omega}{0.291 - 0.08 \omega}\right]^{2/3} (1-T_r)^{11/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 for fluid, [-]

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

    Notes
    -----
    The source of this equation has not been reviewed.
    Internal units of presure are bar, surface tension of mN/m.

    Examples
    --------
    Chlorobenzene from Poling, as compared with a % error value at 293 K.

    >>> Pitzer(293., 633.0, 4530000.0, 0.249)
    0.03458453513446387

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.
    .. [2] Curl, R. F., and Kenneth Pitzer. "Volumetric and Thermodynamic
       Properties of Fluids-Enthalpy, Free Energy, and Entropy." Industrial &
       Engineering Chemistry 50, no. 2 (February 1, 1958): 265-74.
       doi:10.1021/ie50578a047
    .. [3] Pitzer, K. S.: Thermodynamics, 3d ed., New York, McGraw-Hill,
       1995, p. 521.


def Diguilio_Teja(T, xs, sigmas_Tb, Tbs, Tcs):

if not none_and_length_check([xs, sigmas_Tb, Tbs, Tcs]):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>Tc = mixing_simple(xs, Tcs)<EOL>if T > Tc:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>Tb = mixing_simple(xs, Tbs)<EOL>sigmar = mixing_simple(xs, sigmas_Tb)<EOL>Tst = (Tc/T - <NUM_LIT:1.>)/(Tc/Tb - <NUM_LIT:1>)<EOL>return <NUM_LIT>*Tst**<NUM_LIT>*(T/Tb)*sigmar<EOL>

r'''Calculates surface tension of a liquid mixture according to
    mixing rules in [1]_.

    .. math::
        \sigma = 1.002855(T^*)^{1.118091} \frac{T}{T_b} \sigma_r

        T^*  = \frac{(T_c/T)-1}{(T_c/T_b)-1}

        \sigma_r = \sum x_i \sigma_i

        T_b = \sum x_i T_{b,i}

        T_c = \sum x_i T_{c,i}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    xs : array-like
        Mole fractions of all components
    sigmas_Tb : array-like
        Surface tensions of all components at the boiling point, [N/m]
    Tbs : array-like
        Boiling temperatures of all components, [K]
    Tcs : array-like
        Critical temperatures of all components, [K]

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

    Notes
    -----
    Simple model, however it has 0 citations. Gives similar results to the
    `Winterfeld_Scriven_Davis` model.

    Raises a ValueError if temperature is greater than the mixture's critical
    temperature or if the given temperature is negative, or if the mixture's
    boiling temperature is higher than its critical temperature.

    [1]_ claims a 4.63 percent average absolute error on 21 binary and 4
    ternary non-aqueous systems. [1]_ also considered Van der Waals mixing
    rules for `Tc`, but found it provided a higher error of 5.58%

    Examples
    --------
    >>> Diguilio_Teja(T=298.15, xs=[0.1606, 0.8394],
    ... sigmas_Tb=[0.01424, 0.02530], Tbs=[309.21, 312.95], Tcs=[469.7, 508.0])
    0.025716823875045505

    References
    ----------
    .. [1] Diguilio, Ralph, and Amyn S. Teja. "Correlation and Prediction of
       the Surface Tensions of Mixtures." The Chemical Engineering Journal 38,
       no. 3 (July 1988): 205-8. doi:10.1016/0300-9467(88)80079-0.


def Mersmann_Kind_surface_tension(T, Tm, Tb, Tc, Pc, n_associated=<NUM_LIT:1>):

Tr = T/Tc<EOL>sigma_star = ((Tb - Tm)/Tm)**(<NUM_LIT:1>/<NUM_LIT>)*(<NUM_LIT>*(<NUM_LIT:1.> - Tr) + <NUM_LIT>*(<NUM_LIT:1.> - Tr)**(<NUM_LIT:4>/<NUM_LIT>))<EOL>sigma = sigma_star*(k*Tc)**(<NUM_LIT:1>/<NUM_LIT>)*(Tm/Tc)*Pc**(<NUM_LIT:2>/<NUM_LIT>)*n_associated**(-<NUM_LIT:1>/<NUM_LIT>)<EOL>return sigma<EOL>

r'''Estimates the surface tension of organic liquid substances
    according to the method of [1]_.

    .. math::
        \sigma^* = \frac{\sigma n_{ass}^{1/3}} {(kT_c)^{1/3} T_{rm}P_c^{2/3}}

        \sigma^* = \left(\frac{T_b - T_m}{T_m}\right)^{1/3}
        \left[6.25(1-T_r) + 31.3(1-T_r)^{4/3}\right]

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    Tm : float
        Melting temperature [K]
    Tb : float
        Boiling temperature of the fluid [K]
    Tc : float
        Critical temperature of the fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    n_associated : float
        Number of associated molecules in a cluster (2 for alcohols, 1
        otherwise), [-]

    Returns
    -------
    sigma : float
        Liquid-vapor surface tension [N/m]

    Notes
    -----
    In the equation, all quantities must be in SI units. `k` is the boltzman
    constant.

    Examples
    --------
    MTBE at STP (the actual value is 0.0181):

    >>> Mersmann_Kind_surface_tension(298.15, 164.15, 328.25, 497.1, 3430000.0)
    0.016744309508833335

    References
    ----------
    .. [1] Mersmann, Alfons, and Matthias Kind. "Prediction of Mechanical and
       Thermal Properties of Pure Liquids, of Critical Data, and of Vapor
       Pressure." Industrial & Engineering Chemistry Research, January 31,
       2017. https://doi.org/10.1021/acs.iecr.6b04323.


Tc_1, Pc_1, omega_1 = <NUM_LIT>, <NUM_LIT>/<NUM_LIT>, <NUM_LIT><EOL>Tc_2, Pc_2, omega_2 = <NUM_LIT>, <NUM_LIT>/<NUM_LIT>, <NUM_LIT><EOL>Pc = Pc/<NUM_LIT><EOL>def ST_r(ST, Tc, Pc):<EOL><INDENT>return log(<NUM_LIT:1> + ST/(Tc**(<NUM_LIT:1>/<NUM_LIT>)*Pc**(<NUM_LIT:2>/<NUM_LIT>)))<EOL><DEDENT>ST_1 = <NUM_LIT>*(<NUM_LIT:1> - T/Tc)**<NUM_LIT>  <EOL>ST_2 = <NUM_LIT>*(<NUM_LIT:1> - T/Tc)**<NUM_LIT>  <EOL>ST_r_1, ST_r_2 = ST_r(ST_1, Tc_1, Pc_1), ST_r(ST_2, Tc_2, Pc_2)<EOL>sigma_r = ST_r_1 + (omega-omega_1)/(omega_2 - omega_1)*(ST_r_2-ST_r_1)<EOL>sigma = Tc**(<NUM_LIT:1>/<NUM_LIT>)*Pc**(<NUM_LIT:2>/<NUM_LIT>)*(exp(sigma_r)-<NUM_LIT:1>)<EOL>sigma = sigma/<NUM_LIT:1000>  <EOL>return sigma<EOL>

r'''Calculates air-water surface tension using the reference fluids
    methods of [1]_.

    .. math::
        \sigma^{(1)} = 40.520(1-T_r)^{1.287}
        \sigma^{(2)} = 52.095(1-T_r)^{1.21548}
        \sigma_r = \sigma_r^{(1)}+ \frac{\omega - \omega^{(1)}}
        {\omega^{(2)}-\omega^{(1)}} (\sigma_r^{(2)}-\sigma_r^{(1)})
        \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


def EQ115(T, A, B, C=<NUM_LIT:0>, D=<NUM_LIT:0>, E=<NUM_LIT:0>):

return exp(A+B/T+C*log(T)+D*T**<NUM_LIT:2> + E/T**<NUM_LIT:2>)<EOL>

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\log 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 [-]

    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.

    References
    ----------
    .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
       DIPPR/AIChE


def EQ107(T, A=<NUM_LIT:0>, B=<NUM_LIT:0>, C=<NUM_LIT:0>, D=<NUM_LIT:0>, E=<NUM_LIT:0>, order=<NUM_LIT:0>):

if order == <NUM_LIT:0>:<EOL><INDENT>return A + B*((C/T)/sinh(C/T))**<NUM_LIT:2> + D*((E/T)/cosh(E/T))**<NUM_LIT:2><EOL><DEDENT>elif order == <NUM_LIT:1>:<EOL><INDENT>return (<NUM_LIT:2>*B*C**<NUM_LIT:3>*cosh(C/T)/(T**<NUM_LIT:4>*sinh(C/T)**<NUM_LIT:3>) <EOL>- <NUM_LIT:2>*B*C**<NUM_LIT:2>/(T**<NUM_LIT:3>*sinh(C/T)**<NUM_LIT:2>) <EOL>+ <NUM_LIT:2>*D*E**<NUM_LIT:3>*sinh(E/T)/(T**<NUM_LIT:4>*cosh(E/T)**<NUM_LIT:3>)<EOL>- <NUM_LIT:2>*D*E**<NUM_LIT:2>/(T**<NUM_LIT:3>*cosh(E/T)**<NUM_LIT:2>))<EOL><DEDENT>elif order == -<NUM_LIT:1>:<EOL><INDENT>return A*T + B*C/tanh(C/T) - D*E*tanh(E/T)<EOL><DEDENT>elif order == -<NUM_LIT>:<EOL><INDENT>return (A*log(T) + B*C/tanh(C/T)/T - B*log(sinh(C/T)) <EOL>- D*E*tanh(E/T)/T + D*log(cosh(E/T)))<EOL><DEDENT>else:<EOL><INDENT>raise Exception(order_not_found_msg)<EOL><DEDENT>

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.


def EQ104(T, A, B, C, D, E, order=<NUM_LIT:0>):

if order == <NUM_LIT:0>:<EOL><INDENT>T2 = T*T<EOL>return A + (B + (C + (D + E/T)/(T2*T2*T))/T2)/T<EOL><DEDENT>elif order == <NUM_LIT:1>:<EOL><INDENT>T2 = T*T<EOL>T4 = T2*T2<EOL>return (-B + (-<NUM_LIT:3>*C + (-<NUM_LIT:8>*D - <NUM_LIT:9>*E/T)/(T4*T))/T2)/T2<EOL><DEDENT>elif order == -<NUM_LIT:1>:<EOL><INDENT>return A*T + B*log(T) - (<NUM_LIT>*C*T**<NUM_LIT:6> + <NUM_LIT:8>*D*T + <NUM_LIT:7>*E)/(<NUM_LIT>*T**<NUM_LIT:8>)<EOL><DEDENT>elif order == -<NUM_LIT>:<EOL><INDENT>return A*log(T) - (<NUM_LIT>*B*T**<NUM_LIT:8> + <NUM_LIT>*C*T**<NUM_LIT:6> + <NUM_LIT:9>*D*T + <NUM_LIT:8>*E)/(<NUM_LIT>*T**<NUM_LIT:9>)<EOL><DEDENT>else:<EOL><INDENT>raise Exception(order_not_found_msg)<EOL><DEDENT>

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


def EQ100(T, A=<NUM_LIT:0>, B=<NUM_LIT:0>, C=<NUM_LIT:0>, D=<NUM_LIT:0>, E=<NUM_LIT:0>, F=<NUM_LIT:0>, G=<NUM_LIT:0>, order=<NUM_LIT:0>):

if order == <NUM_LIT:0>:<EOL><INDENT>return A + T*(B + T*(C + T*(D + T*(E + T*(F + G*T)))))<EOL><DEDENT>elif order == <NUM_LIT:1>:<EOL><INDENT>return B + T*(<NUM_LIT:2>*C + T*(<NUM_LIT:3>*D + T*(<NUM_LIT:4>*E + T*(<NUM_LIT:5>*F + <NUM_LIT:6>*G*T))))<EOL><DEDENT>elif order == -<NUM_LIT:1>:<EOL><INDENT>return T*(A + T*(B/<NUM_LIT:2> + T*(C/<NUM_LIT:3> + T*(D/<NUM_LIT:4> + T*(E/<NUM_LIT:5> + T*(F/<NUM_LIT:6> + G*T/<NUM_LIT:7>))))))<EOL><DEDENT>elif order == -<NUM_LIT>:<EOL><INDENT>return A*log(T) + T*(B + T*(C/<NUM_LIT:2> + T*(D/<NUM_LIT:3> + T*(E/<NUM_LIT:4> + T*(F/<NUM_LIT:5> + G*T/<NUM_LIT:6>)))))<EOL><DEDENT>else:<EOL><INDENT>raise Exception(order_not_found_msg)<EOL><DEDENT>

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


tot = <NUM_LIT:0.0><EOL>for group, count in counts.items():<EOL><INDENT>tot += joback_groups_id_dict[group].Hfus*count<EOL><DEDENT>Hfus = -<NUM_LIT> + tot<EOL>return Hfus*<NUM_LIT:1000><EOL>

r'''Estimates the enthalpy of fusion of an organic compound at its
        melting point using the Joback method as a function of chemical
        structure only.

        .. math::
            \Delta H_{fus} = -0.88 + \sum_i H_{fus,i}

        In the above equation, enthalpy of fusion is calculated in
        kJ/mol; it is converted to J/mol here.

        For 155 compounds tested by Joback, the absolute average error was
        485.2 cal/mol  and standard deviation was 661.4 cal/mol; the average
        relative error was 38.7%.

        Parameters
        ----------
        counts : dict
            Dictionary of Joback groups present (numerically indexed) and their
            counts, [-]

        Returns
        -------
        Hfus : float
            Estimated enthalpy of fusion of the compound at its melting point,
            [J/mol]

        Examples
        --------
        >>> Joback.Hfus({1: 2, 24: 1})
        5125.0


tot = <NUM_LIT:0.0><EOL>for group, count in counts.items():<EOL><INDENT>tot += joback_groups_id_dict[group].Hvap*count<EOL><DEDENT>Hvap = <NUM_LIT> + tot<EOL>return Hvap*<NUM_LIT:1000><EOL>

r'''Estimates the enthalpy of vaporization of an organic compound at
        its normal boiling point using the Joback method as a function of
        chemical structure only.

        .. math::
            \Delta H_{vap} = 15.30 + \sum_i H_{vap,i}

        In the above equation, enthalpy of fusion is calculated in
        kJ/mol; it is converted to J/mol here.

        For 368 compounds tested by Joback, the absolute average error was
        303.5 cal/mol  and standard deviation was 429 cal/mol; the average
        relative error was 3.88%.

        Parameters
        ----------
        counts : dict
            Dictionary of Joback groups present (numerically indexed) and their
            counts, [-]

        Returns
        -------
        Hvap : float
            Estimated enthalpy of vaporization of the compound at its normal
            boiling point, [J/mol]

        Examples
        --------
        >>> Joback.Hvap({1: 2, 24: 1})
        29018.0


def UNIFAC_psi(T, subgroup1, subgroup2, subgroup_data, interaction_data, <EOL>modified=False):

main1 = subgroup_data[subgroup1].main_group_id<EOL>main2 = subgroup_data[subgroup2].main_group_id<EOL>if modified:<EOL><INDENT>try:<EOL><INDENT>a, b, c = interaction_data[main1][main2]<EOL><DEDENT>except:<EOL><INDENT>return <NUM_LIT:1.><EOL><DEDENT>return exp((-a/T -b - c*T))<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>return exp(-interaction_data[main1][main2]/T)<EOL><DEDENT>except:<EOL><INDENT>return <NUM_LIT:1.><EOL><DEDENT><DEDENT>

r'''Calculates the interaction parameter psi(m, n) for two UNIFAC
    subgroups, given the system temperature, the UNIFAC subgroups considered
    for the variant of UNIFAC used, the interaction parameters for the
    variant of UNIFAC used, and whether or not the temperature dependence is
    modified from the original form, as shown below.

    Original temperature dependence:

    .. math::
        \Psi_{mn} = \exp\left(\frac{-a_{mn}}{T}\right)

    Modified temperature dependence:

    .. math::
        \Psi_{mn} = \exp\left(\frac{-a_{mn} - b_{mn}T - c_{mn}T^2}{T}\right)

    Parameters
    ----------
    T : float
        Temperature of the system, [K]
    subgroup1 : int
        First UNIFAC subgroup for identifier, [-]
    subgroup2 : int
        Second UNIFAC subgroup for identifier, [-]
    subgroup_data : dict[UNIFAC_subgroup]
        Normally provided as inputs to `UNIFAC`.
    interaction_data : dict[dict[tuple(a_mn, b_mn, c_mn)]]
        Normally provided as inputs to `UNIFAC`.
    modified : bool
        True if the modified temperature dependence is used by the interaction
        parameters, otherwise False

    Returns
    -------
    psi : float
        UNIFAC interaction parameter term, [-]

    Notes
    -----
    UNIFAC interaction parameters are asymmetric. No warning is raised if an
    interaction parameter is missing.

    Examples
    --------
    >>> from thermo.unifac import UFSG, UFIP, DOUFSG, DOUFIP2006

    >>> UNIFAC_psi(307, 18, 1, UFSG, UFIP)
    0.9165248264184787

    >>> UNIFAC_psi(373.15, 9, 78, DOUFSG, DOUFIP2006, modified=True)
    1.3703140538273264

    References
    ----------
    .. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
       Weinheim, Germany: Wiley-VCH, 2012.
    .. [2] Fredenslund, Aage, Russell L. Jones, and John M. Prausnitz. "Group
       Contribution Estimation of Activity Coefficients in Nonideal Liquid
       Mixtures." AIChE Journal 21, no. 6 (November 1, 1975): 1086-99.
       doi:10.1002/aic.690210607.


return R*<NUM_LIT><EOL>

r'''Calculates a species Van der Waals molar volume with the UNIFAC method,
    given a species's R parameter.

    .. math::
        V_{wk} = 15.17R_k

    Parameters
    ----------
    R : float
        R UNIFAC parameter (normalized Van der Waals Volume)  [-]

    Returns
    -------
    V_vdw : float
        Unnormalized Van der Waals volume, [m^3/mol]

    Notes
    -----
    The volume was originally given in cm^3/mol, but is converted to SI here.

    Examples
    --------
    >>> Van_der_Waals_volume(4.4998)
    6.826196599999999e-05

    References
    ----------
    .. [1] Wei, James, Morton M. Denn, John H. Seinfeld, Arup Chakraborty,
       Jackie Ying, Nicholas Peppas, and George Stephanopoulos. Molecular
       Modeling and Theory in Chemical Engineering. Academic Press, 2001.


return sum([zi*ci for zi, ci in zip(self.zs, self.charges)])<EOL>

r'''Charge imbalance of the mixture, in units of [faraday].
        Mixtures meeting the electroneutrality condition will have an imbalance
        of 0.

        Examples
        --------
        >>> Mixture(['Na+', 'Cl-', 'water'], zs=[.01, .01, .98]).charge_balance
        0.0


return [i.Vms for i in self.Chemicals]<EOL>

r'''Pure component solid-phase molar volumes of the chemicals in the
        mixture at its current temperature, in units of [m^3/mol].

        Examples
        --------
        >>> Mixture(['iron'], ws=[1], T=320).Vmss
        [7.09593392630242e-06]


Cplm = self.HeatCapacityLiquidMixture(self.T, self.P, self.zs, self.ws)<EOL>if Cplm:<EOL><INDENT>return property_molar_to_mass(Cplm, self.MW)<EOL><DEDENT>return None<EOL>

r'''Liquid-phase heat capacity of the mixture at its current
        temperature and composition, in units of [J/kg/K]. For calculation of
        this property at other temperatures or compositions, or specifying
        manually the method used to calculate it, and more - see the object
        oriented interface :obj:`thermo.heat_capacity.HeatCapacityLiquidMixture`;
        each Mixture instance creates one to actually perform the calculations.
        Note that that interface provides output in molar units.

        Examples
        --------
        >>> Mixture(['water', 'sodium chloride'], ws=[.9, .1], T=301.5).Cpl
        3735.4604049449786


Vmg = self.Vmg<EOL>if Vmg:<EOL><INDENT>return <NUM_LIT:1.>/Vmg<EOL><DEDENT>return None<EOL>

r'''Molar density of the mixture in the gas phase at the
        current temperature, pressure, and composition in units of [mol/m^3].

        Utilizes the object oriented interface and
        :obj:`thermo.volume.VolumeGasMixture` to perform the actual
        calculation of molar volume.

        Examples
        --------
        >>> Mixture(['water'], ws=[1], T=500).rhogm
        24.467426039789093


return self.VolumeGasMixture(T=self.T, P=self.P, zs=self.zs, ws=self.ws)<EOL>

r'''Gas-phase molar volume of the mixture at its current
        temperature, pressure, and composition in units of [m^3/mol]. For
        calculation of this property at other temperatures or pressures or
        compositions, or specifying manually the method used to calculate it,
        and more - see the object oriented interface
        :obj:`thermo.volume.VolumeGasMixture`; each Mixture instance
        creates one to actually perform the calculations.

        Examples
        --------
        >>> Mixture(['hexane'], ws=[1], T=300, P=2E5).Vmg
        0.010888694235142216


Cpgm = self.HeatCapacityGasMixture(self.T, self.P, self.zs, self.ws)<EOL>if Cpgm:<EOL><INDENT>return property_molar_to_mass(Cpgm, self.MW)<EOL><DEDENT>return None<EOL>

r'''Gas-phase heat capacity of the mixture at its current temperature ,
        and composition in units of [J/kg/K]. For calculation of this property at
        other temperatures or compositions, or specifying manually the method
        used to calculate it, and more - see the object oriented interface
        :obj:`thermo.heat_capacity.HeatCapacityGasMixture`; each Mixture
        instance creates one to actually perform the calculations. Note that
        that interface provides output in molar units.

        Examples
        --------
        >>> Mixture(['oxygen', 'nitrogen'], ws=[.4, .6], T=350, P=1E6).Cpg
        995.8911053614883


return [i.Hvapm for i in self.Chemicals]<EOL>

r'''Pure component enthalpies of vaporization of the chemicals in the
        mixture at its current temperature, in units of [J/mol].

        Examples
        --------
        >>> Mixture(['benzene', 'toluene'], ws=[0.5, 0.5], T=320).Hvapms
        [32639.806783391632, 36851.7902195611]