<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 flash_inner_loop(zs, Ks, AvailableMethods=False, Method=None):

l = len(zs)<EOL>def list_methods():<EOL><INDENT>methods = []<EOL>if l in [<NUM_LIT:2>,<NUM_LIT:3>]:<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if l >= <NUM_LIT:2>:<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>if l >= <NUM_LIT:3>:<EOL><INDENT>methods.append('<STR_LIT>')<EOL><DEDENT>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = '<STR_LIT>' if l < <NUM_LIT:4> else '<STR_LIT>'<EOL><DEDENT>if Method == '<STR_LIT>':<EOL><INDENT>if l == <NUM_LIT:2>:<EOL><INDENT>z1, z2 = zs<EOL>K1, K2 = Ks<EOL>V_over_F = (-K1*z1 - K2*z2 + z1 + z2)/(K1*K2*z1 + K1*K2*z2 - K1*z1 - K1*z2 - K2*z1 - K2*z2 + z1 + z2)<EOL><DEDENT>elif l == <NUM_LIT:3>:<EOL><INDENT>z1, z2, z3 = zs<EOL>K1, K2, K3 = Ks<EOL>V_over_F = (-K1*K2*z1/<NUM_LIT:2> - K1*K2*z2/<NUM_LIT:2> - K1*K3*z1/<NUM_LIT:2> - K1*K3*z3/<NUM_LIT:2> + K1*z1 + K1*z2/<NUM_LIT:2> + K1*z3/<NUM_LIT:2> - K2*K3*z2/<NUM_LIT:2> - K2*K3*z3/<NUM_LIT:2> + K2*z1/<NUM_LIT:2> + K2*z2 + K2*z3/<NUM_LIT:2> + K3*z1/<NUM_LIT:2> + K3*z2/<NUM_LIT:2> + K3*z3 - z1 - z2 - z3 - (K1**<NUM_LIT:2>*K2**<NUM_LIT:2>*z1**<NUM_LIT:2> + <NUM_LIT:2>*K1**<NUM_LIT:2>*K2**<NUM_LIT:2>*z1*z2 + K1**<NUM_LIT:2>*K2**<NUM_LIT:2>*z2**<NUM_LIT:2> - <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*K3*z1**<NUM_LIT:2> - <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*K3*z1*z2 - <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*K3*z1*z3 + <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*K3*z2*z3 - <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*z1*z2 + <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*z1*z3 - <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*z2**<NUM_LIT:2> - <NUM_LIT:2>*K1**<NUM_LIT:2>*K2*z2*z3 + K1**<NUM_LIT:2>*K3**<NUM_LIT:2>*z1**<NUM_LIT:2> + <NUM_LIT:2>*K1**<NUM_LIT:2>*K3**<NUM_LIT:2>*z1*z3 + K1**<NUM_LIT:2>*K3**<NUM_LIT:2>*z3**<NUM_LIT:2> + <NUM_LIT:2>*K1**<NUM_LIT:2>*K3*z1*z2 - <NUM_LIT:2>*K1**<NUM_LIT:2>*K3*z1*z3 - <NUM_LIT:2>*K1**<NUM_LIT:2>*K3*z2*z3 - <NUM_LIT:2>*K1**<NUM_LIT:2>*K3*z3**<NUM_LIT:2> + K1**<NUM_LIT:2>*z2**<NUM_LIT:2> + <NUM_LIT:2>*K1**<NUM_LIT:2>*z2*z3 + K1**<NUM_LIT:2>*z3**<NUM_LIT:2> - <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*K3*z1*z2 + <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*K3*z1*z3 - <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*K3*z2**<NUM_LIT:2> - <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*K3*z2*z3 - <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*z1**<NUM_LIT:2> - <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*z1*z2 - <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*z1*z3 + <NUM_LIT:2>*K1*K2**<NUM_LIT:2>*z2*z3 + <NUM_LIT:2>*K1*K2*K3**<NUM_LIT:2>*z1*z2 - <NUM_LIT:2>*K1*K2*K3**<NUM_LIT:2>*z1*z3 - <NUM_LIT:2>*K1*K2*K3**<NUM_LIT:2>*z2*z3 - <NUM_LIT:2>*K1*K2*K3**<NUM_LIT:2>*z3**<NUM_LIT:2> + <NUM_LIT:4>*K1*K2*K3*z1**<NUM_LIT:2> + <NUM_LIT:4>*K1*K2*K3*z1*z2 + <NUM_LIT:4>*K1*K2*K3*z1*z3 + <NUM_LIT:4>*K1*K2*K3*z2**<NUM_LIT:2> + <NUM_LIT:4>*K1*K2*K3*z2*z3 + <NUM_LIT:4>*K1*K2*K3*z3**<NUM_LIT:2> + <NUM_LIT:2>*K1*K2*z1*z2 - <NUM_LIT:2>*K1*K2*z1*z3 - <NUM_LIT:2>*K1*K2*z2*z3 - <NUM_LIT:2>*K1*K2*z3**<NUM_LIT:2> - <NUM_LIT:2>*K1*K3**<NUM_LIT:2>*z1**<NUM_LIT:2> - <NUM_LIT:2>*K1*K3**<NUM_LIT:2>*z1*z2 - <NUM_LIT:2>*K1*K3**<NUM_LIT:2>*z1*z3 + <NUM_LIT:2>*K1*K3**<NUM_LIT:2>*z2*z3 - <NUM_LIT:2>*K1*K3*z1*z2 + <NUM_LIT:2>*K1*K3*z1*z3 - <NUM_LIT:2>*K1*K3*z2**<NUM_LIT:2> - <NUM_LIT:2>*K1*K3*z2*z3 + K2**<NUM_LIT:2>*K3**<NUM_LIT:2>*z2**<NUM_LIT:2> + <NUM_LIT:2>*K2**<NUM_LIT:2>*K3**<NUM_LIT:2>*z2*z3 + K2**<NUM_LIT:2>*K3**<NUM_LIT:2>*z3**<NUM_LIT:2> + <NUM_LIT:2>*K2**<NUM_LIT:2>*K3*z1*z2 - <NUM_LIT:2>*K2**<NUM_LIT:2>*K3*z1*z3 - <NUM_LIT:2>*K2**<NUM_LIT:2>*K3*z2*z3 - <NUM_LIT:2>*K2**<NUM_LIT:2>*K3*z3**<NUM_LIT:2> + K2**<NUM_LIT:2>*z1**<NUM_LIT:2> + <NUM_LIT:2>*K2**<NUM_LIT:2>*z1*z3 + K2**<NUM_LIT:2>*z3**<NUM_LIT:2> - <NUM_LIT:2>*K2*K3**<NUM_LIT:2>*z1*z2 + <NUM_LIT:2>*K2*K3**<NUM_LIT:2>*z1*z3 - <NUM_LIT:2>*K2*K3**<NUM_LIT:2>*z2**<NUM_LIT:2> - <NUM_LIT:2>*K2*K3**<NUM_LIT:2>*z2*z3 - <NUM_LIT:2>*K2*K3*z1**<NUM_LIT:2> - <NUM_LIT:2>*K2*K3*z1*z2 - <NUM_LIT:2>*K2*K3*z1*z3 + <NUM_LIT:2>*K2*K3*z2*z3 + K3**<NUM_LIT:2>*z1**<NUM_LIT:2> + <NUM_LIT:2>*K3**<NUM_LIT:2>*z1*z2 + K3**<NUM_LIT:2>*z2**<NUM_LIT:2>)**<NUM_LIT:0.5>/<NUM_LIT:2>)/(K1*K2*K3*z1 + K1*K2*K3*z2 + K1*K2*K3*z3 - K1*K2*z1 - K1*K2*z2 - K1*K2*z3 - K1*K3*z1 - K1*K3*z2 - K1*K3*z3 + K1*z1 + K1*z2 + K1*z3 - K2*K3*z1 - K2*K3*z2 - K2*K3*z3 + K2*z1 + K2*z2 + K2*z3 + K3*z1 + K3*z2 + K3*z3 - z1 - z2 - z3)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<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><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>return Rachford_Rice_solution(zs=zs, Ks=Ks)<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>return Li_Johns_Ahmadi_solution(zs=zs, Ks=Ks)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''This function handles the solution of the inner loop of a flash
    calculation, solving for liquid and gas mole fractions and vapor fraction
    based on specified overall mole fractions and K values. As K values are
    weak functions of composition, this should be called repeatedly by an outer
    loop. Will automatically select an algorithm to use if no Method is
    provided. Should always provide a solution.

    The automatic algorithm selection will try an analytical solution, and use
    the Rachford-Rice method if there are 4 or more components in the mixture.

    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, [-]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain a solution with the given
        inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are 'Analytical',
        'Rachford-Rice', and 'Li-Johns-Ahmadi'. All valid values are also held
        in the list `flash_inner_loop_methods`.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        a solution for the desired chemical, and will return methods instead of
        `V_over_F`, `xs`, and `ys`.

    Notes
    -----
    A total of three methods are available for this function. They are:

        * 'Analytical', an exact solution derived with SymPy, applicable only
          only to mixtures of two or three components
        * 'Rachford-Rice', which numerically solves an objective function
          described in :obj:`Rachford_Rice_solution`.
        * 'Li-Johns-Ahmadi', which numerically solves an objective function
          described in :obj:`Li_Johns_Ahmadi_solution`.

    Examples
    --------
    >>> flash_inner_loop(zs=[0.5, 0.3, 0.2], Ks=[1.685, 0.742, 0.532])
    (0.6907302627738537, [0.3394086969663437, 0.36505605903717053, 0.29553524399648573], [0.5719036543882892, 0.2708715958055805, 0.1572247498061304])


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.


