def load_group_assignments_DDBST():
    '''Data is stored in the format
    InChI key\tbool bool bool \tsubgroup count ...\tsubgroup count \tsubgroup count...
    where the bools refer to whether or not the original UNIFAC, modified
    UNIFAC, and PSRK group assignments were completed correctly.
    The subgroups and their count have an indefinite length.
    '''
    # Do not allow running multiple times
    if DDBST_UNIFAC_assignments:
        return None
    with open(os.path.join(folder, 'DDBST UNIFAC assignments.tsv')) as f:
        _group_assignments = [DDBST_UNIFAC_assignments, DDBST_MODIFIED_UNIFAC_assignments, DDBST_PSRK_assignments]
        for line in f.readlines():
            key, valids, original, modified, PSRK = line.split('\t')
            # list of whether or not each method was correctly identified or not
            valids = [True if i == '1' else False for i in valids.split(' ')]
            for groups, storage, valid in zip([original, modified, PSRK], _group_assignments, valids):
                if valid:
                    groups = groups.rstrip().split(' ')
                    d_data = {}
                    for i in range(int(len(groups)/2)):
                        d_data[int(groups[i*2])] = int(groups[i*2+1])
                    storage[key] = d_data

def
load_group_assignments_DDBST
(
)
:
if
DDBST_UNIFAC_assignments
:
return
with
open
(
os
.
path
.
join
(
folder
,
'DDBST UNIFAC assignments.tsv'
)
)
as
f
:
_group_assignments
=
[
DDBST_UNIFAC_assignments
,
DDBST_MODIFIED_UNIFAC_assignments
,
DDBST_PSRK_assignments
]
for
line
in
f
.
readlines
(
)
:
key
,
valids
,
original
,
modified
,
PSRK
=
line
.
split
(
'\t'
)
valids
=
[
True
if
i
==
'1'
else
False
for
i
in
valids
.
split
(
' '
)
]
for
groups
,
storage
,
valid
in
zip
(
[
original
,
modified
,
PSRK
]
,
_group_assignments
,
valids
)
:
if
valid
:
groups
=
groups
.
rstrip
(
)
.
split
(
' '
)
d_data
=
{
}
for
i
in
range
(
int
(
len
(
groups
)
/
2
)
)
:
d_data
[
int
(
groups
[
i
*
2
]
)
]
=
int
(
groups
[
i
*
2
+
1
]
)
storage
[
key
]
=
d_data

Data is stored in the format InChI key \ tbool bool bool \ tsubgroup count ... \ tsubgroup count \ tsubgroup count ... where the bools refer to whether or not the original UNIFAC modified UNIFAC and PSRK group assignments were completed correctly . The subgroups and their count have an indefinite length .


def dipole_moment(CASRN, AvailableMethods=False, Method=None):
    r'''This function handles the retrieval of a chemical's dipole moment.
    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 source is 'CCCBDB'. Considerable variation in reported data has
    found.

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

    Returns
    -------
    dipole : float
        Dipole moment, [debye]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain dipole moment with the
        given inputs

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

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

        * 'CCCBDB', a series of critically evaluated data for compounds in
          [1]_, intended for use in predictive modeling.
        * 'MULLER', a collection of data in a
          group-contribution scheme in [2]_.
        * 'POLING', in the appendix in [3].

    This function returns dipole moment in units of Debye. This is actually
    a non-SI unit; to convert to SI, multiply by 3.33564095198e-30 and its
    units will be in ampere*second^2 or equivalently and more commonly given,
    coulomb*second. The constant is the result of 1E-21/c, where c is the
    speed of light.

    Examples
    --------
    >>> dipole_moment(CASRN='64-17-5')
    1.44

    References
    ----------
    .. [1] NIST Computational Chemistry Comparison and Benchmark Database
       NIST Standard Reference Database Number 101 Release 17b, September 2015,
       Editor: Russell D. Johnson III http://cccbdb.nist.gov/
    .. [2] Muller, Karsten, Liudmila Mokrushina, and Wolfgang Arlt. "Second-
       Order Group Contribution Method for the Determination of the Dipole
       Moment." Journal of Chemical & Engineering Data 57, no. 4 (April 12,
       2012): 1231-36. doi:10.1021/je2013395.
    .. [3] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.
    '''
    def list_methods():
        methods = []
        if CASRN in _dipole_CCDB.index and not np.isnan(_dipole_CCDB.at[CASRN, 'Dipole']):
            methods.append(CCCBDB)
        if CASRN in _dipole_Muller.index and not np.isnan(_dipole_Muller.at[CASRN, 'Dipole']):
            methods.append(MULLER)
        if CASRN in _dipole_Poling.index and not np.isnan(_dipole_Poling.at[CASRN, 'Dipole']):
            methods.append(POLING)
        methods.append(NONE)
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]

    if Method == CCCBDB:
        _dipole = float(_dipole_CCDB.at[CASRN, 'Dipole'])
    elif Method == MULLER:
        _dipole = float(_dipole_Muller.at[CASRN, 'Dipole'])
    elif Method == POLING:
        _dipole = float(_dipole_Poling.at[CASRN, 'Dipole'])
    elif Method == NONE:
        _dipole = None
    else:
        raise Exception('Failure in in function')
    return _dipole

