methods = []<EOL>Tmins, Tmaxs = [], []<EOL>if has_CoolProp and self.CASRN in coolprop_dict:<EOL><INDENT>methods.append(COOLPROP)<EOL>self.CP_f = coolprop_fluids[self.CASRN]<EOL>Tmins.append(self.CP_f.Tt); 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 Alibakhshi_Cs.index and self.Tc:<EOL><INDENT>methods.append(ALIBAKHSHI)<EOL>self.Alibakhshi_C = float(Alibakhshi_Cs.at[self.CASRN, '<STR_LIT:C>'])<EOL>Tmaxs.append( max(self.Tc-<NUM_LIT>, <NUM_LIT:0>) )<EOL><DEDENT>if self.CASRN in CRCHvap_data.index and not np.isnan(CRCHvap_data.at[self.CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(CRC_HVAP_TB)<EOL>self.CRC_HVAP_TB_Tb = float(CRCHvap_data.at[self.CASRN, '<STR_LIT>'])<EOL>self.CRC_HVAP_TB_Hvap = float(CRCHvap_data.at[self.CASRN, '<STR_LIT>'])<EOL><DEDENT>if self.CASRN in CRCHvap_data.index and not np.isnan(CRCHvap_data.at[self.CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(CRC_HVAP_298)<EOL>self.CRC_HVAP_298 = float(CRCHvap_data.at[self.CASRN, '<STR_LIT>'])<EOL><DEDENT>if self.CASRN in GharagheiziHvap_data.index:<EOL><INDENT>methods.append(GHARAGHEIZI_HVAP_298)<EOL>self.GHARAGHEIZI_HVAP_298_Hvap = float(GharagheiziHvap_data.at[self.CASRN, '<STR_LIT>'])<EOL><DEDENT>if all((self.Tc, self.omega)):<EOL><INDENT>methods.extend(self.CSP_methods)<EOL>Tmaxs.append(self.Tc); Tmins.append(<NUM_LIT:0>)<EOL><DEDENT>if all((self.Tc, self.Pc)):<EOL><INDENT>methods.append(CLAPEYRON)<EOL>Tmaxs.append(self.Tc); Tmins.append(<NUM_LIT:0>)<EOL><DEDENT>if all((self.Tb, self.Tc, self.Pc)):<EOL><INDENT>methods.extend(self.boiling_methods)<EOL>Tmaxs.append(self.Tc); Tmins.append(<NUM_LIT:0>)<EOL><DEDENT>if self.CASRN in Perrys2_150.index:<EOL><INDENT>methods.append(DIPPR_PERRY_8E)<EOL>_, Tc, C1, C2, C3, C4, self.Perrys2_150_Tmin, self.Perrys2_150_Tmax = _Perrys2_150_values[Perrys2_150.index.get_loc(self.CASRN)].tolist()<EOL>self.Perrys2_150_coeffs = [Tc, C1, C2, C3, C4]<EOL>Tmins.append(self.Perrys2_150_Tmin); Tmaxs.append(self.Perrys2_150_Tmax)<EOL><DEDENT>if self.CASRN in VDI_PPDS_4.index:<EOL><INDENT>_,  MW, Tc, A, B, C, D, E = _VDI_PPDS_4_values[VDI_PPDS_4.index.get_loc(self.CASRN)].tolist()<EOL>self.VDI_PPDS_coeffs = [A, B, C, D, E]<EOL>self.VDI_PPDS_Tc = Tc<EOL>self.VDI_PPDS_MW = MW<EOL>methods.append(VDI_PPDS)<EOL>Tmaxs.append(self.VDI_PPDS_Tc); <EOL><DEDENT>self.all_methods = set(methods)<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`,
        and :obj:`all_methods` 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.


Tbr = Tb/Tc<EOL>return R*Tb*(Tb/<NUM_LIT>)**<NUM_LIT>*(<NUM_LIT:1.> - Tbr)**<NUM_LIT>*log(Pc/<NUM_LIT>)/ (<NUM_LIT:1> - Tbr + <NUM_LIT>*Tbr*log(Tbr))<EOL>

r'''Calculates enthalpy of vaporization at the normal boiling point using
    the Liu [1]_ correlation, and a chemical's critical temperature, pressure
    and boiling point.

    The enthalpy of vaporization is given by:

    .. math::
        \Delta H_{vap} = RT_b \left[ \frac{T_b}{220}\right]^{0.0627} \frac{
        (1-T_{br})^{0.38} \ln(P_c/P_A)}{1-T_{br} + 0.38 T_{br} \ln T_{br}}

    Parameters
    ----------
    Tb : float
        Boiling temperature of the fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]

    Returns
    -------
    Hvap : float
        Enthalpy of vaporization, [J/mol]

    Notes
    -----
    This formulation can be adjusted for lower boiling points, due to the use
    of a rationalized pressure relationship. The formulation is taken from
    the original article.

    A correction for alcohols and organic acids based on carbon number,
    which only modifies the boiling point, is available but not implemented.

    No sample calculations are available in the article.

    Internal units: Pa and K

    Examples
    --------
    Same problem as in Perry's examples

    >>> Liu(294.0, 466.0, 5.55E6)
    26378.566319606754

    References
    ----------
    .. [1] LIU, ZHI-YONG. "Estimation of Heat of Vaporization of Pure Liquid at
       Its Normal Boiling Temperature." Chemical Engineering Communications
       184, no. 1 (February 1, 2001): 221-28. doi:10.1080/00986440108912849.


omegaR1, omegaR2 = <NUM_LIT>, <NUM_LIT><EOL>A10 = <NUM_LIT><EOL>A20 = -<NUM_LIT><EOL>A30 = -<NUM_LIT><EOL>B10 = <NUM_LIT><EOL>B20 = <NUM_LIT><EOL>B30 = -<NUM_LIT><EOL>A11 = -<NUM_LIT><EOL>A21 = -<NUM_LIT><EOL>A31 = -<NUM_LIT><EOL>B11 = <NUM_LIT><EOL>B21 = <NUM_LIT><EOL>B31 = -<NUM_LIT><EOL>tau = <NUM_LIT:1.> - T/Tc<EOL>L0 = A10*tau**(<NUM_LIT:1>/<NUM_LIT>) + A20*tau**(<NUM_LIT:5>/<NUM_LIT>) + A30*tau**(<NUM_LIT:1>-<NUM_LIT:1>/<NUM_LIT> + <NUM_LIT:1>/<NUM_LIT>) +B10*tau + B20*tau**<NUM_LIT:2> + B30*tau**<NUM_LIT:3><EOL>L1 = A11*tau**(<NUM_LIT:1>/<NUM_LIT>) + A21*tau**(<NUM_LIT:5>/<NUM_LIT>) + A31*tau**(<NUM_LIT:1>-<NUM_LIT:1>/<NUM_LIT> + <NUM_LIT:1>/<NUM_LIT>) +B11*tau + B21*tau**<NUM_LIT:2> + B31*tau**<NUM_LIT:3><EOL>domega = (omega - omegaR1)/(omegaR2 - omegaR1)<EOL>return R*Tc*(L0 + domega*L1)<EOL>

r'''Calculates enthalpy of vaporization at arbitrary temperatures using a
    the work of [1]_; requires a chemical's critical temperature and
    acentric factor.

    The enthalpy of vaporization is given by:

    .. math::
         \frac{\Delta H_{vap}} {RT_c} =
         \left( \frac{\Delta H_{vap}} {RT_c} \right)^{(R1)} + \left(
         \frac{\omega - \omega^{(R1)}} {\omega^{(R2)} - \omega^{(R1)}} \right)
         \left[\left( \frac{\Delta H_{vap}} {RT_c} \right)^{(R2)} - \left(
         \frac{\Delta H_{vap}} {RT_c} \right)^{(R1)} \right]

        \left( \frac{\Delta H_{vap}} {RT_c} \right)^{(R1)}
        = 6.537 \tau^{1/3} - 2.467 \tau^{5/6} - 77.251 \tau^{1.208} +
        59.634 \tau + 36.009 \tau^2 - 14.606 \tau^3

        \left( \frac{\Delta H_{vap}} {RT_c} \right)^{(R2)} - \left(
        \frac{\Delta H_{vap}} {RT_c} \right)^{(R1)}=-0.133 \tau^{1/3} - 28.215
        \tau^{5/6} - 82.958 \tau^{1.208} + 99.00 \tau  + 19.105 \tau^2 -2.796 \tau^3

        \tau = 1-T/T_c

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

    Returns
    -------
    Hvap : float
        Enthalpy of vaporization, [J/mol]

    Notes
    -----
    The original article has been reviewed and found to have coefficients with
    slightly more precision. Additionally, the form of the equation is slightly
    different, but numerically equivalent.

    The refence fluids are:

    :math:`\omega_0` = benzene = 0.212

    :math:`\omega_1` = carbazole = 0.461

    A sample problem in the article has been verified. The numerical result
    presented by the author requires high numerical accuracy to obtain.

    Examples
    --------
    Problem in [1]_:

    >>> SMK(553.15, 751.35, 0.302)
    39866.17647797959

    References
    ----------
    .. [1] Sivaraman, Alwarappa, Joe W. Magee, and Riki Kobayashi. "Generalized
       Correlation of Latent Heats of Vaporization of Coal-Liquid Model Compounds
       between Their Freezing Points and Critical Points." Industrial &
       Engineering Chemistry Fundamentals 23, no. 1 (February 1, 1984): 97-100.
       doi:10.1021/i100013a017.


def conductivity_McCleskey(T, M, lambda_coeffs, A_coeffs, B, multiplier, rho=<NUM_LIT>):

t = T - <NUM_LIT><EOL>lambda_coeff = horner(lambda_coeffs, t)<EOL>A = horner(A_coeffs, t)<EOL>M_root = M**<NUM_LIT:0.5><EOL>param = lambda_coeff - A*M_root/(<NUM_LIT:1.> + B*M_root)<EOL>C = M*rho/<NUM_LIT> <EOL>return param*C*multiplier*<NUM_LIT:0.1><EOL>

r'''This function handles the calculation of the electrical conductivity of
    an electrolytic aqueous solution with one electrolyte in solution. It
    handles temperature dependency and concentrated solutions. Requires the
    temperature of the solution; its molality, and four sets of coefficients
    `lambda_coeffs`, `A_coeffs`, `B`, and `multiplier`.

    .. math::
        \Lambda = \frac{\kappa}{C}

        \Lambda = \Lambda^0(t) - A(t) \frac{m^{1/2}}{1+Bm^{1/2}}

        \Lambda^\circ(t) = c_1 t^2 + c_2 t + c_3

        A(t) = d_1 t^2 + d_2 t + d_3

    In the above equations, `t` is temperature in degrees Celcius;
    `m` is molality in mol/kg, and C is the concentration of the elctrolytes
    in mol/m^3, calculated as the product of density and molality.

    Parameters
    ----------
    T : float
        Temperature of the solution, [K]
    M : float
        Molality of the solution with respect to one electrolyte
        (mol solute / kg solvent), [mol/kg]
    lambda_coeffs : list[float]
        List of coefficients for the polynomial used to calculate `lambda`;
        length-3 coefficients provided in [1]_,  [-]
    A_coeffs : list[float]
        List of coefficients for the polynomial used to calculate `A`;
        length-3 coefficients provided in [1]_, [-]
    B : float
        Empirical constant for an electrolyte, [-]
    multiplier : float
        The multiplier to obtain the absolute conductivity from the equivalent
        conductivity; ex 2 for CaCl2, [-]
    rho : float, optional
        The mass density of the aqueous mixture, [kg/m^3]

    Returns
    -------
    kappa : float
        Electrical conductivity of the solution at the specified molality and
        temperature [S/m]

    Notes
    -----
    Coefficients provided in [1]_ result in conductivity being calculated in
    units of mS/cm; they are converted to S/m before returned.

    Examples
    --------
    A 0.5 wt% solution of CaCl2, conductivity calculated in mS/cm

    >>> conductivity_McCleskey(T=293.15, M=0.045053, A_coeffs=[.03918, 3.905,
    ... 137.7], lambda_coeffs=[0.01124, 2.224, 72.36], B=3.8, multiplier=2)
    0.8482584585108555

    References
    ----------
    .. [1] McCleskey, R. Blaine. "Electrical Conductivity of Electrolytes Found
       In Natural Waters from (5 to 90) °C." Journal of Chemical & Engineering
       Data 56, no. 2 (February 10, 2011): 317-27. doi:10.1021/je101012n.


rho_w = Laliberte_density_w(T)<EOL>w_w = <NUM_LIT:1> - sum(ws)<EOL>rho = w_w/rho_w<EOL>for i in range(len(CASRNs)):<EOL><INDENT>d = _Laliberte_Density_ParametersDict[CASRNs[i]]<EOL>rho_i = Laliberte_density_i(T, w_w, d["<STR_LIT>"], d["<STR_LIT>"], d["<STR_LIT>"], d["<STR_LIT>"], d["<STR_LIT>"])<EOL>rho = rho + ws[i]/rho_i<EOL><DEDENT>return <NUM_LIT:1.>/rho<EOL>

r'''Calculate the density of an aqueous electrolyte mixture using the form proposed by [1]_.
    Parameters are loaded by the function as needed. Units are Kelvin and Pa*s.

    .. math::
        \rho_m = \left(\frac{w_w}{\rho_w} + \sum_i \frac{w_i}{\rho_{app_i}}\right)^{-1}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    ws : array
        Weight fractions of fluid components other than water
    CASRNs : array
        CAS numbers of the fluid components other than water

    Returns
    -------
    rho_i : float
        Solution density, [kg/m^3]

    Notes
    -----
    Temperature range check is not used here.

    Examples
    --------
    >>> Laliberte_density(273.15, [0.0037838838], ['7647-14-5'])
    1002.6250120185854

    References
    ----------
    .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of
       Aqueous Solutions, with Updated Density and Viscosity Data." Journal of
       Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60.
       doi:10.1021/je8008123


gamma0 = <NUM_LIT><EOL>gamma1 = <NUM_LIT><EOL>gamma2 = -<NUM_LIT><EOL>gamma3 = <NUM_LIT><EOL>K_w_G = <NUM_LIT:10>**(-<NUM_LIT:1>*(gamma0 + gamma1/T + gamma2/T**<NUM_LIT:2> + gamma3/T**<NUM_LIT:3>))<EOL>return K_w_G<EOL>

r'''Calculates equilibrium constant for OH- and H+ in water vapor,
    according to [1]_.
    This is the most recent formulation available.

    .. math::
        -log_{10}  K_w^G = \gamma_0 + \gamma_1 T^{-1} + \gamma_2 T^{-2} + \gamma_3 T^{-3}

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

    Returns
    -------
    K_w_G : float

    Notes
    -----
    gamma0 = 6.141500E-1;
    gamma1 = 4.825133E4;
    gamma2 = -6.770793E4;
    gamma3 = 1.010210E7

    Examples
    --------
    >>> Kweq_IAPWS_gas(800)
    1.4379721554798815e-61

    References
    ----------
    .. [1] Bandura, Andrei V., and Serguei N. Lvov. "The Ionization Constant
       of Water over Wide Ranges of Temperature and Density." Journal of Physical
       and Chemical Reference Data 35, no. 1 (March 1, 2006): 15-30.
       doi:10.1063/1.1928231


def ion_balance_proportional(anion_charges, cation_charges, zs, n_anions, <EOL>n_cations, balance_error, method):

anion_zs = zs[<NUM_LIT:0>:n_anions]<EOL>cation_zs = zs[n_anions:n_cations+n_anions]<EOL>anion_balance_error = sum([zi*ci for zi, ci in zip(anion_zs, anion_charges)])<EOL>cation_balance_error = sum([zi*ci for zi, ci in zip(cation_zs, cation_charges)])<EOL>if method == '<STR_LIT>':<EOL><INDENT>if balance_error < <NUM_LIT:0>:<EOL><INDENT>multiplier = -anion_balance_error/cation_balance_error<EOL>cation_zs = [i*multiplier for i in cation_zs]<EOL><DEDENT>else:<EOL><INDENT>multiplier = -cation_balance_error/anion_balance_error<EOL>anion_zs = [i*multiplier for i in anion_zs]<EOL><DEDENT><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>if balance_error < <NUM_LIT:0>:<EOL><INDENT>multiplier = -cation_balance_error/anion_balance_error<EOL>anion_zs = [i*multiplier for i in anion_zs]<EOL><DEDENT>else:<EOL><INDENT>multiplier = -anion_balance_error/cation_balance_error<EOL>cation_zs = [i*multiplier for i in cation_zs]<EOL><DEDENT><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>multiplier = -anion_balance_error/cation_balance_error<EOL>cation_zs = [i*multiplier for i in cation_zs]<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>multiplier = -cation_balance_error/anion_balance_error<EOL>anion_zs = [i*multiplier for i in anion_zs]<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>' %charge_balance_methods)<EOL><DEDENT>z_water = <NUM_LIT:1.> - sum(anion_zs) - sum(cation_zs)<EOL>return anion_zs, cation_zs, z_water<EOL>

Helper method for balance_ions for the proportional family of methods.
    See balance_ions for a description of the methods; parameters are fairly
    obvious.


def thermal_conductivity_Magomedov(T, P, ws, CASRNs, k_w=None):

P = P/<NUM_LIT><EOL>ws = [i*<NUM_LIT:100> for i in ws]<EOL>if not k_w:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>sum1 = <NUM_LIT:0><EOL>for i, CASRN in enumerate(CASRNs):<EOL><INDENT>Ai = float(Magomedovk_thermal_cond.at[CASRN, '<STR_LIT>'])<EOL>sum1 += Ai*(ws[i] + <NUM_LIT>*ws[i]**<NUM_LIT:3>)<EOL><DEDENT>return k_w*(<NUM_LIT:1> - sum1) - <NUM_LIT>*P*T*sum(ws)<EOL>

r'''Calculate the thermal conductivity of an aqueous mixture of
    electrolytes using the form proposed by Magomedov [1]_.
    Parameters are loaded by the function as needed. Function will fail if an
    electrolyte is not in the database.

    .. math::
        \lambda = \lambda_w\left[ 1 - \sum_{i=1}^n A_i (w_i + 2\times10^{-4}
        w_i^3)\right] - 2\times10^{-8} PT\sum_{i=1}^n w_i

    Parameters
    ----------
    T : float
        Temperature of liquid [K]
    P : float
        Pressure of the liquid [Pa]
    ws : array
        Weight fractions of liquid components other than water
    CASRNs : array
        CAS numbers of the liquid components other than water
    k_w : float
        Liquid thermal condiuctivity or pure water at T and P, [W/m/K]

    Returns
    -------
    kl : float
        Liquid thermal condiuctivity, [W/m/K]

    Notes
    -----
    Range from 273 K to 473 K, P from 0.1 MPa to 100 MPa. C from 0 to 25 mass%.
    Internal untis are MPa for pressure and weight percent.

    An example is sought for this function. It is not possible to reproduce
    the author's values consistently.

    Examples
    --------
    >>> thermal_conductivity_Magomedov(293., 1E6, [.25], ['7758-94-3'], k_w=0.59827)
    0.548654049375

    References
    ----------
    .. [1] Magomedov, U. B. "The Thermal Conductivity of Binary and
       Multicomponent Aqueous Solutions of Inorganic Substances at High
       Parameters of State." High Temperature 39, no. 2 (March 1, 2001):
       221-26. doi:10.1023/A:1017518731726.


def conductivity(CASRN=None, AvailableMethods=False, Method=None, full_info=True):

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in Lange_cond_pure.index:<EOL><INDENT>methods.append(LANGE_COND)<EOL><DEDENT>methods.append(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == LANGE_COND:<EOL><INDENT>kappa = float(Lange_cond_pure.at[CASRN, '<STR_LIT>'])<EOL>if full_info:<EOL><INDENT>T = float(Lange_cond_pure.at[CASRN, '<STR_LIT:T>'])<EOL><DEDENT><DEDENT>elif Method == NONE:<EOL><INDENT>kappa, T = None, None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if full_info:<EOL><INDENT>return kappa, T<EOL><DEDENT>else:<EOL><INDENT>return kappa<EOL><DEDENT>

r'''This function handles the retrieval of a chemical's conductivity.
    Lookup is based on CASRNs. Will automatically select a data source to use
    if no Method is provided; returns None if the data is not available.

    Function has data for approximately 100 chemicals.

    Parameters
    ----------
    CASRN : string
        CASRN [-]

    Returns
    -------
    kappa : float
        Electrical conductivity of the fluid, [S/m]
    T : float, only returned if full_info == True
        Temperature at which conductivity measurement was made
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain RI with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        A string for the method name to use, as defined by constants in
        conductivity_methods
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        conductivity for the desired chemical, and will return methods instead
        of conductivity
    full_info : bool, optional
        If True, function will return the temperature at which the conductivity
        reading was made

    Notes
    -----
    Only one source is available in this function. It is:

        * 'LANGE_COND' which is from Lange's Handbook, Table 8.34 Electrical
        Conductivity of Various Pure Liquids', a compillation of data in [1]_.

    Examples
    --------
    >>> conductivity('7732-18-5')
    (4e-06, 291.15)

    References
    ----------
    .. [1] Speight, James. Lange's Handbook of Chemistry. 16 edition.
       McGraw-Hill Professional, 2005.


rho_w = rho_w/<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>G = <NUM_LIT><EOL>return <NUM_LIT:10>**(A + B/T + C/T**<NUM_LIT:2> + D/T**<NUM_LIT:3> + (E + F/T + G/T**<NUM_LIT:2>)*log10(rho_w))<EOL>

r'''Calculates equilibrium constant for OH- and H+ in water, according to
    [1]_. Second most recent formulation.

    .. math::
        \log_{10} K_w= A + B/T + C/T^2 + D/T^3 + (E+F/T+G/T^2)\log_{10} \rho_w

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    rho_w : float
        Density of water, [kg/m^3]

    Returns
    -------
    Kweq : float
        Ionization constant of water, [-]

    Notes
    -----
    Density is internally converted to units of g/cm^3.

    A = -4.098;
    B = -3245.2;
    C = 2.2362E5;
    D = -3.984E7;
    E = 13.957;
    F = -1262.3;
    G = 8.5641E5

    Examples
    --------
    >>> -1*log10(Kweq_1981(600, 700))
    11.274522047458206

    References
    ----------
    .. [1] Marshall, William L., and E. U. Franck. "Ion Product of Water
       Substance, 0-1000  degree C, 1010,000 Bars New International Formulation
       and Its Background." Journal of Physical and Chemical Reference Data 10,
       no. 2 (April 1, 1981): 295-304. doi:10.1063/1.555643.


return <NUM_LIT:0.5>*sum([mi*zi*zi for mi, zi in zip(mis, zis)])<EOL>

r'''Calculate the ionic strength of a solution in one of two ways,
    depending on the inputs only. For Pitzer and Bromley models,
    `mis` should be molalities of each component. For eNRTL models,
    `mis` should be mole fractions of each electrolyte in the solution.
    This will sum to be much less than 1.

    .. math::
        I = \frac{1}{2} \sum M_i z_i^2

        I = \frac{1}{2} \sum x_i z_i^2

    Parameters
    ----------
    mis : list
        Molalities of each ion, or mole fractions of each ion [mol/kg or -]
    zis : list
        Charges of each ion [-]

    Returns
    -------
    I : float
        ionic strength, [?]

    Examples
    --------
    >>> ionic_strength([0.1393, 0.1393], [1, -1])
    0.1393

    References
    ----------
    .. [1] Chen, Chau-Chyun, H. I. Britt, J. F. Boston, and L. B. Evans. "Local
       Composition Model for Excess Gibbs Energy of Electrolyte Systems.
       Part I: Single Solvent, Single Completely Dissociated Electrolyte
       Systems." AIChE Journal 28, no. 4 (July 1, 1982): 588-96.
       doi:10.1002/aic.690280410
    .. [2] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
       Weinheim, Germany: Wiley-VCH, 2012.


def balance_ions(anions, cations, anion_zs=None, cation_zs=None, <EOL>anion_concs=None, cation_concs=None, rho_w=<NUM_LIT>, <EOL>method='<STR_LIT>', selected_ion=None):

anions = list(anions)<EOL>cations = list(cations)<EOL>n_anions = len(anions)<EOL>n_cations = len(cations)<EOL>ions = anions + cations<EOL>anion_charges = [i.charge for i in anions]<EOL>cation_charges = [i.charge for i in cations]<EOL>charges = anion_charges + cation_charges + [<NUM_LIT:0>]<EOL>MW_water = [<NUM_LIT>]<EOL>rho_w = rho_w/<NUM_LIT:1000> <EOL>if anion_concs is not None and cation_concs is not None:<EOL><INDENT>anion_ws = [i*<NUM_LIT>/rho_w for i in anion_concs]<EOL>cation_ws = [i*<NUM_LIT>/rho_w for i in cation_concs]<EOL>w_water = <NUM_LIT:1> - sum(anion_ws) - sum(cation_ws)<EOL>anion_MWs = [i.MW for i in anions]<EOL>cation_MWs = [i.MW for i in cations]<EOL>MWs = anion_MWs + cation_MWs + MW_water<EOL>zs = ws_to_zs(anion_ws + cation_ws + [w_water], MWs)<EOL><DEDENT>else:<EOL><INDENT>if anion_zs is None or cation_zs is None:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>zs = anion_zs + cation_zs<EOL>zs = zs + [<NUM_LIT:1> - sum(zs)]<EOL><DEDENT><DEDENT>impacts = [zi*ci for zi, ci in zip(zs, charges)]<EOL>balance_error = sum(impacts)<EOL>if abs(balance_error) < <NUM_LIT>:<EOL><INDENT>anion_zs = zs[<NUM_LIT:0>:n_anions]<EOL>cation_zs = zs[n_anions:n_cations+n_anions]<EOL>z_water = zs[-<NUM_LIT:1>]<EOL>return anions, cations, anion_zs, cation_zs, z_water<EOL><DEDENT>if '<STR_LIT>' in method:<EOL><INDENT>anion_zs, cation_zs, z_water = ion_balance_dominant(impacts,<EOL>balance_error, charges, zs, n_anions, n_cations, method)<EOL>return anions, cations, anion_zs, cation_zs, z_water<EOL><DEDENT>elif '<STR_LIT>' in method:<EOL><INDENT>anion_zs, cation_zs, z_water = ion_balance_proportional(<EOL>anion_charges, cation_charges, zs, n_anions, n_cations,<EOL>balance_error, method)<EOL>return anions, cations, anion_zs, cation_zs, z_water<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>increase = True<EOL>if balance_error < <NUM_LIT:0>:<EOL><INDENT>selected_ion = pubchem_db.search_name('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>selected_ion = pubchem_db.search_name('<STR_LIT>')<EOL><DEDENT><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>increase = False<EOL>if balance_error > <NUM_LIT:0>:<EOL><INDENT>selected_ion = pubchem_db.search_name('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>selected_ion = pubchem_db.search_name('<STR_LIT>')<EOL><DEDENT><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>increase = None<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>increase = True<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>increase = False<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>increase = True<EOL>if balance_error < <NUM_LIT:0>:<EOL><INDENT>selected_ion = selected_ion[<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>selected_ion = selected_ion[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if selected_ion is None:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>anion_zs, cation_zs, z_water = ion_balance_adjust_wrapper(charges, zs, n_anions, n_cations,<EOL>anions, cations, selected_ion, increase=increase)<EOL>return anions, cations, anion_zs, cation_zs, z_water<EOL>

r'''Performs an ion balance to adjust measured experimental ion
    compositions to electroneutrality. Can accept either the actual mole
    fractions of the ions, or their concentrations in units of [mg/L] as well
    for convinience.

    The default method will locate the most prevalent ion in the type of
    ion not in excess - and increase it until the two ion types balance.

    Parameters
    ----------
    anions : list(ChemicalMetadata)
        List of all negatively charged ions measured as being in the solution;
        ChemicalMetadata instances or simply objects with the attributes `MW`
        and `charge`, [-]
    cations : list(ChemicalMetadata)
        List of all positively charged ions measured as being in the solution;
        ChemicalMetadata instances or simply objects with the attributes `MW`
        and `charge`, [-]
    anion_zs : list, optional
        Mole fractions of each anion as measured in the aqueous solution, [-]
    cation_zs : list, optional
        Mole fractions of each cation as measured in the aqueous solution, [-]
    anion_concs : list, optional
        Concentrations of each anion in the aqueous solution in the units often
        reported (for convinience only) [mg/L]
    cation_concs : list, optional
        Concentrations of each cation in the aqueous solution in the units
        often reported (for convinience only) [mg/L]
    rho_w : float, optional
        Density of the aqueous solutionr at the temperature and pressure the
        anion and cation concentrations were measured (if specified), [kg/m^3]
    method : str, optional
        The method to use to balance the ionimbalance; one of 'dominant',
        'decrease dominant', 'increase dominant',
        'proportional insufficient ions increase',
        'proportional excess ions decrease',
        'proportional cation adjustment', 'proportional anion adjustment',
        'Na or Cl increase', 'Na or Cl decrease', 'adjust', 'increase',
        'decrease', 'makeup'].
    selected_ion : ChemicalMetadata, optional
        Some methods adjust only one user-specified ion; this is that input.
        For the case of the 'makeup' method, this is a tuple of (anion, cation)
        ChemicalMetadata instances and only the ion type not in excess will be
        used.

    Returns
    -------
    anions : list(ChemicalMetadata)
        List of all negatively charged ions measured as being in the solution;
        ChemicalMetadata instances after potentially adding in an ion which
        was not present but specified by the user, [-]
    cations : list(ChemicalMetadata)
        List of all positively charged ions measured as being in the solution;
        ChemicalMetadata instances after potentially adding in an ion which
        was not present but specified by the user, [-]
    anion_zs : list,
        Mole fractions of each anion in the aqueous solution after the charge
        balance, [-]
    cation_zs : list
        Mole fractions of each cation in the aqueous solution after the charge
        balance, [-]
    z_water : float
        Mole fraction of the water in the solution, [-]

    Notes
    -----
    The methods perform the charge balance as follows:

    * 'dominant' : The ion with the largest mole fraction in solution has its
      concentration adjusted up or down as necessary to balance the solution.
    * 'decrease dominant' : The ion with the largest mole fraction in the type
      of ion with *excess* charge has its own mole fraction decreased to balance
      the solution.
    * 'increase dominant' : The ion with the largest mole fraction in the type
      of ion with *insufficient* charge has its own mole fraction decreased to
      balance the solution.
    * 'proportional insufficient ions increase' : The ion charge type which is
      present insufficiently has each of the ions mole fractions *increased*
      proportionally until the solution is balanced.
    * 'proportional excess ions decrease' :  The ion charge type which is
      present in excess has each of the ions mole fractions *decreased*
      proportionally until the solution is balanced.
    * 'proportional cation adjustment' : All *cations* have their mole fractions
      increased or decreased proportionally as necessary to balance the
      solution.
    * 'proportional anion adjustment' : All *anions* have their mole fractions
      increased or decreased proportionally as necessary to balance the
      solution.
    * 'Na or Cl increase' : Either Na+ or Cl- is *added* to the solution until
      the solution is balanced; the species will be added if they were not
      present initially as well.
    * 'Na or Cl decrease' : Either Na+ or Cl- is *removed* from the solution
      until the solution is balanced; the species will be added if they were
      not present initially as well.
    * 'adjust' : An ion specified with the parameter `selected_ion` has its
      mole fraction *increased or decreased* as necessary to balance the
      solution. An exception is raised if the specified ion alone cannot
      balance the solution.
    * 'increase' : An ion specified with the parameter `selected_ion` has its
      mole fraction *increased* as necessary to balance the
      solution. An exception is raised if the specified ion alone cannot
      balance the solution.
    * 'decrease' : An ion specified with the parameter `selected_ion` has its
      mole fraction *decreased* as necessary to balance the
      solution. An exception is raised if the specified ion alone cannot
      balance the solution.
    * 'makeup' : Two ions ase specified as a tuple with the parameter
      `selected_ion`. Whichever ion type is present in the solution
      insufficiently is added; i.e. if the ions were Mg+2 and Cl-, and there
      was too much negative charge in the solution, Mg+2 would be added until
      the solution was balanced.

    Examples
    --------
    >>> anions_n = ['Cl-', 'HCO3-', 'SO4-2']
    >>> cations_n = ['Na+', 'K+', 'Ca+2', 'Mg+2']
    >>> cations = [pubchem_db.search_name(i) for i in cations_n]
    >>> anions = [pubchem_db.search_name(i) for i in anions_n]
    >>> an_res, cat_res, an_zs, cat_zs, z_water = balance_ions(anions, cations,
    ... anion_zs=[0.02557, 0.00039, 0.00026], cation_zs=[0.0233, 0.00075,
    ... 0.00262, 0.00119], method='proportional excess ions decrease')
    >>> an_zs
    [0.02557, 0.00039, 0.00026]
    >>> cat_zs
    [0.01948165456267761, 0.0006270918850647299, 0.0021906409851594564, 0.0009949857909693717]
    >>> z_water
    0.9504856267761288

    References
    ----------


def Laliberte_heat_capacity(T, ws, CASRNs):

Cp_w = Laliberte_heat_capacity_w(T)<EOL>w_w = <NUM_LIT:1> - sum(ws)<EOL>Cp = w_w*Cp_w<EOL>for i in range(len(CASRNs)):<EOL><INDENT>d = _Laliberte_Heat_Capacity_ParametersDict[CASRNs[i]]<EOL>Cp_i = Laliberte_heat_capacity_i(T, w_w, d["<STR_LIT>"], d["<STR_LIT>"], d["<STR_LIT>"], d["<STR_LIT>"], d["<STR_LIT>"], d["<STR_LIT>"])<EOL>Cp = Cp + ws[i]*Cp_i<EOL><DEDENT>return Cp<EOL>

r'''Calculate the heat capacity of an aqueous electrolyte mixture using the
    form proposed by [1]_.
    Parameters are loaded by the function as needed.

    .. math::
        TODO

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    ws : array
        Weight fractions of fluid components other than water
    CASRNs : array
        CAS numbers of the fluid components other than water

    Returns
    -------
    Cp : float
        Solution heat capacity, [J/kg/K]

    Notes
    -----
    Temperature range check is not implemented.
    Units are Kelvin and J/kg/K.

    Examples
    --------
    >>> Laliberte_heat_capacity(273.15+1.5, [0.00398447], ['7647-14-5'])
    4186.569908672113

    References
    ----------
    .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of
       Aqueous Solutions, with Updated Density and Viscosity Data." Journal of
       Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60.
       doi:10.1021/je8008123


def Laliberte_viscosity_i(T, w_w, v1, v2, v3, v4, v5, v6):

t = T-<NUM_LIT><EOL>mu_i = exp((v1*(<NUM_LIT:1>-w_w)**v2 + v3)/(v4*t+<NUM_LIT:1>))/(v5*(<NUM_LIT:1>-w_w)**v6 + <NUM_LIT:1>)<EOL>return mu_i/<NUM_LIT><EOL>

r'''Calculate the viscosity of a solute using the form proposed by [1]_
    Parameters are needed, and a temperature. Units are Kelvin and Pa*s.

    .. math::
        \mu_i = \frac{\exp\left( \frac{v_1(1-w_w)^{v_2}+v_3}{v_4 t +1}\right)}
            {v_5(1-w_w)^{v_6}+1}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    w_w : float
        Weight fraction of water in the solution
    v1-v6 : floats
        Function fit parameters

    Returns
    -------
    mu_i : float
        Solute partial viscosity, Pa*s

    Notes
    -----
    Temperature range check is outside of this function.
    Check is performed using NaCl at 5 degC from the first value in [1]_'s spreadsheet.

    Examples
    --------
    >>> d =  _Laliberte_Viscosity_ParametersDict['7647-14-5']
    >>> Laliberte_viscosity_i(273.15+5, 1-0.005810, d["V1"], d["V2"], d["V3"], d["V4"], d["V5"], d["V6"] )
    0.004254025533308794

    References
    ----------
    .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of
       Aqueous Solutions, with Updated Density and Viscosity Data." Journal of
       Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60.
       doi:10.1021/je8008123


def identify_phase(T, P, Tm=None, Tb=None, Tc=None, Psat=None):

if Tm and T <= Tm:<EOL><INDENT>return '<STR_LIT:s>'<EOL><DEDENT>elif Tc and T >= Tc:<EOL><INDENT>return '<STR_LIT:g>'<EOL><DEDENT>elif Psat:<EOL><INDENT>if P <= Psat:<EOL><INDENT>return '<STR_LIT:g>'<EOL><DEDENT>elif P > Psat:<EOL><INDENT>return '<STR_LIT:l>'<EOL><DEDENT><DEDENT>elif Tb:<EOL><INDENT>if <NUM_LIT> < P < <NUM_LIT>:<EOL><INDENT>if T < Tb:<EOL><INDENT>return  '<STR_LIT:l>'<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT:g>'<EOL><DEDENT><DEDENT>elif P > <NUM_LIT> and T <= Tb:<EOL><INDENT>return '<STR_LIT:l>'<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

r'''Determines the phase of a one-species chemical system according to
    basic rules, using whatever information is available. Considers only the
    phases liquid, solid, and gas; does not consider two-phase
    scenarios, as should occurs between phase boundaries.

    * If the melting temperature is known and the temperature is under or equal
      to it, consider it a solid.
    * If the critical temperature is known and the temperature is greater or
      equal to it, consider it a gas.
    * If the vapor pressure at `T` is known and the pressure is under or equal
      to it, consider it a gas. If the pressure is greater than the vapor
      pressure, consider it a liquid.
    * If the melting temperature, critical temperature, and vapor pressure are
      not known, attempt to use the boiling point to provide phase information.
      If the pressure is between 90 kPa and 110 kPa (approximately normal),
      consider it a liquid if it is under the boiling temperature and a gas if
      above the boiling temperature.
    * If the pressure is above 110 kPa and the boiling temperature is known,
      consider it a liquid if the temperature is under the boiling temperature.
    * Return None otherwise.

    Parameters
    ----------
    T : float
        Temperature, [K]
    P : float
        Pressure, [Pa]
    Tm : float, optional
        Normal melting temperature, [K]
    Tb : float, optional
        Normal boiling point, [K]
    Tc : float, optional
        Critical temperature, [K]
    Psat : float, optional
        Vapor pressure of the fluid at `T`, [Pa]

    Returns
    -------
    phase : str
        Either 's', 'l', 'g', or None if the phase cannot be determined

    Notes
    -----
    No special attential is paid to any phase transition. For the case where
    the melting point is not provided, the possibility of the fluid being solid
    is simply ignored.

    Examples
    --------
    >>> identify_phase(T=280, P=101325, Tm=273.15, Psat=991)
    'l'


<EOL>p = sorted(zip(Ks,zs), reverse=True)<EOL>Ks_sorted, zs_sorted = [K for (K,z) in p], [z for (K,z) in p]<EOL>k1 = Ks_sorted[<NUM_LIT:0>]<EOL>z1 = zs_sorted[<NUM_LIT:0>]<EOL>kn = Ks_sorted[-<NUM_LIT:1>]<EOL>x_min = (<NUM_LIT:1.> - kn)/(k1 - kn)*z1<EOL>x_max = (<NUM_LIT:1.> - kn)/(k1 - kn)<EOL>x_min2 = max(<NUM_LIT:0.>, x_min)<EOL>x_max2 = min(<NUM_LIT:1.>, x_max)<EOL>x_guess = (x_min2 + x_max2)*<NUM_LIT:0.5><EOL>length = len(zs)-<NUM_LIT:1><EOL>kn_m_1 = kn-<NUM_LIT:1.><EOL>k1_m_1 = (k1-<NUM_LIT:1.>)<EOL>t1 = (k1-kn)/(kn-<NUM_LIT:1.>)<EOL>objective = lambda x1: <NUM_LIT:1.> + t1*x1 + sum([(ki-kn)/(kn_m_1) * zi*k1_m_1*x1 /( (ki-<NUM_LIT:1.>)*z1 + (k1-ki)*x1) for ki, zi in zip(Ks_sorted[<NUM_LIT:1>:length], zs_sorted[<NUM_LIT:1>:length])])<EOL>try:<EOL><INDENT>x1 = newton(objective, x_guess)<EOL>assert x1 >= x_min2<EOL>assert x1 <= x_max2<EOL>V_over_F = (-x1 + z1)/(x1*(k1 - <NUM_LIT:1.>))<EOL>assert <NUM_LIT:0> <= V_over_F <= <NUM_LIT:1><EOL><DEDENT>except:<EOL><INDENT>x1 = brenth(objective, x_min, x_max)<EOL>V_over_F = (-x1 + z1)/(x1*(k1 - <NUM_LIT:1.>))<EOL><DEDENT>xs = [zi/(<NUM_LIT:1.>+V_over_F*(Ki-<NUM_LIT:1.>)) for zi, Ki in zip(zs, Ks)]<EOL>ys = [Ki*xi for xi, Ki in zip(xs, Ks)]<EOL>return V_over_F, xs, ys<EOL>

r'''Solves the objective function of the Li-Johns-Ahmadi flash equation.
    Uses the method proposed in [1]_ to obtain an initial guess.

    .. math::
        0 = 1 + \left(\frac{K_{max}-K_{min}}{K_{min}-1}\right)x_1
        + \sum_{i=2}^{n-1}\frac{K_i-K_{min}}{K_{min}-1}\left[\frac{z_i(K_{max}
        -1)x_{max}}{(K_i-1)z_{max} + (K_{max}-K_i)x_{max}}\right]

    Parameters
    ----------
    zs : list[float]
        Overall mole fractions of all species, [-]
    Ks : list[float]
        Equilibrium K-values, [-]

    Returns
    -------
    V_over_F : float
        Vapor fraction solution [-]
    xs : list[float]
        Mole fractions of each species in the liquid phase, [-]
    ys : list[float]
        Mole fractions of each species in the vapor phase, [-]

    Notes
    -----
    The initial guess is the average of the following, as described in [1]_.
    Each guess should be limited to be between 0 and 1 as they are often
    negative or larger than 1. `max` refers to the corresponding mole fractions
    for the species with the largest K value.

    .. math::
        \left(\frac{1-K_{min}}{K_{max}-K_{min}}\right)z_{max}\le x_{max} \le
        \left(\frac{1-K_{min}}{K_{max}-K_{min}}\right)

    If the `newton` method does not converge, a bisection method (brenth) is
    used instead. However, it is somewhat slower, especially as newton will
    attempt 50 iterations before giving up.

    This method does not work for problems of only two components.
    K values are sorted internally. Has not been found to be quicker than the
    Rachford-Rice equation.

    Examples
    --------
    >>> Li_Johns_Ahmadi_solution(zs=[0.5, 0.3, 0.2], Ks=[1.685, 0.742, 0.532])
    (0.6907302627738544, [0.33940869696634357, 0.3650560590371706, 0.2955352439964858], [0.5719036543882889, 0.27087159580558057, 0.15722474980613044])

    References
    ----------
    .. [1] Li, Yinghui, Russell T. Johns, and Kaveh Ahmadi. "A Rapid and Robust
       Alternative to Rachford-Rice in Flash Calculations." Fluid Phase
       Equilibria 316 (February 25, 2012): 85-97.
       doi:10.1016/j.fluid.2011.12.005.


def Rachford_Rice_flash_error(V_over_F, zs, Ks):

return sum([zi*(Ki-<NUM_LIT:1.>)/(<NUM_LIT:1.>+V_over_F*(Ki-<NUM_LIT:1.>)) for Ki, zi in zip(Ks, zs)])<EOL>

r'''Calculates the objective function of the Rachford-Rice flash equation.
    This function should be called by a solver seeking a solution to a flash
    calculation. The unknown variable is `V_over_F`, for which a solution
    must be between 0 and 1.

    .. math::
        \sum_i \frac{z_i(K_i-1)}{1 + \frac{V}{F}(K_i-1)} = 0

    Parameters
    ----------
    V_over_F : float
        Vapor fraction guess [-]
    zs : list[float]
        Overall mole fractions of all species, [-]
    Ks : list[float]
        Equilibrium K-values, [-]

    Returns
    -------
    error : float
        Deviation between the objective function at the correct V_over_F
        and the attempted V_over_F, [-]

    Notes
    -----
    The derivation is as follows:

    .. math::
        F z_i = L x_i + V y_i

        x_i = \frac{z_i}{1 + \frac{V}{F}(K_i-1)}

        \sum_i y_i = \sum_i K_i x_i = 1

        \sum_i(y_i - x_i)=0

        \sum_i \frac{z_i(K_i-1)}{1 + \frac{V}{F}(K_i-1)} = 0

    Examples
    --------
    >>> Rachford_Rice_flash_error(0.5, zs=[0.5, 0.3, 0.2],
    ... Ks=[1.685, 0.742, 0.532])
    0.04406445591174976

    References
    ----------
    .. [1] Rachford, H. H. Jr, and J. D. Rice. "Procedure for Use of Electronic
       Digital Computers in Calculating Flash Vaporization Hydrocarbon
       Equilibrium." Journal of Petroleum Technology 4, no. 10 (October 1,
       1952): 19-3. doi:10.2118/952327-G.


cmps = range(len(xs))<EOL>rsxs = sum([rs[i]*xs[i] for i in cmps])<EOL>phis = [rs[i]*xs[i]/rsxs for i in cmps]<EOL>qsxs = sum([qs[i]*xs[i] for i in cmps])<EOL>vs = [qs[i]*xs[i]/qsxs for i in cmps]<EOL>Ss = [sum([vs[j]*taus[j][i] for j in cmps]) for i in cmps]<EOL>loggammacs = [log(phis[i]/xs[i]) + <NUM_LIT:1> - phis[i]/xs[i]<EOL>- <NUM_LIT:5>*qs[i]*(log(phis[i]/vs[i]) + <NUM_LIT:1> - phis[i]/vs[i]) for i in cmps]<EOL>loggammars = [qs[i]*(<NUM_LIT:1> - log(Ss[i]) - sum([taus[i][j]*vs[j]/Ss[j]<EOL>for j in cmps])) for i in cmps]<EOL>return [exp(loggammacs[i] + loggammars[i]) for i in cmps]<EOL>

r'''Calculates the activity coefficients of each species in a mixture
    using the Universal quasi-chemical (UNIQUAC) equation, given their mole
    fractions, `rs`, `qs`, and dimensionless interaction parameters. The
    interaction parameters are normally correlated with temperature, and need
    to be calculated separately.

    .. math::
        \ln \gamma_i = \ln \frac{\Phi_i}{x_i} + \frac{z}{2} q_i \ln
        \frac{\theta_i}{\Phi_i}+ l_i - \frac{\Phi_i}{x_i}\sum_j^N x_j l_j
        - q_i \ln\left( \sum_j^N \theta_j \tau_{ji}\right)+ q_i - q_i\sum_j^N
        \frac{\theta_j \tau_{ij}}{\sum_k^N \theta_k \tau_{kj}}

        \theta_i = \frac{x_i q_i}{\displaystyle\sum_{j=1}^{n} x_j q_j}

         \Phi_i = \frac{x_i r_i}{\displaystyle\sum_{j=1}^{n} x_j r_j}

         l_i = \frac{z}{2}(r_i - q_i) - (r_i - 1)

    Parameters
    ----------
    xs : list[float]
        Liquid mole fractions of each species, [-]
    rs : list[float]
        Van der Waals volume parameters for each species, [-]
    qs : list[float]
        Surface area parameters for each species, [-]
    taus : list[list[float]]
        Dimensionless interaction parameters of each compound with each other,
        [-]

    Returns
    -------
    gammas : list[float]
        Activity coefficient for each species in the liquid mixture, [-]

    Notes
    -----
    This model needs N^2 parameters.

    The original expression for the interaction parameters is as follows:

    .. math::
        \tau_{ji} = \exp\left(\frac{-\Delta u_{ij}}{RT}\right)

    However, it is seldom used. Most correlations for the interaction
    parameters include some of the terms shown in the following form:

    .. math::
        \ln \tau{ij} =a_{ij}+\frac{b_{ij}}{T}+c_{ij}\ln T + d_{ij}T
        + \frac{e_{ij}}{T^2}

    This model is recast in a slightly more computationally efficient way in
    [2]_, as shown below:

    .. math::
        \ln \gamma_i = \ln \gamma_i^{res} + \ln \gamma_i^{comb}

        \ln \gamma_i^{res} = q_i \left(1 - \ln\frac{\sum_j^N q_j x_j \tau_{ji}}
        {\sum_j^N q_j x_j}- \sum_j \frac{q_k x_j \tau_{ij}}{\sum_k q_k x_k
        \tau_{kj}}\right)

        \ln \gamma_i^{comb} = (1 - V_i + \ln V_i) - \frac{z}{2}q_i\left(1 -
        \frac{V_i}{F_i} + \ln \frac{V_i}{F_i}\right)

        V_i = \frac{r_i}{\sum_j^N r_j x_j}

        F_i = \frac{q_i}{\sum_j q_j x_j}

    Examples
    --------
    Ethanol-water example, at 343.15 K and 1 MPa:

    >>> UNIQUAC(xs=[0.252, 0.748], rs=[2.1055, 0.9200], qs=[1.972, 1.400],
    ... taus=[[1.0, 1.0919744384510301], [0.37452902779205477, 1.0]])
    [2.35875137797083, 1.2442093415968987]

    References
    ----------
    .. [1] Abrams, Denis S., and John M. Prausnitz. "Statistical Thermodynamics
       of Liquid Mixtures: A New Expression for the Excess Gibbs Energy of
       Partly or Completely Miscible Systems." AIChE Journal 21, no. 1 (January
       1, 1975): 116-28. doi:10.1002/aic.690210115.
    .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey.
       Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim:
       Wiley-VCH, 2012.
    .. [3] Maurer, G., and J. M. Prausnitz. "On the Derivation and Extension of
       the Uniquac Equation." Fluid Phase Equilibria 2, no. 2 (January 1,
       1978): 91-99. doi:10.1016/0378-3812(78)85002-X.


gammas = []<EOL>cmps = range(len(xs))<EOL>Gs = [[exp(-alphas[i][j]*taus[i][j]) for j in cmps] for i in cmps]<EOL>for i in cmps:<EOL><INDENT>tn1, td1, total2 = <NUM_LIT:0.>, <NUM_LIT:0.>, <NUM_LIT:0.><EOL>for j in cmps:<EOL><INDENT>tn1 += xs[j]*taus[j][i]*Gs[j][i]<EOL>td1 +=  xs[j]*Gs[j][i]<EOL>tn2 = xs[j]*Gs[i][j]<EOL>td2 = td3 = sum([xs[k]*Gs[k][j] for k in cmps])<EOL>tn3 = sum([xs[m]*taus[m][j]*Gs[m][j] for m in cmps])<EOL>total2 += tn2/td2*(taus[i][j] - tn3/td3)<EOL><DEDENT>gamma = exp(tn1/td1 + total2)<EOL>gammas.append(gamma)<EOL><DEDENT>return gammas<EOL>

r'''Calculates the activity coefficients of each species in a mixture
    using the Non-Random Two-Liquid (NRTL) method, given their mole fractions,
    dimensionless interaction parameters, and nonrandomness constants. Those
    are normally correlated with temperature in some form, and need to be
    calculated separately.

    .. math::
        \ln(\gamma_i)=\frac{\displaystyle\sum_{j=1}^{n}{x_{j}\tau_{ji}G_{ji}}}
        {\displaystyle\sum_{k=1}^{n}{x_{k}G_{ki}}}+\sum_{j=1}^{n}
        {\frac{x_{j}G_{ij}}{\displaystyle\sum_{k=1}^{n}{x_{k}G_{kj}}}}
        {\left ({\tau_{ij}-\frac{\displaystyle\sum_{m=1}^{n}{x_{m}\tau_{mj}
        G_{mj}}}{\displaystyle\sum_{k=1}^{n}{x_{k}G_{kj}}}}\right )}

        G_{ij}=\text{exp}\left ({-\alpha_{ij}\tau_{ij}}\right )

    Parameters
    ----------
    xs : list[float]
        Liquid mole fractions of each species, [-]
    taus : list[list[float]]
        Dimensionless interaction parameters of each compound with each other,
        [-]
    alphas : list[list[float]]
        Nonrandomness constants of each compound interacting with each other, [-]

    Returns
    -------
    gammas : list[float]
        Activity coefficient for each species in the liquid mixture, [-]

    Notes
    -----
    This model needs N^2 parameters.

    One common temperature dependence of the nonrandomness constants is:

    .. math::
        \alpha_{ij}=c_{ij}+d_{ij}T

    Most correlations for the interaction parameters include some of the terms
    shown in the following form:

    .. math::
        \tau_{ij}=A_{ij}+\frac{B_{ij}}{T}+\frac{C_{ij}}{T^{2}}+D_{ij}
        \ln{\left ({T}\right )}+E_{ij}T^{F_{ij}}

    Examples
    --------
    Ethanol-water example, at 343.15 K and 1 MPa:

    >>> NRTL(xs=[0.252, 0.748], taus=[[0, -0.178], [1.963, 0]],
    ... alphas=[[0, 0.2974],[.2974, 0]])
    [1.9363183763514304, 1.1537609663170014]

    References
    ----------
    .. [1] Renon, Henri, and J. M. Prausnitz. "Local Compositions in
       Thermodynamic Excess Functions for Liquid Mixtures." AIChE Journal 14,
       no. 1 (1968): 135-144. doi:10.1002/aic.690140124.
    .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey.
       Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim:
       Wiley-VCH, 2012.


def identify_phase_mixture(T=None, P=None, zs=None, Tcs=None, Pcs=None,<EOL>Psats=None, CASRNs=None,<EOL>AvailableMethods=False, Method=None):

def list_methods():<EOL><INDENT>methods = []<EOL>if Psats and none_and_length_check((Psats, zs)):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if Tcs and none_and_length_check([Tcs]) and all([T >= i for i in Tcs]):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if Pcs and none_and_length_check([Pcs]) and all([P >= i for i in Pcs]):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if Tcs and none_and_length_check([zs, Tcs]) and any([T > Tc for Tc in Tcs]):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>methods.append('<STR_LIT>')<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>xs, ys, phase, V_over_F = None, None, None, None<EOL>if Method == '<STR_LIT>':<EOL><INDENT>Pdew = dew_at_T(zs, Psats)<EOL>Pbubble = bubble_at_T(zs, Psats)<EOL>if P >= Pbubble:<EOL><INDENT>phase = '<STR_LIT:l>'<EOL>ys = None<EOL>xs = zs<EOL>V_over_F = <NUM_LIT:0><EOL><DEDENT>elif P <= Pdew:<EOL><INDENT>phase = '<STR_LIT:g>'<EOL>ys = zs<EOL>xs = None<EOL>V_over_F = <NUM_LIT:1><EOL><DEDENT>elif Pdew < P < Pbubble:<EOL><INDENT>xs, ys, V_over_F = flash(P, zs, Psats)<EOL>phase = '<STR_LIT>'<EOL><DEDENT><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>if all([T >= i for i in Tcs]):<EOL><INDENT>phase = '<STR_LIT:g>'<EOL><DEDENT>else: <EOL><INDENT>phase = '<STR_LIT>'<EOL><DEDENT><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>if all([P >= i for i in Pcs]):<EOL><INDENT>phase = '<STR_LIT:g>'<EOL><DEDENT>else: <EOL><INDENT>phase = '<STR_LIT>'<EOL><DEDENT><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>Psats = list(Psats)<EOL>for i in range(len(Psats)):<EOL><INDENT>if not Psats[i] and Tcs[i] and Tcs[i] <= T:<EOL><INDENT>Psats[i] = <NUM_LIT><EOL><DEDENT><DEDENT>Pdew = dew_at_T(zs, Psats)<EOL>Pbubble = <NUM_LIT><EOL>if P >= Pbubble:<EOL><INDENT>phase = '<STR_LIT:l>'<EOL>ys = None<EOL>xs = zs<EOL>V_over_F = <NUM_LIT:0><EOL><DEDENT>elif P <= Pdew:<EOL><INDENT>phase = '<STR_LIT:g>'<EOL>ys = zs<EOL>xs = None<EOL>V_over_F = <NUM_LIT:1><EOL><DEDENT>elif Pdew < P < Pbubble:<EOL><INDENT>xs, ys, V_over_F = flash(P, zs, Psats)<EOL>phase = '<STR_LIT>'<EOL><DEDENT><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return phase, xs, ys, V_over_F<EOL>


def bubble_at_P(P, zs, vapor_pressure_eqns, fugacities=None, gammas=None):

def bubble_P_error(T):<EOL><INDENT>Psats = [VP(T) for VP in vapor_pressure_eqns]<EOL>Pcalc = bubble_at_T(zs, Psats, fugacities, gammas)<EOL>return P - Pcalc<EOL><DEDENT>T_bubble = newton(bubble_P_error, <NUM_LIT>)<EOL>return T_bubble<EOL>

Calculates bubble point for a given pressure

    Parameters
    ----------
    P : float
        Pressure, [Pa]
    zs : list[float]
        Overall mole fractions of all species, [-]
    vapor_pressure_eqns : list[functions]
        Temperature dependent function for each specie, Returns Psat, [Pa]
    fugacities : list[float], optional
        fugacities of each species, defaults to list of ones, [-]
    gammas : list[float], optional
        gammas of each species, defaults to list of ones, [-]

    Returns
    -------
    Tbubble : float, optional
        Temperature of bubble point at pressure `P`, [K]


def bubble_at_T(zs, Psats, fugacities=None, gammas=None):

if not fugacities:<EOL><INDENT>fugacities = [<NUM_LIT:1> for i in range(len(Psats))]<EOL><DEDENT>if not gammas:<EOL><INDENT>gammas = [<NUM_LIT:1> for i in range(len(Psats))]<EOL><DEDENT>if not none_and_length_check((zs, Psats, fugacities, gammas)):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>P = sum(zs[i]*Psats[i]*gammas[i]/fugacities[i] for i in range(len(zs)))<EOL>return P<EOL>


def omega_mixture(omegas, zs, CASRNs=None, Method=None,<EOL>AvailableMethods=False):

def list_methods():<EOL><INDENT>methods = []<EOL>if none_and_length_check([zs, omegas]):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>methods.append('<STR_LIT>')<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == '<STR_LIT>':<EOL><INDENT>_omega = mixing_simple(zs, omegas)<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>_omega = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _omega<EOL>

r'''This function handles the calculation of a mixture's acentric factor.
    Calculation is based on the omegas provided for each pure component. Will
    automatically select a method to use if no Method is provided;
    returns None if insufficient data is available.

    Examples
    --------
    >>> omega_mixture([0.025, 0.12], [0.3, 0.7])
    0.0915

    Parameters
    ----------
    omegas : array-like
        acentric factors of each component, [-]
    zs : array-like
        mole fractions of each component, [-]
    CASRNs: list of strings
        CASRNs, not currently used [-]

    Returns
    -------
    omega : float
        acentric factor of the mixture, [-]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain omega with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Only 'SIMPLE' is accepted so far.
        All valid values are also held in the list omega_mixture_methods.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        omega for the desired chemical, and will return methods instead of
        omega

    Notes
    -----
    The only data used in the methods implemented to date are mole fractions
    and pure-component omegas. An alternate definition could be based on
    the dew point or bubble point of a multicomponent mixture, but this has
    not been done to date.

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


T_br = Tb/Tc<EOL>omega = (log(<NUM_LIT>/Pc) - <NUM_LIT> + <NUM_LIT>/T_br + <NUM_LIT>*log(T_br) -<EOL><NUM_LIT>*T_br**<NUM_LIT:6>)/(<NUM_LIT> - <NUM_LIT>/T_br - <NUM_LIT>*log(T_br) +<EOL><NUM_LIT>*T_br**<NUM_LIT:6>)<EOL>return omega<EOL>

r'''Estimates the acentric factor of a fluid using a correlation in [1]_.

    .. math::
        \omega = \frac{\ln P_{br}^{sat} - 5.92714 + 6.09648/T_{br} + 1.28862
        \ln T_{br} -0.169347T_{br}^6}
        {15.2518 - 15.6875/T_{br} - 13.4721 \ln T_{br} + 0.43577 T_{br}^6}

    Parameters
    ----------
    Tb : float
        Boiling temperature of the fluid [K]
    Tc : float
        Critical temperature of the fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]

    Returns
    -------
    omega : float
        Acentric factor of the fluid [-]

    Notes
    -----
    Internal units are atmosphere and Kelvin.
    Example value from Reid (1987). Using ASPEN V8.4, LK method gives 0.325595.

    Examples
    --------
    Isopropylbenzene

    >>> LK_omega(425.6, 631.1, 32.1E5)
    0.32544249926397856

    References
    ----------
    .. [1] Lee, Byung Ik, and Michael G. Kesler. "A Generalized Thermodynamic
       Correlation Based on Three-Parameter Corresponding States." AIChE Journal
       21, no. 3 (1975): 510-527. doi:10.1002/aic.690210313.


def StielPolar(Tc=None, Pc=None, omega=None, CASRN='<STR_LIT>', Method=None,<EOL>AvailableMethods=False):

def list_methods():<EOL><INDENT>methods = []<EOL>if Tc and Pc and omega:<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>methods.append('<STR_LIT>')<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == '<STR_LIT>':<EOL><INDENT>P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc*<NUM_LIT>)<EOL>if not P:<EOL><INDENT>factor = None<EOL><DEDENT>else:<EOL><INDENT>Pr = P/Pc<EOL>factor = log10(Pr) + <NUM_LIT>*omega + <NUM_LIT><EOL><DEDENT><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>factor = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return factor<EOL>

r'''This function handles the calculation of a chemical's Stiel Polar
    factor, directly through the definition of Stiel-polar factor if possible.
    Requires Tc, Pc, acentric factor, and a vapor pressure datum at Tr=0.6.

    Will automatically select a method to use if no Method is provided;
    returns None if the data is not available and cannot be calculated.

    .. math::
        x = \log P_r|_{T_r=0.6} + 1.70 \omega + 1.552

    Parameters
    ----------
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    omega : float
        Acentric factor of the fluid [-]
    CASRN : string
        CASRN [-]

    Returns
    -------
    factor : float
        Stiel polar factor of compound
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain Stiel polar factor with the
        given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Only 'DEFINITION' is accepted so far.
        All valid values are also held in the list Stiel_polar_methods.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        Stiel-polar factor for the desired chemical, and will return methods
        instead of stiel-polar factor

    Notes
    -----
    Only one source is available for this function. It is:

        * 'DEFINITION', based on the definition of
          Stiel Polar Factor presented in [1]_, using vapor pressure data.

    A few points have also been published in [2]_, which may be used for
    comparison. Currently this is only used for a surface tension correlation.

    Examples
    --------
    >>> StielPolar(647.3, 22048321.0, 0.344, CASRN='7732-18-5')
    0.024581140348734376

    References
    ----------
    .. [1] Halm, Roland L., and Leonard I. Stiel. "A Fourth Parameter for the
       Vapor Pressure and Entropy of Vaporization of Polar Fluids." AIChE
       Journal 13, no. 2 (1967): 351-355. doi:10.1002/aic.690130228.
    .. [2] D, Kukoljac Miloš, and Grozdanić Dušan K. "New Values of the
       Polarity Factor." Journal of the Serbian Chemical Society 65, no. 12
       (January 1, 2000). http://www.shd.org.rs/JSCS/Vol65/No12-Pdf/JSCS12-07.pdf


def omega(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=['<STR_LIT>', '<STR_LIT>']):

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>Tcrit, Pcrit = Tc(CASRN), Pc(CASRN)<EOL>if Tcrit and Pcrit:<EOL><INDENT>if Tb(CASRN):<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if VaporPressure(CASRN=CASRN).T_dependent_property(Tcrit*<NUM_LIT>):<EOL><INDENT>methods.append('<STR_LIT>')  <EOL><DEDENT><DEDENT>if IgnoreMethods:<EOL><INDENT>for Method in IgnoreMethods:<EOL><INDENT>if Method in methods:<EOL><INDENT>methods.remove(Method)<EOL><DEDENT><DEDENT><DEDENT>methods.append('<STR_LIT>')<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == '<STR_LIT>':<EOL><INDENT>_omega = float(_crit_PSRKR4.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>_omega = float(_crit_PassutDanner.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>_omega = float(_crit_Yaws.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>_omega = LK_omega(Tb(CASRN), Tc(CASRN), Pc(CASRN))<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc(CASRN)*<NUM_LIT>)<EOL>_omega = -log10(P/Pc(CASRN)) - <NUM_LIT:1.0><EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>_omega = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _omega<EOL>

r'''This function handles the retrieval of a chemical's acentric factor,
    `omega`, or its calculation from correlations or directly through the
    definition of acentric factor if possible. Requires a known boiling point,
    critical temperature and pressure for use of the correlations. Requires
    accurate vapor pressure data for direct calculation.

    Will automatically select a method to use if no Method is provided;
    returns None if the data is not available and cannot be calculated.

    .. math::
        \omega \equiv -\log_{10}\left[\lim_{T/T_c=0.7}(P^{sat}/P_c)\right]-1.0

    Examples
    --------
    >>> omega(CASRN='64-17-5')
    0.635

    Parameters
    ----------
    CASRN : string
        CASRN [-]

    Returns
    -------
    omega : float
        Acentric factor of compound
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain omega with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are 'PSRK', 'PD', 'YAWS',
        'LK', and 'DEFINITION'. All valid values are also held in the list
        omega_methods.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        omega for the desired chemical, and will return methods instead of
        omega
    IgnoreMethods : list, optional
        A list of methods to ignore in obtaining the full list of methods,
        useful for for performance reasons and ignoring inaccurate methods

    Notes
    -----
    A total of five sources are available for this function. They are:

        * 'PSRK', a compillation of experimental and estimated data published
          in the Appendix of [15]_, the fourth revision of the PSRK model.
        * 'PD', an older compillation of
          data published in (Passut & Danner, 1973) [16]_.
        * 'YAWS', a large compillation of data from a
          variety of sources; no data points are sourced in the work of [17]_.
        * 'LK', a estimation method for hydrocarbons.
        * 'DEFINITION', based on the definition of omega as
          presented in [1]_, using vapor pressure data.

    References
    ----------
    .. [1] Pitzer, K. S., D. Z. Lippmann, R. F. Curl, C. M. Huggins, and
       D. E. Petersen: The Volumetric and Thermodynamic Properties of Fluids.
       II. Compressibility Factor, Vapor Pressure and Entropy of Vaporization.
       J. Am. Chem. Soc., 77: 3433 (1955).
    .. [2] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and
       Jürgen Gmehling. "PSRK Group Contribution Equation of State:
       Comprehensive Revision and Extension IV, Including Critical Constants
       and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria
       227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002.
    .. [3] Passut, Charles A., and Ronald P. Danner. "Acentric Factor. A
       Valuable Correlating Parameter for the Properties of Hydrocarbons."
       Industrial & Engineering Chemistry Process Design and Development 12,
       no. 3 (July 1, 1973): 365-68. doi:10.1021/i260047a026.
    .. [4] Yaws, Carl L. Thermophysical Properties of Chemicals and
       Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
       Publishing, 2014.


def BVirial_Pitzer_Curl(T, Tc, Pc, omega, order=<NUM_LIT:0>):

Tr = T/Tc<EOL>if order == <NUM_LIT:0>:<EOL><INDENT>B0 = <NUM_LIT> - <NUM_LIT>/Tr - <NUM_LIT>/Tr**<NUM_LIT:2> - <NUM_LIT>/Tr**<NUM_LIT:3><EOL>B1 = <NUM_LIT> + <NUM_LIT>/Tr - <NUM_LIT:0.5>/Tr**<NUM_LIT:2> - <NUM_LIT>/Tr**<NUM_LIT:3> - <NUM_LIT>/Tr**<NUM_LIT:8><EOL><DEDENT>elif order == <NUM_LIT:1>:<EOL><INDENT>B0 = Tc*(<NUM_LIT>*T**<NUM_LIT:2> + <NUM_LIT>*T*Tc + <NUM_LIT>*Tc**<NUM_LIT:2>)/(<NUM_LIT>*T**<NUM_LIT:4>)<EOL>B1 = Tc*(-<NUM_LIT>*T**<NUM_LIT:7> + <NUM_LIT>*T**<NUM_LIT:6>*Tc + <NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:2> + <NUM_LIT>*Tc**<NUM_LIT:7>)/(<NUM_LIT>*T**<NUM_LIT:9>)<EOL><DEDENT>elif order == <NUM_LIT:2>:<EOL><INDENT>B0 = -<NUM_LIT:3>*Tc*(<NUM_LIT>*T**<NUM_LIT:2> + <NUM_LIT>*T*Tc + <NUM_LIT>*Tc**<NUM_LIT:2>)/(<NUM_LIT>*T**<NUM_LIT:5>)<EOL>B1 = Tc*(<NUM_LIT>*T**<NUM_LIT:7> - <NUM_LIT>*T**<NUM_LIT:6>*Tc - <NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:2> - <NUM_LIT>*Tc**<NUM_LIT:7>)/(<NUM_LIT>*T**<NUM_LIT:10>)<EOL><DEDENT>elif order == <NUM_LIT:3>:<EOL><INDENT>B0 = <NUM_LIT:3>*Tc*(<NUM_LIT>*T**<NUM_LIT:2> + <NUM_LIT>*T*Tc + <NUM_LIT>*Tc**<NUM_LIT:2>)/(<NUM_LIT>*T**<NUM_LIT:6>)<EOL>B1 = <NUM_LIT:3>*Tc*(-<NUM_LIT>*T**<NUM_LIT:7> + <NUM_LIT:1000>*T**<NUM_LIT:6>*Tc + <NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:2> + <NUM_LIT>*Tc**<NUM_LIT:7>)/(<NUM_LIT>*T**<NUM_LIT:11>)<EOL><DEDENT>elif order == -<NUM_LIT:1>:<EOL><INDENT>B0 = <NUM_LIT>*T/<NUM_LIT> - <NUM_LIT>*Tc*log(T)/<NUM_LIT:100> + (<NUM_LIT>*T*Tc**<NUM_LIT:2> + <NUM_LIT>*Tc**<NUM_LIT:3>)/(<NUM_LIT>*T**<NUM_LIT:2>)<EOL>B1 = <NUM_LIT>*T/<NUM_LIT:1000> + <NUM_LIT>*Tc*log(T)/<NUM_LIT:50> + (<NUM_LIT>*T**<NUM_LIT:6>*Tc**<NUM_LIT:2> + <NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:3> + <NUM_LIT>*Tc**<NUM_LIT:8>)/(<NUM_LIT>*T**<NUM_LIT:7>)<EOL><DEDENT>elif order == -<NUM_LIT:2>:<EOL><INDENT>B0 = <NUM_LIT>*T**<NUM_LIT:2>/<NUM_LIT> - <NUM_LIT>*T*Tc*log(T)/<NUM_LIT:100> + <NUM_LIT>*T*Tc/<NUM_LIT:100> + <NUM_LIT>*Tc**<NUM_LIT:2>*log(T)/<NUM_LIT> - <NUM_LIT>*Tc**<NUM_LIT:3>/(<NUM_LIT>*T)<EOL>B1 = <NUM_LIT>*T**<NUM_LIT:2>/<NUM_LIT> + <NUM_LIT>*T*Tc*log(T)/<NUM_LIT:50> - <NUM_LIT>*T*Tc/<NUM_LIT:50> + Tc**<NUM_LIT:2>*log(T)/<NUM_LIT:2> - (<NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:3> + <NUM_LIT>*Tc**<NUM_LIT:8>)/(<NUM_LIT>*T**<NUM_LIT:6>)<EOL><DEDENT>else: <EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>Br = B0 + omega*B1<EOL>return Br*R*Tc/Pc<EOL>

r'''Calculates the second virial coefficient using the model in [1]_.
    Designed for simple calculations.

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

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

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

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

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

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

    For first temperature derivative of B:

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

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

    For the second temperature derivative of B:

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

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

    For the third temperature derivative of B:

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

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

    For the first indefinite integral of B:

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

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

    For the second indefinite integral of B:

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

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

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

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

    References
    ----------
    .. [1] Pitzer, Kenneth S., and R. F. Curl. "The Volumetric and
       Thermodynamic Properties of Fluids. III. Empirical Equation for the
       Second Virial Coefficient1." Journal of the American Chemical Society
       79, no. 10 (May 1, 1957): 2369-70. doi:10.1021/ja01567a007.


def BVirial_Tsonopoulos_extended(T, Tc, Pc, omega, a=<NUM_LIT:0>, b=<NUM_LIT:0>, species_type='<STR_LIT>', <EOL>dipole=<NUM_LIT:0>, order=<NUM_LIT:0>):

Tr = T/Tc<EOL>if order == <NUM_LIT:0>:<EOL><INDENT>B0 = <NUM_LIT> - <NUM_LIT>/Tr - <NUM_LIT>/Tr**<NUM_LIT:2> - <NUM_LIT>/Tr**<NUM_LIT:3> - <NUM_LIT>/Tr**<NUM_LIT:8><EOL>B1 = <NUM_LIT> + <NUM_LIT>/Tr**<NUM_LIT:2> - <NUM_LIT>/Tr**<NUM_LIT:3> - <NUM_LIT>/Tr**<NUM_LIT:8><EOL>B2 = <NUM_LIT:1.>/Tr**<NUM_LIT:6><EOL>B3 = -<NUM_LIT:1.>/Tr**<NUM_LIT:8><EOL><DEDENT>elif order == <NUM_LIT:1>:<EOL><INDENT>B0 = <NUM_LIT>*Tc/(<NUM_LIT:100>*T**<NUM_LIT:2>) + <NUM_LIT>*Tc**<NUM_LIT:2>/(<NUM_LIT:1000>*T**<NUM_LIT:3>) + <NUM_LIT>*Tc**<NUM_LIT:3>/(<NUM_LIT>*T**<NUM_LIT:4>) + <NUM_LIT>*Tc**<NUM_LIT:8>/(<NUM_LIT>*T**<NUM_LIT:9>)<EOL>B1 = -<NUM_LIT>*Tc**<NUM_LIT:2>/(<NUM_LIT>*T**<NUM_LIT:3>) + <NUM_LIT>*Tc**<NUM_LIT:3>/(<NUM_LIT:1000>*T**<NUM_LIT:4>) + <NUM_LIT:8>*Tc**<NUM_LIT:8>/(<NUM_LIT>*T**<NUM_LIT:9>)<EOL>B2 = -<NUM_LIT>*Tc**<NUM_LIT:6>/T**<NUM_LIT:7><EOL>B3 = <NUM_LIT>*Tc**<NUM_LIT:8>/T**<NUM_LIT:9><EOL><DEDENT>elif order == <NUM_LIT:2>:<EOL><INDENT>B0 = -<NUM_LIT:3>*Tc*(<NUM_LIT> + <NUM_LIT>*Tc/T + <NUM_LIT>*Tc**<NUM_LIT:2>/T**<NUM_LIT:2> + <NUM_LIT>*Tc**<NUM_LIT:7>/T**<NUM_LIT:7>)/(<NUM_LIT>*T**<NUM_LIT:3>)<EOL>B1 = <NUM_LIT:3>*Tc**<NUM_LIT:2>*(<NUM_LIT> - <NUM_LIT>*Tc/T - <NUM_LIT>*Tc**<NUM_LIT:6>/T**<NUM_LIT:6>)/(<NUM_LIT>*T**<NUM_LIT:4>)<EOL>B2 = <NUM_LIT>*Tc**<NUM_LIT:6>/T**<NUM_LIT:8><EOL>B3 = -<NUM_LIT>*Tc**<NUM_LIT:8>/T**<NUM_LIT:10><EOL><DEDENT>elif order == <NUM_LIT:3>:<EOL><INDENT>B0 = <NUM_LIT:3>*Tc*(<NUM_LIT> + <NUM_LIT>*Tc/T + <NUM_LIT>*Tc**<NUM_LIT:2>/T**<NUM_LIT:2> + <NUM_LIT>*Tc**<NUM_LIT:7>/T**<NUM_LIT:7>)/(<NUM_LIT>*T**<NUM_LIT:4>)<EOL>B1 = <NUM_LIT:3>*Tc**<NUM_LIT:2>*(-<NUM_LIT> + <NUM_LIT>*Tc/T + <NUM_LIT>*Tc**<NUM_LIT:6>/T**<NUM_LIT:6>)/(<NUM_LIT>*T**<NUM_LIT:5>)<EOL>B2 = -<NUM_LIT>*Tc**<NUM_LIT:6>/T**<NUM_LIT:9><EOL>B3 = <NUM_LIT>*Tc**<NUM_LIT:8>/T**<NUM_LIT:11><EOL><DEDENT>elif order == -<NUM_LIT:1>:<EOL><INDENT>B0 = <NUM_LIT>*T/<NUM_LIT> - <NUM_LIT>*Tc*log(T)/<NUM_LIT> + (<NUM_LIT>*T**<NUM_LIT:6>*Tc**<NUM_LIT:2> + <NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:3> + <NUM_LIT>*Tc**<NUM_LIT:8>)/(<NUM_LIT>*T**<NUM_LIT:7>)<EOL>B1 = <NUM_LIT>*T/<NUM_LIT> - (<NUM_LIT>*T**<NUM_LIT:6>*Tc**<NUM_LIT:2> - <NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:3> - <NUM_LIT>*Tc**<NUM_LIT:8>)/(<NUM_LIT>*T**<NUM_LIT:7>)<EOL>B2 = -Tc**<NUM_LIT:6>/(<NUM_LIT:5>*T**<NUM_LIT:5>)<EOL>B3 = Tc**<NUM_LIT:8>/(<NUM_LIT:7>*T**<NUM_LIT:7>)<EOL><DEDENT>elif order == -<NUM_LIT:2>:<EOL><INDENT>B0 = <NUM_LIT>*T**<NUM_LIT:2>/<NUM_LIT> - <NUM_LIT>*T*Tc*log(T)/<NUM_LIT> + <NUM_LIT>*T*Tc/<NUM_LIT> + <NUM_LIT>*Tc**<NUM_LIT:2>*log(T)/<NUM_LIT> - (<NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:3> + <NUM_LIT>*Tc**<NUM_LIT:8>)/(<NUM_LIT>*T**<NUM_LIT:6>)<EOL>B1 = <NUM_LIT>*T**<NUM_LIT:2>/<NUM_LIT> - <NUM_LIT>*Tc**<NUM_LIT:2>*log(T)/<NUM_LIT> - (<NUM_LIT>*T**<NUM_LIT:5>*Tc**<NUM_LIT:3> + <NUM_LIT>*Tc**<NUM_LIT:8>)/(<NUM_LIT>*T**<NUM_LIT:6>)<EOL>B2 = Tc**<NUM_LIT:6>/(<NUM_LIT:20>*T**<NUM_LIT:4>)<EOL>B3 = -Tc**<NUM_LIT:8>/(<NUM_LIT>*T**<NUM_LIT:6>)<EOL><DEDENT>else: <EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if a == <NUM_LIT:0> and b == <NUM_LIT:0> and species_type != '<STR_LIT>':<EOL><INDENT>if species_type == '<STR_LIT>' or species_type == '<STR_LIT>':<EOL><INDENT>a, b = <NUM_LIT:0>, <NUM_LIT:0><EOL><DEDENT>elif species_type == '<STR_LIT>':<EOL><INDENT>a, b = <NUM_LIT>, <NUM_LIT><EOL><DEDENT>elif species_type == '<STR_LIT>':<EOL><INDENT>a, b = -<NUM_LIT>, <NUM_LIT:0><EOL><DEDENT>elif dipole != <NUM_LIT:0> and Tc != <NUM_LIT:0> and Pc != <NUM_LIT:0>:<EOL><INDENT>dipole_r = <NUM_LIT>*dipole**<NUM_LIT:2>*(Pc/<NUM_LIT>)/Tc**<NUM_LIT:2><EOL>if (species_type == '<STR_LIT>' or species_type == '<STR_LIT>'<EOL>or species_type == '<STR_LIT>' or species_type == '<STR_LIT>'<EOL>or species_type == '<STR_LIT>' or species_type == '<STR_LIT>'):<EOL><INDENT>a, b = -<NUM_LIT>*dipole_r-<NUM_LIT>*dipole_r**<NUM_LIT:8>, <NUM_LIT:0><EOL><DEDENT>elif (species_type == '<STR_LIT>' or species_type == '<STR_LIT>'<EOL>or species_type == '<STR_LIT>' or species_type == '<STR_LIT>'):<EOL><INDENT>a, b = -<NUM_LIT>*dipole_r**<NUM_LIT:4>-<NUM_LIT>*dipole_r**<NUM_LIT:8>, <NUM_LIT:0><EOL><DEDENT>elif species_type == '<STR_LIT>':<EOL><INDENT>a, b = <NUM_LIT>, <NUM_LIT>+<NUM_LIT>*dipole_r<EOL><DEDENT><DEDENT><DEDENT>Br = B0 + omega*B1 + a*B2 + b*B3<EOL>return Br*R*Tc/Pc<EOL>

r'''Calculates the second virial coefficient using the
    comprehensive model in [1]_. See the notes for the calculation of `a` and
    `b`.

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

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

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

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

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

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

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

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

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

    For 'simple' or 'normal' fluids:

    .. math::
        a = 0

        b = 0

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

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

        b = 0

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

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

        b = 0

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

    .. math::
        a = 0.0878

        b = 0.00908 + 0.0006957 \mu_r

    For methanol:

    .. math::
        a = 0.0878

        b = 0.0525

    For water:

    .. math::
        a = -0.0109

        b = 0

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

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

    For first temperature derivative of B:

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

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

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

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

    For the second temperature derivative of B:

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

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

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

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

    For the third temperature derivative of B:

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

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

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

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

    For the first indefinite integral of B:

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

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

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

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

    For the second indefinite integral of B:

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

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

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

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

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

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

    References
    ----------
    .. [1] Tsonopoulos, C., and J. L. Heidman. "From the Virial to the Cubic
       Equation of State." Fluid Phase Equilibria 57, no. 3 (1990): 261-76.
       doi:10.1016/0378-3812(90)85126-U
    .. [2] Tsonopoulos, Constantine, and John H. Dymond. "Second Virial
       Coefficients of Normal Alkanes, Linear 1-Alkanols (and Water), Alkyl
       Ethers, and Their Mixtures." Fluid Phase Equilibria, International
       Workshop on Vapour-Liquid Equilibria and Related Properties in Binary
       and Ternary Mixtures of Ethers, Alkanes and Alkanols, 133, no. 1-2
       (June 1997): 11-34. doi:10.1016/S0378-3812(97)00058-7.


def BVirial_Abbott(T, Tc, Pc, omega, order=<NUM_LIT:0>):

Tr = T/Tc<EOL>if order == <NUM_LIT:0>:<EOL><INDENT>B0 = <NUM_LIT> - <NUM_LIT>/Tr**<NUM_LIT><EOL>B1 = <NUM_LIT> - <NUM_LIT>/Tr**<NUM_LIT><EOL><DEDENT>elif order == <NUM_LIT:1>:<EOL><INDENT>B0 = <NUM_LIT>*Tr**(-<NUM_LIT>)/T<EOL>B1 = <NUM_LIT>*Tr**(-<NUM_LIT>)/T<EOL><DEDENT>elif order == <NUM_LIT:2>:<EOL><INDENT>B0 = -<NUM_LIT>*Tr**(-<NUM_LIT>)/T**<NUM_LIT:2><EOL>B1 = -<NUM_LIT>*Tr**(-<NUM_LIT>)/T**<NUM_LIT:2><EOL><DEDENT>elif order == <NUM_LIT:3>:<EOL><INDENT>B0 = <NUM_LIT>*Tr**(-<NUM_LIT>)/T**<NUM_LIT:3><EOL>B1 = <NUM_LIT>*Tr**(-<NUM_LIT>)/T**<NUM_LIT:3><EOL><DEDENT>elif order == -<NUM_LIT:1>:<EOL><INDENT>B0 = <NUM_LIT>*T + <NUM_LIT>/<NUM_LIT>*Tc*(Tr)**(-<NUM_LIT>)<EOL>B1 = <NUM_LIT>*T + <NUM_LIT>*Tc*Tr**(-<NUM_LIT>)<EOL><DEDENT>elif order == -<NUM_LIT:2>:<EOL><INDENT>B0 = <NUM_LIT>*T**<NUM_LIT:2> + <NUM_LIT>/<NUM_LIT>*Tc**<NUM_LIT:2>*Tr**<NUM_LIT><EOL>B1 = <NUM_LIT>*T**<NUM_LIT:2> - <NUM_LIT>/<NUM_LIT>*Tc**<NUM_LIT:2>*Tr**(-<NUM_LIT>)<EOL><DEDENT>else: <EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>Br = B0 + omega*B1<EOL>return Br*R*Tc/Pc<EOL>

r'''Calculates the second virial coefficient using the model in [1]_.
    Simple fit to the Lee-Kesler equation.

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

        B^{(0)}=0.083+\frac{0.422}{T_r^{1.6}}

        B^{(1)}=0.139-\frac{0.172}{T_r^{4.2}}

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

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

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

    For first temperature derivative of B:

    .. math::
        \frac{d B^{(0)}}{dT} = \frac{0.6752}{T \left(\frac{T}{Tc}\right)^{1.6}}

        \frac{d B^{(1)}}{dT} = \frac{0.7224}{T \left(\frac{T}{Tc}\right)^{4.2}}

    For the second temperature derivative of B:

    .. math::
        \frac{d^2 B^{(0)}}{dT^2} = - \frac{1.75552}{T^{2} \left(\frac{T}{Tc}\right)^{1.6}}

        \frac{d^2 B^{(1)}}{dT^2} = - \frac{3.75648}{T^{2} \left(\frac{T}{Tc}\right)^{4.2}}

    For the third temperature derivative of B:

    .. math::
        \frac{d^3 B^{(0)}}{dT^3} = \frac{6.319872}{T^{3} \left(\frac{T}{Tc}\right)^{1.6}}

        \frac{d^3 B^{(1)}}{dT^3} = \frac{23.290176}{T^{3} \left(\frac{T}{Tc}\right)^{4.2}}

    For the first indefinite integral of B:

    .. math::
        \int{B^{(0)}} dT = 0.083 T + \frac{\frac{211}{300} Tc}{\left(\frac{T}{Tc}\right)^{0.6}}

        \int{B^{(1)}} dT = 0.139 T + \frac{0.05375 Tc}{\left(\frac{T}{Tc}\right)^{3.2}}

    For the second indefinite integral of B:

    .. math::
        \int\int B^{(0)} dT dT = 0.0415 T^{2} + \frac{211}{120} Tc^{2} \left(\frac{T}{Tc}\right)^{0.4}

        \int\int B^{(1)} dT dT = 0.0695 T^{2} - \frac{\frac{43}{1760} Tc^{2}}{\left(\frac{T}{Tc}\right)^{2.2}}

    Examples
    --------
    Example is from [1]_, p. 93, and matches the result exactly, for isobutane.

    >>> BVirial_Abbott(510., 425.2, 38E5, 0.193)
    -0.00020570178037383633

    References
    ----------
    .. [1] Smith, H. C. Van Ness Joseph M. Introduction to Chemical Engineering
       Thermodynamics 4E 1987.


def Hcombustion(atoms, Hf=None, HfH2O=-<NUM_LIT>, HfCO2=-<NUM_LIT>,<EOL>HfSO2=-<NUM_LIT>, HfBr2=<NUM_LIT>, HfI2=<NUM_LIT>, HfHCl=-<NUM_LIT>,<EOL>HfHF=-<NUM_LIT>, HfP4O10=-<NUM_LIT>, HfO2=<NUM_LIT:0>, HfN2=<NUM_LIT:0>):

if not Hf or not atoms:<EOL><INDENT>return None<EOL><DEDENT>nC, nH, nN, nO, nS, nBr, nI, nCl, nF, nP = <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0><EOL>if '<STR_LIT:C>' in atoms and atoms['<STR_LIT:C>'] != <NUM_LIT:0>:<EOL><INDENT>nC = atoms['<STR_LIT:C>']<EOL><DEDENT>else:<EOL><INDENT>return None  <EOL><DEDENT>if '<STR_LIT:H>' in atoms:<EOL><INDENT>nH = atoms['<STR_LIT:H>']<EOL><DEDENT>if '<STR_LIT:N>' in atoms:<EOL><INDENT>nN = atoms['<STR_LIT:N>']<EOL><DEDENT>if '<STR_LIT:O>' in atoms:<EOL><INDENT>nO = atoms['<STR_LIT:O>']<EOL><DEDENT>if '<STR_LIT:S>' in atoms:<EOL><INDENT>nS = atoms['<STR_LIT:S>']<EOL><DEDENT>if '<STR_LIT>' in atoms:<EOL><INDENT>nBr = atoms['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT:I>' in atoms:<EOL><INDENT>nI = atoms['<STR_LIT:I>']<EOL><DEDENT>if '<STR_LIT>' in atoms:<EOL><INDENT>nCl = atoms['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT:F>' in atoms:<EOL><INDENT>nF = atoms['<STR_LIT:F>']<EOL><DEDENT>if '<STR_LIT:P>' in atoms:<EOL><INDENT>nP = atoms['<STR_LIT:P>']<EOL><DEDENT>nO2_req = nC + nS + nH/<NUM_LIT> + <NUM_LIT:5>*nP/<NUM_LIT> - (nCl + nF)/<NUM_LIT> - nO/<NUM_LIT><EOL>nCO2 = nC<EOL>nBr2 = nBr/<NUM_LIT><EOL>nI2 = nI/<NUM_LIT><EOL>nHCl = nCl<EOL>nHF = nF<EOL>nSO2 = nS<EOL>nN2 = nN/<NUM_LIT><EOL>nP4O10 = nP/<NUM_LIT><EOL>nH2O = (nH - nCl - nF)/<NUM_LIT><EOL>Hc = (nBr2*HfBr2 + nI2*HfI2) + (nHCl*HfHCl + nHF*HfHF) + nSO2*HfSO2 +nN2*HfN2 + nP4O10*HfP4O10 + nH2O*HfH2O - nO2_req*HfO2 + nCO2*HfCO2 - Hf<EOL>return Hc<EOL>

Calculates the heat of combustion, in J/mol.
    Value non-hydrocarbons is not correct, but still calculable.

    Parameters
    ----------
    atoms : dict
        Dictionary of atoms and their counts, []
    Hf : float
        Heat of formation of given chemical, [J/mol]
    HfH2O : float, optional
        Heat of formation of water, [J/mol]
    HfCO2 : float, optional
        Heat of formation of carbon dioxide, [J/mol]
    HfSO2 : float, optional
        Heat of formation of sulfur dioxide, [J/mol]
    HfBr2 : float, optional
        Heat of formation of bromine, [J/mol]
    HfI2 : float, optional
        Heat of formation of iodine, [J/mol]
    HfHCl : float, optional
        Heat of formation of chlorine, [J/mol]
    HfHF : float, optional
        Heat of formation of hydrogen fluoride, [J/mol]
    HfP4O10 : float, optional
        Heat of formation of phosphorus pentoxide, [J/mol]
    HfO2 : float, optional
        Heat of formation of oxygen, [J/mol]
    HfN2 : float, optional
        Heat of formation of nitrogen, [J/mol]

    Returns
    -------
    Hc : float
        Heat of combustion of chemical, [J/mol]

    Notes
    -----
    Default heats of formation for chemicals are at 298 K, 1 atm.

    Examples
    --------
    Liquid methanol burning

    >>> Hcombustion({'H': 4, 'C': 1, 'O': 1}, Hf=-239100)
    -726024.0


def Wagner_original(T, Tc, Pc, a, b, c, d):

Tr = T/Tc<EOL>tau = <NUM_LIT:1.0> - Tr<EOL>return Pc*exp((a*tau + b*tau**<NUM_LIT> + c*tau**<NUM_LIT:3> + d*tau**<NUM_LIT:6>)/Tr)<EOL>

r'''Calculates vapor pressure using the Wagner equation (3, 6 form).

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

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

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

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

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

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

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

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

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.
    .. [2] McGarry, Jack. "Correlation and Prediction of the Vapor Pressures of
       Pure Liquids over Large Pressure Ranges." Industrial & Engineering
       Chemistry Process Design and Development 22, no. 2 (April 1, 1983):
       313-22. doi:10.1021/i200021a023.


tau = <NUM_LIT:1.> - T/Tc<EOL>a = -<NUM_LIT> - <NUM_LIT>*omega<EOL>c = -<NUM_LIT> - <NUM_LIT>*omega<EOL>d = <NUM_LIT:1.>/(-<NUM_LIT> - <NUM_LIT>*omega + <NUM_LIT>*omega**<NUM_LIT:2>)<EOL>b = <NUM_LIT> - <NUM_LIT>*omega - <NUM_LIT>*d<EOL>lnPr = (a*tau + b*tau**<NUM_LIT> + c*tau**<NUM_LIT:3> + d*tau**<NUM_LIT:6>)/(<NUM_LIT:1.>-tau)<EOL>return exp(lnPr)*Pc<EOL>

r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a
    CSP relationship by [1]_. Requires a chemical's critical temperature,
    pressure, and acentric factor. Claimed to have a higher accuracy than the
    Lee-Kesler CSP relationship.

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

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

        a = -6.1559 - 4.0855\omega

        b = 1.5737 - 1.0540\omega - 4.4365\times 10^{-3} d

        c = -0.8747 - 7.8874\omega

        d = \frac{1}{-0.4893 - 0.9912\omega + 3.1551\omega^2}

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

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

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

    Notes
    -----
    [1]_ found an average error of 6.06% on 94 compounds and 1106 data points.

    Examples
    --------
    >>> Edalat(347.2, 617.1, 36E5, 0.299)
    13461.273080743307

    References
    ----------
    .. [1] Edalat, M., R. B. Bozar-Jomehri, and G. A. Mansoori. "Generalized
       Equation Predicts Vapor Pressure of Hydrocarbons." Oil and Gas Journal;
       91:5 (February 1, 1993).


Tr = T/Tc<EOL>f0 = <NUM_LIT> - <NUM_LIT>/Tr - <NUM_LIT>*log(Tr) + <NUM_LIT>*Tr**<NUM_LIT:6><EOL>f1 = <NUM_LIT> - <NUM_LIT>/Tr - <NUM_LIT>*log(Tr) + <NUM_LIT>*Tr**<NUM_LIT:6><EOL>return exp(f0 + omega*f1)*Pc<EOL>

r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a
    CSP relationship by [1]_; requires a chemical's critical temperature and
    acentric factor.

    The vapor pressure is given by:

    .. math::
        \ln P^{sat}_r = f^{(0)} + \omega f^{(1)}

        f^{(0)} = 5.92714-\frac{6.09648}{T_r}-1.28862\ln T_r + 0.169347T_r^6

        f^{(1)} = 15.2518-\frac{15.6875}{T_r} - 13.4721 \ln T_r + 0.43577T_r^6

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

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

    Notes
    -----
    This equation appears in [1]_ in expanded form.
    The reduced pressure form of the equation ensures predicted vapor pressure
    cannot surpass the critical pressure.

    Examples
    --------
    Example from [2]_; ethylbenzene at 347.2 K.

    >>> Lee_Kesler(347.2, 617.1, 36E5, 0.299)
    13078.694162949312

    References
    ----------
    .. [1] Lee, Byung Ik, and Michael G. Kesler. "A Generalized Thermodynamic
       Correlation Based on Three-Parameter Corresponding States." AIChE Journal
       21, no. 3 (1975): 510-527. doi:10.1002/aic.690210313.
    .. [2] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E.
       The Properties of Gases and Liquids. McGraw-Hill Companies, 1987.


Tr = T/Tc<EOL>tau = <NUM_LIT:1.0> - T/Tc<EOL>return Pc*exp((a*tau + b*tau**<NUM_LIT> + c*tau**<NUM_LIT> + d*tau**<NUM_LIT:5>)/Tr)<EOL>

r'''Calculates vapor pressure using the Wagner equation (2.5, 5 form).

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

    .. math::
        \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^{2.5}
        + d\tau^5} {T_r}

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

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

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

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

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

    >>> Wagner(100., 190.551, 4599200, -6.02242, 1.26652, -0.5707, -1.366)
    34415.00476263708

    References
    ----------
    .. [1] Wagner, W. "New Vapour Pressure Measurements for Argon and Nitrogen and
       a New Method for Establishing Rational Vapour Pressure Equations."
       Cryogenics 13, no. 8 (August 1973): 470-82. doi:10.1016/0011-2275(73)90003-9
    .. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.


def TRC_Antoine_extended(T, Tc, to, A, B, C, n, E, F):

x = max((T - to - <NUM_LIT>)/Tc, <NUM_LIT:0.>)<EOL>return <NUM_LIT>**(A - B/(T+C) + <NUM_LIT>*x**n + E*x**<NUM_LIT:8> + F*x**<NUM_LIT:12>)<EOL>

r'''Calculates vapor pressure of a chemical using the TRC Extended Antoine
    equation. Parameters are chemical dependent, and said to be from the
    Thermodynamics Research Center (TRC) at Texas A&M. Coefficients for various
    chemicals can be found in [1]_.

    .. math::
        \log_{10} P^{sat} = A - \frac{B}{T + C} + 0.43429x^n + Ex^8 + Fx^{12}

        x = \max \left(\frac{T-t_o-273.15}{T_c}, 0 \right)

    Parameters
    ----------
    T : float
        Temperature of fluid, [K]
    A, B, C, n, E, F : floats
        Regressed coefficients for the Antoine Extended (TRC) equation,
        specific for each chemical, [-]

    Returns
    -------
    Psat : float
        Vapor pressure calculated with coefficients [Pa]

    Notes
    -----
    Assumes coefficients are for calculating vapor pressure in Pascal.
    Coefficients should be consistent with input temperatures in Kelvin;

    Examples
    --------
    Tetrafluoromethane, coefficients from [1]_, at 180 K:

    >>> TRC_Antoine_extended(180.0, 227.51, -120., 8.95894, 510.595, -15.95,
    ... 2.41377, -93.74, 7425.9)
    706317.0898414153

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