gammas = []<EOL>cmps = range(len(xs))<EOL>for i in cmps:<EOL><INDENT>tot1 = log(sum([params[i][j]*xs[j] for j in cmps]))<EOL>tot2 = <NUM_LIT:0.><EOL>for j in cmps:<EOL><INDENT>tot2 += params[j][i]*xs[j]/sum([params[j][k]*xs[k] for k in cmps])<EOL><DEDENT>gamma = exp(<NUM_LIT:1.> - tot1 - tot2)<EOL>gammas.append(gamma)<EOL><DEDENT>return gammas<EOL>

r'''Calculates the activity coefficients of each species in a mixture
    using the Wilson method, given their mole fractions, and
    dimensionless interaction parameters. Those are normally correlated with
    temperature, and need to be calculated separately.

    .. math::
        \ln \gamma_i = 1 - \ln \left(\sum_j^N \Lambda_{ij} x_j\right)
        -\sum_j^N \frac{\Lambda_{ji}x_j}{\displaystyle\sum_k^N \Lambda_{jk}x_k}

    Parameters
    ----------
    xs : list[float]
        Liquid mole fractions of each species, [-]
    params : 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 model correlated the interaction parameters using the standard
    pure-component molar volumes of each species at 25°C, in the following form:

    .. math::
        \Lambda_{ij} = \frac{V_j}{V_i} \exp\left(\frac{-\lambda_{i,j}}{RT}\right)

    However, that form has less flexibility and offered no advantage over
    using only regressed parameters.

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

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

    The Wilson model is not applicable to liquid-liquid systems.

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

    >>> Wilson([0.252, 0.748], [[1, 0.154], [0.888, 1]])
    [1.8814926087178843, 1.1655774931125487]

    References
    ----------
    .. [1] Wilson, Grant M. "Vapor-Liquid Equilibrium. XI. A New Expression for
       the Excess Free Energy of Mixing." Journal of the American Chemical
       Society 86, no. 2 (January 1, 1964): 127-130. doi:10.1021/ja01056a002.
    .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey.
       Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim:
       Wiley-VCH, 2012.


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.


def dew_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 = <NUM_LIT:1>/sum(zs[i]*fugacities[i]/Psats[i]/gammas[i] for i in range(len(zs)))<EOL>return P<EOL>


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 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'


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 Pbubble_mixture(T=None, zs=None, Psats=None, CASRNs=None,<EOL>AvailableMethods=False, Method=None):

def list_methods():<EOL><INDENT>methods = []<EOL>if none_and_length_check((Psats, zs)):<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>Pbubble = bubble_at_T(zs, Psats)<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>Pbubble = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return Pbubble<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 Pdew_mixture(T=None, zs=None, Psats=None, CASRNs=None,<EOL>AvailableMethods=False, Method=None):

def list_methods():<EOL><INDENT>methods = []<EOL>if none_and_length_check((Psats, zs)):<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>Pdew = dew_at_T(zs, Psats)<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>Pdew = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return Pdew<EOL>


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.


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


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 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_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 BVirial_Tsonopoulos(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> - <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><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><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><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><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><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><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]_.

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

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

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

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

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

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

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

    For first temperature derivative of B:

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

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

    For the second temperature derivative of B:

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

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

    For the third temperature derivative of B:

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

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

    For the first indefinite integral of B:

    .. math::
        \int{B^{(0)}} dT = \frac{289 T}{2000} - \frac{33 Tc}{100} \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)

    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)

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

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

    References
    ----------
    .. [1] Tsonopoulos, Constantine. "An Empirical Correlation of Second Virial
       Coefficients." AIChE Journal 20, no. 2 (March 1, 1974): 263-72.
       doi:10.1002/aic.690200209.


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 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 Antoine(T, A, B, C, base=<NUM_LIT>):

return base**(A-B/(T+C))<EOL>

r'''Calculates vapor pressure of a chemical using the Antoine equation.
    Parameters `A`, `B`, and `C` are chemical-dependent. Parameters can be
    found in numerous sources; however units of the coefficients used vary.
    Originally proposed by Antoine (1888) [2]_.

    .. math::
        \log_{\text{base}} P^{\text{sat}} = A - \frac{B}{T+C}

    Parameters
    ----------
    T : float
        Temperature of fluid, [K]
    A, B, C : floats
        Regressed coefficients for Antoine equation for a chemical

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

    Other Parameters
    ----------------
    Base : float
        Optional base of logarithm; 10 by default

    Notes
    -----
    Assumes coefficients are for calculating vapor pressure in Pascal.
    Coefficients should be consistent with input temperatures in Kelvin;
    however, if both the given temperature and units are specific to degrees
    Celcius, the result will still be correct.

    **Converting units in input coefficients:**

        * **ln to log10**: Divide A and B by ln(10)=2.302585 to change
          parameters for a ln equation to a log10 equation.
        * **log10 to ln**: Multiply A and B by ln(10)=2.302585 to change
          parameters for a log equation to a ln equation.
        * **mmHg to Pa**: Add log10(101325/760)= 2.1249 to A.
        * **kPa to Pa**: Add log_{base}(1000)= 6.908 to A for log(base)
        * **°C to K**: Subtract 273.15 from C only!

    Examples
    --------
    Methane, coefficients from [1]_, at 100 K:

    >>> Antoine(100.0, 8.7687, 395.744, -6.469)
    34478.367349639906

    Tetrafluoromethane, coefficients from [1]_, at 180 K

    >>> Antoine(180, A=8.95894, B=510.595, C=-15.95)
    702271.0518579542

    Oxygen at 94.91 K, with coefficients from [3]_ in units of °C, mmHg, log10,
    showing the conversion of coefficients A (mmHg to Pa) and C (°C to K)

    >>> Antoine(94.91, 6.83706+2.1249, 339.2095, 268.70-273.15)
    162978.88655572367

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.
    .. [2] Antoine, C. 1888. Tensions des Vapeurs: Nouvelle Relation Entre les
       Tensions et les Tempé. Compt.Rend. 107:681-684.
    .. [3] Yaws, Carl L. The Yaws Handbook of Vapor Pressure: Antoine
       Coefficients. 1 edition. Houston, Tex: Gulf Publishing Company, 2007.


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.


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.


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 boiling_critical_relation(T, Tb, Tc, Pc):