def
dipole_moment
(
CASRN
,
AvailableMethods
=
False
,
Method
=
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
_dipole_CCDB
.
index
and
not
np
.
isnan
(
_dipole_CCDB
.
at
[
CASRN
,
'Dipole'
]
)
:
methods
.
append
(
CCCBDB
)
if
CASRN
in
_dipole_Muller
.
index
and
not
np
.
isnan
(
_dipole_Muller
.
at
[
CASRN
,
'Dipole'
]
)
:
methods
.
append
(
MULLER
)
if
CASRN
in
_dipole_Poling
.
index
and
not
np
.
isnan
(
_dipole_Poling
.
at
[
CASRN
,
'Dipole'
]
)
:
methods
.
append
(
POLING
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
CCCBDB
:
_dipole
=
float
(
_dipole_CCDB
.
at
[
CASRN
,
'Dipole'
]
)
elif
Method
==
MULLER
:
_dipole
=
float
(
_dipole_Muller
.
at
[
CASRN
,
'Dipole'
]
)
elif
Method
==
POLING
:
_dipole
=
float
(
_dipole_Poling
.
at
[
CASRN
,
'Dipole'
]
)
elif
Method
==
:
_dipole
=
else
:
raise
Exception
(
'Failure in in function'
)
return
_dipole

r This function handles the retrieval of a chemical s dipole moment . 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 .


def Pc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[SURF]):
    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.
    '''
    def list_methods():
        methods = []
        if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, 'Pc']):
            methods.append(IUPAC)
        if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, 'Pc']):
            methods.append(MATTHEWS)
        if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, 'Pc']):
            methods.append(CRC)
        if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'Pc']):
            methods.append(PSRK)
        if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, 'Pc']):
            methods.append(PD)
        if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'Pc']):
            methods.append(YAWS)
        if CASRN:
            methods.append(SURF)
        if IgnoreMethods:
            for Method in IgnoreMethods:
                if Method in methods:
                    methods.remove(Method)
        methods.append(NONE)
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]

    if Method == IUPAC:
        _Pc = float(_crit_IUPAC.at[CASRN, 'Pc'])
    elif Method == MATTHEWS:
        _Pc = float(_crit_Matthews.at[CASRN, 'Pc'])
    elif Method == CRC:
        _Pc = float(_crit_CRC.at[CASRN, 'Pc'])
    elif Method == PSRK:
        _Pc = float(_crit_PSRKR4.at[CASRN, 'Pc'])
    elif Method == PD:
        _Pc = float(_crit_PassutDanner.at[CASRN, 'Pc'])
    elif Method == YAWS:
        _Pc = float(_crit_Yaws.at[CASRN, 'Pc'])
    elif Method == SURF:
        _Pc = third_property(CASRN=CASRN, P=True)
    elif Method == NONE:
        return None
    else:
        raise Exception('Failure in in function')
    return _Pc

def
Pc
(
CASRN
,
AvailableMethods
=
False
,
Method
=
,
IgnoreMethods
=
[
SURF
]
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
_crit_IUPAC
.
index
and
not
np
.
isnan
(
_crit_IUPAC
.
at
[
CASRN
,
'Pc'
]
)
:
methods
.
append
(
IUPAC
)
if
CASRN
in
_crit_Matthews
.
index
and
not
np
.
isnan
(
_crit_Matthews
.
at
[
CASRN
,
'Pc'
]
)
:
methods
.
append
(
MATTHEWS
)
if
CASRN
in
_crit_CRC
.
index
and
not
np
.
isnan
(
_crit_CRC
.
at
[
CASRN
,
'Pc'
]
)
:
methods
.
append
(
CRC
)
if
CASRN
in
_crit_PSRKR4
.
index
and
not
np
.
isnan
(
_crit_PSRKR4
.
at
[
CASRN
,
'Pc'
]
)
:
methods
.
append
(
PSRK
)
if
CASRN
in
_crit_PassutDanner
.
index
and
not
np
.
isnan
(
_crit_PassutDanner
.
at
[
CASRN
,
'Pc'
]
)
:
methods
.
append
(
PD
)
if
CASRN
in
_crit_Yaws
.
index
and
not
np
.
isnan
(
_crit_Yaws
.
at
[
CASRN
,
'Pc'
]
)
:
methods
.
append
(
YAWS
)
if
CASRN
:
methods
.
append
(
SURF
)
if
IgnoreMethods
:
for
Method
in
IgnoreMethods
:
if
Method
in
methods
:
methods
.
remove
(
Method
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
IUPAC
:
_Pc
=
float
(
_crit_IUPAC
.
at
[
CASRN
,
'Pc'
]
)
elif
Method
==
MATTHEWS
:
_Pc
=
float
(
_crit_Matthews
.
at
[
CASRN
,
'Pc'
]
)
elif
Method
==
CRC
:
_Pc
=
float
(
_crit_CRC
.
at
[
CASRN
,
'Pc'
]
)
elif
Method
==
PSRK
:
_Pc
=
float
(
_crit_PSRKR4
.
at
[
CASRN
,
'Pc'
]
)
elif
Method
==
PD
:
_Pc
=
float
(
_crit_PassutDanner
.
at
[
CASRN
,
'Pc'
]
)
elif
Method
==
YAWS
:
_Pc
=
float
(
_crit_Yaws
.
at
[
CASRN
,
'Pc'
]
)
elif
Method
==
SURF
:
_Pc
=
third_property
(
CASRN
=
CASRN
,
P
=
True
)
elif
Method
==
:
return
else
:
raise
Exception
(
'Failure in in function'
)
return
_Pc

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 .


def Vc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[SURF]):
    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 list_methods():
        methods = []
        if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, 'Vc']):
            methods.append(IUPAC)
        if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, 'Vc']):
            methods.append(MATTHEWS)
        if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, 'Vc']):
            methods.append(CRC)
        if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'Vc']):
            methods.append(PSRK)
        if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'Vc']):
            methods.append(YAWS)
        if CASRN:
            methods.append(SURF)
        if IgnoreMethods:
            for Method in IgnoreMethods:
                if Method in methods:
                    methods.remove(Method)
        methods.append(NONE)
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]

    if Method == IUPAC:
        _Vc = float(_crit_IUPAC.at[CASRN, 'Vc'])
    elif Method == PSRK:
        _Vc = float(_crit_PSRKR4.at[CASRN, 'Vc'])
    elif Method == MATTHEWS:
        _Vc = float(_crit_Matthews.at[CASRN, 'Vc'])
    elif Method == CRC:
        _Vc = float(_crit_CRC.at[CASRN, 'Vc'])
    elif Method == YAWS:
        _Vc = float(_crit_Yaws.at[CASRN, 'Vc'])
    elif Method == SURF:
        _Vc = third_property(CASRN=CASRN, V=True)
    elif Method == NONE:
        return None
    else:
        raise Exception('Failure in in function')
    return _Vc

def
Vc
(
CASRN
,
AvailableMethods
=
False
,
Method
=
,
IgnoreMethods
=
[
SURF
]
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
_crit_IUPAC
.
index
and
not
np
.
isnan
(
_crit_IUPAC
.
at
[
CASRN
,
'Vc'
]
)
:
methods
.
append
(
IUPAC
)
if
CASRN
in
_crit_Matthews
.
index
and
not
np
.
isnan
(
_crit_Matthews
.
at
[
CASRN
,
'Vc'
]
)
:
methods
.
append
(
MATTHEWS
)
if
CASRN
in
_crit_CRC
.
index
and
not
np
.
isnan
(
_crit_CRC
.
at
[
CASRN
,
'Vc'
]
)
:
methods
.
append
(
CRC
)
if
CASRN
in
_crit_PSRKR4
.
index
and
not
np
.
isnan
(
_crit_PSRKR4
.
at
[
CASRN
,
'Vc'
]
)
:
methods
.
append
(
PSRK
)
if
CASRN
in
_crit_Yaws
.
index
and
not
np
.
isnan
(
_crit_Yaws
.
at
[
CASRN
,
'Vc'
]
)
:
methods
.
append
(
YAWS
)
if
CASRN
:
methods
.
append
(
SURF
)
if
IgnoreMethods
:
for
Method
in
IgnoreMethods
:
if
Method
in
methods
:
methods
.
remove
(
Method
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
IUPAC
:
_Vc
=
float
(
_crit_IUPAC
.
at
[
CASRN
,
'Vc'
]
)
elif
Method
==
PSRK
:
_Vc
=
float
(
_crit_PSRKR4
.
at
[
CASRN
,
'Vc'
]
)
elif
Method
==
MATTHEWS
:
_Vc
=
float
(
_crit_Matthews
.
at
[
CASRN
,
'Vc'
]
)
elif
Method
==
CRC
:
_Vc
=
float
(
_crit_CRC
.
at
[
CASRN
,
'Vc'
]
)
elif
Method
==
YAWS
:
_Vc
=
float
(
_crit_Yaws
.
at
[
CASRN
,
'Vc'
]
)
elif
Method
==
SURF
:
_Vc
=
third_property
(
CASRN
=
CASRN
,
V
=
True
)
elif
Method
==
:
return
else
:
raise
Exception
(
'Failure in in function'
)
return
_Vc

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 .


def Zc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[COMBINED]):
    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 list_methods():
        methods = []
        if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, 'Zc']):
            methods.append(IUPAC)
        if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, 'Zc']):
            methods.append(MATTHEWS)
        if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, 'Zc']):
            methods.append(CRC)
        if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'Zc']):
            methods.append(PSRK)
        if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'Zc']):
            methods.append(YAWS)
        if Tc(CASRN) and Vc(CASRN) and Pc(CASRN):
            methods.append(COMBINED)
        if IgnoreMethods:
            for Method in IgnoreMethods:
                if Method in methods:
                    methods.remove(Method)
        methods.append(NONE)
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]
    # This is the calculate, given the method section
    if Method == IUPAC:
        _Zc = float(_crit_IUPAC.at[CASRN, 'Zc'])
    elif Method == PSRK:
        _Zc = float(_crit_PSRKR4.at[CASRN, 'Zc'])
    elif Method == MATTHEWS:
        _Zc = float(_crit_Matthews.at[CASRN, 'Zc'])
    elif Method == CRC:
        _Zc = float(_crit_CRC.at[CASRN, 'Zc'])
    elif Method == YAWS:
        _Zc = float(_crit_Yaws.at[CASRN, 'Zc'])
    elif Method == COMBINED:
        _Zc = Vc(CASRN)*Pc(CASRN)/Tc(CASRN)/R
    elif Method == NONE:
        return None
    else:
        raise Exception('Failure in in function')
    return _Zc

def
Zc
(
CASRN
,
AvailableMethods
=
False
,
Method
=
,
IgnoreMethods
=
[
COMBINED
]
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
_crit_IUPAC
.
index
and
not
np
.
isnan
(
_crit_IUPAC
.
at
[
CASRN
,
'Zc'
]
)
:
methods
.
append
(
IUPAC
)
if
CASRN
in
_crit_Matthews
.
index
and
not
np
.
isnan
(
_crit_Matthews
.
at
[
CASRN
,
'Zc'
]
)
:
methods
.
append
(
MATTHEWS
)
if
CASRN
in
_crit_CRC
.
index
and
not
np
.
isnan
(
_crit_CRC
.
at
[
CASRN
,
'Zc'
]
)
:
methods
.
append
(
CRC
)
if
CASRN
in
_crit_PSRKR4
.
index
and
not
np
.
isnan
(
_crit_PSRKR4
.
at
[
CASRN
,
'Zc'
]
)
:
methods
.
append
(
PSRK
)
if
CASRN
in
_crit_Yaws
.
index
and
not
np
.
isnan
(
_crit_Yaws
.
at
[
CASRN
,
'Zc'
]
)
:
methods
.
append
(
YAWS
)
if
Tc
(
CASRN
)
and
Vc
(
CASRN
)
and
Pc
(
CASRN
)
:
methods
.
append
(
COMBINED
)
if
IgnoreMethods
:
for
Method
in
IgnoreMethods
:
if
Method
in
methods
:
methods
.
remove
(
Method
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
IUPAC
:
_Zc
=
float
(
_crit_IUPAC
.
at
[
CASRN
,
'Zc'
]
)
elif
Method
==
PSRK
:
_Zc
=
float
(
_crit_PSRKR4
.
at
[
CASRN
,
'Zc'
]
)
elif
Method
==
MATTHEWS
:
_Zc
=
float
(
_crit_Matthews
.
at
[
CASRN
,
'Zc'
]
)
elif
Method
==
CRC
:
_Zc
=
float
(
_crit_CRC
.
at
[
CASRN
,
'Zc'
]
)
elif
Method
==
YAWS
:
_Zc
=
float
(
_crit_Yaws
.
at
[
CASRN
,
'Zc'
]
)
elif
Method
==
COMBINED
:
_Zc
=
Vc
(
CASRN
)
*
Pc
(
CASRN
)
/
Tc
(
CASRN
)
/
R
elif
Method
==
:
return
else
:
raise
Exception
(
'Failure in in function'
)
return
_Zc

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 .


def critical_surface(Tc=None, Pc=None, Vc=None, AvailableMethods=False,
                     Method=None):
    r'''Function for calculating a critical property of a substance from its
    other two critical properties. Calls functions Ihmels, Meissner, and
    Grigoras, each of which use a general 'Critical surface' type of equation.
    Limited accuracy is expected due to very limited theoretical backing.

    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]
    AvailableMethods : bool
        Request available methods for given parameters
    Method : string
        Request calculation uses the requested method

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

    Notes
    -----

    Examples
    --------
    Decamethyltetrasiloxane [141-62-8]

    >>> critical_surface(Tc=599.4, Pc=1.19E6, Method='IHMELS')
    0.0010927333333333334
    '''
    def list_methods():
        methods = []
        if (Tc and Pc) or (Tc and Vc) or (Pc and Vc):
            methods.append(IHMELS)
            methods.append(MEISSNER)
            methods.append(GRIGORAS)
        methods.append(NONE)
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]
    # This is the calculate, given the method section
    if Method == IHMELS:
        Third = Ihmels(Tc=Tc, Pc=Pc, Vc=Vc)
    elif Method == MEISSNER:
        Third = Meissner(Tc=Tc, Pc=Pc, Vc=Vc)
    elif Method == GRIGORAS:
        Third = Grigoras(Tc=Tc, Pc=Pc, Vc=Vc)
    elif Method == NONE:
        Third = None
    else:
        raise Exception('Failure in in function')
    return Third

def
critical_surface
(
Tc
=
,
Pc
=
,
Vc
=
,
AvailableMethods
=
False
,
Method
=
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
(
Tc
and
Pc
)
or
(
Tc
and
Vc
)
or
(
Pc
and
Vc
)
:
methods
.
append
(
IHMELS
)
methods
.
append
(
MEISSNER
)
methods
.
append
(
GRIGORAS
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
IHMELS
:
Third
=
Ihmels
(
Tc
=
Tc
,
Pc
=
Pc
,
Vc
=
Vc
)
elif
Method
==
MEISSNER
:
Third
=
Meissner
(
Tc
=
Tc
,
Pc
=
Pc
,
Vc
=
Vc
)
elif
Method
==
GRIGORAS
:
Third
=
Grigoras
(
Tc
=
Tc
,
Pc
=
Pc
,
Vc
=
Vc
)
elif
Method
==
:
Third
=
else
:
raise
Exception
(
'Failure in in function'
)
return
Third

r Function for calculating a critical property of a substance from its other two critical properties . Calls functions Ihmels Meissner and Grigoras each of which use a general Critical surface type of equation . Limited accuracy is expected due to very limited theoretical backing .


def third_property(CASRN=None, T=False, P=False, V=False):
    r'''Function for calculating a critical property of a substance from its
    other two critical properties, but retrieving the actual other critical
    values for convenient calculation.
    Calls functions Ihmels, Meissner, and
    Grigoras, each of which use a general 'Critical surface' type of equation.
    Limited accuracy is expected due to very limited theoretical backing.

    Parameters
    ----------
    CASRN : string
        The CAS number of the desired chemical
    T : bool
        Estimate critical temperature
    P : bool
        Estimate critical pressure
    V : bool
        Estimate critical volume

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

    Notes
    -----
    Avoids recursion only by eliminating the None and critical surface options
    for calculating each critical property. So long as it never calls itself.
    Note that when used by Tc, Pc or Vc, this function results in said function
    calling the other functions (to determine methods) and (with method specified)

    Examples
    --------
    >>> # Decamethyltetrasiloxane [141-62-8]
    >>> third_property('141-62-8', V=True)
    0.0010920041152263375

    >>> # Succinic acid 110-15-6
    >>> third_property('110-15-6', P=True)
    6095016.233766234
    '''
    Third = None
    if V:
        Tc_methods = Tc(CASRN, AvailableMethods=True)[0:-2]
        Pc_methods = Pc(CASRN, AvailableMethods=True)[0:-2]
        if Tc_methods and Pc_methods:
            _Tc = Tc(CASRN=CASRN, Method=Tc_methods[0])
            _Pc = Pc(CASRN=CASRN, Method=Pc_methods[0])
            Third = critical_surface(Tc=_Tc, Pc=_Pc, Vc=None)
    elif P:
        Tc_methods = Tc(CASRN, AvailableMethods=True)[0:-2]
        Vc_methods = Vc(CASRN, AvailableMethods=True)[0:-2]
        if Tc_methods and Vc_methods:
            _Tc = Tc(CASRN=CASRN, Method=Tc_methods[0])
            _Vc = Vc(CASRN=CASRN, Method=Vc_methods[0])
            Third = critical_surface(Tc=_Tc, Vc=_Vc, Pc=None)
    elif T:
        Pc_methods = Pc(CASRN, AvailableMethods=True)[0:-2]
        Vc_methods = Vc(CASRN, AvailableMethods=True)[0:-2]
        if Pc_methods and Vc_methods:
            _Pc = Pc(CASRN=CASRN, Method=Pc_methods[0])
            _Vc = Vc(CASRN=CASRN, Method=Vc_methods[0])
            Third = critical_surface(Pc=_Pc, Vc=_Vc, Tc=None)
    else:
        raise Exception('Error in function')
    if not Third:
        return None
    return Third

def
third_property
(
CASRN
=
,
T
=
False
,
P
=
False
,
V
=
False
)
:
r
Third
=
if
V
:
Tc_methods
=
Tc
(
CASRN
,
AvailableMethods
=
True
)
[
0
:
2
]
Pc_methods
=
Pc
(
CASRN
,
AvailableMethods
=
True
)
[
0
:
2
]
if
Tc_methods
and
Pc_methods
:
_Tc
=
Tc
(
CASRN
=
CASRN
,
Method
=
Tc_methods
[
0
]
)
_Pc
=
Pc
(
CASRN
=
CASRN
,
Method
=
Pc_methods
[
0
]
)
Third
=
critical_surface
(
Tc
=
_Tc
,
Pc
=
_Pc
,
Vc
=
)
elif
P
:
Tc_methods
=
Tc
(
CASRN
,
AvailableMethods
=
True
)
[
0
:
2
]
Vc_methods
=
Vc
(
CASRN
,
AvailableMethods
=
True
)
[
0
:
2
]
if
Tc_methods
and
Vc_methods
:
_Tc
=
Tc
(
CASRN
=
CASRN
,
Method
=
Tc_methods
[
0
]
)
_Vc
=
Vc
(
CASRN
=
CASRN
,
Method
=
Vc_methods
[
0
]
)
Third
=
critical_surface
(
Tc
=
_Tc
,
Vc
=
_Vc
,
Pc
=
)
elif
T
:
Pc_methods
=
Pc
(
CASRN
,
AvailableMethods
=
True
)
[
0
:
2
]
Vc_methods
=
Vc
(
CASRN
,
AvailableMethods
=
True
)
[
0
:
2
]
if
Pc_methods
and
Vc_methods
:
_Pc
=
Pc
(
CASRN
=
CASRN
,
Method
=
Pc_methods
[
0
]
)
_Vc
=
Vc
(
CASRN
=
CASRN
,
Method
=
Vc_methods
[
0
]
)
Third
=
critical_surface
(
Pc
=
_Pc
,
Vc
=
_Vc
,
Tc
=
)
else
:
raise
Exception
(
'Error in function'
)
if
not
Third
:
return
return
Third

r Function for calculating a critical property of a substance from its other two critical properties but retrieving the actual other critical values for convenient calculation . Calls functions Ihmels Meissner and Grigoras each of which use a general Critical surface type of equation . Limited accuracy is expected due to very limited theoretical backing .


def checkCAS(CASRN):
    '''Checks if a CAS number is valid. Returns False if the parser cannot
    parse the given string..

    Parameters
    ----------
    CASRN : string
        A three-piece, dash-separated set of numbers

    Returns
    -------
    result : bool
        Boolean value if CASRN was valid. If parsing fails, return False also.

    Notes
    -----
    Check method is according to Chemical Abstract Society. However, no lookup
    to their service is performed; therefore, this function cannot detect
    false positives.

    Function also does not support additional separators, apart from '-'.

    CAS numbers up to the series 1 XXX XXX-XX-X are now being issued.

    A long can hold CAS numbers up to 2 147 483-64-7

    Examples
    --------
    >>> checkCAS('7732-18-5')
    True
    >>> checkCAS('77332-18-5')
    False
    '''
    try:
        check = CASRN[-1]
        CASRN = CASRN[::-1][1:]
        productsum = 0
        i = 1
        for num in CASRN:
            if num == '-':
                pass
            else:
                productsum += i*int(num)
                i += 1
        return (productsum % 10 == int(check))
    except:
        return False

def checkCAS ( CASRN ) : try : check = CASRN [ - 1 ] CASRN = CASRN [ : : - 1 ] [ 1 : ] productsum = 0 i = 1 for num in CASRN : if num == '-' : pass else : productsum += i * int ( num ) i += 1 return ( productsum % 10 == int ( check ) ) except : return False

Checks if a CAS number is valid . Returns False if the parser cannot parse the given string ..


def mixture_from_any(ID):
    '''Looks up a string which may represent a mixture in the database of
    thermo to determine the key by which the composition of that mixture can
    be obtained in the dictionary `_MixtureDict`.

    Parameters
    ----------
    ID : str
        A string or 1-element list containing the name which may represent a
        mixture.

    Returns
    -------
    key : str
        Key for access to the data on the mixture in `_MixtureDict`.

    Notes
    -----
    White space, '-', and upper case letters are removed in the search.

    Examples
    --------
    >>> mixture_from_any('R512A')
    'R512A'
    >>> mixture_from_any([u'air'])
    'Air'
    '''
    if type(ID) == list:
        if len(ID) == 1:
            ID = ID[0]
        else:
            raise Exception('If the input is a list, the list must contain only one item.')
    ID = ID.lower().strip()
    ID2 = ID.replace(' ', '')
    ID3 = ID.replace('-', '')
    for i in [ID, ID2, ID3]:
        if i in _MixtureDictLookup:
            return _MixtureDictLookup[i]
    raise Exception('Mixture name not recognized')

Looks up a string which may represent a mixture in the database of thermo to determine the key by which the composition of that mixture can be obtained in the dictionary _MixtureDict .


def charge(self):
        '''Charge of the species as an integer. Computed as a property as most
        species do not have a charge and so storing it would be a waste of
        memory.
        '''
        try:
            return self._charge
        except AttributeError:
            self._charge = charge_from_formula(self.formula)
            return self._charge

def charge ( self ) : try : return self . _charge except AttributeError : self . _charge = charge_from_formula ( self . formula ) return self . _charge

Charge of the species as an integer . Computed as a property as most species do not have a charge and so storing it would be a waste of memory .


def load_included_indentifiers(self, file_name):
        '''Loads a file with newline-separated integers representing which
        chemical should be kept in memory; ones not included are ignored.
        '''
        self.restrict_identifiers = True
        included_identifiers = set()
        with open(file_name) as f:
            [included_identifiers.add(int(line)) for line in f]
        self.included_identifiers = included_identifiers

def load_included_indentifiers ( self , file_name ) : self . restrict_identifiers = True included_identifiers = set ( ) with open ( file_name ) as f : [ included_identifiers . add ( int ( line ) ) for line in f ] self . included_identifiers = included_identifiers

Loads a file with newline - separated integers representing which chemical should be kept in memory ; ones not included are ignored .


def CoolProp_T_dependent_property(T, CASRN, prop, phase):
    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 has_CoolProp:  # pragma: no cover
        raise Exception('CoolProp library is not installed')
    if CASRN not in coolprop_dict:
        raise Exception('CASRN not in list of supported fluids')
    Tc = coolprop_fluids[CASRN].Tc
    T = float(T) # Do not allow custom objects here
    if phase == 'l':
        if T > Tc:
            raise Exception('For liquid properties, must be under the critical temperature.')
        if PhaseSI('T', T, 'P', 101325, CASRN) in [u'liquid', u'supercritical_liquid']:
            return PropsSI(prop, 'T', T, 'P', 101325, CASRN)
        else:
            return PropsSI(prop, 'T', T, 'Q', 0, CASRN)
    elif phase == 'g':
        if PhaseSI('T', T, 'P', 101325, CASRN) == 'gas':
            return PropsSI(prop, 'T', T, 'P', 101325, CASRN)
        else:
            if T < Tc:
                return PropsSI(prop, 'T', T, 'Q', 1, CASRN)
            else:
                # catch supercritical_gas and friends
                return PropsSI(prop, 'T', T, 'P', 101325, CASRN)
    else:
        raise Exception('Error in CoolProp property function')

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 .


def Stockmayer(Tm=None, Tb=None, Tc=None, Zc=None, omega=None,
               CASRN='', AvailableMethods=False, Method=None):
    r'''This function handles the retrieval or calculation a chemical's
    Stockmayer parameter. Values are available from one source with lookup
    based on CASRNs, or can be estimated from 7 CSP methods.
    Will automatically select a data source to use if no Method is provided;
    returns None if the data is not available.

    Prefered sources are 'Magalhães, Lito, Da Silva, and Silva (2013)' for
    common chemicals which had valies listed in that source, and the CSP method
    `Tee, Gotoh, and Stewart CSP with Tc, omega (1966)` for chemicals which
    don't.

    Examples
    --------
    >>> Stockmayer(CASRN='64-17-5')
    1291.41

    Parameters
    ----------
    Tm : float, optional
        Melting temperature of fluid [K]
    Tb : float, optional
        Boiling temperature of fluid [K]
    Tc : float, optional
        Critical temperature, [K]
    Zc : float, optional
        Critical compressibility, [-]
    omega : float, optional
        Acentric factor of compound, [-]
    CASRN : string, optional
        CASRN [-]

    Returns
    -------
    epsilon_k : float
        Lennard-Jones depth of potential-energy minimum over k, [K]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain epsilon with the given
        inputs

    Other Parameters
    ----------------
    Method : string, optional
        A string for the method name to use, as defined by constants in
        Stockmayer_methods
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        epsilon for the desired chemical, and will return methods instead of
        epsilon

    Notes
    -----
    These values are somewhat rough, as they attempt to pigeonhole a chemical
    into L-J behavior.

    The tabulated data is from [2]_, for 322 chemicals.

    References
    ----------
    .. [1] Bird, R. Byron, Warren E. Stewart, and Edwin N. Lightfoot.
       Transport Phenomena, Revised 2nd Edition. New York:
       John Wiley & Sons, Inc., 2006
    .. [2] Magalhães, Ana L., Patrícia F. Lito, Francisco A. Da Silva, and
       Carlos M. Silva. "Simple and Accurate Correlations for Diffusion
       Coefficients of Solutes in Liquids and Supercritical Fluids over Wide
       Ranges of Temperature and Density." The Journal of Supercritical Fluids
       76 (April 2013): 94-114. doi:10.1016/j.supflu.2013.02.002.
    '''
    def list_methods():
        methods = []
        if CASRN in MagalhaesLJ_data.index:
            methods.append(MAGALHAES)
        if Tc and omega:
            methods.append(TEEGOTOSTEWARD2)
        if Tc:
            methods.append(FLYNN)
            methods.append(BSLC)
            methods.append(TEEGOTOSTEWARD1)
        if Tb:
            methods.append(BSLB)
        if Tm:
            methods.append(BSLM)
        if Tc and Zc:
            methods.append(STIELTHODOS)
        methods.append(NONE)
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]

    if Method == FLYNN:
        epsilon = epsilon_Flynn(Tc)
    elif Method == BSLC:
        epsilon = epsilon_Bird_Stewart_Lightfoot_critical(Tc)
    elif Method == BSLB:
        epsilon = epsilon_Bird_Stewart_Lightfoot_boiling(Tb)
    elif Method == BSLM:
        epsilon = epsilon_Bird_Stewart_Lightfoot_melting(Tm)
    elif Method == STIELTHODOS:
        epsilon = epsilon_Stiel_Thodos(Tc, Zc)
    elif Method == TEEGOTOSTEWARD1:
        epsilon = epsilon_Tee_Gotoh_Steward_1(Tc)
    elif Method == TEEGOTOSTEWARD2:
        epsilon = epsilon_Tee_Gotoh_Steward_2(Tc, omega)

    elif Method == MAGALHAES:
        epsilon = float(MagalhaesLJ_data.at[CASRN, "epsilon"])
    elif Method == NONE:
        epsilon = None
    else:
        raise Exception('Failure in in function')
    return epsilon

def
Stockmayer
(
Tm
=
,
Tb
=
,
Tc
=
,
Zc
=
,
omega
=
,
CASRN
=
''
,
AvailableMethods
=
False
,
Method
=
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
MagalhaesLJ_data
.
index
:
methods
.
append
(
MAGALHAES
)
if
Tc
and
omega
:
methods
.
append
(
TEEGOTOSTEWARD2
)
if
Tc
:
methods
.
append
(
FLYNN
)
methods
.
append
(
BSLC
)
methods
.
append
(
TEEGOTOSTEWARD1
)
if
Tb
:
methods
.
append
(
BSLB
)
if
Tm
:
methods
.
append
(
BSLM
)
if
Tc
and
Zc
:
methods
.
append
(
STIELTHODOS
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
FLYNN
:
epsilon
=
epsilon_Flynn
(
Tc
)
elif
Method
==
BSLC
:
epsilon
=
epsilon_Bird_Stewart_Lightfoot_critical
(
Tc
)
elif
Method
==
BSLB
:
epsilon
=
epsilon_Bird_Stewart_Lightfoot_boiling
(
Tb
)
elif
Method
==
BSLM
:
epsilon
=
epsilon_Bird_Stewart_Lightfoot_melting
(
Tm
)
elif
Method
==
STIELTHODOS
:
epsilon
=
epsilon_Stiel_Thodos
(
Tc
,
Zc
)
elif
Method
==
TEEGOTOSTEWARD1
:
epsilon
=
epsilon_Tee_Gotoh_Steward_1
(
Tc
)
elif
Method
==
TEEGOTOSTEWARD2
:
epsilon
=
epsilon_Tee_Gotoh_Steward_2
(
Tc
,
omega
)
elif
Method
==
MAGALHAES
:
epsilon
=
float
(
MagalhaesLJ_data
.
at
[
CASRN
,
"epsilon"
]
)
elif
Method
==
:
epsilon
=
else
:
raise
Exception
(
'Failure in in function'
)
return
epsilon

r This function handles the retrieval or calculation a chemical s Stockmayer parameter . Values are available from one source with lookup based on CASRNs or can be estimated from 7 CSP methods . Will automatically select a data source to use if no Method is provided ; returns None if the data is not available .


def molecular_diameter(Tc=None, Pc=None, Vc=None, Zc=None, omega=None,
          Vm=None, Vb=None, CASRN='', AvailableMethods=False, Method=None):
    r'''This function handles the retrieval or calculation a chemical's
    L-J molecular diameter. Values are available from one source with lookup
    based on CASRNs, or can be estimated from 9 CSP methods.
    Will automatically select a data source to use if no Method is provided;
    returns None if the data is not available.

    Prefered sources are 'Magalhães, Lito, Da Silva, and Silva (2013)' for
    common chemicals which had valies listed in that source, and the CSP method
    `Tee, Gotoh, and Stewart CSP with Tc, Pc, omega (1966)` for chemicals which
    don't.

    Examples
    --------
    >>> molecular_diameter(CASRN='64-17-5')
    4.23738

    Parameters
    ----------
    Tc : float, optional
        Critical temperature, [K]
    Pc : float, optional
        Critical pressure, [Pa]
    Vc : float, optional
        Critical volume, [m^3/mol]
    Zc : float, optional
        Critical compressibility, [-]
    omega : float, optional
        Acentric factor of compound, [-]
    Vm : float, optional
        Molar volume of liquid at the melting point of the fluid [K]
    Vb : float, optional
        Molar volume of liquid at the boiling point of the fluid [K]
    CASRN : string, optional
        CASRN [-]

    Returns
    -------
    sigma : float
        Lennard-Jones molecular diameter, [Angstrom]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain epsilon with the given
        inputs

    Other Parameters
    ----------------
    Method : string, optional
        A string for the method name to use, as defined by constants in
        molecular_diameter_methods
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        sigma for the desired chemical, and will return methods instead of
        sigma

    Notes
    -----
    These values are somewhat rough, as they attempt to pigeonhole a chemical
    into L-J behavior.

    The tabulated data is from [2]_, for 322 chemicals.

    References
    ----------
    .. [1] Bird, R. Byron, Warren E. Stewart, and Edwin N. Lightfoot.
       Transport Phenomena, Revised 2nd Edition. New York:
       John Wiley & Sons, Inc., 2006
    .. [2] Magalhães, Ana L., Patrícia F. Lito, Francisco A. Da Silva, and
       Carlos M. Silva. "Simple and Accurate Correlations for Diffusion
       Coefficients of Solutes in Liquids and Supercritical Fluids over Wide
       Ranges of Temperature and Density." The Journal of Supercritical Fluids
       76 (April 2013): 94-114. doi:10.1016/j.supflu.2013.02.002.
    '''
    def list_methods():
        methods = []
        if CASRN in MagalhaesLJ_data.index:
            methods.append(MAGALHAES)
        if Tc and Pc and omega:
            methods.append(TEEGOTOSTEWARD4)
        if Tc and Pc:
            methods.append(SILVALIUMACEDO)
            methods.append(BSLC2)
            methods.append(TEEGOTOSTEWARD3)
        if Vc and Zc:
            methods.append(STIELTHODOSMD)
        if Vc:
            methods.append(FLYNN)
            methods.append(BSLC1)
        if Vb:
            methods.append(BSLB)
        if Vm:
            methods.append(BSLM)
        methods.append(NONE)
        return methods

    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]
    if Method == FLYNN:
        sigma = sigma_Flynn(Vc)
    elif Method == BSLC1:
        sigma = sigma_Bird_Stewart_Lightfoot_critical_1(Vc)
    elif Method == BSLC2:
        sigma = sigma_Bird_Stewart_Lightfoot_critical_2(Tc, Pc)
    elif Method == TEEGOTOSTEWARD3:
        sigma = sigma_Tee_Gotoh_Steward_1(Tc, Pc)
    elif Method == SILVALIUMACEDO:
        sigma = sigma_Silva_Liu_Macedo(Tc, Pc)
    elif Method == BSLB:
        sigma = sigma_Bird_Stewart_Lightfoot_boiling(Vb)
    elif Method == BSLM:
        sigma = sigma_Bird_Stewart_Lightfoot_melting(Vm)
    elif Method == STIELTHODOSMD:
        sigma = sigma_Stiel_Thodos(Vc, Zc)
    elif Method == TEEGOTOSTEWARD4:
        sigma = sigma_Tee_Gotoh_Steward_2(Tc, Pc, omega)
    elif Method == MAGALHAES:
        sigma = float(MagalhaesLJ_data.at[CASRN, "sigma"])
    elif Method == NONE:
        sigma = None
    else:
        raise Exception('Failure in in function')
    return sigma

def
molecular_diameter
(
Tc
=
,
Pc
=
,
Vc
=
,
Zc
=
,
omega
=
,
Vm
=
,
Vb
=
,
CASRN
=
''
,
AvailableMethods
=
False
,
Method
=
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
MagalhaesLJ_data
.
index
:
methods
.
append
(
MAGALHAES
)
if
Tc
and
Pc
and
omega
:
methods
.
append
(
TEEGOTOSTEWARD4
)
if
Tc
and
Pc
:
methods
.
append
(
SILVALIUMACEDO
)
methods
.
append
(
BSLC2
)
methods
.
append
(
TEEGOTOSTEWARD3
)
if
Vc
and
Zc
:
methods
.
append
(
STIELTHODOSMD
)
if
Vc
:
methods
.
append
(
FLYNN
)
methods
.
append
(
BSLC1
)
if
Vb
:
methods
.
append
(
BSLB
)
if
Vm
:
methods
.
append
(
BSLM
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
FLYNN
:
sigma
=
sigma_Flynn
(
Vc
)
elif
Method
==
BSLC1
:
sigma
=
sigma_Bird_Stewart_Lightfoot_critical_1
(
Vc
)
elif
Method
==
BSLC2
:
sigma
=
sigma_Bird_Stewart_Lightfoot_critical_2
(
Tc
,
Pc
)
elif
Method
==
TEEGOTOSTEWARD3
:
sigma
=
sigma_Tee_Gotoh_Steward_1
(
Tc
,
Pc
)
elif
Method
==
SILVALIUMACEDO
:
sigma
=
sigma_Silva_Liu_Macedo
(
Tc
,
Pc
)
elif
Method
==
BSLB
:
sigma
=
sigma_Bird_Stewart_Lightfoot_boiling
(
Vb
)
elif
Method
==
BSLM
:
sigma
=
sigma_Bird_Stewart_Lightfoot_melting
(
Vm
)
elif
Method
==
STIELTHODOSMD
:
sigma
=
sigma_Stiel_Thodos
(
Vc
,
Zc
)
elif
Method
==
TEEGOTOSTEWARD4
:
sigma
=
sigma_Tee_Gotoh_Steward_2
(
Tc
,
Pc
,
omega
)
elif
Method
==
MAGALHAES
:
sigma
=
float
(
MagalhaesLJ_data
.
at
[
CASRN
,
"sigma"
]
)
elif
Method
==
:
sigma
=
else
:
raise
Exception
(
'Failure in in function'
)
return
sigma

r This function handles the retrieval or calculation a chemical s L - J molecular diameter . Values are available from one source with lookup based on CASRNs or can be estimated from 9 CSP methods . Will automatically select a data source to use if no Method is provided ; returns None if the data is not available .


def Tstar(T, epsilon_k=None, epsilon=None):
    r'''This function calculates the parameter `Tstar` as needed in performing
    collision integral calculations.

    .. math::
        T^* = \frac{kT}{\epsilon}

    Examples
    --------
    >>> Tstar(T=318.2, epsilon_k=308.43)
    1.0316765554582887

    Parameters
    ----------
    epsilon_k : float, optional
        Lennard-Jones depth of potential-energy minimum over k, [K]
    epsilon : float, optional
        Lennard-Jones depth of potential-energy minimum [J]

    Returns
    -------
    Tstar : float
        Dimentionless temperature for calculating collision integral, [-]

    Notes
    -----
    Tabulated values are normally listed as epsilon/k. k is the Boltzman
    constant, with units of J/K.

    References
    ----------
    .. [1] Bird, R. Byron, Warren E. Stewart, and Edwin N. Lightfoot.
       Transport Phenomena, Revised 2nd Edition. New York:
       John Wiley & Sons, Inc., 2006
    '''
    if epsilon_k:
        _Tstar = T/(epsilon_k)
    elif epsilon:
        _Tstar = k*T/epsilon
    else:
        raise Exception('Either epsilon/k or epsilon must be provided')
    return _Tstar

r This function calculates the parameter Tstar as needed in performing collision integral calculations .


def Hf_g(CASRN, AvailableMethods=False, Method=None):
    r'''This function handles the retrieval of a chemical's gas heat of
    formation. 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 'Active Thermochemical Tables (g)' for high accuracy,
    and 'TRC' for less accuracy but more chemicals.
    Function has data for approximately 2000 chemicals.

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

    Returns
    -------
    _Hfg : float
        Gas phase heat of formation, [J/mol]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain Hf(g) with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        A string for the method name to use, as defined by constants in
        Hf_g_methods
    AvailableMethods : bool, optional
        If True, function will determine which methods can be used to obtain
        Hf(g) for the desired chemical, and will return methods instead of Hf(g)

    Notes
    -----
    Sources are:

        * 'ATCT_G', the Active Thermochemical Tables version 1.112.
        * 'TRC', from a 1994 compilation.

    Examples
    --------
    >>> Hf_g('67-56-1')
    -200700.0

    References
    ----------
    .. [1] Ruscic, Branko, Reinhardt E. Pinzon, Gregor von Laszewski, Deepti
       Kodeboyina, Alexander Burcat, David Leahy, David Montoy, and Albert F.
       Wagner. "Active Thermochemical Tables: Thermochemistry for the 21st
       Century." Journal of Physics: Conference Series 16, no. 1
       (January 1, 2005): 561. doi:10.1088/1742-6596/16/1/078.
    .. [2] Frenkelʹ, M. L, Texas Engineering Experiment Station, and
       Thermodynamics Research Center. Thermodynamics of Organic Compounds in
       the Gas State. College Station, Tex.: Thermodynamics Research Center,
       1994.
    '''
    def list_methods():
        methods = []
        if CASRN in ATcT_g.index:
            methods.append(ATCT_G)
        if CASRN in TRC_gas_data.index and not np.isnan(TRC_gas_data.at[CASRN, 'Hf']):
            methods.append(TRC)
        methods.append(NONE)
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]

    if Method == ATCT_G:
        _Hfg = float(ATcT_g.at[CASRN, 'Hf_298K'])
    elif Method == TRC:
        _Hfg = float(TRC_gas_data.at[CASRN, 'Hf'])
    elif Method == NONE:
        return None
    else:
        raise Exception('Failure in in function')
    return _Hfg

def
Hf_g
(
CASRN
,
AvailableMethods
=
False
,
Method
=
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
ATcT_g
.
index
:
methods
.
append
(
ATCT_G
)
if
CASRN
in
TRC_gas_data
.
index
and
not
np
.
isnan
(
TRC_gas_data
.
at
[
CASRN
,
'Hf'
]
)
:
methods
.
append
(
TRC
)
methods
.
append
(
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
ATCT_G
:
_Hfg
=
float
(
ATcT_g
.
at
[
CASRN
,
'Hf_298K'
]
)
elif
Method
==
TRC
:
_Hfg
=
float
(
TRC_gas_data
.
at
[
CASRN
,
'Hf'
]
)
elif
Method
==
:
return
else
:
raise
Exception
(
'Failure in in function'
)
return
_Hfg

r This function handles the retrieval of a chemical s gas heat of formation . 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 .


def omega(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=['LK', 'DEFINITION']):
    r'''This function handles the retrieval of a chemical's acentric factor,
    `omega`, or its calculation from correlations or directly through the
    definition of acentric factor if possible. Requires a known boiling point,
    critical temperature and pressure for use of the correlations. Requires
    accurate vapor pressure data for direct calculation.

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

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

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

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

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

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

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

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

    References
    ----------
    .. [1] Pitzer, K. S., D. Z. Lippmann, R. F. Curl, C. M. Huggins, and
       D. E. Petersen: The Volumetric and Thermodynamic Properties of Fluids.
       II. Compressibility Factor, Vapor Pressure and Entropy of Vaporization.
       J. Am. Chem. Soc., 77: 3433 (1955).
    .. [2] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and
       Jürgen Gmehling. "PSRK Group Contribution Equation of State:
       Comprehensive Revision and Extension IV, Including Critical Constants
       and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria
       227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002.
    .. [3] Passut, Charles A., and Ronald P. Danner. "Acentric Factor. A
       Valuable Correlating Parameter for the Properties of Hydrocarbons."
       Industrial & Engineering Chemistry Process Design and Development 12,
       no. 3 (July 1, 1973): 365-68. doi:10.1021/i260047a026.
    .. [4] Yaws, Carl L. Thermophysical Properties of Chemicals and
       Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
       Publishing, 2014.
    '''
    def list_methods():
        methods = []
        if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'omega']):
            methods.append('PSRK')
        if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, 'omega']):
            methods.append('PD')
        if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'omega']):
            methods.append('YAWS')
        Tcrit, Pcrit = Tc(CASRN), Pc(CASRN)
        if Tcrit and Pcrit:
            if Tb(CASRN):
                methods.append('LK')
            if VaporPressure(CASRN=CASRN).T_dependent_property(Tcrit*0.7):
                methods.append('DEFINITION')  # TODO: better integration
        if IgnoreMethods:
            for Method in IgnoreMethods:
                if Method in methods:
                    methods.remove(Method)
        methods.append('NONE')
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]
    # This is the calculate, given the method section
    if Method == 'PSRK':
        _omega = float(_crit_PSRKR4.at[CASRN, 'omega'])
    elif Method == 'PD':
        _omega = float(_crit_PassutDanner.at[CASRN, 'omega'])
    elif Method == 'YAWS':
        _omega = float(_crit_Yaws.at[CASRN, 'omega'])
    elif Method == 'LK':
        _omega = LK_omega(Tb(CASRN), Tc(CASRN), Pc(CASRN))
    elif Method == 'DEFINITION':
        P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc(CASRN)*0.7)
        _omega = -log10(P/Pc(CASRN)) - 1.0
    elif Method == 'NONE':
        _omega = None
    else:
        raise Exception('Failure in in function')
    return _omega

def
omega
(
CASRN
,
AvailableMethods
=
False
,
Method
=
,
IgnoreMethods
=
[
'LK'
,
'DEFINITION'
]
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
CASRN
in
_crit_PSRKR4
.
index
and
not
np
.
isnan
(
_crit_PSRKR4
.
at
[
CASRN
,
'omega'
]
)
:
methods
.
append
(
'PSRK'
)
if
CASRN
in
_crit_PassutDanner
.
index
and
not
np
.
isnan
(
_crit_PassutDanner
.
at
[
CASRN
,
'omega'
]
)
:
methods
.
append
(
'PD'
)
if
CASRN
in
_crit_Yaws
.
index
and
not
np
.
isnan
(
_crit_Yaws
.
at
[
CASRN
,
'omega'
]
)
:
methods
.
append
(
'YAWS'
)
Tcrit
,
Pcrit
=
Tc
(
CASRN
)
,
Pc
(
CASRN
)
if
Tcrit
and
Pcrit
:
if
Tb
(
CASRN
)
:
methods
.
append
(
'LK'
)
if
VaporPressure
(
CASRN
=
CASRN
)
.
T_dependent_property
(
Tcrit
*
0.7
)
:
methods
.
append
(
'DEFINITION'
)
if
IgnoreMethods
:
for
Method
in
IgnoreMethods
:
if
Method
in
methods
:
methods
.
remove
(
Method
)
methods
.
append
(
'NONE'
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
'PSRK'
:
_omega
=
float
(
_crit_PSRKR4
.
at
[
CASRN
,
'omega'
]
)
elif
Method
==
'PD'
:
_omega
=
float
(
_crit_PassutDanner
.
at
[
CASRN
,
'omega'
]
)
elif
Method
==
'YAWS'
:
_omega
=
float
(
_crit_Yaws
.
at
[
CASRN
,
'omega'
]
)
elif
Method
==
'LK'
:
_omega
=
LK_omega
(
Tb
(
CASRN
)
,
Tc
(
CASRN
)
,
Pc
(
CASRN
)
)
elif
Method
==
'DEFINITION'
:
P
=
VaporPressure
(
CASRN
=
CASRN
)
.
T_dependent_property
(
Tc
(
CASRN
)
*
0.7
)
_omega
=
log10
(
P
/
Pc
(
CASRN
)
)
1.0
elif
Method
==
'NONE'
:
_omega
=
else
:
raise
Exception
(
'Failure in in function'
)
return
_omega

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


def omega_mixture(omegas, zs, CASRNs=None, Method=None,
                  AvailableMethods=False):
    r'''This function handles the calculation of a mixture's acentric factor.
    Calculation is based on the omegas provided for each pure component. Will
    automatically select a method to use if no Method is provided;
    returns None if insufficient data is available.

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

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

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

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

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

    References
    ----------
    .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
       New York: McGraw-Hill Professional, 2000.
    '''
    def list_methods():
        methods = []
        if none_and_length_check([zs, omegas]):
            methods.append('SIMPLE')
        methods.append('NONE')
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]

    if Method == 'SIMPLE':
        _omega = mixing_simple(zs, omegas)
    elif Method == 'NONE':
        _omega = None
    else:
        raise Exception('Failure in in function')
    return _omega

def
omega_mixture
(
omegas
,
zs
,
CASRNs
=
,
Method
=
,
AvailableMethods
=
False
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
none_and_length_check
(
[
zs
,
omegas
]
)
:
methods
.
append
(
'SIMPLE'
)
methods
.
append
(
'NONE'
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
'SIMPLE'
:
_omega
=
mixing_simple
(
zs
,
omegas
)
elif
Method
==
'NONE'
:
_omega
=
else
:
raise
Exception
(
'Failure in in function'
)
return
_omega

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


def StielPolar(Tc=None, Pc=None, omega=None, CASRN='', Method=None,
               AvailableMethods=False):
    r'''This function handles the calculation of a chemical's Stiel Polar
    factor, directly through the definition of Stiel-polar factor if possible.
    Requires Tc, Pc, acentric factor, and a vapor pressure datum at Tr=0.6.

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

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

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

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

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

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

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

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

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

    References
    ----------
    .. [1] Halm, Roland L., and Leonard I. Stiel. "A Fourth Parameter for the
       Vapor Pressure and Entropy of Vaporization of Polar Fluids." AIChE
       Journal 13, no. 2 (1967): 351-355. doi:10.1002/aic.690130228.
    .. [2] D, Kukoljac Miloš, and Grozdanić Dušan K. "New Values of the
       Polarity Factor." Journal of the Serbian Chemical Society 65, no. 12
       (January 1, 2000). http://www.shd.org.rs/JSCS/Vol65/No12-Pdf/JSCS12-07.pdf
    '''
    def list_methods():
        methods = []
        if Tc and Pc and omega:
            methods.append('DEFINITION')
        methods.append('NONE')
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]
    if Method == 'DEFINITION':
        P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc*0.6)
        if not P:
            factor = None
        else:
            Pr = P/Pc
            factor = log10(Pr) + 1.70*omega + 1.552
    elif Method == 'NONE':
        factor = None
    else:
        raise Exception('Failure in in function')
    return factor

def
StielPolar
(
Tc
=
,
Pc
=
,
omega
=
,
CASRN
=
''
,
Method
=
,
AvailableMethods
=
False
)
:
r
def
list_methods
(
)
:
methods
=
[
]
if
Tc
and
Pc
and
omega
:
methods
.
append
(
'DEFINITION'
)
methods
.
append
(
'NONE'
)
return
methods
if
AvailableMethods
:
return
list_methods
(
)
if
not
Method
:
Method
=
list_methods
(
)
[
0
]
if
Method
==
'DEFINITION'
:
P
=
VaporPressure
(
CASRN
=
CASRN
)
.
T_dependent_property
(
Tc
*
0.6
)
if
not
P
:
factor
=
else
:
Pr
=
P
/
Pc
factor
=
log10
(
Pr
)
+
1.70
*
omega
+
1.552
elif
Method
==
'NONE'
:
factor
=
else
:
raise
Exception
(
'Failure in in function'
)
return
factor

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


def ViswanathNatarajan2(T, A, B):
    '''
    This function is known to produce values 10 times too low.
    The author's data must have an error.
    I have adjusted it to fix this.

    # DDBST has 0.0004580 as a value at this temperature
    >>> ViswanathNatarajan2(348.15, -5.9719, 1007.0)
    0.00045983686956829517
    '''
    mu = exp(A + B/T)
    mu = mu/1000.
    mu = mu*10
    return mu

def ViswanathNatarajan2 ( T , A , B ) : mu = exp ( A + B / T ) mu = mu / 1000. mu = mu * 10 return mu

This function is known to produce values 10 times too low . The author s data must have an error . I have adjusted it to fix this .


def _round_whole_even(i):
    r'''Round a number to the nearest whole number. If the number is exactly
    between two numbers, round to the even whole number. Used by
    `viscosity_index`.

    Parameters
    ----------
    i : float
        Number, [-]

    Returns
    -------
    i : int
        Rounded number, [-]

    Notes
    -----
    Should never run with inputs from a practical function, as numbers on
    computers aren't really normally exactly between two numbers.

    Examples
    --------
    _round_whole_even(116.5)
    116
    '''
    if i % .5 == 0:
        if (i + 0.5) % 2 == 0:
            i = i + 0.5
        else:
            i = i - 0.5
    else:
        i = round(i, 0)
    return int(i)

def _round_whole_even ( i ) : r if i % .5 == 0 : if ( i + 0.5 ) % 2 == 0 : i = i + 0.5 else : i = i - 0.5 else : i = round ( i , 0 ) return int ( i )

r Round a number to the nearest whole number . If the number is exactly between two numbers round to the even whole number . Used by viscosity_index .


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

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

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


def calculate_P(self, T, P, method):
        r'''Method to calculate pressure-dependent liquid viscosity at
        temperature `T` and pressure `P` with a given method.

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

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

        Returns
        -------
        mu : float
            Viscosity of the liquid at T and P, [Pa*S]
        '''
        if method == LUCAS:
            mu = self.T_dependent_property(T)
            Psat = self.Psat(T) if hasattr(self.Psat, '__call__') else self.Psat
            mu = Lucas(T, P, self.Tc, self.Pc, self.omega, Psat, mu)
        elif method == COOLPROP:
            mu = PropsSI('V', 'T', T, 'P', P, self.CASRN)
        elif method in self.tabular_data:
            mu = self.interpolate_P(T, P, method)
        return mu

def calculate_P ( self , T , P , method ) : r if method == LUCAS : mu = self . T_dependent_property ( T ) Psat = self . Psat ( T ) if hasattr ( self . Psat , '__call__' ) else self . Psat mu = Lucas ( T , P , self . Tc , self . Pc , self . omega , Psat , mu ) elif method == COOLPROP : mu = PropsSI ( 'V' , 'T' , T , 'P' , P , self . CASRN ) elif method in self . tabular_data : mu = self . interpolate_P ( T , P , method ) return mu

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


def calculate(self, T, P, zs, ws, method):
        r'''Method to calculate viscosity of a liquid mixture at
        temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
        `ws` with a given method.

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

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

        Returns
        -------
        mu : float
            Viscosity of the liquid mixture, [Pa*s]
        '''
        if method == MIXING_LOG_MOLAR:
            mus = [i(T, P) for i in self.ViscosityLiquids]
            return mixing_logarithmic(zs, mus)
        elif method == MIXING_LOG_MASS:
            mus = [i(T, P) for i in self.ViscosityLiquids]
            return mixing_logarithmic(ws, mus)
        elif method == LALIBERTE_MU:
            ws = list(ws) ; ws.pop(self.index_w)
            return Laliberte_viscosity(T, ws, self.wCASs)
        else:
            raise Exception('Method not valid')

def
calculate
(
self
,
T
,
P
,
zs
,
ws
,
method
)
:
r
if
method
==
MIXING_LOG_MOLAR
:
mus
=
[
i
(
T
,
P
)
for
i
in
self
.
ViscosityLiquids
]
return
mixing_logarithmic
(
zs
,
mus
)
elif
method
==
MIXING_LOG_MASS
:
mus
=
[
i
(
T
,
P
)
for
i
in
self
.
ViscosityLiquids
]
return
mixing_logarithmic
(
ws
,
mus
)
elif
method
==
LALIBERTE_MU
:
ws
=
list
(
ws
)
ws
.
pop
(
self
.
index_w
)
return
Laliberte_viscosity
(
T
,
ws
,
self
.
wCASs
)
else
:
raise
Exception
(
'Method not valid'
)

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


def calculate(self, T, method):
        r'''Method to calculate low-pressure gas viscosity at
        tempearture `T` with a given method.

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

        Parameters
        ----------
        T : float
            Temperature of the gas, [K]
        method : str
            Name of the method to use

        Returns
        -------
        mu : float
            Viscosity of the gas at T and a low pressure, [Pa*S]
        '''
        if method == GHARAGHEIZI:
            mu = Gharagheizi_gas_viscosity(T, self.Tc, self.Pc, self.MW)
        elif method == COOLPROP:
            mu = CoolProp_T_dependent_property(T, self.CASRN, 'V', 'g')
        elif method == DIPPR_PERRY_8E:
            mu = EQ102(T, *self.Perrys2_312_coeffs)
        elif method == VDI_PPDS:
            mu =  horner(self.VDI_PPDS_coeffs, T)
        elif method == YOON_THODOS:
            mu = Yoon_Thodos(T, self.Tc, self.Pc, self.MW)
        elif method == STIEL_THODOS:
            mu = Stiel_Thodos(T, self.Tc, self.Pc, self.MW)
        elif method == LUCAS_GAS:
            mu = lucas_gas(T, self.Tc, self.Pc, self.Zc, self.MW, self.dipole, CASRN=self.CASRN)
        elif method in self.tabular_data:
            mu = self.interpolate(T, method)
        return mu

def calculate ( self , T , method ) : r if method == GHARAGHEIZI : mu = Gharagheizi_gas_viscosity ( T , self . Tc , self . Pc , self . MW ) elif method == COOLPROP : mu = CoolProp_T_dependent_property ( T , self . CASRN , 'V' , 'g' ) elif method == DIPPR_PERRY_8E : mu = EQ102 ( T , * self . Perrys2_312_coeffs ) elif method == VDI_PPDS : mu = horner ( self . VDI_PPDS_coeffs , T ) elif method == YOON_THODOS : mu = Yoon_Thodos ( T , self . Tc , self . Pc , self . MW ) elif method == STIEL_THODOS : mu = Stiel_Thodos ( T , self . Tc , self . Pc , self . MW ) elif method == LUCAS_GAS : mu = lucas_gas ( T , self . Tc , self . Pc , self . Zc , self . MW , self . dipole , CASRN = self . CASRN ) elif method in self . tabular_data : mu = self . interpolate ( T , method ) return mu

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


def calculate_P(self, T, P, method):
        r'''Method to calculate pressure-dependent gas viscosity
        at temperature `T` and pressure `P` with a given method.

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

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

        Returns
        -------
        mu : float
            Viscosity of the gas at T and P, [Pa*]
        '''
        if method == COOLPROP:
            mu = PropsSI('V', 'T', T, 'P', P, self.CASRN)
        elif method in self.tabular_data:
            mu = self.interpolate_P(T, P, method)
        return mu

def calculate_P ( self , T , P , method ) : r if method == COOLPROP : mu = PropsSI ( 'V' , 'T' , T , 'P' , P , self . CASRN ) elif method in self . tabular_data : mu = self . interpolate_P ( T , P , method ) return mu

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


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

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

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

        Returns
        -------
        mu : float
            Viscosity of gas mixture, [Pa*s]
        '''
        if method == SIMPLE:
            mus = [i(T, P) for i in self.ViscosityGases]
            return mixing_simple(zs, mus)
        elif method == HERNING_ZIPPERER:
            mus = [i(T, P) for i in self.ViscosityGases]
            return Herning_Zipperer(zs, mus, self.MWs)
        elif method == WILKE:
            mus = [i(T, P) for i in self.ViscosityGases]
            return Wilke(zs, mus, self.MWs)
        elif method == BROKAW:
            mus = [i(T, P) for i in self.ViscosityGases]
            return Brokaw(T, zs, mus, self.MWs, self.molecular_diameters, self.Stockmayers)
        else:
            raise Exception('Method not valid')

def
calculate
(
self
,
T
,
P
,
zs
,
ws
,
method
)
:
r
if
method
==
SIMPLE
:
mus
=
[
i
(
T
,
P
)
for
i
in
self
.
ViscosityGases
]
return
mixing_simple
(
zs
,
mus
)
elif
method
==
HERNING_ZIPPERER
:
mus
=
[
i
(
T
,
P
)
for
i
in
self
.
ViscosityGases
]
return
Herning_Zipperer
(
zs
,
mus
,
self
.
MWs
)
elif
method
==
WILKE
:
mus
=
[
i
(
T
,
P
)
for
i
in
self
.
ViscosityGases
]
return
Wilke
(
zs
,
mus
,
self
.
MWs
)
elif
method
==
BROKAW
:
mus
=
[
i
(
T
,
P
)
for
i
in
self
.
ViscosityGases
]
return
Brokaw
(
T
,
zs
,
mus
,
self
.
MWs
,
self
.
molecular_diameters
,
self
.
Stockmayers
)
else
:
raise
Exception
(
'Method not valid'
)

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