def logP(CASRN, AvailableMethods=False, Method=None):

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

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

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

    Returns
    -------
    logP : float
        Octanol-water partition coefficient, [-]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain logP with the
        given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are 'SYRRES', or 'CRC',
        All valid values are also held in the list logP_methods.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        the logP for the desired chemical, and will return methods
        instead of the logP

    Notes
    -----
    .. math::
        \log P_{ oct/wat} = \log\left(\frac{\left[{solute}
        \right]_{ octanol}^{un-ionized}}{\left[{solute}
        \right]_{ water}^{ un-ionized}}\right)

    Examples
    --------
    >>> logP('67-56-1')
    -0.74

    References
    ----------
    .. [1] Syrres. 2006. KOWWIN Data, SrcKowData2.zip.
       http://esc.syrres.com/interkow/Download/SrcKowData2.zip
    .. [2] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
       Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.


def GWP(CASRN, AvailableMethods=False, Method=None):

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in GWP_data.index:<EOL><INDENT>methods.append(IPCC100)<EOL>if not pd.isnull(GWP_data.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(IPCC100SAR)<EOL><DEDENT>methods.append(IPCC20)<EOL>methods.append(IPCC500)<EOL><DEDENT>methods.append(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == IPCC100:<EOL><INDENT>return float(GWP_data.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == IPCC100SAR:<EOL><INDENT>return float(GWP_data.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == IPCC20:<EOL><INDENT>return float(GWP_data.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == IPCC500:<EOL><INDENT>return float(GWP_data.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == NONE:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

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

    Returns the GWP for the 100yr outlook by default.

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

    Returns
    -------
    GWP : float
        Global warming potential, [(impact/mass chemical)/(impact/mass CO2)]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain GWP with the
        given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are IPCC (2007) 100yr',
        'IPCC (2007) 100yr-SAR', 'IPCC (2007) 20yr', and 'IPCC (2007) 500yr'.
        All valid values are also held in the list GWP_methods.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        the GWP for the desired chemical, and will return methods
        instead of the GWP

    Notes
    -----
    All data is from [1]_, the official source. Several chemicals are available
    in [1]_ are not included here as they do not have a CAS.
    Methods are 'IPCC (2007) 100yr', 'IPCC (2007) 100yr-SAR',
    'IPCC (2007) 20yr', and 'IPCC (2007) 500yr'.

    Examples
    --------
    Methane, 100-yr outlook

    >>> GWP(CASRN='74-82-8')
    25.0

    References
    ----------
    .. [1] IPCC. "2.10.2 Direct Global Warming Potentials - AR4 WGI Chapter 2:
       Changes in Atmospheric Constituents and in Radiative Forcing." 2007.
       https://www.ipcc.ch/publications_and_data/ar4/wg1/en/ch2s2-10-2.html.


def economic_status(CASRN, Method=None, AvailableMethods=False):

load_economic_data()<EOL>CASi = CAS2int(CASRN)<EOL>def list_methods():<EOL><INDENT>methods = []<EOL>methods.append('<STR_LIT>')<EOL>if CASRN in _EPACDRDict:<EOL><INDENT>methods.append(EPACDR)<EOL><DEDENT>if CASRN in _ECHATonnageDict:<EOL><INDENT>methods.append(ECHA)<EOL><DEDENT>if CASi in HPV_data.index:<EOL><INDENT>methods.append(OECD)<EOL><DEDENT>methods.append(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == EPACDR:<EOL><INDENT>status = '<STR_LIT>' + str(_EPACDRDict[CASRN])<EOL><DEDENT>elif Method == ECHA:<EOL><INDENT>status = _ECHATonnageDict[CASRN]<EOL><DEDENT>elif Method == OECD:<EOL><INDENT>status = '<STR_LIT>'<EOL><DEDENT>elif Method == '<STR_LIT>':<EOL><INDENT>status = []<EOL>if CASRN in _EPACDRDict:<EOL><INDENT>status += ['<STR_LIT>' + str(_EPACDRDict[CASRN])]<EOL><DEDENT>if CASRN in _ECHATonnageDict:<EOL><INDENT>status += _ECHATonnageDict[CASRN]<EOL><DEDENT>if CASi in HPV_data.index:<EOL><INDENT>status += ['<STR_LIT>']<EOL><DEDENT><DEDENT>elif Method == NONE:<EOL><INDENT>status = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return status<EOL>

Look up the economic status of a chemical.

    This API is considered experimental, and is expected to be removed in a
    future release in favor of a more complete object-oriented interface.

    >>> pprint(economic_status(CASRN='98-00-0'))
    ["US public: {'Manufactured': 0.0, 'Imported': 10272.711, 'Exported': 184.127}",
     u'10,000 - 100,000 tonnes per annum',
     'OECD HPV Chemicals']

    >>> economic_status(CASRN='13775-50-3')  # SODIUM SESQUISULPHATE
    []
    >>> economic_status(CASRN='98-00-0', Method='OECD high production volume chemicals')
    'OECD HPV Chemicals'
    >>> economic_status(CASRN='98-01-1', Method='European Chemicals Agency Total Tonnage Bands')
    [u'10,000 - 100,000 tonnes per annum']


def legal_status(CASRN, Method=None, AvailableMethods=False, CASi=None):

load_law_data()<EOL>if not CASi:<EOL><INDENT>CASi = CAS2int(CASRN)<EOL><DEDENT>methods = [COMBINED, DSL, TSCA, EINECS, NLP, SPIN]<EOL>if AvailableMethods:<EOL><INDENT>return methods<EOL><DEDENT>if not Method:<EOL><INDENT>Method = methods[<NUM_LIT:0>]<EOL><DEDENT>if Method == DSL:<EOL><INDENT>if CASi in DSL_data.index:<EOL><INDENT>status = CAN_DSL_flags[DSL_data.at[CASi, '<STR_LIT>']]<EOL><DEDENT>else:<EOL><INDENT>status = UNLISTED<EOL><DEDENT><DEDENT>elif Method == TSCA:<EOL><INDENT>if CASi in TSCA_data.index:<EOL><INDENT>data = TSCA_data.loc[CASi].to_dict()<EOL>if any(data.values()):<EOL><INDENT>status = sorted([TSCA_flags[i] for i in data.keys() if data[i]])<EOL><DEDENT>else:<EOL><INDENT>status = LISTED<EOL><DEDENT><DEDENT>else:<EOL><INDENT>status = UNLISTED<EOL><DEDENT><DEDENT>elif Method == EINECS:<EOL><INDENT>if CASi in EINECS_data.index:<EOL><INDENT>status = LISTED<EOL><DEDENT>else:<EOL><INDENT>status = UNLISTED<EOL><DEDENT><DEDENT>elif Method == NLP:<EOL><INDENT>if CASi in NLP_data.index:<EOL><INDENT>status = LISTED<EOL><DEDENT>else:<EOL><INDENT>status = UNLISTED<EOL><DEDENT><DEDENT>elif Method == SPIN:<EOL><INDENT>if CASi in SPIN_data.index:<EOL><INDENT>status = LISTED<EOL><DEDENT>else:<EOL><INDENT>status = UNLISTED<EOL><DEDENT><DEDENT>elif Method == COMBINED:<EOL><INDENT>status = {}<EOL>for method in methods[<NUM_LIT:1>:]:<EOL><INDENT>status[method] = legal_status(CASRN, Method=method, CASi=CASi)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return status<EOL>

r'''Looks up the legal status of a chemical according to either a specifc
    method or with all methods.

    Returns either the status as a string for a specified method, or the
    status of the chemical in all available data sources, in the format
    {source: status}.

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

    Returns
    -------
    status : str or dict
        Legal status information [-]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain legal status with the
        given inputs

    Other Parameters
    ----------------
    Method : string, optional
        A string for the method name to use, as defined by constants in
        legal_status_methods
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        the legal status for the desired chemical, and will return methods
        instead of the status
    CASi : int, optional
        CASRN as an integer, used internally [-]

    Notes
    -----

    Supported methods are:

        * **DSL**: Canada Domestic Substance List, [1]_. As extracted on Feb 11, 2015
          from a html list. This list is updated continuously, so this version
          will always be somewhat old. Strictly speaking, there are multiple
          lists but they are all bundled together here. A chemical may be
          'Listed', or be on the 'Non-Domestic Substances List (NDSL)',
          or be on the list of substances with 'Significant New Activity (SNAc)',
          or be on the DSL but with a 'Ministerial Condition pertaining to this
          substance', or have been removed from the DSL, or have had a
          Ministerial prohibition for the substance.
        * **TSCA**: USA EPA Toxic Substances Control Act Chemical Inventory, [2]_.
          This list is as extracted on 2016-01. It is believed this list is
          updated on a periodic basis (> 6 month). A chemical may simply be
          'Listed', or may have certain flags attached to it. All these flags
          are described in the dict TSCA_flags.
        * **EINECS**: European INventory of Existing Commercial chemical
          Substances, [3]_. As extracted from a spreadsheet dynamically
          generated at [1]_. This list was obtained March 2015; a more recent
          revision already exists.
        * **NLP**: No Longer Polymers, a list of chemicals with special
          regulatory exemptions in EINECS. Also described at [3]_.
        * **SPIN**: Substances Prepared in Nordic Countries. Also a boolean
          data type. Retrieved 2015-03 from [4]_.

    Other methods which could be added are:

        * Australia: AICS Australian Inventory of Chemical Substances
        * China: Inventory of Existing Chemical Substances Produced or Imported
          in China (IECSC)
        * Europe: REACH List of Registered Substances
        * India: List of Hazardous Chemicals
        * Japan: ENCS: Inventory of existing and new chemical substances
        * Korea: Existing Chemicals Inventory (KECI)
        * Mexico: INSQ National Inventory of Chemical Substances in Mexico
        * New Zealand:  Inventory of Chemicals (NZIoC)
        * Philippines: PICCS Philippines Inventory of Chemicals and Chemical
          Substances

    Examples
    --------
    >>> pprint(legal_status('64-17-5'))
    {'DSL': 'LISTED',
     'EINECS': 'LISTED',
     'NLP': 'UNLISTED',
     'SPIN': 'LISTED',
     'TSCA': 'LISTED'}

    References
    ----------
    .. [1] Government of Canada.. "Substances Lists" Feb 11, 2015.
       https://www.ec.gc.ca/subsnouvelles-newsubs/default.asp?n=47F768FE-1.
    .. [2] US EPA. "TSCA Chemical Substance Inventory." Accessed April 2016.
       https://www.epa.gov/tsca-inventory.
    .. [3] ECHA. "EC Inventory". Accessed March 2015.
       http://echa.europa.eu/information-on-chemicals/ec-inventory.
    .. [4] SPIN. "SPIN Substances in Products In Nordic Countries." Accessed
       March 2015. http://195.215.202.233/DotNetNuke/default.aspx.


def Zc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[COMBINED]):

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(IUPAC)<EOL><DEDENT>if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(MATTHEWS)<EOL><DEDENT>if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(CRC)<EOL><DEDENT>if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(PSRK)<EOL><DEDENT>if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(YAWS)<EOL><DEDENT>if Tc(CASRN) and Vc(CASRN) and Pc(CASRN):<EOL><INDENT>methods.append(COMBINED)<EOL><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(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == IUPAC:<EOL><INDENT>_Zc = float(_crit_IUPAC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == PSRK:<EOL><INDENT>_Zc = float(_crit_PSRKR4.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == MATTHEWS:<EOL><INDENT>_Zc = float(_crit_Matthews.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == CRC:<EOL><INDENT>_Zc = float(_crit_CRC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == YAWS:<EOL><INDENT>_Zc = float(_crit_Yaws.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == COMBINED:<EOL><INDENT>_Zc = Vc(CASRN)*Pc(CASRN)/Tc(CASRN)/R<EOL><DEDENT>elif Method == NONE:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _Zc<EOL>

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

    Prefered sources are 'IUPAC' for organic chemicals, and 'MATTHEWS' for
    inorganic chemicals. Function has data for approximately 1000 chemicals.

    Examples
    --------
    >>> Zc(CASRN='64-17-5')
    0.24100000000000002

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

    Returns
    -------
    Zc : float
        Critical compressibility, [-]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain Vc with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS',
        'CRC', 'PSRK', 'YAWS', and 'COMBINED'. All valid values are also held
        in `Zc_methods`.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        Zc for the desired chemical, and will return methods instead of Zc
    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:

        * 'IUPAC', a series of critically evaluated
          experimental datum for organic compounds in [1]_, [2]_, [3]_, [4]_,
          [5]_, [6]_, [7]_, [8]_, [9]_, [10]_, [11]_, and [12]_.
        * 'MATTHEWS', a series of critically
          evaluated data for inorganic compounds in [13]_.
        * 'CRC', a compillation of critically
          evaluated data by the TRC as published in [14]_.
        * 'PSRK', a compillation of experimental and
          estimated data published in [15]_.
        * 'YAWS', a large compillation of data from a
          variety of sources; no data points are sourced in the work of [16]_.

    References
    ----------
    .. [1] Ambrose, Douglas, and Colin L. Young. "Vapor-Liquid Critical
       Properties of Elements and Compounds. 1. An Introductory Survey."
       Journal of Chemical & Engineering Data 41, no. 1 (January 1, 1996):
       154-154. doi:10.1021/je950378q.
    .. [2] Ambrose, Douglas, and Constantine Tsonopoulos. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 2. Normal Alkanes."
       Journal of Chemical & Engineering Data 40, no. 3 (May 1, 1995): 531-46.
       doi:10.1021/je00019a001.
    .. [3] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 3. Aromatic
       Hydrocarbons." Journal of Chemical & Engineering Data 40, no. 3
       (May 1, 1995): 547-58. doi:10.1021/je00019a002.
    .. [4] Gude, Michael, and Amyn S. Teja. "Vapor-Liquid Critical Properties
       of Elements and Compounds. 4. Aliphatic Alkanols." Journal of Chemical
       & Engineering Data 40, no. 5 (September 1, 1995): 1025-36.
       doi:10.1021/je00021a001.
    .. [5] Daubert, Thomas E. "Vapor-Liquid Critical Properties of Elements
       and Compounds. 5. Branched Alkanes and Cycloalkanes." Journal of
       Chemical & Engineering Data 41, no. 3 (January 1, 1996): 365-72.
       doi:10.1021/je9501548.
    .. [6] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 6. Unsaturated Aliphatic
       Hydrocarbons." Journal of Chemical & Engineering Data 41, no. 4
       (January 1, 1996): 645-56. doi:10.1021/je9501999.
    .. [7] Kudchadker, Arvind P., Douglas Ambrose, and Constantine Tsonopoulos.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 7. Oxygen
       Compounds Other Than Alkanols and Cycloalkanols." Journal of Chemical &
       Engineering Data 46, no. 3 (May 1, 2001): 457-79. doi:10.1021/je0001680.
    .. [8] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 8. Organic Sulfur,
       Silicon, and Tin Compounds (C + H + S, Si, and Sn)." Journal of Chemical
       & Engineering Data 46, no. 3 (May 1, 2001): 480-85.
       doi:10.1021/je000210r.
    .. [9] Marsh, Kenneth N., Colin L. Young, David W. Morton, Douglas Ambrose,
       and Constantine Tsonopoulos. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 9. Organic Compounds Containing Nitrogen."
       Journal of Chemical & Engineering Data 51, no. 2 (March 1, 2006):
       305-14. doi:10.1021/je050221q.
    .. [10] Marsh, Kenneth N., Alan Abramson, Douglas Ambrose, David W. Morton,
       Eugene Nikitin, Constantine Tsonopoulos, and Colin L. Young.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 10. Organic
       Compounds Containing Halogens." Journal of Chemical & Engineering Data
       52, no. 5 (September 1, 2007): 1509-38. doi:10.1021/je700336g.
    .. [11] Ambrose, Douglas, Constantine Tsonopoulos, and Eugene D. Nikitin.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 11. Organic
       Compounds Containing B + O; Halogens + N, + O, + O + S, + S, + Si;
       N + O; and O + S, + Si." Journal of Chemical & Engineering Data 54,
       no. 3 (March 12, 2009): 669-89. doi:10.1021/je800580z.
    .. [12] Ambrose, Douglas, Constantine Tsonopoulos, Eugene D. Nikitin, David
       W. Morton, and Kenneth N. Marsh. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 12. Review of Recent Data for Hydrocarbons and
       Non-Hydrocarbons." Journal of Chemical & Engineering Data, October 5,
       2015, 151005081500002. doi:10.1021/acs.jced.5b00571.
    .. [13] Mathews, Joseph F. "Critical Constants of Inorganic Substances."
       Chemical Reviews 72, no. 1 (February 1, 1972): 71-100.
       doi:10.1021/cr60275a004.
    .. [14] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
       Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
    .. [15] 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.
    .. [16] Yaws, Carl L. Thermophysical Properties of Chemicals and
       Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
       Publishing, 2014.


def Pc_mixture(Pcs=None, zs=None, CASRNs=None, AvailableMethods=False, Method=None):

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

This function handles the retrival of a mixture's critical temperature.

    This API is considered experimental, and is expected to be removed in a
    future release in favor of a more complete object-oriented interface.

    >>> Pc_mixture([2.2E7, 1.1E7], [0.3, 0.7])
    14300000.0


def Mersmann_Kind_predictor(atoms, coeff=<NUM_LIT>, power=<NUM_LIT:0.5>, <EOL>covalent_radii=rcovs_Mersmann_Kind):

H_RADIUS_COV = covalent_radii['<STR_LIT:H>']<EOL>tot = <NUM_LIT:0><EOL>atom_count = <NUM_LIT:0><EOL>for atom, count in atoms.items():<EOL><INDENT>if atom not in covalent_radii:<EOL><INDENT>raise Exception('<STR_LIT>' %atom)<EOL><DEDENT>tot += count*covalent_radii[atom]<EOL>atom_count += count<EOL><DEDENT>da = <NUM_LIT>*tot/atom_count<EOL>ra = da/<NUM_LIT><EOL>da_SI = da*<NUM_LIT> <EOL>return ((coeff/(ra/H_RADIUS_COV)**power)*da_SI)**<NUM_LIT:3>*N_A*atom_count<EOL>

r'''Predicts the critical molar volume of a chemical based only on its
    atomic composition according to [1]_ and [2]_. This is a crude approach,
    but provides very reasonable
    estimates in practice. Optionally, the `coeff` used and the `power` in the
    fraction as well as the atomic contributions can be adjusted; this method
    is general and atomic contributions can be regressed to predict other
    properties with this routine.

    .. math::
        \frac{\left(\frac{V_c}{n_a N_A}\right)^{1/3}}{d_a}
        = \frac{3.645}{\left(\frac{r_a}{r_H}\right)^{1/2}}

        r_a = d_a/2

        d_a = 2 \frac{\sum_i (n_i r_i)}{n_a}

    In the above equations, :math:`n_i` is the number of atoms of species i in
    the molecule, :math:`r_i` is the covalent atomic radius of the atom, and
    :math:`n_a` is the total number of atoms in the molecule.

    Parameters
    ----------
    atoms : dict
        Dictionary of atoms and their counts, [-]
    coeff : float, optional
        Coefficient used in the relationship, [m^2]
    power : float, optional
        Power applied to the relative atomic radius, [-]
    covalent_radii : dict or indexable, optional
        Object which can be indexed to atomic contrinbutions (by symbol), [-]

    Returns
    -------
    Vc : float
        Predicted critical volume of the chemical, [m^3/mol]

    Notes
    -----
    Using the :obj:`thermo.elements.periodic_table` covalent radii (from RDKit),
    the coefficient and power should be 4.261206523632586 and 0.5597281770786228
    respectively for best results.

    Examples
    --------
    Prediction of critical volume of decane:

    >>> Mersmann_Kind_predictor({'C': 10, 'H': 22})
    0.0005851859052024729

    This is compared against the experimental value, 0.000624 (a 6.2% relative
    error)

    Using custom fitted coefficients we can do a bit better:

    >>> from thermo.critical import rcovs_regressed
    >>> Mersmann_Kind_predictor({'C': 10, 'H': 22}, coeff=4.261206523632586,
    ... power=0.5597281770786228, covalent_radii=rcovs_regressed)
    0.0005956871011923075

    The relative error is only 4.5% now. This is compared to an experimental
    uncertainty of 5.6%.

    Evaluating 1321 critical volumes in the database, the average relative
    error is 5.0%; standard deviation 6.8%; and worst value of 79% relative
    error for phosphorus.

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


def Tc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[SURF]):

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(IUPAC)<EOL><DEDENT>if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(MATTHEWS)<EOL><DEDENT>if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(CRC)<EOL><DEDENT>if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(PSRK)<EOL><DEDENT>if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(PD)<EOL><DEDENT>if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(YAWS)<EOL><DEDENT>if CASRN:<EOL><INDENT>methods.append(SURF)<EOL><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(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == IUPAC:<EOL><INDENT>_Tc = float(_crit_IUPAC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == MATTHEWS:<EOL><INDENT>_Tc = float(_crit_Matthews.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == PSRK:<EOL><INDENT>_Tc = float(_crit_PSRKR4.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == PD:<EOL><INDENT>_Tc = float(_crit_PassutDanner.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == CRC:<EOL><INDENT>_Tc = float(_crit_CRC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == YAWS:<EOL><INDENT>_Tc = float(_crit_Yaws.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == SURF:<EOL><INDENT>_Tc = third_property(CASRN=CASRN, T=True)<EOL><DEDENT>elif Method == NONE:<EOL><INDENT>_Tc = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _Tc<EOL>

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

    Prefered sources are 'IUPAC' for organic chemicals, and 'MATTHEWS' for
    inorganic chemicals. Function has data for approximately 1000 chemicals.

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

    Returns
    -------
    Tc : float
        Critical temperature, [K]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain Tc with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS',
        'CRC', 'PSRK', 'PD', 'YAWS', and 'SURF'. All valid values are also held
        in the list `Tc_methods`.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        Tc for the desired chemical, and will return methods instead of Tc
    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 seven sources are available for this function. They are:

        * 'IUPAC Organic Critical Properties', a series of critically evaluated
          experimental datum for organic compounds in [1]_, [2]_, [3]_, [4]_,
          [5]_, [6]_, [7]_, [8]_, [9]_, [10]_, [11]_, and [12]_.
        * 'Matthews Inorganic Critical Properties', a series of critically
          evaluated data for inorganic compounds in [13]_.
        * 'CRC Organic Critical Properties', a compillation of critically
          evaluated data by the TRC as published in [14]_.
        * 'PSRK Revision 4 Appendix', a compillation of experimental and
          estimated data published in [15]_.
        * 'Passut Danner 1973 Critical Properties', an older compillation of
          data published in [16]_
        * 'Yaws Critical Properties', a large compillation of data from a
          variety of sources; no data points are sourced in the work of [17]_.
        * Critical Surface', an estimation method using a
          simple quadratic method for estimating Tc from Pc and Vc. This is
          ignored and not returned as a method by default, as no compounds
          have values of Pc and Vc but not Tc currently.

    Examples
    --------
    >>> Tc(CASRN='64-17-5')
    514.0

    References
    ----------
    .. [1] Ambrose, Douglas, and Colin L. Young. "Vapor-Liquid Critical
       Properties of Elements and Compounds. 1. An Introductory Survey."
       Journal of Chemical & Engineering Data 41, no. 1 (January 1, 1996):
       154-154. doi:10.1021/je950378q.
    .. [2] Ambrose, Douglas, and Constantine Tsonopoulos. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 2. Normal Alkanes."
       Journal of Chemical & Engineering Data 40, no. 3 (May 1, 1995): 531-46.
       doi:10.1021/je00019a001.
    .. [3] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 3. Aromatic
       Hydrocarbons." Journal of Chemical & Engineering Data 40, no. 3
       (May 1, 1995): 547-58. doi:10.1021/je00019a002.
    .. [4] Gude, Michael, and Amyn S. Teja. "Vapor-Liquid Critical Properties
       of Elements and Compounds. 4. Aliphatic Alkanols." Journal of Chemical
       & Engineering Data 40, no. 5 (September 1, 1995): 1025-36.
       doi:10.1021/je00021a001.
    .. [5] Daubert, Thomas E. "Vapor-Liquid Critical Properties of Elements
       and Compounds. 5. Branched Alkanes and Cycloalkanes." Journal of
       Chemical & Engineering Data 41, no. 3 (January 1, 1996): 365-72.
       doi:10.1021/je9501548.
    .. [6] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 6. Unsaturated Aliphatic
       Hydrocarbons." Journal of Chemical & Engineering Data 41, no. 4
       (January 1, 1996): 645-56. doi:10.1021/je9501999.
    .. [7] Kudchadker, Arvind P., Douglas Ambrose, and Constantine Tsonopoulos.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 7. Oxygen
       Compounds Other Than Alkanols and Cycloalkanols." Journal of Chemical &
       Engineering Data 46, no. 3 (May 1, 2001): 457-79. doi:10.1021/je0001680.
    .. [8] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 8. Organic Sulfur,
       Silicon, and Tin Compounds (C + H + S, Si, and Sn)." Journal of Chemical
       & Engineering Data 46, no. 3 (May 1, 2001): 480-85.
       doi:10.1021/je000210r.
    .. [9] Marsh, Kenneth N., Colin L. Young, David W. Morton, Douglas Ambrose,
       and Constantine Tsonopoulos. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 9. Organic Compounds Containing Nitrogen."
       Journal of Chemical & Engineering Data 51, no. 2 (March 1, 2006):
       305-14. doi:10.1021/je050221q.
    .. [10] Marsh, Kenneth N., Alan Abramson, Douglas Ambrose, David W. Morton,
       Eugene Nikitin, Constantine Tsonopoulos, and Colin L. Young.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 10. Organic
       Compounds Containing Halogens." Journal of Chemical & Engineering Data
       52, no. 5 (September 1, 2007): 1509-38. doi:10.1021/je700336g.
    .. [11] Ambrose, Douglas, Constantine Tsonopoulos, and Eugene D. Nikitin.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 11. Organic
       Compounds Containing B + O; Halogens + N, + O, + O + S, + S, + Si;
       N + O; and O + S, + Si." Journal of Chemical & Engineering Data 54,
       no. 3 (March 12, 2009): 669-89. doi:10.1021/je800580z.
    .. [12] Ambrose, Douglas, Constantine Tsonopoulos, Eugene D. Nikitin, David
       W. Morton, and Kenneth N. Marsh. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 12. Review of Recent Data for Hydrocarbons and
       Non-Hydrocarbons." Journal of Chemical & Engineering Data, October 5,
       2015, 151005081500002. doi:10.1021/acs.jced.5b00571.
    .. [13] Mathews, Joseph F. "Critical Constants of Inorganic Substances."
       Chemical Reviews 72, no. 1 (February 1, 1972): 71-100.
       doi:10.1021/cr60275a004.
    .. [14] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
       Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
    .. [15] 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.
    .. [16] 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.
    .. [17] Yaws, Carl L. Thermophysical Properties of Chemicals and
       Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
       Publishing, 2014.


def Meissner(Tc=None, Pc=None, Vc=None):

if Tc and Vc:<EOL><INDENT>Vc = Vc*<NUM_LIT><EOL>Pc = <NUM_LIT>*Tc/(Vc-<NUM_LIT:8>)<EOL>Pc = <NUM_LIT>*Pc  <EOL>return Pc<EOL><DEDENT>elif Tc and Pc:<EOL><INDENT>Pc = Pc/<NUM_LIT>  <EOL>Vc = <NUM_LIT>/<NUM_LIT>*Tc/Pc+<NUM_LIT:8><EOL>Vc = Vc/<NUM_LIT>  <EOL>return Vc<EOL><DEDENT>elif Pc and Vc:<EOL><INDENT>Pc = Pc/<NUM_LIT>  <EOL>Vc = Vc*<NUM_LIT>  <EOL>Tc = <NUM_LIT>/<NUM_LIT>*Pc*(Vc-<NUM_LIT:8>)<EOL>return Tc<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Old (1942) relationship for estimating critical
    properties from each other. Two of the three properties are required.
    This model uses the "critical surface", a general plot of Tc vs Pc vs Vc.
    The model used 42 organic and inorganic compounds to derive the equation.
    The general equation is in [1]_:

    .. math::
        P_c = \frac{2.08 T_c}{V_c-8}

    Parameters
    ----------
    Tc : float, optional
        Critical temperature of fluid [K]
    Pc : float, optional
        Critical pressure of fluid [Pa]
    Vc : float, optional
        Critical volume of fluid [m^3/mol]

    Returns
    -------
    Tc, Pc or Vc : float
        Critical property of fluid [K], [Pa], or [m^3/mol]

    Notes
    -----
    The prediction of Tc from Pc and Vc is not tested, as this is not necessary
    anywhere, but it is implemented.
    Internal units are atm, cm^3/mol, and K. A slight error occurs when
    Pa, cm^3/mol and K are used instead, on the order of <0.2%.
    This equation is less accurate than that of Ihmels, but surprisingly close.
    The author also proposed means of estimated properties independently.

    Examples
    --------
    Succinic acid [110-15-6]

    >>> Meissner(Tc=851.0, Vc=0.000308)
    5978445.199999999

    References
    ----------
    .. [1] Meissner, H. P., and E. M. Redding. "Prediction of Critical
           Constants." Industrial & Engineering Chemistry 34, no. 5
           (May 1, 1942): 521-26. doi:10.1021/ie50389a003.


if Tc and Vc:<EOL><INDENT>Vc = Vc*<NUM_LIT>  <EOL>Pc = -<NUM_LIT>+<NUM_LIT>*Tc/Vc<EOL>Pc = Pc*<NUM_LIT>  <EOL>return Pc<EOL><DEDENT>elif Tc and Pc:<EOL><INDENT>Pc = Pc/<NUM_LIT>  <EOL>Vc = <NUM_LIT>*Tc/(<NUM_LIT:200>*Pc+<NUM_LIT:5>)<EOL>Vc = Vc/<NUM_LIT>  <EOL>return Vc<EOL><DEDENT>elif Pc and Vc:<EOL><INDENT>Pc = Pc/<NUM_LIT>  <EOL>Vc = Vc*<NUM_LIT>  <EOL>Tc = <NUM_LIT>/<NUM_LIT>*(<NUM_LIT>*Pc*Vc + Vc)<EOL>return Tc<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Most recent, and most recommended method of estimating critical
    properties from each other. Two of the three properties are required.
    This model uses the "critical surface", a general plot of Tc vs Pc vs Vc.
    The model used 421 organic compounds to derive equation.
    The general equation is in [1]_:

    .. math::
        P_c = -0.025 + 2.215 \frac{T_c}{V_c}

    Parameters
    ----------
    Tc : float
        Critical temperature of fluid (optional) [K]
    Pc : float
        Critical pressure of fluid (optional) [Pa]
    Vc : float
        Critical volume of fluid (optional) [m^3/mol]

    Returns
    -------
    Tc, Pc or Vc : float
        Critical property of fluid [K], [Pa], or [m^3/mol]

    Notes
    -----
    The prediction of Tc from Pc and Vc is not tested, as this is not necessary
    anywhere, but it is implemented.
    Internal units are MPa, cm^3/mol, and K. A slight error occurs when
    Pa, cm^3/mol and K are used instead, on the order of <0.2%.
    Their equation was also compared with 56 inorganic and elements.
    Devations of 20% for <200K or >1000K points.

    Examples
    --------a
    Succinic acid [110-15-6]

    >>> Ihmels(Tc=851.0, Vc=0.000308)
    6095016.233766234

    References
    ----------
    .. [1] Ihmels, E. Christian. "The Critical Surface." Journal of Chemical
           & Engineering Data 55, no. 9 (September 9, 2010): 3474-80.
           doi:10.1021/je100167w.


def Vc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[SURF]):

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(IUPAC)<EOL><DEDENT>if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(MATTHEWS)<EOL><DEDENT>if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(CRC)<EOL><DEDENT>if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(PSRK)<EOL><DEDENT>if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(YAWS)<EOL><DEDENT>if CASRN:<EOL><INDENT>methods.append(SURF)<EOL><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(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == IUPAC:<EOL><INDENT>_Vc = float(_crit_IUPAC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == PSRK:<EOL><INDENT>_Vc = float(_crit_PSRKR4.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == MATTHEWS:<EOL><INDENT>_Vc = float(_crit_Matthews.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == CRC:<EOL><INDENT>_Vc = float(_crit_CRC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == YAWS:<EOL><INDENT>_Vc = float(_crit_Yaws.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == SURF:<EOL><INDENT>_Vc = third_property(CASRN=CASRN, V=True)<EOL><DEDENT>elif Method == NONE:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _Vc<EOL>

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

    Prefered sources are 'IUPAC' for organic chemicals, and 'MATTHEWS' for
    inorganic chemicals. Function has data for approximately 1000 chemicals.

    Examples
    --------
    >>> Vc(CASRN='64-17-5')
    0.000168

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

    Returns
    -------
    Vc : float
        Critical volume, [m^3/mol]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain Vc with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS',
        'CRC', 'PSRK', 'YAWS', and 'SURF'. All valid values are also held
        in the list `Vc_methods`.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        Vc for the desired chemical, and will return methods instead of Vc
    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 six sources are available for this function. They are:

        * 'IUPAC', a series of critically evaluated
          experimental datum for organic compounds in [1]_, [2]_, [3]_, [4]_,
          [5]_, [6]_, [7]_, [8]_, [9]_, [10]_, [11]_, and [12]_.
        * 'MATTHEWS', a series of critically
          evaluated data for inorganic compounds in [13]_.
        * 'CRC', a compillation of critically
          evaluated data by the TRC as published in [14]_.
        * 'PSRK', a compillation of experimental and
          estimated data published in [15]_.
        * 'YAWS', a large compillation of data from a
          variety of sources; no data points are sourced in the work of [16]_.
        * 'SURF', an estimation method using a
          simple quadratic method for estimating Pc from Tc and Vc. This is
          ignored and not returned as a method by default

    References
    ----------
    .. [1] Ambrose, Douglas, and Colin L. Young. "Vapor-Liquid Critical
       Properties of Elements and Compounds. 1. An Introductory Survey."
       Journal of Chemical & Engineering Data 41, no. 1 (January 1, 1996):
       154-154. doi:10.1021/je950378q.
    .. [2] Ambrose, Douglas, and Constantine Tsonopoulos. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 2. Normal Alkanes."
       Journal of Chemical & Engineering Data 40, no. 3 (May 1, 1995): 531-46.
       doi:10.1021/je00019a001.
    .. [3] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 3. Aromatic
       Hydrocarbons." Journal of Chemical & Engineering Data 40, no. 3
       (May 1, 1995): 547-58. doi:10.1021/je00019a002.
    .. [4] Gude, Michael, and Amyn S. Teja. "Vapor-Liquid Critical Properties
       of Elements and Compounds. 4. Aliphatic Alkanols." Journal of Chemical
       & Engineering Data 40, no. 5 (September 1, 1995): 1025-36.
       doi:10.1021/je00021a001.
    .. [5] Daubert, Thomas E. "Vapor-Liquid Critical Properties of Elements
       and Compounds. 5. Branched Alkanes and Cycloalkanes." Journal of
       Chemical & Engineering Data 41, no. 3 (January 1, 1996): 365-72.
       doi:10.1021/je9501548.
    .. [6] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 6. Unsaturated Aliphatic
       Hydrocarbons." Journal of Chemical & Engineering Data 41, no. 4
       (January 1, 1996): 645-56. doi:10.1021/je9501999.
    .. [7] Kudchadker, Arvind P., Douglas Ambrose, and Constantine Tsonopoulos.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 7. Oxygen
       Compounds Other Than Alkanols and Cycloalkanols." Journal of Chemical &
       Engineering Data 46, no. 3 (May 1, 2001): 457-79. doi:10.1021/je0001680.
    .. [8] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 8. Organic Sulfur,
       Silicon, and Tin Compounds (C + H + S, Si, and Sn)." Journal of Chemical
       & Engineering Data 46, no. 3 (May 1, 2001): 480-85.
       doi:10.1021/je000210r.
    .. [9] Marsh, Kenneth N., Colin L. Young, David W. Morton, Douglas Ambrose,
       and Constantine Tsonopoulos. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 9. Organic Compounds Containing Nitrogen."
       Journal of Chemical & Engineering Data 51, no. 2 (March 1, 2006):
       305-14. doi:10.1021/je050221q.
    .. [10] Marsh, Kenneth N., Alan Abramson, Douglas Ambrose, David W. Morton,
       Eugene Nikitin, Constantine Tsonopoulos, and Colin L. Young.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 10. Organic
       Compounds Containing Halogens." Journal of Chemical & Engineering Data
       52, no. 5 (September 1, 2007): 1509-38. doi:10.1021/je700336g.
    .. [11] Ambrose, Douglas, Constantine Tsonopoulos, and Eugene D. Nikitin.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 11. Organic
       Compounds Containing B + O; Halogens + N, + O, + O + S, + S, + Si;
       N + O; and O + S, + Si." Journal of Chemical & Engineering Data 54,
       no. 3 (March 12, 2009): 669-89. doi:10.1021/je800580z.
    .. [12] Ambrose, Douglas, Constantine Tsonopoulos, Eugene D. Nikitin, David
       W. Morton, and Kenneth N. Marsh. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 12. Review of Recent Data for Hydrocarbons and
       Non-Hydrocarbons." Journal of Chemical & Engineering Data, October 5,
       2015, 151005081500002. doi:10.1021/acs.jced.5b00571.
    .. [13] Mathews, Joseph F. "Critical Constants of Inorganic Substances."
       Chemical Reviews 72, no. 1 (February 1, 1972): 71-100.
       doi:10.1021/cr60275a004.
    .. [14] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
       Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
    .. [15] 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.
    .. [16] Yaws, Carl L. Thermophysical Properties of Chemicals and
       Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
       Publishing, 2014.


def Grigoras(Tc=None, Pc=None, Vc=None):

if Tc and Vc:<EOL><INDENT>Vc = Vc*<NUM_LIT>  <EOL>Pc = <NUM_LIT> + <NUM_LIT>*Tc/Vc<EOL>Pc = Pc*<NUM_LIT>  <EOL>return Pc<EOL><DEDENT>elif Tc and Pc:<EOL><INDENT>Pc = Pc/<NUM_LIT>  <EOL>Vc = <NUM_LIT>*Tc/(<NUM_LIT:10>*Pc-<NUM_LIT>)<EOL>Vc = Vc/<NUM_LIT>  <EOL>return Vc<EOL><DEDENT>elif Pc and Vc:<EOL><INDENT>Pc = Pc/<NUM_LIT>  <EOL>Vc = Vc*<NUM_LIT>  <EOL>Tc = <NUM_LIT:1.0>/<NUM_LIT>*(<NUM_LIT:10>*Pc-<NUM_LIT>)*Vc<EOL>return Tc<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Relatively recent (1990) relationship for estimating critical
    properties from each other. Two of the three properties are required.
    This model uses the "critical surface", a general plot of Tc vs Pc vs Vc.
    The model used 137 organic and inorganic compounds to derive the equation.
    The general equation is in [1]_:

    .. math::
        P_c = 2.9 + 20.2 \frac{T_c}{V_c}

    Parameters
    ----------
    Tc : float
        Critical temperature of fluid (optional) [K]
    Pc : float
        Critical pressure of fluid (optional) [Pa]
    Vc : float
        Critical volume of fluid (optional) [m^3/mol]

    Returns
    -------
    Tc, Pc or Vc : float
        Critical property of fluid [K], [Pa], or [m^3/mol]

    Notes
    -----
    The prediction of Tc from Pc and Vc is not tested, as this is not necessary
    anywhere, but it is implemented.
    Internal units are bar, cm^3/mol, and K. A slight error occurs when
    Pa, cm^3/mol and K are used instead, on the order of <0.2%.
    This equation is less accurate than that of Ihmels, but surprisingly close.
    The author also investigated an early QSPR model.

    Examples
    --------
    Succinic acid [110-15-6]

    >>> Grigoras(Tc=851.0, Vc=0.000308)
    5871233.766233766

    References
    ----------
    .. [1] Grigoras, Stelian. "A Structural Approach to Calculate Physical
           Properties of Pure Organic Substances: The Critical Temperature,
           Critical Volume and Related Properties." Journal of Computational
           Chemistry 11, no. 4 (May 1, 1990): 493-510.
           doi:10.1002/jcc.540110408


def Pc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[SURF]):

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(IUPAC)<EOL><DEDENT>if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(MATTHEWS)<EOL><DEDENT>if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(CRC)<EOL><DEDENT>if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(PSRK)<EOL><DEDENT>if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(PD)<EOL><DEDENT>if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(YAWS)<EOL><DEDENT>if CASRN:<EOL><INDENT>methods.append(SURF)<EOL><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(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == IUPAC:<EOL><INDENT>_Pc = float(_crit_IUPAC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == MATTHEWS:<EOL><INDENT>_Pc = float(_crit_Matthews.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == CRC:<EOL><INDENT>_Pc = float(_crit_CRC.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == PSRK:<EOL><INDENT>_Pc = float(_crit_PSRKR4.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == PD:<EOL><INDENT>_Pc = float(_crit_PassutDanner.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == YAWS:<EOL><INDENT>_Pc = float(_crit_Yaws.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == SURF:<EOL><INDENT>_Pc = third_property(CASRN=CASRN, P=True)<EOL><DEDENT>elif Method == NONE:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _Pc<EOL>

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

    Prefered sources are 'IUPAC' for organic chemicals, and 'MATTHEWS' for
    inorganic chemicals. Function has data for approximately 1000 chemicals.

    Examples
    --------
    >>> Pc(CASRN='64-17-5')
    6137000.0

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

    Returns
    -------
    Pc : float
        Critical pressure, [Pa]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain Pc with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS',
        'CRC', 'PSRK', 'PD', 'YAWS', and 'SURF'. All valid values are also held
        in the list `Pc_methods`.
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        Pc for the desired chemical, and will return methods instead of Pc
    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 seven sources are available for this function. They are:

        * 'IUPAC', a series of critically evaluated
          experimental datum for organic compounds in [1]_, [2]_, [3]_, [4]_,
          [5]_, [6]_, [7]_, [8]_, [9]_, [10]_, [11]_, and [12]_.
        * 'MATTHEWS', a series of critically
          evaluated data for inorganic compounds in [13]_.
        * 'CRC', a compillation of critically
          evaluated data by the TRC as published in [14]_.
        * 'PSRK', a compillation of experimental and
          estimated data published in [15]_.
        * 'PD', an older compillation of
          data published in [16]_
        * 'YAWS', a large compillation of data from a
          variety of sources; no data points are sourced in the work of [17]_.
        * SURF', an estimation method using a
          simple quadratic method for estimating Pc from Tc and Vc. This is
          ignored and not returned as a method by default.

    References
    ----------
    .. [1] Ambrose, Douglas, and Colin L. Young. "Vapor-Liquid Critical
       Properties of Elements and Compounds. 1. An Introductory Survey."
       Journal of Chemical & Engineering Data 41, no. 1 (January 1, 1996):
       154-154. doi:10.1021/je950378q.
    .. [2] Ambrose, Douglas, and Constantine Tsonopoulos. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 2. Normal Alkanes."
       Journal of Chemical & Engineering Data 40, no. 3 (May 1, 1995): 531-46.
       doi:10.1021/je00019a001.
    .. [3] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 3. Aromatic
       Hydrocarbons." Journal of Chemical & Engineering Data 40, no. 3
       (May 1, 1995): 547-58. doi:10.1021/je00019a002.
    .. [4] Gude, Michael, and Amyn S. Teja. "Vapor-Liquid Critical Properties
       of Elements and Compounds. 4. Aliphatic Alkanols." Journal of Chemical
       & Engineering Data 40, no. 5 (September 1, 1995): 1025-36.
       doi:10.1021/je00021a001.
    .. [5] Daubert, Thomas E. "Vapor-Liquid Critical Properties of Elements
       and Compounds. 5. Branched Alkanes and Cycloalkanes." Journal of
       Chemical & Engineering Data 41, no. 3 (January 1, 1996): 365-72.
       doi:10.1021/je9501548.
    .. [6] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 6. Unsaturated Aliphatic
       Hydrocarbons." Journal of Chemical & Engineering Data 41, no. 4
       (January 1, 1996): 645-56. doi:10.1021/je9501999.
    .. [7] Kudchadker, Arvind P., Douglas Ambrose, and Constantine Tsonopoulos.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 7. Oxygen
       Compounds Other Than Alkanols and Cycloalkanols." Journal of Chemical &
       Engineering Data 46, no. 3 (May 1, 2001): 457-79. doi:10.1021/je0001680.
    .. [8] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
       Critical Properties of Elements and Compounds. 8. Organic Sulfur,
       Silicon, and Tin Compounds (C + H + S, Si, and Sn)." Journal of Chemical
       & Engineering Data 46, no. 3 (May 1, 2001): 480-85.
       doi:10.1021/je000210r.
    .. [9] Marsh, Kenneth N., Colin L. Young, David W. Morton, Douglas Ambrose,
       and Constantine Tsonopoulos. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 9. Organic Compounds Containing Nitrogen."
       Journal of Chemical & Engineering Data 51, no. 2 (March 1, 2006):
       305-14. doi:10.1021/je050221q.
    .. [10] Marsh, Kenneth N., Alan Abramson, Douglas Ambrose, David W. Morton,
       Eugene Nikitin, Constantine Tsonopoulos, and Colin L. Young.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 10. Organic
       Compounds Containing Halogens." Journal of Chemical & Engineering Data
       52, no. 5 (September 1, 2007): 1509-38. doi:10.1021/je700336g.
    .. [11] Ambrose, Douglas, Constantine Tsonopoulos, and Eugene D. Nikitin.
       "Vapor-Liquid Critical Properties of Elements and Compounds. 11. Organic
       Compounds Containing B + O; Halogens + N, + O, + O + S, + S, + Si;
       N + O; and O + S, + Si." Journal of Chemical & Engineering Data 54,
       no. 3 (March 12, 2009): 669-89. doi:10.1021/je800580z.
    .. [12] Ambrose, Douglas, Constantine Tsonopoulos, Eugene D. Nikitin, David
       W. Morton, and Kenneth N. Marsh. "Vapor-Liquid Critical Properties of
       Elements and Compounds. 12. Review of Recent Data for Hydrocarbons and
       Non-Hydrocarbons." Journal of Chemical & Engineering Data, October 5,
       2015, 151005081500002. doi:10.1021/acs.jced.5b00571.
    .. [13] Mathews, Joseph F. "Critical Constants of Inorganic Substances."
       Chemical Reviews 72, no. 1 (February 1, 1972): 71-100.
       doi:10.1021/cr60275a004.
    .. [14] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
       Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
    .. [15] 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.
    .. [16] 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.
    .. [17] Yaws, Carl L. Thermophysical Properties of Chemicals and
       Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
       Publishing, 2014.


if not none_and_length_check([zs, Vcs]): <EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>denominator = sum(zs[i]*Vcs[i]**(<NUM_LIT:2>/<NUM_LIT>) for i in range(len(zs)))<EOL>Vcm = <NUM_LIT:0><EOL>for i in range(len(zs)):<EOL><INDENT>Vcm += zs[i]*Vcs[i]**(<NUM_LIT:2>/<NUM_LIT>)*Vcs[i]/denominator<EOL>for j in range(len(zs)):<EOL><INDENT>Vcm += (zs[i]*Vcs[i]**(<NUM_LIT:2>/<NUM_LIT>)/denominator)*(zs[j]*Vcs[j]**(<NUM_LIT:2>/<NUM_LIT>)/denominator)*nus[i][j]/<NUM_LIT><EOL><DEDENT><DEDENT>return Vcm<EOL>

r'''Calculates critical volume of a mixture according to
    mixing rules in [1]_ with an interaction parameter.

    .. math::
        V_{cm} = \sum_i^n \theta_i V_{ci} + \sum_i^n\sum_j^n(\theta_i \theta_j \nu_{ij})V_{ref}
        \theta = \frac{x_i V_{ci}^{2/3}}{\sum_{j=1}^n x_j V_{cj}^{2/3}}

    Parameters
    ----------
    zs : float
        Mole fractions of all components
    Vcs : float
        Critical volumes of all components, [m^3/mol]
    nus : matrix
        Interaction parameters, [cm^3/mol]

    Returns
    -------
    Vcm : float
        Critical volume of the mixture, [m^3/mol]

    Notes
    -----
    All parameters, even if zero, must be given to this function.
    nu parameters are in cm^3/mol, but are converted to m^3/mol inside the function

    Examples
    --------
    1-butanol/benzene 0.4271/0.5729 mixture, Vcm = 268.096 mL/mol.

    >>> Chueh_Prausnitz_Vc([0.4271, 0.5729], [0.000273, 0.000256], [[0, 5.61847], [5.61847, 0]])
    0.00026620503424517445

    References
    ----------
    .. [1] Chueh, P. L., and J. M. Prausnitz. "Vapor-Liquid Equilibria at High
       Pressures: Calculation of Critical Temperatures, Volumes, and Pressures
       of Nonpolar Mixtures." AIChE Journal 13, no. 6 (November 1, 1967):
       1107-13. doi:10.1002/aic.690130613.
    .. [2] Najafi, Hamidreza, Babak Maghbooli, and Mohammad Amin Sobati.
       "Prediction of True Critical Volume of Multi-Component Mixtures:
       Extending Fast Estimation Methods." Fluid Phase Equilibria 386
       (January 25, 2015): 13-29. doi:10.1016/j.fluid.2014.11.008.


def Chueh_Prausnitz_Tc(zs, Tcs, Vcs, taus):

if not none_and_length_check([zs, Tcs, Vcs]):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>denominator = sum(zs[i]*Vcs[i]**(<NUM_LIT:2>/<NUM_LIT>) for i in range(len(zs)))<EOL>Tcm = <NUM_LIT:0><EOL>for i in range(len(zs)):<EOL><INDENT>Tcm += zs[i]*Vcs[i]**(<NUM_LIT:2>/<NUM_LIT>)*Tcs[i]/denominator<EOL>for j in range(len(zs)):<EOL><INDENT>Tcm += (zs[i]*Vcs[i]**(<NUM_LIT:2>/<NUM_LIT>)/denominator)*(zs[j]*Vcs[j]**(<NUM_LIT:2>/<NUM_LIT>)/denominator)*taus[i][j]<EOL><DEDENT><DEDENT>return Tcm<EOL>

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

    .. math::
        T_{cm} = \sum_i^n \theta_i Tc_i + \sum_i^n\sum_j^n(\theta_i \theta_j
        \tau_{ij})T_{ref}

        \theta = \frac{x_i V_{ci}^{2/3}}{\sum_{j=1}^n x_j V_{cj}^{2/3}}

    For a binary mxiture, this simplifies to:

    .. math::
        T_{cm} = \theta_1T_{c1} + \theta_2T_{c2}  + 2\theta_1\theta_2\tau_{12}

    Parameters
    ----------
    zs : array-like
        Mole fractions of all components
    Tcs : array-like
        Critical temperatures of all components, [K]
    Vcs : array-like
        Critical volumes of all components, [m^3/mol]
    taus : array-like of shape `zs` by `zs`
        Interaction parameters

    Returns
    -------
    Tcm : float
        Critical temperatures of the mixture, [K]

    Notes
    -----
    All parameters, even if zero, must be given to this function.

    Examples
    --------
    butane/pentane/hexane 0.6449/0.2359/0.1192 mixture, exp: 450.22 K.

    >>> Chueh_Prausnitz_Tc([0.6449, 0.2359, 0.1192], [425.12, 469.7, 507.6],
    ... [0.000255, 0.000313, 0.000371], [[0, 1.92681, 6.80358],
    ... [1.92681, 0, 1.89312], [ 6.80358, 1.89312, 0]])
    450.1225764723492

    References
    ----------
    .. [1] Chueh, P. L., and J. M. Prausnitz. "Vapor-Liquid Equilibria at High
       Pressures: Calculation of Critical Temperatures, Volumes, and Pressures
       of Nonpolar Mixtures." AIChE Journal 13, no. 6 (November 1, 1967):
       1107-13. doi:10.1002/aic.690130613.
    .. [2] Najafi, Hamidreza, Babak Maghbooli, and Mohammad Amin Sobati.
       "Prediction of True Critical Temperature of Multi-Component Mixtures:
       Extending Fast Estimation Methods." Fluid Phase Equilibria 392
       (April 25, 2015): 104-26. doi:10.1016/j.fluid.2015.02.001.


def Vc_mixture(Vcs=None, zs=None, CASRNs=None, AvailableMethods=False, Method=None):

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

This function handles the retrival of a mixture's critical temperature.

    This API is considered experimental, and is expected to be removed in a
    future release in favor of a more complete object-oriented interface.

    >>> Vc_mixture([5.6E-5, 2E-4], [0.3, 0.7])
    0.0001568


def range_check(T, Tmin, Tmax):<EOL><INDENT>if T < Tmin or T > Tmax:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if current == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>elif current == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T68_to_T90(T)<EOL><DEDENT>elif current == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T76_to_T90(T)<EOL><DEDENT>elif current == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T48_to_T90(T)<EOL><DEDENT>elif current == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T27_to_T90(T)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if desired == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>elif desired == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T90_to_T68(T)<EOL><DEDENT>elif desired == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T90_to_T76(T)<EOL><DEDENT>elif desired == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T90_to_T48(T)<EOL><DEDENT>elif desired == '<STR_LIT>':<EOL><INDENT>range_check(T, <NUM_LIT>, <NUM_LIT>)<EOL>T = T90_to_T27(T)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return float(T)<EOL>

r'''Converts the a temperature reading made in any of the scales
    'ITS-90', 'ITS-68','ITS-48', 'ITS-76', or 'ITS-27' to any of the other
    scales. Not all temperature ranges can be converted to other ranges; for
    instance, 'ITS-76' is purely for low temperatures, and 5 K on it has no
    conversion to 'ITS-90' or any other scale. Both a conversion to ITS-90 and
    to the desired scale must be possible for the conversion to occur.
    The conversion uses cubic spline interpolation.

    ITS-68 conversion is valid from 14 K to 4300 K.
    ITS-48 conversion is valid from 93.15 K to 4273.15 K
    ITS-76 conversion is valid from 5 K to 27 K.
    ITS-27 is valid from 903.15 K to 4273.15 k.

    Parameters
    ----------
    T : float
        Temperature, on `current` scale [K]
    current : str
        String representing the scale T is in, 'ITS-90', 'ITS-68',
        'ITS-48', 'ITS-76', or 'ITS-27'.
    desired : str
        String representing the scale T will be returned in, 'ITS-90',
        'ITS-68', 'ITS-48', 'ITS-76', or 'ITS-27'.

    Returns
    -------
    T : float
        Temperature, on scale `desired` [K]

    Notes
    -----
    Because the conversion is performed by spline functions, a re-conversion
    of a value will not yield exactly the original value. However, it is quite
    close.

    The use of splines is quite quick (20 micro seconds/calculation). While
    just a spline for one-way conversion could be used, a numerical solver
    would have to be used to obtain an exact result for the reverse conversion.
    This was found to take approximately 1 ms/calculation, depending on the
    region.

    Examples
    --------
    >>> T_converter(500, 'ITS-68', 'ITS-48')
    499.9470092992346

    References
    ----------
    .. [1] Wier, Ron D., and Robert N. Goldberg. "On the Conversion of
       Thermodynamic Properties to the Basis of the International Temperature
       Scale of 1990." The Journal of Chemical Thermodynamics 28, no. 3
       (March 1996): 261-76. doi:10.1006/jcht.1996.0026.
    .. [2] Goldberg, Robert N., and R. D. Weir. "Conversion of Temperatures
       and Thermodynamic Properties to the Basis of the International
       Temperature Scale of 1990 (Technical Report)." Pure and Applied
       Chemistry 64, no. 10 (1992): 1545-1562. doi:10.1351/pac199264101545.


ais = [-<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL>-<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>,<EOL>-<NUM_LIT>]<EOL>bis = [<NUM_LIT:0>, -<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, -<NUM_LIT>,<EOL><NUM_LIT>, -<NUM_LIT>]<EOL><INDENT>cis = [-<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, -<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>]<EOL><DEDENT>new_cs = [<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, -<NUM_LIT>,<EOL><NUM_LIT>, -<NUM_LIT>]<EOL>dT = <NUM_LIT:0><EOL>if T < <NUM_LIT>:<EOL><INDENT>dT = <NUM_LIT:0><EOL><DEDENT>elif T >= <NUM_LIT> and T <= <NUM_LIT>:<EOL><INDENT>for i in range(<NUM_LIT>):<EOL><INDENT>dT += ais[i]*((T - <NUM_LIT>)/<NUM_LIT>)**i<EOL><DEDENT><DEDENT>elif T > <NUM_LIT> and T < <NUM_LIT>:<EOL><INDENT>dT = <NUM_LIT:0><EOL><DEDENT>elif T >= <NUM_LIT> and T <= <NUM_LIT>:<EOL><INDENT>for i in range(<NUM_LIT:9>):<EOL><INDENT>dT += bis[i]*((T - <NUM_LIT>)/<NUM_LIT>)**i<EOL><DEDENT><DEDENT>elif T > <NUM_LIT> and T <= <NUM_LIT>:<EOL><INDENT>for i in range(<NUM_LIT:6>):<EOL><INDENT>dT += new_cs[i]*(T-<NUM_LIT>)**i<EOL><DEDENT><DEDENT>elif T > <NUM_LIT>:<EOL><INDENT>dT = -<NUM_LIT>*T**<NUM_LIT:2><EOL><DEDENT>return dT<EOL>

r'''Calculates the difference between ITS-90 and ITS-68 scales using a
    series of models listed in [1]_, [2]_, and [3]_.

    The temperature difference is given by the following equations:

    From 13.8 K to 73.15 K:

    .. math::
        T_{90} - T_{68} = a_0 + \sum_{i=1}^{12} a_i[(T_{90}/K-40)/40]^i

    From 83.8 K to 903.75 K:

    .. math::
        T_{90} - T_{68} = \sum_{i=1}^8 b_i[(T_{90}/K - 273.15)/630]^i

    From 903.75 K to 1337.33 K:

    .. math::
        T_{90} - T_{68} = \sum_{i=0}^5 c_i[T_{90}/^\circ C]^i

    Above 1337.33 K:

    .. math::
        T_{90} - T_{68} = -1.398\cdot 10^{-7}\left(\frac{T_{90}}{K}\right)^2

    Parameters
    ----------
    T : float
        Temperature, ITS-90, or approximately ITS-68 [K]

    Returns
    -------
    dT : float
        Temperature, difference between ITS-90 and ITS-68 at T [K]

    Notes
    -----
    The conversion is straightforward when T90 is known. Theoretically, the
    model should be solved numerically to convert the reverse way. However,
    according to [4]_, the difference is under 0.05 mK from 73.15 K to
    903.15 K, and under 0.26 mK up to 1337.33 K.

    For temperatures under 13.8 K, no conversion is performed.

    The first set of coefficients are:
    -0.005903, 0.008174, -0.061924, -0.193388, 1.490793, 1.252347, -9.835868,
    1.411912, 25.277595, -19.183815, -18.437089, 27.000895, -8.716324.

    The second set of coefficients are:
    0, -0.148759, -0.267408, 1.08076, 1.269056, -4.089591, -1.871251,
    7.438081, -3.536296.

    The third set of coefficients are:
    7.8687209E1, -4.7135991E-1, 1.0954715E-3, -1.2357884E-6, 6.7736583E-10,
    -1.4458081E-13.
    These last coefficients use the temperature in degrees Celcius. A slightly
    older model used the following coefficients but a different equation over
    the same range:
    -0.00317, -0.97737, 1.2559, 2.03295, -5.91887, -3.23561, 7.23364,
    5.04151. The model for these coefficients was:

    .. math::
        T_{90} - T_{68} = c_0 + \sum_{i=1}^7 c_i[(T_{90}/K - 1173.15)/300]^i

    For temperatures larger than several thousand K, the differences have no
    meaning and grows quadratically.

    Examples
    --------
    >>> ITS90_68_difference(1000.)
    0.01231818956580355

    References
    ----------
    .. [1] Bedford, R. E., G. Bonnier, H. Maas, and F. Pavese. "Techniques for
       Approximating the International Temperature Scale of 1990." Bureau
       International Des Poids et Mesures, Sfievres, 1990.
    .. [2] Wier, Ron D., and Robert N. Goldberg. "On the Conversion of
       Thermodynamic Properties to the Basis of the International Temperature
       Scale of 1990." The Journal of Chemical Thermodynamics 28, no. 3
       (March 1996): 261-76. doi:10.1006/jcht.1996.0026.
    .. [3] Goldberg, Robert N., and R. D. Weir. "Conversion of Temperatures
       and Thermodynamic Properties to the Basis of the International
       Temperature Scale of 1990 (Technical Report)." Pure and Applied
       Chemistry 64, no. 10 (1992): 1545-1562. doi:10.1351/pac199264101545.
    .. [4] Code10.info. "Conversions among International Temperature Scales."
       Accessed May 22, 2016. http://www.code10.info/index.php%3Foption%3Dcom_content%26view%3Darticle%26id%3D83:conversions-among-international-temperature-scales%26catid%3D60:temperature%26Itemid%3D83.


def CoolProp_T_dependent_property(T, CASRN, prop, phase):

if not has_CoolProp:  <EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if CASRN not in coolprop_dict:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>Tc = coolprop_fluids[CASRN].Tc<EOL>T = float(T) <EOL>if phase == '<STR_LIT:l>':<EOL><INDENT>if T > Tc:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if PhaseSI('<STR_LIT:T>', T, '<STR_LIT:P>', <NUM_LIT>, CASRN) in [u'<STR_LIT>', u'<STR_LIT>']:<EOL><INDENT>return PropsSI(prop, '<STR_LIT:T>', T, '<STR_LIT:P>', <NUM_LIT>, CASRN)<EOL><DEDENT>else:<EOL><INDENT>return PropsSI(prop, '<STR_LIT:T>', T, '<STR_LIT>', <NUM_LIT:0>, CASRN)<EOL><DEDENT><DEDENT>elif phase == '<STR_LIT:g>':<EOL><INDENT>if PhaseSI('<STR_LIT:T>', T, '<STR_LIT:P>', <NUM_LIT>, CASRN) == '<STR_LIT>':<EOL><INDENT>return PropsSI(prop, '<STR_LIT:T>', T, '<STR_LIT:P>', <NUM_LIT>, CASRN)<EOL><DEDENT>else:<EOL><INDENT>if T < Tc:<EOL><INDENT>return PropsSI(prop, '<STR_LIT:T>', T, '<STR_LIT>', <NUM_LIT:1>, CASRN)<EOL><DEDENT>else:<EOL><INDENT>return PropsSI(prop, '<STR_LIT:T>', T, '<STR_LIT:P>', <NUM_LIT>, CASRN)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Calculates a property of a chemical in either the liquid or gas phase
    as a function of temperature only. This means that the property is
    either at 1 atm or along the saturation curve.

    Parameters
    ----------
    T : float
        Temperature of the fluid [K]
    CASRN : str
        CAS number of the fluid
    prop : str
        CoolProp string shortcut for desired property
    phase : str
        Either 'l' or 'g' for liquid or gas properties respectively

    Returns
    -------
    prop : float
        Desired chemical property, [units]

    Notes
    -----
    For liquids above their boiling point, the liquid property is found on the
    saturation line (at higher pressures). Under their boiling point, the
    property is calculated at 1 atm.

    No liquid calculations are permitted above the critical temperature.

    For gases under the chemical's boiling point, the gas property is found
    on the saturation line (at sub-atmospheric pressures). Above the boiling
    point, the property is calculated at 1 atm.

    An exception is raised if the desired CAS is not supported, or if CoolProp
    is not available.

    The list of strings acceptable as an input for property types is:
    http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function

    Examples
    --------
    Water at STP according to IAPWS-95

    >>> CoolProp_T_dependent_property(298.15, '7732-18-5', 'D', 'l')
    997.047636760347

    References
    ----------
    .. [1] Bell, Ian H., Jorrit Wronski, Sylvain Quoilin, and Vincent Lemort.
       "Pure and Pseudo-Pure Fluid Thermophysical Property Evaluation and the
       Open-Source Thermophysical Property Library CoolProp." Industrial &
       Engineering Chemistry Research 53, no. 6 (February 12, 2014):
       2498-2508. doi:10.1021/ie4033999. http://www.coolprop.org/


if not MW:<EOL><INDENT>MW = molecular_weight(atoms)<EOL><DEDENT>mfracs = {}<EOL>for i in atoms:<EOL><INDENT>if i in periodic_table:<EOL><INDENT>mfracs[i] = periodic_table[i].MW*atoms[i]/MW<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>return mfracs<EOL>

r'''Calculates the mass fractions of each element in a compound,
    given a dictionary of its atoms and their counts, in the format
    {symbol: count}.

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

    Parameters
    ----------
    atoms : dict
        dictionary of counts of individual atoms, indexed by symbol with
        proper capitalization, [-]
    MW : float, optional
        Molecular weight, [g/mol]

    Returns
    -------
    mfracs : dict
        dictionary of mass fractions of individual atoms, indexed by symbol
        with proper capitalization, [-]

    Notes
    -----
    Molecular weight is optional, but speeds up the calculation slightly. It
    is calculated using the function `molecular_weight` if not specified.

    Elemental data is from rdkit, with CAS numbers added. An exception is
    raised if an incorrect element symbol is given. Elements up to 118 are
    supported.

    Examples
    --------
    >>> mass_fractions({'H': 12, 'C': 20, 'O': 5})
    {'H': 0.03639798802478244, 'C': 0.7228692758981262, 'O': 0.24073273607709128}

    References
    ----------
    .. [1] RDKit: Open-source cheminformatics; http://www.rdkit.org


negative = '<STR_LIT:->' in formula<EOL>positive = '<STR_LIT:+>' in formula<EOL>if positive and negative:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif not (positive or negative):<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>multiplier, sign = (-<NUM_LIT:1>, '<STR_LIT:->') if negative else (<NUM_LIT:1>, '<STR_LIT:+>')<EOL>hit = False<EOL>if '<STR_LIT:(>' in formula:<EOL><INDENT>hit = bracketed_charge_re.findall(formula)<EOL>if hit:<EOL><INDENT>formula = hit[-<NUM_LIT:1>].replace('<STR_LIT:(>', '<STR_LIT>').replace('<STR_LIT:)>', '<STR_LIT>')<EOL><DEDENT><DEDENT>count = formula.count(sign)<EOL>if count == <NUM_LIT:1>:<EOL><INDENT>splits = formula.split(sign)<EOL>if splits[<NUM_LIT:1>] == '<STR_LIT>' or splits[<NUM_LIT:1>] == '<STR_LIT:)>':<EOL><INDENT>return multiplier<EOL><DEDENT>else:<EOL><INDENT>return multiplier*int(splits[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return multiplier*count<EOL><DEDENT>

r'''Basic formula parser to determine the charge from a formula - given
    that the charge is already specified as one element of the formula.

    Performs no sanity checking that elements are actually elements.

    Parameters
    ----------
    formula : str
        Formula string, very simply formats only, ending in one of '+x',
        '-x', n*'+', or n*'-' or any of them surrounded by brackets but always
        at the end of a formula.

    Returns
    -------
    charge : int
        Charge of the molecule, [faraday]

    Notes
    -----

    Examples
    --------
    >>> charge_from_formula('Br3-')
    -1
    >>> charge_from_formula('Br3(-)')
    -1


MW = <NUM_LIT:0><EOL>for i in atoms:<EOL><INDENT>if i in periodic_table:<EOL><INDENT>MW += periodic_table[i].MW*atoms[i]<EOL><DEDENT>elif i == '<STR_LIT:D>':<EOL><INDENT>MW += <NUM_LIT>*atoms[i]<EOL><DEDENT>elif i == '<STR_LIT:T>':<EOL><INDENT>MW += <NUM_LIT>*atoms[i]<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>return MW<EOL>

r'''Calculates molecular weight of a molecule given a dictionary of its
    atoms and their counts, in the format {symbol: count}.

    .. math::
        MW = \sum_i n_i MW_i

    Parameters
    ----------
    atoms : dict
        dictionary of counts of individual atoms, indexed by symbol with
        proper capitalization, [-]

    Returns
    -------
    MW : float
        Calculated molecular weight [g/mol]

    Notes
    -----
    Elemental data is from rdkit, with CAS numbers added. An exception is
    raised if an incorrect element symbol is given. Elements up to 118 are
    supported, as are deutreium and tritium.

    Examples
    --------
    >>> molecular_weight({'H': 12, 'C': 20, 'O': 5}) # DNA
    332.30628

    References
    ----------
    .. [1] RDKit: Open-source cheminformatics; http://www.rdkit.org


formula = formula.replace('<STR_LIT:[>', '<STR_LIT>').replace('<STR_LIT:]>', '<STR_LIT>')<EOL>charge_splits = bracketed_charge_re.split(formula)<EOL>if len(charge_splits) > <NUM_LIT:1>:<EOL><INDENT>formula = charge_splits[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>formula = formula.split('<STR_LIT:+>')[<NUM_LIT:0>].split('<STR_LIT:->')[<NUM_LIT:0>]<EOL><DEDENT>stack = [[]]<EOL>last = stack[<NUM_LIT:0>]<EOL>tokens = formula_token_matcher_rational.findall(formula)<EOL>if check:<EOL><INDENT>token_letters = set([j for i in tokens for j in i if j in letter_set])<EOL>formula_letters = set(i for i in formula if i in letter_set)<EOL>if formula_letters != token_letters:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>for token in tokens:<EOL><INDENT>if token == "<STR_LIT:(>":<EOL><INDENT>stack.append([])<EOL>last = stack[-<NUM_LIT:1>]<EOL><DEDENT>elif token == "<STR_LIT:)>":<EOL><INDENT>temp_dict = {}<EOL>for d in last:<EOL><INDENT>for ele, count in d.items():<EOL><INDENT>if ele in temp_dict:<EOL><INDENT>temp_dict[ele] = temp_dict[ele] + count<EOL><DEDENT>else:<EOL><INDENT>temp_dict[ele] = count<EOL><DEDENT><DEDENT><DEDENT>stack.pop()<EOL>last = stack[-<NUM_LIT:1>]<EOL>last.append(temp_dict)<EOL><DEDENT>elif token.isalpha():<EOL><INDENT>last.append({token: <NUM_LIT:1>})<EOL><DEDENT>else:<EOL><INDENT>v = float(token)<EOL>v_int = int(v)<EOL>if v_int == v:<EOL><INDENT>v = v_int<EOL><DEDENT>last[-<NUM_LIT:1>] = {ele: count*v for ele, count in last[-<NUM_LIT:1>].items()}<EOL><DEDENT><DEDENT>ans = {}<EOL>for d in last:<EOL><INDENT>for ele, count in d.items():<EOL><INDENT>if ele in ans:<EOL><INDENT>ans[ele] = ans[ele] + count<EOL><DEDENT>else:<EOL><INDENT>ans[ele] = count<EOL><DEDENT><DEDENT><DEDENT>return ans<EOL>

r'''Improved formula parser which handles braces and their multipliers,
    as well as rational element counts.

    Strips charges from the end of a formula first. Accepts repeated chemical
    units. Performs no sanity checking that elements are actually elements.
    As it uses regular expressions for matching, errors are mostly just ignored.

    Parameters
    ----------
    formula : str
        Formula string, very simply formats only.
    check : bool
        If `check` is True, a simple check will be performed to determine if
        a formula is not a formula and an exception will be raised if it is
        not, [-]

    Returns
    -------
    atoms : dict
        dictionary of counts of individual atoms, indexed by symbol with
        proper capitalization, [-]

    Notes
    -----
    Inspired by the approach taken by CrazyMerlyn on a reddit DailyProgrammer
    challenge, at https://www.reddit.com/r/dailyprogrammer/comments/6eerfk/20170531_challenge_317_intermediate_counting/

    Examples
    --------
    >>> pprint(nested_formula_parser('Pd(NH3)4.0001+2'))
    {'H': 12.0003, 'N': 4.0001, 'Pd': 1}


charge = charge_from_formula(formula)<EOL>element_dict = nested_formula_parser(formula)<EOL>base = atoms_to_Hill(element_dict)<EOL>if charge  == <NUM_LIT:0>:<EOL><INDENT>pass<EOL><DEDENT>elif charge > <NUM_LIT:0>:<EOL><INDENT>if charge == <NUM_LIT:1>:<EOL><INDENT>base += '<STR_LIT:+>'<EOL><DEDENT>else:<EOL><INDENT>base += '<STR_LIT:+>' + str(charge)<EOL><DEDENT><DEDENT>elif charge < <NUM_LIT:0>:<EOL><INDENT>if charge == -<NUM_LIT:1>:<EOL><INDENT>base += '<STR_LIT:->'<EOL><DEDENT>else:<EOL><INDENT>base +=  str(charge)<EOL><DEDENT><DEDENT>return base<EOL>

r'''Basic formula serializer to construct a consistently-formatted formula.
    This is necessary for handling user-supplied formulas, which are not always
    well formatted.

    Performs no sanity checking that elements are actually elements.

    Parameters
    ----------
    formula : str
        Formula string as parseable by the method nested_formula_parser, [-]

    Returns
    -------
    formula : str
        A consistently formatted formula to describe a molecular formula, [-]

    Notes
    -----

    Examples
    --------
    >>> serialize_formula('Pd(NH3)4+3')
    'H12N4Pd+3'


def setup_a_alpha_and_derivatives(self, i, T=None):

self.a, self.m, self.Tc = self.ais[i], self.ms[i], self.Tcs[i]<EOL>

r'''Sets `a`, `m`, and `Tc` for a specific component before the
        pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
        called by `GCEOSMIX.a_alpha_and_derivatives` for every component.


phis = []<EOL>V = Z*R*self.T/self.P<EOL>for i in self.cmps:<EOL><INDENT>phi = self.bs[i]/(V-self.b) - log(Z*(<NUM_LIT:1.> - self.b/V)) - <NUM_LIT>*(self.a_alpha*self.ais[i])**<NUM_LIT:0.5>/(R*self.T*V)<EOL>phis.append(exp(phi))<EOL><DEDENT>return phis<EOL>

r'''Literature formula for calculating fugacity coefficients for each
        species in a mixture. Verified numerically.
        Called by `fugacities` on initialization, or by a solver routine
        which is performing a flash calculation.

        .. math::
            \ln \hat \phi_i = \frac{b_i}{V-b} - \ln\left[Z\left(1
            - \frac{b}{V}\right)\right] - \frac{2\sqrt{aa_i}}{RTV}

        Parameters
        ----------
        Z : float
            Compressibility of the mixture for a desired phase, [-]
        zs : list[float], optional
            List of mole factions, either overall or in a specific phase, [-]

        Returns
        -------
        phis : float
            Fugacity coefficient for each species, [-]

        References
        ----------
        .. [1] Walas, Stanley M. Phase Equilibria in Chemical Engineering.
           Butterworth-Heinemann, 1985.


del(self.a, self.kappa, self.Tc)<EOL>

r'''Removes properties set by `setup_a_alpha_and_derivatives`; run by
        `GCEOSMIX.a_alpha_and_derivatives` after `a_alpha` is calculated for
        every component


self.a = self.ais[i]<EOL>

r'''Sets `a` for a specific component before the
        pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
        called by `GCEOSMIX.a_alpha_and_derivatives` for every component.


del(self.a, self.Tc, self.S1, self.S2)<EOL>


from cmath import log<EOL>A = self.a_alpha*self.P/(R2*self.T*self.T)<EOL>B = self.b*self.P/(R*self.T)<EOL>phis = []<EOL>for i in self.cmps:<EOL><INDENT>t1 = self.bs[i]/self.b*(Z - <NUM_LIT:1.>) - log(Z - B).real<EOL>t2 = <NUM_LIT>/self.a_alpha*sum([zs[j]*self.a_alpha_ijs[i][j] for j in self.cmps])<EOL>t3 = t1 - A/(two_root_two*B)*(t2 - self.bs[i]/self.b)*log((Z + (root_two + <NUM_LIT:1.>)*B)/(Z - (root_two - <NUM_LIT:1.>)*B)).real<EOL>phis.append(exp(t3))<EOL><DEDENT>return phis<EOL>

r'''Literature formula for calculating fugacity coefficients for each
        species in a mixture. Verified numerically. Applicable to most
        derivatives of the Peng-Robinson equation of state as well.
        Called by `fugacities` on initialization, or by a solver routine
        which is performing a flash calculation.

        .. math::
            \ln \hat \phi_i = \frac{B_i}{B}(Z-1)-\ln(Z-B) + \frac{A}{2\sqrt{2}B}
            \left[\frac{B_i}{B} - \frac{2}{a\alpha}\sum_i y_i(a\alpha)_{ij}\right]
            \log\left[\frac{Z + (1+\sqrt{2})B}{Z-(\sqrt{2}-1)B}\right]

            A = \frac{(a\alpha)P}{R^2 T^2}

            B = \frac{b P}{RT}

        Parameters
        ----------
        Z : float
            Compressibility of the mixture for a desired phase, [-]
        zs : list[float], optional
            List of mole factions, either overall or in a specific phase, [-]

        Returns
        -------
        phis : float
            Fugacity coefficient for each species, [-]

        References
        ----------
        .. [1] Peng, Ding-Yu, and Donald B. Robinson. "A New Two-Constant
           Equation of State." Industrial & Engineering Chemistry Fundamentals
           15, no. 1 (February 1, 1976): 59-64. doi:10.1021/i160057a011.
        .. [2] Walas, Stanley M. Phase Equilibria in Chemical Engineering.
           Butterworth-Heinemann, 1985.


if self.phase in ['<STR_LIT:l>', '<STR_LIT>']:<EOL><INDENT>if xs is None:<EOL><INDENT>xs = self.zs<EOL><DEDENT>self.phis_l = self.fugacity_coefficients(self.Z_l, zs=xs)<EOL>self.fugacities_l = [phi*x*self.P for phi, x in zip(self.phis_l, xs)]<EOL>self.lnphis_l = [log(i) for i in self.phis_l]<EOL><DEDENT>if self.phase in ['<STR_LIT:g>', '<STR_LIT>']:<EOL><INDENT>if ys is None:<EOL><INDENT>ys = self.zs<EOL><DEDENT>self.phis_g = self.fugacity_coefficients(self.Z_g, zs=ys)<EOL>self.fugacities_g = [phi*y*self.P for phi, y in zip(self.phis_g, ys)]<EOL>self.lnphis_g = [log(i) for i in self.phis_g]<EOL><DEDENT>

r'''Helper method for calculating fugacity coefficients for any
        phases present, using either the overall mole fractions for both phases
        or using specified mole fractions for each phase.

        Requires `fugacity_coefficients` to be implemented by each subclassing
        EOS.

        In addition to setting `fugacities_l` and/or `fugacities_g`, this also
        sets the fugacity coefficients `phis_l` and/or `phis_g`.

        .. math::
            \hat \phi_i^g = \frac{\hat f_i^g}{x_i P}

            \hat \phi_i^l = \frac{\hat f_i^l}{x_i P}

        Parameters
        ----------
        xs : list[float], optional
            Liquid-phase mole fractions of each species, [-]
        ys : list[float], optional
            Vapor-phase mole fractions of each species, [-]

        Notes
        -----
        It is helpful to check that `fugacity_coefficients` has been
        implemented correctly using the following expression, from [1]_.

        .. math::
            \ln \hat \phi_i = \left[\frac{\partial (n\log \phi)}{\partial
            n_i}\right]_{T,P,n_j,V_t}

        For reference, several expressions for fugacity of a component are as
        follows, shown in [1]_ and [2]_.

        .. math::
             \ln \hat \phi_i = \int_{0}^P\left(\frac{\hat V_i}
             {RT} - \frac{1}{P}\right)dP

             \ln \hat \phi_i = \int_V^\infty \left[
             \frac{1}{RT}\frac{\partial P}{ \partial n_i}
             - \frac{1}{V}\right] d V - \ln Z

        References
        ----------
        .. [1] Hu, Jiawen, Rong Wang, and Shide Mao. "Some Useful Expressions
           for Deriving Component Fugacity Coefficients from Mixture Fugacity
           Coefficient." Fluid Phase Equilibria 268, no. 1-2 (June 25, 2008):
           7-13. doi:10.1016/j.fluid.2008.03.007.
        .. [2] Walas, Stanley M. Phase Equilibria in Chemical Engineering.
           Butterworth-Heinemann, 1985.


del(self.a, self.kappa, self.kappa0, self.kappa1, self.kappa2, self.kappa3, self.Tc)<EOL>


del(self.a, self.kappa, self.kappa0, self.kappa1, self.Tc)<EOL>


methods = [SIMPLE]        <EOL>if none_and_length_check((self.MWs, self.molecular_diameters, self.Stockmayers)):<EOL><INDENT>methods.append(BROKAW)<EOL><DEDENT>if none_and_length_check([self.MWs]):<EOL><INDENT>methods.extend([WILKE, HERNING_ZIPPERER])<EOL><DEDENT>self.all_methods = set(methods)<EOL>Tmins = [i.Tmin for i in self.ViscosityGases if i.Tmin]<EOL>Tmaxs = [i.Tmax for i in self.ViscosityGases if i.Tmax]<EOL>if Tmins:<EOL><INDENT>self.Tmin = max(Tmins)<EOL><DEDENT>if Tmaxs:<EOL><INDENT>self.Tmax = max(Tmaxs)<EOL><DEDENT>

r'''Method to initialize the object by precomputing any values which
        may be used repeatedly and by retrieving mixture-specific variables.
        All data are stored as attributes. This method also sets :obj:`Tmin`,
        :obj:`Tmax`, and :obj:`all_methods` as a set of methods which should
        work to calculate the property.

        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 == DUTT_PRASAD:<EOL><INDENT>A, B, C = self.DUTT_PRASAD_coeffs<EOL>mu = ViswanathNatarajan3(T, A, B, C, )<EOL><DEDENT>elif method == VISWANATH_NATARAJAN_3:<EOL><INDENT>A, B, C = self.VISWANATH_NATARAJAN_3_coeffs<EOL>mu = ViswanathNatarajan3(T, A, B, C)<EOL><DEDENT>elif method == VISWANATH_NATARAJAN_2:<EOL><INDENT>A, B = self.VISWANATH_NATARAJAN_2_coeffs<EOL>mu = ViswanathNatarajan2(T, self.VISWANATH_NATARAJAN_2_coeffs[<NUM_LIT:0>], self.VISWANATH_NATARAJAN_2_coeffs[<NUM_LIT:1>])<EOL><DEDENT>elif method == VISWANATH_NATARAJAN_2E:<EOL><INDENT>C, D = self.VISWANATH_NATARAJAN_2E_coeffs<EOL>mu = ViswanathNatarajan2Exponential(T, C, D)<EOL><DEDENT>elif method == DIPPR_PERRY_8E:<EOL><INDENT>mu = EQ101(T, *self.Perrys2_313_coeffs)<EOL><DEDENT>elif method == COOLPROP:<EOL><INDENT>mu = CoolProp_T_dependent_property(T, self.CASRN, '<STR_LIT>', '<STR_LIT:l>')<EOL><DEDENT>elif method == LETSOU_STIEL:<EOL><INDENT>mu = Letsou_Stiel(T, self.MW, self.Tc, self.Pc, self.omega)<EOL><DEDENT>elif method == PRZEDZIECKI_SRIDHAR:<EOL><INDENT>Vml = self.Vml(T) if hasattr(self.Vml, '<STR_LIT>') else self.Vml<EOL>mu = Przedziecki_Sridhar(T, self.Tm, self.Tc, self.Pc, self.Vc, Vml, self.omega, self.MW)<EOL><DEDENT>elif method == VDI_PPDS:<EOL><INDENT>A, B, C, D, E = self.VDI_PPDS_coeffs<EOL>term = (C - T)/(T-D)<EOL>if term < <NUM_LIT:0>:<EOL><INDENT>term1 = -((T - C)/(T-D))**(<NUM_LIT:1>/<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>term1 = term**(<NUM_LIT:1>/<NUM_LIT>)<EOL><DEDENT>term2 = term*term1<EOL>mu = E*exp(A*term1 + B*term2)<EOL><DEDENT>elif method in self.tabular_data:<EOL><INDENT>mu = self.interpolate(T, method)<EOL><DEDENT>return mu<EOL>

r'''Method to calculate low-pressure liquid viscosity at tempearture
        `T` with a given method.

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

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

        Returns
        -------
        mu : float
            Viscosity of the liquid at T and a low pressure, [Pa*S]


def lucas_gas(T, Tc, Pc, Zc, MW, dipole=<NUM_LIT:0>, CASRN=None):

Tr = T/Tc<EOL>xi = <NUM_LIT>*(Tc/MW**<NUM_LIT:3>/(Pc/<NUM_LIT>)**<NUM_LIT:4>)**(<NUM_LIT:1>/<NUM_LIT>)  <EOL>if dipole is None:<EOL><INDENT>dipole = <NUM_LIT:0><EOL><DEDENT>dipoler = <NUM_LIT>*dipole**<NUM_LIT:2>*(Pc/<NUM_LIT>)/Tc**<NUM_LIT:2>  <EOL>if dipoler < <NUM_LIT>:<EOL><INDENT>Fp = <NUM_LIT:1><EOL><DEDENT>elif <NUM_LIT> <= dipoler < <NUM_LIT>:<EOL><INDENT>Fp = <NUM_LIT:1> + <NUM_LIT>*(<NUM_LIT> - Zc)**<NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>Fp = <NUM_LIT:1> + <NUM_LIT>*(<NUM_LIT> - Zc)**<NUM_LIT>*abs(<NUM_LIT> + <NUM_LIT:0.1>*(Tr-<NUM_LIT>))<EOL><DEDENT>if CASRN and CASRN in _lucas_Q_dict:<EOL><INDENT>Q = _lucas_Q_dict[CASRN]<EOL>if Tr - <NUM_LIT:12> > <NUM_LIT:0>:<EOL><INDENT>value = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>value = -<NUM_LIT:1><EOL><DEDENT>FQ = <NUM_LIT>*Q**<NUM_LIT>*(<NUM_LIT:1> + <NUM_LIT>*((Tr-<NUM_LIT:12>)**<NUM_LIT:2>)**(<NUM_LIT:1.>/MW)*value)<EOL><DEDENT>else:<EOL><INDENT>FQ = <NUM_LIT:1><EOL><DEDENT>eta = (<NUM_LIT>*Tr**<NUM_LIT> - <NUM_LIT>*exp(-<NUM_LIT>*Tr) + <NUM_LIT>*exp(-<NUM_LIT>*Tr) + <NUM_LIT>)*Fp*FQ/xi<EOL>return eta/<NUM_LIT><EOL>

r'''Estimate the viscosity of a gas using an emperical
    formula developed in several sources, but as discussed in [1]_ as the
    original sources are in German or merely personal communications with the
    authors of [1]_.

    .. math::
        \eta  = \left[0.807T_r^{0.618}-0.357\exp(-0.449T_r) + 0.340\exp(-4.058
        T_r) + 0.018\right]F_p^\circ F_Q^\circ /\xi

        F_p^\circ=1, 0 \le \mu_{r} < 0.022

        F_p^\circ = 1+30.55(0.292-Z_c)^{1.72}, 0.022 \le \mu_{r} < 0.075

        F_p^\circ = 1+30.55(0.292-Z_c)^{1.72}|0.96+0.1(T_r-0.7)| 0.075 < \mu_{r}

        F_Q^\circ = 1.22Q^{0.15}\left\{ 1+0.00385[(T_r-12)^2]^{1/M}\text{sign}
        (T_r-12)\right\}

        \mu_r = 52.46 \frac{\mu^2 P_c}{T_c^2}

        \xi=0.176\left(\frac{T_c}{MW^3 P_c^4}\right)^{1/6}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc: float
        Critical point of fluid [K]
    Pc : float
        Critical pressure of the fluid [Pa]
    Zc : float
        Critical compressibility of the fluid [Pa]
    dipole : float
        Dipole moment of fluid [debye]
    CASRN : str, optional
        CAS of the fluid

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

    Notes
    -----
    The example is from [1]_; all results agree.
    Viscosity is calculated in micropoise, and converted to SI internally (1E-7).
    Q for He = 1.38; Q for H2 = 0.76; Q for D2 = 0.52.

    Examples
    --------
    >>> lucas_gas(T=550., Tc=512.6, Pc=80.9E5, Zc=0.224, MW=32.042, dipole=1.7)
    1.7822676912698928e-05

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


methods = [MIXING_LOG_MOLAR, MIXING_LOG_MASS]<EOL>if len(self.CASs) > <NUM_LIT:1> and '<STR_LIT>' in self.CASs:<EOL><INDENT>wCASs = [i for i in self.CASs if i != '<STR_LIT>'] <EOL>if all([i in _Laliberte_Viscosity_ParametersDict for i in wCASs]):<EOL><INDENT>methods.append(LALIBERTE_MU)<EOL>self.wCASs = wCASs<EOL>self.index_w = self.CASs.index('<STR_LIT>')<EOL><DEDENT><DEDENT>self.all_methods = set(methods)<EOL>Tmins = [i.Tmin for i in self.ViscosityLiquids if i.Tmin]<EOL>Tmaxs = [i.Tmax for i in self.ViscosityLiquids if i.Tmax]<EOL>if Tmins:<EOL><INDENT>self.Tmin = max(Tmins)<EOL><DEDENT>if Tmaxs:<EOL><INDENT>self.Tmax = max(Tmaxs)<EOL><DEDENT>