Tbr = Tb/Tc<EOL>Tr = T/Tc<EOL>h = Tbr*log(Pc/<NUM_LIT>)/(<NUM_LIT:1> - Tbr)<EOL>return exp(h*(<NUM_LIT:1>-<NUM_LIT:1>/Tr))*Pc<EOL>

r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a
    CSP relationship as in [1]_; requires a chemical's critical temperature
    and pressure as well as boiling point.

    The vapor pressure is given by:

    .. math::
        \ln P^{sat}_r = h\left( 1 - \frac{1}{T_r}\right)

        h = T_{br} \frac{\ln(P_c/101325)}{1-T_{br}}

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

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

    Notes
    -----
    Units are Pa. Formulation makes intuitive sense; a logarithmic form of
    interpolation.

    Examples
    --------
    Example as in [1]_ for ethylbenzene

    >>> boiling_critical_relation(347.2, 409.3, 617.1, 36E5)
    15209.467273093938

    References
    ----------
    .. [1] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E.
       The Properties of Gases and Liquids. McGraw-Hill Companies, 1987.


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> - T/Tc<EOL>f0 = (-<NUM_LIT>*tau + <NUM_LIT>*tau**<NUM_LIT> - <NUM_LIT>*tau**<NUM_LIT> - <NUM_LIT>*tau**<NUM_LIT:5>)/Tr<EOL>f1 = (-<NUM_LIT>*tau + <NUM_LIT>*tau**<NUM_LIT> - <NUM_LIT>*tau**<NUM_LIT> - <NUM_LIT>*tau**<NUM_LIT:5>)/Tr<EOL>f2 = (-<NUM_LIT>*tau + <NUM_LIT>*tau**<NUM_LIT> - <NUM_LIT>*tau**<NUM_LIT> + <NUM_LIT>*tau**<NUM_LIT:5>)/Tr<EOL>return Pc*exp(f0 + omega*f1 + omega**<NUM_LIT:2>*f2)<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_r=f^{(0)}+\omega f^{(1)}+\omega^2f^{(2)}

        f^{(0)}=\frac{-5.97616\tau + 1.29874\tau^{1.5}- 0.60394\tau^{2.5}
        -1.06841\tau^5}{T_r}

        f^{(1)}=\frac{-5.03365\tau + 1.11505\tau^{1.5}- 5.41217\tau^{2.5}
        -7.46628\tau^5}{T_r}

        f^{(2)}=\frac{-0.64771\tau + 2.41539\tau^{1.5}- 4.26979\tau^{2.5}
        +3.25259\tau^5}{T_r}

        \tau = 1-T_{r}

    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
    -----
    Somewhat more accurate than the :obj:`Lee_Kesler` formulation.

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

    >>> Ambrose_Walton(347.25, 617.15, 36.09E5, 0.304)
    13278.878504306222

    References
    ----------
    .. [1] Ambrose, D., and J. Walton. "Vapour Pressures up to Their Critical
       Temperatures of Normal Alkanes and 1-Alkanols." Pure and Applied
       Chemistry 61, no. 8 (1989): 1395-1403. doi:10.1351/pac198961081395.
    .. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.


Tr = T/Tc<EOL>f0 = <NUM_LIT> + -<NUM_LIT>/Tr + <NUM_LIT>*log(Tr) + -<NUM_LIT>*Tr**<NUM_LIT><EOL>f1 = <NUM_LIT> + -<NUM_LIT>/Tr + -<NUM_LIT>*log(Tr) + <NUM_LIT>*Tr**<NUM_LIT><EOL>f2 = <NUM_LIT> + <NUM_LIT>/Tr + <NUM_LIT>*log(Tr) + -<NUM_LIT>*Tr**<NUM_LIT><EOL>return Pc*exp(f0 + omega*f1 + omega**<NUM_LIT:2>*f2)<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. Although developed for refrigerants,
    this model should have some general predictive ability.

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

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

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

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

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

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

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

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

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

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

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

    References
    ----------
    .. [1] Sanjari, Ehsan, Mehrdad Honarmand, Hamidreza Badihi, and Ali
       Ghaheri. "An Accurate Generalized Model for Predict Vapor Pressure of
       Refrigerants." International Journal of Refrigeration 36, no. 4
       (June 2013): 1327-32. doi:10.1016/j.ijrefrig.2013.01.007.


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


methods = []<EOL>Tmins, Tmaxs = [], []<EOL>if self.CASRN in WagnerMcGarry.index:<EOL><INDENT>methods.append(WAGNER_MCGARRY)<EOL>_, A, B, C, D, self.WAGNER_MCGARRY_Pc, self.WAGNER_MCGARRY_Tc, self.WAGNER_MCGARRY_Tmin = _WagnerMcGarry_values[WagnerMcGarry.index.get_loc(self.CASRN)].tolist()<EOL>self.WAGNER_MCGARRY_coefs = [A, B, C, D]<EOL>Tmins.append(self.WAGNER_MCGARRY_Tmin); Tmaxs.append(self.WAGNER_MCGARRY_Tc)<EOL><DEDENT>if self.CASRN in WagnerPoling.index:<EOL><INDENT>methods.append(WAGNER_POLING)<EOL>_, A, B, C, D, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc, Tmin, self.WAGNER_POLING_Tmax = _WagnerPoling_values[WagnerPoling.index.get_loc(self.CASRN)].tolist()<EOL>self.WAGNER_POLING_Tmin = Tmin if not np.isnan(Tmin) else self.WAGNER_POLING_Tmax*<NUM_LIT:0.1><EOL>self.WAGNER_POLING_coefs = [A, B, C, D]<EOL>Tmins.append(Tmin); Tmaxs.append(self.WAGNER_POLING_Tmax)<EOL><DEDENT>if self.CASRN in AntoineExtended.index:<EOL><INDENT>methods.append(ANTOINE_EXTENDED_POLING)<EOL>_, A, B, C, Tc, to, n, E, F, self.ANTOINE_EXTENDED_POLING_Tmin, self.ANTOINE_EXTENDED_POLING_Tmax = _AntoineExtended_values[AntoineExtended.index.get_loc(self.CASRN)].tolist()<EOL>self.ANTOINE_EXTENDED_POLING_coefs = [Tc, to, A, B, C, n, E, F]<EOL>Tmins.append(self.ANTOINE_EXTENDED_POLING_Tmin); Tmaxs.append(self.ANTOINE_EXTENDED_POLING_Tmax)<EOL><DEDENT>if self.CASRN in AntoinePoling.index:<EOL><INDENT>methods.append(ANTOINE_POLING)<EOL>_, A, B, C, self.ANTOINE_POLING_Tmin, self.ANTOINE_POLING_Tmax = _AntoinePoling_values[AntoinePoling.index.get_loc(self.CASRN)].tolist()<EOL>self.ANTOINE_POLING_coefs = [A, B, C]<EOL>Tmins.append(self.ANTOINE_POLING_Tmin); Tmaxs.append(self.ANTOINE_POLING_Tmax)<EOL><DEDENT>if self.CASRN in Perrys2_8.index:<EOL><INDENT>methods.append(DIPPR_PERRY_8E)<EOL>_, C1, C2, C3, C4, C5, self.Perrys2_8_Tmin, self.Perrys2_8_Tmax = _Perrys2_8_values[Perrys2_8.index.get_loc(self.CASRN)].tolist()<EOL>self.Perrys2_8_coeffs = [C1, C2, C3, C4, C5]<EOL>Tmins.append(self.Perrys2_8_Tmin); Tmaxs.append(self.Perrys2_8_Tmax)<EOL><DEDENT>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.Tmin); Tmaxs.append(self.CP_f.Tc)<EOL><DEDENT>if self.CASRN in _VDISaturationDict:<EOL><INDENT>methods.append(VDI_TABULAR)<EOL>Ts, props = VDI_tabular_data(self.CASRN, '<STR_LIT:P>')<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 VDI_PPDS_3.index:<EOL><INDENT>_,  Tm, Tc, Pc, A, B, C, D = _VDI_PPDS_3_values[VDI_PPDS_3.index.get_loc(self.CASRN)].tolist()<EOL>self.VDI_PPDS_coeffs = [A, B, C, D]<EOL>self.VDI_PPDS_Tc = Tc<EOL>self.VDI_PPDS_Tm = Tm<EOL>self.VDI_PPDS_Pc = Pc<EOL>methods.append(VDI_PPDS)<EOL>Tmins.append(self.VDI_PPDS_Tm); Tmaxs.append(self.VDI_PPDS_Tc)<EOL><DEDENT>if all((self.Tb, self.Tc, self.Pc)):<EOL><INDENT>methods.append(BOILING_CRITICAL)<EOL>Tmins.append(<NUM_LIT>); Tmaxs.append(self.Tc)<EOL><DEDENT>if all((self.Tc, self.Pc, self.omega)):<EOL><INDENT>methods.append(LEE_KESLER_PSAT)<EOL>methods.append(AMBROSE_WALTON)<EOL>methods.append(SANJARI)<EOL>methods.append(EDALAT)<EOL>if self.eos:<EOL><INDENT>methods.append(EOS)<EOL><DEDENT>Tmins.append(<NUM_LIT>); Tmaxs.append(self.Tc)<EOL><DEDENT>self.all_methods = set(methods)<EOL>if Tmins and Tmaxs:<EOL><INDENT>self.Tmin = min(Tmins)<EOL>self.Tmax = 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.


if method == WAGNER_MCGARRY:<EOL><INDENT>Psat = Wagner_original(T, self.WAGNER_MCGARRY_Tc, self.WAGNER_MCGARRY_Pc, *self.WAGNER_MCGARRY_coefs)<EOL><DEDENT>elif method == WAGNER_POLING:<EOL><INDENT>Psat = Wagner(T, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc, *self.WAGNER_POLING_coefs)<EOL><DEDENT>elif method == ANTOINE_EXTENDED_POLING:<EOL><INDENT>Psat = TRC_Antoine_extended(T, *self.ANTOINE_EXTENDED_POLING_coefs)<EOL><DEDENT>elif method == ANTOINE_POLING:<EOL><INDENT>A, B, C = self.ANTOINE_POLING_coefs<EOL>Psat = Antoine(T, A, B, C, base=<NUM_LIT>)<EOL><DEDENT>elif method == DIPPR_PERRY_8E:<EOL><INDENT>Psat = EQ101(T, *self.Perrys2_8_coeffs)<EOL><DEDENT>elif method == VDI_PPDS:<EOL><INDENT>Psat = Wagner(T, self.VDI_PPDS_Tc, self.VDI_PPDS_Pc, *self.VDI_PPDS_coeffs)<EOL><DEDENT>elif method == COOLPROP:<EOL><INDENT>Psat = PropsSI('<STR_LIT:P>','<STR_LIT:T>', T,'<STR_LIT>',<NUM_LIT:0>, self.CASRN)<EOL><DEDENT>elif method == BOILING_CRITICAL:<EOL><INDENT>Psat = boiling_critical_relation(T, self.Tb, self.Tc, self.Pc)<EOL><DEDENT>elif method == LEE_KESLER_PSAT:<EOL><INDENT>Psat = Lee_Kesler(T, self.Tc, self.Pc, self.omega)<EOL><DEDENT>elif method == AMBROSE_WALTON:<EOL><INDENT>Psat = Ambrose_Walton(T, self.Tc, self.Pc, self.omega)<EOL><DEDENT>elif method == SANJARI:<EOL><INDENT>Psat = Sanjari(T, self.Tc, self.Pc, self.omega)<EOL><DEDENT>elif method == EDALAT:<EOL><INDENT>Psat = Edalat(T, self.Tc, self.Pc, self.omega)<EOL><DEDENT>elif method == EOS:<EOL><INDENT>Psat = self.eos[<NUM_LIT:0>].Psat(T)<EOL><DEDENT>elif method in self.tabular_data:<EOL><INDENT>Psat = self.interpolate(T, method)<EOL><DEDENT>return Psat<EOL>

r'''Method to calculate vapor pressure of a fluid at temperature `T`
        with a given method.

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

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

        Returns
        -------
        Psat : float
            Vapor pressure at T, [pa]


return <NUM_LIT>*(<NUM_LIT:1> - <NUM_LIT>*(T - Tm))/(Tm**<NUM_LIT>*M**<NUM_LIT>)<EOL>

r'''Calculate the thermal conductivity of a liquid as a function of
    temperature using the Sheffy-Johnson (1961) method. Requires
    Temperature, molecular weight, and melting point.

    .. math::
        k = 1.951 \frac{1-0.00126(T-T_m)}{T_m^{0.216}MW^{0.3}}

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    M : float
        Molecular weight of the fluid [g/mol]
    Tm : float
        Melting point of the fluid [K]

    Returns
    -------
    kl : float
        Thermal conductivity of the fluid, W/m/k

    Notes
    -----
    The origin of this equation has been challenging to trace. It is
    presently unknown, and untested.

    Examples
    --------
    >>> Sheffy_Johnson(300, 47, 280)
    0.17740150413112196

    References
    ----------
    .. [1] Scheffy, W. J., and E. F. Johnson. "Thermal Conductivities of
       Liquids at High Temperatures." Journal of Chemical & Engineering Data
       6, no. 2 (April 1, 1961): 245-49. doi:10.1021/je60010a019


Tr = T/Tc<EOL>Tbr = Tb/Tc<EOL>return <NUM_LIT>*(<NUM_LIT> + <NUM_LIT>*(<NUM_LIT:1> - Tr)**(<NUM_LIT:2>/<NUM_LIT>))*M**-<NUM_LIT:0.5>/(<NUM_LIT> + <NUM_LIT>*(<NUM_LIT:1> - Tbr)**(<NUM_LIT:2>/<NUM_LIT>))<EOL>

r'''Calculate the thermal conductivity of a liquid as a function of
    temperature using the CSP method of Sato-Riedel [1]_, [2]_, published in
    Reid [3]_. Requires temperature, molecular weight, and boiling and critical
    temperatures.

    .. math::
        k = \frac{1.1053}{\sqrt{MW}}\frac{3+20(1-T_r)^{2/3}}
        {3+20(1-T_{br})^{2/3}}

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    M : float
        Molecular weight of the fluid [g/mol]
    Tb : float
        Boiling temperature of the fluid [K]
    Tc : float
        Critical temperature of the fluid [K]

    Returns
    -------
    kl : float
        Estimated liquid thermal conductivity [W/m/k]

    Notes
    -----
    This equation has a complicated history. It is proposed by Reid [3]_.
    Limited accuracy should be expected. Uncheecked.

    Examples
    --------
    >>> Sato_Riedel(300, 47, 390, 520)
    0.21037692461337687

    References
    ----------
    .. [1] Riedel, L.: Chem. Ing. Tech., 21, 349 (1949); 23: 59, 321, 465 (1951)
    .. [2] Maejima, T., private communication, 1973
    .. [3] Properties of Gases and Liquids", 3rd Ed., McGraw-Hill, 1977


return <NUM_LIT> - <NUM_LIT>*T + (<NUM_LIT> - <NUM_LIT>*T)*M**-<NUM_LIT:0.5><EOL>

r'''Estimates thermal conductivity of pure liquids as a function of
    temperature using a reference fluid approach. Low accuracy but quick.
    Developed using several organic fluids.

    .. math::
        \lambda = 0.0655-0.0005T + \frac{1.3855-0.00197T}{M^{0.5}}

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    M : float
        Molecular weight of the fluid [g/mol]

    Returns
    -------
    kl : float
        Estimated liquid thermal conductivity [W/m/k]

    Notes
    -----
    This equation returns negative numbers at high T sometimes.
    This equation is one of those implemented by DDBST.
    If this results in a negative thermal conductivity, no value is returned.

    Examples
    --------
    >>> Lakshmi_Prasad(273.15, 100)
    0.013664450000000009

    References
    ----------
    .. [1] Lakshmi, D. S., and D. H. L. Prasad. "A Rapid Estimation Method for
       Thermal Conductivity of Pure Liquids." The Chemical Engineering Journal
       48, no. 3 (April 1992): 211-14. doi:10.1016/0300-9467(92)80037-B


def Gharagheizi_liquid(T, M, Tb, Pc, omega):

Pc = Pc/<NUM_LIT><EOL>B = <NUM_LIT>*M + <NUM_LIT>*Tb - <NUM_LIT><EOL>A = <NUM_LIT>*M**<NUM_LIT:8>*(<NUM_LIT>*B + <NUM_LIT>*M - <NUM_LIT>)<EOL>kl = <NUM_LIT>*(<NUM_LIT>*omega + <NUM_LIT>*Pc - <NUM_LIT>*T + <NUM_LIT> + <NUM_LIT>*(Tb + <NUM_LIT>*B*B/(M*M))<EOL>+ <NUM_LIT>*M**<NUM_LIT:4>*B**-<NUM_LIT:4> + A*B**-<NUM_LIT:8>)<EOL>return kl<EOL>

r'''Estimates the thermal conductivity of a liquid as a function of
    temperature using the CSP method of Gharagheizi [1]_. A  convoluted
    method claiming high-accuracy and using only statistically significant
    variable following analalysis.

    Requires temperature, molecular weight, boiling temperature and critical
    pressure and acentric factor.

    .. math::
        &k = 10^{-4}\left[10\omega + 2P_c-2T+4+1.908(T_b+\frac{1.009B^2}{MW^2})
        +\frac{3.9287MW^4}{B^4}+\frac{A}{B^8}\right]

        &A = 3.8588MW^8(1.0045B+6.5152MW-8.9756)

        &B = 16.0407MW+2T_b-27.9074

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    M : float
        Molecular weight of the fluid [g/mol]
    Tb : float
        Boiling temperature of the fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    omega : float
        Acentric factor of the fluid [-]

    Returns
    -------
    kl : float
        Estimated liquid thermal conductivity [W/m/k]

    Notes
    -----
    Pressure is internally converted into bar, as used in the original equation.

    This equation was derived with 19000 points representing 1640 unique compounds.

    Examples
    --------
    >>> Gharagheizi_liquid(300, 40, 350, 1E6, 0.27)
    0.2171113029534838

    References
    ----------
    .. [1] Gharagheizi, Farhad, Poorandokht Ilani-Kashkouli, Mehdi Sattari,
        Amir H. Mohammadi, Deresh Ramjugernath, and Dominique Richon.
        "Development of a General Model for Determination of Thermal
        Conductivity of Liquid Chemical Compounds at Atmospheric Pressure."
        AIChE Journal 59, no. 5 (May 1, 2013): 1702-8. doi:10.1002/aic.13938