kdnodes = self.__get_nodes()<EOL>level = kdnodes[<NUM_LIT:0>]<EOL>for kdnode in kdnodes:<EOL><INDENT>self.__print_node(level, kdnode)<EOL><DEDENT>self.__tree_text += self.__tree_level_text<EOL>if display is True:<EOL><INDENT>print(self.__tree_text)<EOL><DEDENT>return self.__tree_text<EOL>

!
        @brief Display KD-tree to console.

        @param[in] display (bool): If 'True' then tree will be shown in console.

        @return (string) Text representation of the KD-tree.


def __init__(self, data=None, payload=None, left=None, right=None, disc=None, parent=None):

<EOL>self.data = data<EOL>self.payload = payload<EOL>self.left = left<EOL>self.right = right<EOL>self.disc = disc<EOL>self.parent = parent<EOL>

!
        @brief

        @param[in] data (list): Data point that is presented as list of coodinates.
        @param[in] payload (*): Payload of node (pointer to essense that is attached to this node).
        @param[in] left (node): Node of KD-Tree that is represented left successor.
        @param[in] right (node): Node of KD-Tree that is represented right successor.
        @param[in] disc (uint): Index of dimension of that node.
        @param[in] parent (node): Node of KD-Tree that is represented parent.


left = None<EOL>right = None<EOL>if self.left is not None:<EOL><INDENT>left = self.left.data<EOL><DEDENT>if self.right is not None:<EOL><INDENT>right = self.right.data<EOL><DEDENT>return "<STR_LIT>" % (self.data, left, right)<EOL>

!
        @return (string) Default representation of the node.


return self.__repr__()<EOL>

!
        @return (string) String representation of the node.


def __init__(self, data_list = None, payload_list = None):

self.__root = None<EOL>self.__dimension = None<EOL>self.__point_comparator = None<EOL>self.__fill_tree(data_list, payload_list)<EOL>

!
        @brief Create kd-tree from list of points and from according list of payloads.
        @details If lists were not specified then empty kd-tree will be created.

        @param[in] data_list (list): Insert points from the list to created KD tree.
        @param[in] payload_list (list): Insert payload from the list to created KD tree, length should be equal to length of data_list if it is specified.


if self.__root is None:<EOL><INDENT>self.__dimension = len(point)<EOL>self.__root = node(point, payload, None, None, <NUM_LIT:0>)<EOL>self.__point_comparator = self.__create_point_comparator(type(point))<EOL>return self.__root<EOL><DEDENT>cur_node = self.__root<EOL>while True:<EOL><INDENT>if cur_node.data[cur_node.disc] <= point[cur_node.disc]:<EOL><INDENT>if cur_node.right is None:<EOL><INDENT>discriminator = cur_node.disc + <NUM_LIT:1><EOL>if discriminator >= self.__dimension:<EOL><INDENT>discriminator = <NUM_LIT:0><EOL><DEDENT>cur_node.right = node(point, payload, None, None, discriminator, cur_node)<EOL>return cur_node.right<EOL><DEDENT>else: <EOL><INDENT>cur_node = cur_node.right<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if cur_node.left is None:<EOL><INDENT>discriminator = cur_node.disc + <NUM_LIT:1><EOL>if discriminator >= self.__dimension:<EOL><INDENT>discriminator = <NUM_LIT:0><EOL><DEDENT>cur_node.left = node(point, payload, None, None, discriminator, cur_node)<EOL>return cur_node.left<EOL><DEDENT>else:<EOL><INDENT>cur_node = cur_node.left<EOL><DEDENT><DEDENT><DEDENT>

!
        @brief Insert new point with payload to kd-tree.

        @param[in] point (list): Coordinates of the point of inserted node.
        @param[in] payload (any-type): Payload of inserted node. It can be identificator of the node or
                    some useful payload that belongs to the point.

        @return (node) Inserted node to the kd-tree.


<EOL>node_for_remove = None<EOL>if '<STR_LIT>' in kwargs:<EOL><INDENT>node_for_remove = self.find_node_with_payload(point, kwargs['<STR_LIT>'], None)<EOL><DEDENT>else:<EOL><INDENT>node_for_remove = self.find_node(point, None)<EOL><DEDENT>if node_for_remove is None:<EOL><INDENT>return None<EOL><DEDENT>parent = node_for_remove.parent<EOL>minimal_node = self.__recursive_remove(node_for_remove)<EOL>if parent is None:<EOL><INDENT>self.__root = minimal_node<EOL>if minimal_node is not None:<EOL><INDENT>minimal_node.parent = None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if parent.left is node_for_remove:<EOL><INDENT>parent.left = minimal_node<EOL><DEDENT>elif parent.right is node_for_remove:<EOL><INDENT>parent.right = minimal_node<EOL><DEDENT><DEDENT>return self.__root<EOL>

!
        @brief Remove specified point from kd-tree.
        @details It removes the first found node that satisfy to the input parameters. Make sure that
                  pair (point, payload) is unique for each node, othewise the first found is removed.

        @param[in] point (list): Coordinates of the point of removed node.
        @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'payload').

        Keyword Args:

            - payload (any): Payload of the node that should be removed.

        @return (node) Root if node has been successfully removed, otherwise None.


<EOL>if (node_removed.right is None) and (node_removed.left is None):<EOL><INDENT>return None<EOL><DEDENT>discriminator = node_removed.disc<EOL>if node_removed.right is None:<EOL><INDENT>node_removed.right = node_removed.left<EOL>node_removed.left = None<EOL><DEDENT>minimal_node = self.find_minimal_node(node_removed.right, discriminator)<EOL>parent = minimal_node.parent<EOL>if parent.left is minimal_node:<EOL><INDENT>parent.left = self.__recursive_remove(minimal_node)<EOL><DEDENT>elif parent.right is minimal_node:<EOL><INDENT>parent.right = self.__recursive_remove(minimal_node)<EOL><DEDENT>minimal_node.parent = node_removed.parent<EOL>minimal_node.disc = node_removed.disc<EOL>minimal_node.right = node_removed.right<EOL>minimal_node.left = node_removed.left<EOL>if minimal_node.right is not None:<EOL><INDENT>minimal_node.right.parent = minimal_node<EOL><DEDENT>if minimal_node.left is not None:<EOL><INDENT>minimal_node.left.parent = minimal_node<EOL><DEDENT>return minimal_node<EOL>

!
        @brief Delete node and return root of subtree.

        @param[in] node_removed (node): Node that should be removed.

        @return (node) Minimal node in line with coordinate that is defined by descriminator.


def find_minimal_node(self, node_head, discriminator):

min_key = lambda cur_node: cur_node.data[discriminator]<EOL>stack = []<EOL>candidates = []<EOL>isFinished = False<EOL>while isFinished is False:<EOL><INDENT>if node_head is not None:<EOL><INDENT>stack.append(node_head)<EOL>node_head = node_head.left<EOL><DEDENT>else:<EOL><INDENT>if len(stack) != <NUM_LIT:0>:<EOL><INDENT>node_head = stack.pop()<EOL>candidates.append(node_head)<EOL>node_head = node_head.right<EOL><DEDENT>else:<EOL><INDENT>isFinished = True<EOL><DEDENT><DEDENT><DEDENT>return min(candidates, key = min_key)<EOL>

!
        @brief Find minimal node in line with coordinate that is defined by discriminator.

        @param[in] node_head (node): Node of KD tree from that search should be started.
        @param[in] discriminator (uint): Coordinate number that is used for comparison.

        @return (node) Minimal node in line with descriminator from the specified node.


def __fill_tree(self, data_list, payload_list):

if data_list is None or len(data_list) == <NUM_LIT:0>:<EOL><INDENT>return <EOL><DEDENT>if payload_list is None:<EOL><INDENT>for index in range(<NUM_LIT:0>, len(data_list)):<EOL><INDENT>self.insert(data_list[index], None)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for index in range(<NUM_LIT:0>, len(data_list)):<EOL><INDENT>self.insert(data_list[index], payload_list[index])<EOL><DEDENT><DEDENT>self.__point_comparator = self.__create_point_comparator(type(self.__root.data))<EOL>

!
        @brief Fill KD-tree by specified data and create point comparator in line with data type.

        @param[in] data_list (array_like): Data points that should be inserted to the tree.
        @param[in] payload_list (array_like): Data point payloads that follows data points inserted to the tree.


if type_point == numpy.ndarray:<EOL><INDENT>return lambda obj1, obj2: numpy.array_equal(obj1, obj2)<EOL><DEDENT>return lambda obj1, obj2: obj1 == obj2<EOL>

!
        @brief Create point comparator.
        @details In case of numpy.array specific comparator is required.

        @param[in] type_point (data_type): Type of point that is stored in KD-node.

        @return (callable) Callable point comparator to compare to points.


def __find_node_by_rule(self, point, search_rule, cur_node):

req_node = None<EOL>if cur_node is None:<EOL><INDENT>cur_node = self.__root<EOL><DEDENT>while cur_node:<EOL><INDENT>if cur_node.data[cur_node.disc] <= point[cur_node.disc]:<EOL><INDENT>if search_rule(cur_node):<EOL><INDENT>req_node = cur_node<EOL>break<EOL><DEDENT>cur_node = cur_node.right<EOL><DEDENT>else:<EOL><INDENT>cur_node = cur_node.left<EOL><DEDENT><DEDENT>return req_node<EOL>

!
        @brief Search node that satisfy to parameters in search rule.
        @details If node with specified parameters does not exist then None will be returned,
                  otherwise required node will be returned.

        @param[in] point (list): Coordinates of the point whose node should be found.
        @param[in] search_rule (lambda): Rule that is called to check whether node satisfies to search parameter.
        @param[in] cur_node (node): Node from which search should be started.

        @return (node) Node if it satisfies to input parameters, otherwise it return None.


def find_node_with_payload(self, point, point_payload, cur_node = None):

rule_search = lambda node, point=point, payload=point_payload: self.__point_comparator(node.data, point) and node.payload == payload<EOL>return self.__find_node_by_rule(point, rule_search, cur_node)<EOL>

!
        @brief Find node with specified coordinates and payload.
        @details If node with specified parameters does not exist then None will be returned,
                  otherwise required node will be returned.

        @param[in] point (list): Coordinates of the point whose node should be found.
        @param[in] point_payload (any): Payload of the node that is searched in the tree.
        @param[in] cur_node (node): Node from which search should be started.

        @return (node) Node if it satisfies to input parameters, otherwise it return None.


def find_node(self, point, cur_node = None):

rule_search = lambda node, point=point: self.__point_comparator(node.data, point)<EOL>return self.__find_node_by_rule(point, rule_search, cur_node)<EOL>

!
        @brief Find node with coordinates that are defined by specified point.
        @details If node with specified parameters does not exist then None will be returned,
                  otherwise required node will be returned.

        @param[in] point (list): Coordinates of the point whose node should be found.
        @param[in] cur_node (node): Node from which search should be started.

        @return (node) Node if it satisfies to input parameters, otherwise it return None.


def find_nearest_dist_node(self, point, distance, retdistance = False):

best_nodes = self.find_nearest_dist_nodes(point, distance)<EOL>if best_nodes == []:<EOL><INDENT>return None<EOL><DEDENT>nearest = min(best_nodes, key = lambda item: item[<NUM_LIT:0>])<EOL>if retdistance is True:<EOL><INDENT>return nearest<EOL><DEDENT>else:<EOL><INDENT>return nearest[<NUM_LIT:1>]<EOL><DEDENT>

!
        @brief Find nearest neighbor in area with radius = distance.

        @param[in] point (list): Maximum distance where neighbors are searched.
        @param[in] distance (double): Maximum distance where neighbors are searched.
        @param[in] retdistance (bool): If True - returns neighbors with distances to them, otherwise only neighbors is returned.

        @return (node|list) Nearest neighbor if 'retdistance' is False and list with two elements [node, distance] if 'retdistance' is True,
                 where the first element is pointer to node and the second element is distance to it.


def find_nearest_dist_nodes(self, point, distance):

best_nodes = []<EOL>if self.__root is not None:<EOL><INDENT>self.__recursive_nearest_nodes(point, distance, distance * distance, self.__root, best_nodes)<EOL><DEDENT>return best_nodes<EOL>

!
        @brief Find neighbors that are located in area that is covered by specified distance.

        @param[in] point (list): Coordinates that is considered as centroind for searching.
        @param[in] distance (double): Distance from the center where seaching is performed.

        @return (list) Neighbors in area that is specified by point (center) and distance (radius).


def __recursive_nearest_nodes(self, point, distance, sqrt_distance, node_head, best_nodes):

if node_head.right is not None:<EOL><INDENT>minimum = node_head.data[node_head.disc] - distance<EOL>if point[node_head.disc] >= minimum:<EOL><INDENT>self.__recursive_nearest_nodes(point, distance, sqrt_distance, node_head.right, best_nodes)<EOL><DEDENT><DEDENT>if node_head.left is not None:<EOL><INDENT>maximum = node_head.data[node_head.disc] + distance<EOL>if point[node_head.disc] < maximum:<EOL><INDENT>self.__recursive_nearest_nodes(point, distance, sqrt_distance, node_head.left, best_nodes)<EOL><DEDENT><DEDENT>candidate_distance = euclidean_distance_square(point, node_head.data)<EOL>if candidate_distance <= sqrt_distance:<EOL><INDENT>best_nodes.append( (candidate_distance, node_head) )<EOL><DEDENT>

!
        @brief Returns list of neighbors such as tuple (distance, node) that is located in area that is covered by distance.

        @param[in] point (list): Coordinates that is considered as centroind for searching
        @param[in] distance (double): Distance from the center where seaching is performed.
        @param[in] sqrt_distance (double): Square distance from the center where searching is performed.
        @param[in] node_head (node): Node from that searching is performed.
        @param[in|out] best_nodes (list): List of founded nodes.


if node_parent.left is not None:<EOL><INDENT>yield node_parent.left<EOL><DEDENT>if node_parent.right is not None:<EOL><INDENT>yield node_parent.right<EOL><DEDENT>

!
        @brief Returns list of children of node.

        @param[in] node_parent (node): Node whose children are required.

        @return (list) Children of node. If node haven't got any child then None is returned.


def traverse(self, start_node = None, level = None):

if start_node is None:<EOL><INDENT>start_node  = self.__root<EOL>level = <NUM_LIT:0><EOL><DEDENT>if start_node is None:<EOL><INDENT>return []<EOL><DEDENT>items = [ (level, start_node) ]<EOL>for child in self.children(start_node):<EOL><INDENT>if child is not None:<EOL><INDENT>items += self.traverse(child, level + <NUM_LIT:1>)<EOL><DEDENT><DEDENT>return items<EOL>

!
        @brief Traverses all nodes of subtree that is defined by node specified in input parameter.

        @param[in] start_node (node): Node from that travering of subtree is performed.
        @param[in, out] level (uint): Should be ignored by application.

        @return (list) All nodes of the subtree.


self.__answer_path = answer_path<EOL>self.__clusters = None<EOL>self.__noise = None<EOL>

!
        @brief Creates instance of answer reader to read proper clustering results of samples.

        @param[in] answer_path (string): Path to clustering results (answers).


self.__read_answer()<EOL>return self.__clusters<EOL>

!
        @brief Read proper clustering results.

        @return (list) Clusters where each cluster is represented by list of index point from dataset.


self.__read_answer()<EOL>return self.__noise<EOL>

!
        @brief Read proper clustering results

        @return (list) Noise where each outlier is represented by index point from dataset.


clusters = self.get_clusters()<EOL>return [len(cluster) for cluster in clusters]<EOL>

!
        @brief Read proper cluster lengths.
        @details Cluster length means amount of point in a cluster.

        @return (list) Cluster lengths where each length means amount of points in a cluster.


def __read_answer_from_line(self, index_point, line):

if line[<NUM_LIT:0>] == '<STR_LIT:n>':<EOL><INDENT>self.__noise.append(index_point)<EOL><DEDENT>else:<EOL><INDENT>index_cluster = int(line)<EOL>if index_cluster >= len(self.__clusters):<EOL><INDENT>self.__clusters.append([index_point])<EOL><DEDENT>else:<EOL><INDENT>self.__clusters[index_cluster].append(index_point)<EOL><DEDENT><DEDENT>

!
        @brief Read information about point from the specific line and place it to cluster or noise in line with that
                information.

        @param[in] index_point (uint): Index point that should be placed to cluster or noise.
        @param[in] line (string): Line where information about point should be read.


if self.__clusters is not None:<EOL><INDENT>return<EOL><DEDENT>file = open(self.__answer_path, '<STR_LIT:r>')<EOL>self.__clusters, self.__noise = [], []<EOL>index_point = <NUM_LIT:0><EOL>for line in file:<EOL><INDENT>self.__read_answer_from_line(index_point, line)<EOL>index_point += <NUM_LIT:1><EOL><DEDENT>file.close()<EOL>

!
        @brief Read information about proper clusters and noises from the file.


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

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in _dipole_CCDB.index and not np.isnan(_dipole_CCDB.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(CCCBDB)<EOL><DEDENT>if CASRN in _dipole_Muller.index and not np.isnan(_dipole_Muller.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(MULLER)<EOL><DEDENT>if CASRN in _dipole_Poling.index and not np.isnan(_dipole_Poling.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(POLING)<EOL><DEDENT>methods.append(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == CCCBDB:<EOL><INDENT>_dipole = float(_dipole_CCDB.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == MULLER:<EOL><INDENT>_dipole = float(_dipole_Muller.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == POLING:<EOL><INDENT>_dipole = float(_dipole_Poling.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == NONE:<EOL><INDENT>_dipole = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _dipole<EOL>

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 Hf(CASRN, AvailableMethods=False, Method=None):

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

r'''This function handles the retrieval of a chemical's standard-phase
    heat of formation. The lookup is based on CASRNs. Selects the only
    data source available ('API TDB') if the chemical is in it.
    Returns None if the data is not available.

    Function has data for 571 chemicals.

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

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

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

    Notes
    -----
    Only one source of information is available to this function. it is:

        * 'API_TDB', a compilation of heats of formation of unspecified phase.
          Not the original data, but as reproduced in [1]_. Some chemicals with
          duplicated CAS numbers were removed.

    Examples
    --------
    >>> Hf(CASRN='7732-18-5')
    -241820.0

    References
    ----------
    .. [1] Albahri, Tareq A., and Abdulla F. Aljasmi. "SGC Method for
       Predicting the Standard Enthalpy of Formation of Pure Compounds from
       Their Molecular Structures." Thermochimica Acta 568
       (September 20, 2013): 46-60. doi:10.1016/j.tca.2013.06.020.


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

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

r'''This function handles the retrieval of a chemical's liquid standard
    phase heat of formation. The lookup is based on CASRNs. Selects the only
    data source available, Active Thermochemical Tables (l), if the chemical is
    in it. Returns None if the data is not available.

    Function has data for 34 chemicals.

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

    Returns
    -------
    Hfl : float
        Liquid standard-state heat of formation, [J/mol]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain Hf(l) with the given inputs

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

    Notes
    -----
    Only one source of information is available to this function. It is:

        * 'ATCT_L', the Active Thermochemical Tables version 1.112.

    Examples
    --------
    >>> Hf_l('67-56-1')
    -238400.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.


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

def list_methods():<EOL><INDENT>methods = []<EOL>if CASRN in ATcT_g.index:<EOL><INDENT>methods.append(ATCT_G)<EOL><DEDENT>if CASRN in TRC_gas_data.index and not np.isnan(TRC_gas_data.at[CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(TRC)<EOL><DEDENT>methods.append(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == ATCT_G:<EOL><INDENT>_Hfg = float(ATcT_g.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == TRC:<EOL><INDENT>_Hfg = float(TRC_gas_data.at[CASRN, '<STR_LIT>'])<EOL><DEDENT>elif Method == NONE:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return _Hfg<EOL>

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.


try:<EOL><INDENT>check = CASRN[-<NUM_LIT:1>]<EOL>CASRN = CASRN[::-<NUM_LIT:1>][<NUM_LIT:1>:]<EOL>productsum = <NUM_LIT:0><EOL>i = <NUM_LIT:1><EOL>for num in CASRN:<EOL><INDENT>if num == '<STR_LIT:->':<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>productsum += i*int(num)<EOL>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>return (productsum % <NUM_LIT:10> == int(check))<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>

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


ID = ID.strip()<EOL>ID_lower = ID.lower()<EOL>if ID in periodic_table:<EOL><INDENT>if periodic_table[ID].number not in homonuclear_elemental_gases:<EOL><INDENT>return periodic_table[ID].CAS<EOL><DEDENT>else:<EOL><INDENT>for i in [periodic_table.symbol_to_elements, <EOL>periodic_table.number_to_elements,<EOL>periodic_table.CAS_to_elements]:<EOL><INDENT>if i == periodic_table.number_to_elements:<EOL><INDENT>if int(ID in i):<EOL><INDENT>return periodic_table[int(ID)].CAS<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if ID in i:<EOL><INDENT>return periodic_table[ID].CAS<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if checkCAS(ID):<EOL><INDENT>CAS_lookup = pubchem_db.search_CAS(ID, autoload)<EOL>if CAS_lookup:<EOL><INDENT>return CAS_lookup.CASs<EOL><DEDENT>CAS_alternate_loopup = pubchem_db.search_name(ID, autoload)<EOL>if CAS_alternate_loopup:<EOL><INDENT>return CAS_alternate_loopup.CASs<EOL><DEDENT>if not autoload:<EOL><INDENT>return CAS_from_any(ID, autoload=True)<EOL><DEDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>ID_len = len(ID)<EOL>if ID_len > <NUM_LIT:9>:<EOL><INDENT>inchi_search = False<EOL>if ID_lower[<NUM_LIT:0>:<NUM_LIT:9>] == '<STR_LIT>':<EOL><INDENT>inchi_search = ID[<NUM_LIT:9>:]<EOL><DEDENT>elif ID_lower[<NUM_LIT:0>:<NUM_LIT:8>] == '<STR_LIT>':<EOL><INDENT>inchi_search = ID[<NUM_LIT:8>:]<EOL><DEDENT>if inchi_search:<EOL><INDENT>inchi_lookup = pubchem_db.search_InChI(inchi_search, autoload)<EOL>if inchi_lookup:<EOL><INDENT>return inchi_lookup.CASs<EOL><DEDENT>else:<EOL><INDENT>if not autoload:<EOL><INDENT>return CAS_from_any(ID, autoload=True)<EOL><DEDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>if ID_lower[<NUM_LIT:0>:<NUM_LIT:9>] == '<STR_LIT>':<EOL><INDENT>inchi_key_lookup = pubchem_db.search_InChI_key(ID[<NUM_LIT:9>:], autoload)<EOL>if inchi_key_lookup:<EOL><INDENT>return inchi_key_lookup.CASs<EOL><DEDENT>else:<EOL><INDENT>if not autoload:<EOL><INDENT>return CAS_from_any(ID, autoload=True)<EOL><DEDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>if ID_len > <NUM_LIT:8>:<EOL><INDENT>if ID_lower[<NUM_LIT:0>:<NUM_LIT:8>] == '<STR_LIT>':<EOL><INDENT>pubchem_lookup = pubchem_db.search_pubchem(ID[<NUM_LIT:8>:], autoload)<EOL>if pubchem_lookup:<EOL><INDENT>return pubchem_lookup.CASs<EOL><DEDENT>else:<EOL><INDENT>if not autoload:<EOL><INDENT>return CAS_from_any(ID, autoload=True)<EOL><DEDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>if ID_len > <NUM_LIT:7>:<EOL><INDENT>if ID_lower[<NUM_LIT:0>:<NUM_LIT:7>] == '<STR_LIT>':<EOL><INDENT>smiles_lookup = pubchem_db.search_smiles(ID[<NUM_LIT:7>:], autoload)<EOL>if smiles_lookup:<EOL><INDENT>return smiles_lookup.CASs<EOL><DEDENT>else:<EOL><INDENT>if not autoload:<EOL><INDENT>return CAS_from_any(ID, autoload=True)<EOL><DEDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>smiles_lookup = pubchem_db.search_smiles(ID, autoload)<EOL>if smiles_lookup:<EOL><INDENT>return smiles_lookup.CASs<EOL><DEDENT>try:<EOL><INDENT>formula_query = pubchem_db.search_formula(serialize_formula(ID), autoload)<EOL>if formula_query and type(formula_query) == ChemicalMetadata:<EOL><INDENT>return formula_query.CASs<EOL><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>name_lookup = pubchem_db.search_name(ID, autoload)<EOL>if name_lookup:<EOL><INDENT>return name_lookup.CASs<EOL>

Looks up the CAS number of a chemical by searching and testing for the
    string being any of the following types of chemical identifiers:

    * Name, in IUPAC form or common form or a synonym registered in PubChem
    * InChI name, prefixed by 'InChI=1S/' or 'InChI=1/'
    * InChI key, prefixed by 'InChIKey='
    * PubChem CID, prefixed by 'PubChem='
    * SMILES (prefix with 'SMILES=' to ensure smiles parsing; ex.
      'C' will return Carbon as it is an element whereas the SMILES
      interpretation for 'C' is methane)
    * CAS number (obsolete numbers may point to the current number)

    If the input is an ID representing an element, the following additional
    inputs may be specified as

    * Atomic symbol (ex 'Na')
    * Atomic number (as a string)

    Parameters
    ----------
    ID : str
        One of the name formats described above

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

    Notes
    -----
    An exception is raised if the name cannot be identified. The PubChem
    database includes a wide variety of other synonyms, but these may not be
    present for all chemcials.

    Examples
    --------
    >>> CAS_from_any('water')
    '7732-18-5'
    >>> CAS_from_any('InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3')
    '64-17-5'
    >>> CAS_from_any('CCCCCCCCCC')
    '124-18-5'
    >>> CAS_from_any('InChIKey=LFQSCWFLJHTTHZ-UHFFFAOYSA-N')
    '64-17-5'
    >>> CAS_from_any('pubchem=702')
    '64-17-5'
    >>> CAS_from_any('O') # only elements can be specified by symbol
    '17778-80-2'


return pubchem_db.search_CAS(CASRN).pubchemid<EOL>

Given a CASRN in the database, obtain the PubChem database
    number of the compound.

    Parameters
    ----------
    CASRN : string
        Valid CAS number in PubChem database [-]

    Returns
    -------
    pubchem : int
        PubChem database id, as an integer [-]

    Notes
    -----
    CASRN must be an indexing key in the pubchem database.

    Examples
    --------
    >>> PubChem('7732-18-5')
    962

    References
    ----------
    .. [1] Pubchem.


return pubchem_db.search_CAS(CASRN).MW<EOL>

Given a CASRN in the database, obtain the Molecular weight of the
    compound, if it is in the database.

    Parameters
    ----------
    CASRN : string
        Valid CAS number in PubChem database

    Returns
    -------
    MolecularWeight : float

    Notes
    -----
    CASRN must be an indexing key in the pubchem database. No MW Calculation is
    performed; nor are any historical isotopic corrections applied.

    Examples
    --------
    >>> MW('7732-18-5')
    18.01528

    References
    ----------
    .. [1] Pubchem.


return pubchem_db.search_CAS(CASRN).formula<EOL>


return pubchem_db.search_CAS(CASRN).smiles<EOL>


return pubchem_db.search_CAS(CASRN).InChI<EOL>


return pubchem_db.search_CAS(CASRN).InChI_key<EOL>


return pubchem_db.search_CAS(CASRN).iupac_name<EOL>


return pubchem_db.search_CAS(CASRN).common_name<EOL>


return pubchem_db.search_CAS(CASRN).all_names<EOL>

>>> synonyms('98-00-0')
['furan-2-ylmethanol', 'furfuryl alcohol', '2-furanmethanol', '2-furancarbinol', '2-furylmethanol', '2-furylcarbinol', '98-00-0', '2-furanylmethanol', 'furfuranol', 'furan-2-ylmethanol', '2-furfuryl alcohol', '5-hydroxymethylfuran', 'furfural alcohol', 'alpha-furylcarbinol', '2-hydroxymethylfuran', 'furfuralcohol', 'furylcarbinol', 'furyl alcohol', '2-(hydroxymethyl)furan', 'furan-2-yl-methanol', 'furfurylalcohol', 'furfurylcarb', 'methanol, (2-furyl)-', '2-furfurylalkohol', 'furan-2-methanol', '2-furane-methanol', '2-furanmethanol, homopolymer', '(2-furyl)methanol', '2-hydroxymethylfurane', 'furylcarbinol (van)', '2-furylmethan-1-ol', '25212-86-6', '93793-62-5', 'furanmethanol', 'polyfurfuryl alcohol', 'pffa', 'poly(furfurylalcohol)', 'poly-furfuryl alcohol', '(fur-2-yl)methanol', '.alpha.-furylcarbinol', '2-hydroxymethyl-furan', 'poly(furfuryl alcohol)', '.alpha.-furfuryl alcohol', 'agn-pc-04y237', 'h159', 'omega-hydroxypoly(furan-2,5-diylmethylene)', '(2-furyl)-methanol (furfurylalcohol)', '40795-25-3', '88161-36-8']


if type(ID) == list:<EOL><INDENT>if len(ID) == <NUM_LIT:1>:<EOL><INDENT>ID = ID[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>ID = ID.lower().strip()<EOL>ID2 = ID.replace('<STR_LIT:U+0020>', '<STR_LIT>')<EOL>ID3 = ID.replace('<STR_LIT:->', '<STR_LIT>')<EOL>for i in [ID, ID2, ID3]:<EOL><INDENT>if i in _MixtureDictLookup:<EOL><INDENT>return _MixtureDictLookup[i]<EOL><DEDENT><DEDENT>raise Exception('<STR_LIT>')<EOL>

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'


try:<EOL><INDENT>return self._charge<EOL><DEDENT>except AttributeError:<EOL><INDENT>self._charge = charge_from_formula(self.formula)<EOL>return self._charge<EOL><DEDENT>

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.


self.restrict_identifiers = True<EOL>included_identifiers = set()       <EOL>with open(file_name) as f:<EOL><INDENT>[included_identifiers.add(int(line)) for line in f]<EOL><DEDENT>self.included_identifiers = included_identifiers<EOL>

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


def solubility_parameter(T=<NUM_LIT>, Hvapm=None, Vml=None,<EOL>CASRN='<STR_LIT>', AvailableMethods=False, Method=None):

def list_methods():<EOL><INDENT>methods = []<EOL>if T and Hvapm and Vml:<EOL><INDENT>methods.append(DEFINITION)<EOL><DEDENT>methods.append(NONE)<EOL>return methods<EOL><DEDENT>if AvailableMethods:<EOL><INDENT>return list_methods()<EOL><DEDENT>if not Method:<EOL><INDENT>Method = list_methods()[<NUM_LIT:0>]<EOL><DEDENT>if Method == DEFINITION:<EOL><INDENT>if (not Hvapm) or (not T) or (not Vml):<EOL><INDENT>delta = None<EOL><DEDENT>else:<EOL><INDENT>if Hvapm < R*T or Vml < <NUM_LIT:0>:  <EOL><INDENT>delta = None<EOL><DEDENT>else:<EOL><INDENT>delta = ((Hvapm - R*T)/Vml)**<NUM_LIT:0.5><EOL><DEDENT><DEDENT><DEDENT>elif Method == NONE:<EOL><INDENT>delta = None<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return delta<EOL>

r'''This function handles the calculation of a chemical's solubility
    parameter. Calculation is a function of temperature, but is not always
    presented as such. No lookup values are available; either `Hvapm`, `Vml`,
    and `T` are provided or the calculation cannot be performed.

    .. math::
        \delta = \sqrt{\frac{\Delta H_{vap} - RT}{V_m}}

    Parameters
    ----------
    T : float
        Temperature of the fluid [k]
    Hvapm : float
        Heat of vaporization [J/mol/K]
    Vml : float
        Specific volume of the liquid [m^3/mol]
    CASRN : str, optional
        CASRN of the fluid, not currently used [-]

    Returns
    -------
    delta : float
        Solubility parameter, [Pa^0.5]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to obtain the solubility parameter
        with the given inputs

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

    Notes
    -----
    Undefined past the critical point. For convenience, if Hvap is not defined,
    an error is not raised; None is returned instead. Also for convenience,
    if Hvapm is less than RT, None is returned to avoid taking the root of a
    negative number.

    This parameter is often given in units of cal/ml, which is 2045.48 times
    smaller than the value returned here.

    Examples
    --------
    Pentane at STP

    >>> solubility_parameter(T=298.2, Hvapm=26403.3, Vml=0.000116055)
    14357.681538173534

    References
    ----------
    .. [1] Barton, Allan F. M. CRC Handbook of Solubility Parameters and Other
       Cohesion Parameters, Second Edition. CRC Press, 1991.


def solubility_eutectic(T, Tm, Hm, Cpl=<NUM_LIT:0>, Cps=<NUM_LIT:0>, gamma=<NUM_LIT:1>):

dCp = Cpl-Cps<EOL>x = exp(- Hm/R/T*(<NUM_LIT:1>-T/Tm) + dCp*(Tm-T)/R/T - dCp/R*log(Tm/T))/gamma<EOL>return x<EOL>

r'''Returns the maximum solubility of a solute in a solvent.

    .. math::
        \ln x_i^L \gamma_i^L = \frac{\Delta H_{m,i}}{RT}\left(
        1 - \frac{T}{T_{m,i}}\right) - \frac{\Delta C_{p,i}(T_{m,i}-T)}{RT}
        + \frac{\Delta C_{p,i}}{R}\ln\frac{T_m}{T}

        \Delta C_{p,i} = C_{p,i}^L - C_{p,i}^S

    Parameters
    ----------
    T : float
        Temperature of the system [K]
    Tm : float
        Melting temperature of the solute [K]
    Hm : float
        Heat of melting at the melting temperature of the solute [J/mol]
    Cpl : float, optional
        Molar heat capacity of the solute as a liquid [J/mol/K]
    Cpls: float, optional
        Molar heat capacity of the solute as a solid [J/mol/K]
    gamma : float, optional
        Activity coefficient of the solute as a liquid [-]

    Returns
    -------
    x : float
        Mole fraction of solute at maximum solubility [-]

    Notes
    -----
    gamma is of the solute in liquid phase

    Examples
    --------
    From [1]_, matching example

    >>> solubility_eutectic(T=260., Tm=278.68, Hm=9952., Cpl=0, Cps=0, gamma=3.0176)
    0.24340068761677464

    References
    ----------
    .. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
       Weinheim, Germany: Wiley-VCH, 2012.


def Tm_depression_eutectic(Tm, Hm, x=None, M=None, MW=None):

if x:<EOL><INDENT>dTm = R*Tm**<NUM_LIT:2>*x/Hm<EOL><DEDENT>elif M and MW:<EOL><INDENT>MW = MW/<NUM_LIT> <EOL>dTm = R*Tm**<NUM_LIT:2>*MW*M/Hm<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return dTm<EOL>

r'''Returns the freezing point depression caused by a solute in a solvent.
    Can use either the mole fraction of the solute or its molality and the
    molecular weight of the solvent. Assumes ideal system behavior.

    .. math::
        \Delta T_m = \frac{R T_m^2 x}{\Delta H_m}

        \Delta T_m = \frac{R T_m^2 (MW) M}{1000 \Delta H_m}

    Parameters
    ----------
    Tm : float
        Melting temperature of the solute [K]
    Hm : float
        Heat of melting at the melting temperature of the solute [J/mol]
    x : float, optional
        Mole fraction of the solute [-]
    M : float, optional
        Molality [mol/kg]
    MW: float, optional
        Molecular weight of the solvent [g/mol]

    Returns
    -------
    dTm : float
        Freezing point depression [K]

    Notes
    -----
    MW is the molecular weight of the solvent. M is the molality of the solute.

    Examples
    --------
    From [1]_, matching example.

    >>> Tm_depression_eutectic(353.35, 19110, .02)
    1.0864594900639515

    References
    ----------
    .. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
       Weinheim, Germany: Wiley-VCH, 2012.


H = <NUM_LIT:0><EOL>T = self.T<EOL>if self.phase == '<STR_LIT:g>':<EOL><INDENT>for i in self.cmps:<EOL><INDENT>H += self.zs[i]*self.HeatCapacityGases[i].T_dependent_property_integral(self.T_REF_IG, T)<EOL><DEDENT><DEDENT>elif self.phase == '<STR_LIT:l>':<EOL><INDENT>for i in self.cmps:<EOL><INDENT>Hg298_to_T = self.HeatCapacityGases[i].T_dependent_property_integral(self.T_REF_IG, T)<EOL>Hvap = self.EnthalpyVaporizations[i](T) <EOL>if Hvap is None:<EOL><INDENT>Hvap = <NUM_LIT:0> <EOL><DEDENT>H += self.zs[i]*(Hg298_to_T - Hvap)<EOL><DEDENT><DEDENT>elif self.phase == '<STR_LIT>':<EOL><INDENT>for i in self.cmps:<EOL><INDENT>Hg298_to_T_zi = self.zs[i]*self.HeatCapacityGases[i].T_dependent_property_integral(self.T_REF_IG, T)<EOL>Hvap = self.EnthalpyVaporizations[i](T) <EOL>if Hvap is None:<EOL><INDENT>Hvap = <NUM_LIT:0> <EOL><DEDENT>Hvap_contrib = -self.xs[i]*(<NUM_LIT:1>-self.V_over_F)*Hvap<EOL>H += (Hg298_to_T_zi + Hvap_contrib)<EOL><DEDENT><DEDENT>return H<EOL>

r'''Method to calculate the enthalpy of an ideal mixture (no pressure
        effects). This routine is based on "route A", where only the gas heat
        capacity and enthalpy of vaporization are used.

        The reference temperature is a property of the class; it defaults to
        298.15 K.

        For a pure gas mixture:

        .. math::
             H = \sum_i z_i \cdot \int_{T_{ref}}^T C_{p}^{ig}(T) dT

        For a pure liquid mixture:

        .. math::
             H = \sum_i z_i \left( \int_{T_{ref}}^T C_{p}^{ig}(T) dT + H_{vap, i}(T) \right)

        For a vapor-liquid mixture:

        .. math::
             H = \sum_i z_i \cdot \int_{T_{ref}}^T C_{p}^{ig}(T) dT
                 + \sum_i x_i\left(1 - \frac{V}{F}\right)H_{vap, i}(T)

        Returns
        -------
        H : float
            Enthalpy of the mixture with respect to the reference temperature,
            [J/mol]

        Notes
        -----
        The object must be flashed before this routine can be used. It
        depends on the properties T, zs, xs, V_over_F, HeatCapacityGases,
        EnthalpyVaporizations, and.


S = <NUM_LIT:0><EOL>T = self.T<EOL>P = self.P<EOL>S -= R*sum([zi*log(zi) for zi in self.zs if zi > <NUM_LIT:0>]) <EOL>if self.phase == '<STR_LIT:g>':<EOL><INDENT>S -= R*log(P/<NUM_LIT>) <EOL>for i in self.cmps:<EOL><INDENT>S += self.HeatCapacityGases[i].T_dependent_property_integral_over_T(<NUM_LIT>, T)<EOL><DEDENT><DEDENT>elif self.phase == '<STR_LIT:l>':<EOL><INDENT>Psats = self._Psats(T)<EOL>for i in self.cmps:<EOL><INDENT>Sg298_to_T = self.HeatCapacityGases[i].T_dependent_property_integral_over_T(<NUM_LIT>, T)<EOL>Hvap = self.EnthalpyVaporizations[i](T)<EOL>if Hvap is None:<EOL><INDENT>Hvap = <NUM_LIT:0> <EOL><DEDENT>Svap = -Hvap/T <EOL>S_P = -R*log(Psats[i]/<NUM_LIT>)<EOL>S += self.zs[i]*(Sg298_to_T + Svap + S_P)<EOL><DEDENT><DEDENT>elif self.phase == '<STR_LIT>':<EOL><INDENT>Psats = self._Psats(T)<EOL>S_P_vapor = -R*log(P/<NUM_LIT>) <EOL>for i in self.cmps:<EOL><INDENT>Sg298_to_T_zi = self.zs[i]*self.HeatCapacityGases[i].T_dependent_property_integral_over_T(<NUM_LIT>, T)<EOL>Hvap = self.EnthalpyVaporizations[i](T) <EOL>if Hvap is None:<EOL><INDENT>Hvap = <NUM_LIT:0> <EOL><DEDENT>Svap_contrib = -self.xs[i]*(<NUM_LIT:1>-self.V_over_F)*Hvap/T<EOL>S_P_vapor_i = self.V_over_F*self.ys[i]*S_P_vapor<EOL>S_P_liquid_i = -R*log(Psats[i]/<NUM_LIT>)*(<NUM_LIT:1>-self.V_over_F)*self.xs[i]<EOL>S += (Sg298_to_T_zi + Svap_contrib + S_P_vapor_i + S_P_liquid_i)<EOL><DEDENT><DEDENT>return S<EOL>

r'''Method to calculate the entropy of an ideal mixture. This routine
        is based on "route A", where only the gas heat capacity and enthalpy of
        vaporization are used.

        The reference temperature and pressure are properties of the class; it
        defaults to 298.15 K and 101325 Pa.

        There is a contribution due to mixing:

        .. math::
            \Delta S_{mixing} = -R\sum_i z_i \log(z_i)

        The ideal gas pressure contribution is:

        .. math::
            \Delta S_{P} = -R\log\left(\frac{P}{P_{ref}}\right)

        For a liquid mixture or a partially liquid mixture, the entropy
        contribution is not so strong - all such pressure effects find that
        expression capped at the vapor pressure, as shown in [1]_.

        .. math::
            \Delta S_{P} = - \sum_i x_i\left(1 - \frac{V}{F}\right)
            R\log\left(\frac{P_{sat, i}}{P_{ref}}\right) - \sum_i y_i\left(
            \frac{V}{F}\right) R\log\left(\frac{P}{P_{ref}}\right)

        These expressions are combined with the standard heat capacity and
        enthalpy of vaporization expressions to calculate the total entropy:

        For a pure gas mixture:

        .. math::
             S = \Delta S_{mixing} + \Delta S_{P} + \sum_i z_i \cdot
             \int_{T_{ref}}^T \frac{C_{p}^{ig}(T)}{T} dT

        For a pure liquid mixture:

        .. math::
             S = \Delta S_{mixing} + \Delta S_{P} + \sum_i z_i \left(
             \int_{T_{ref}}^T \frac{C_{p}^{ig}(T)}{T} dT + \frac{H_{vap, i}
             (T)}{T} \right)

        For a vapor-liquid mixture:

        .. math::
             S = \Delta S_{mixing} + \Delta S_{P} + \sum_i z_i \cdot
             \int_{T_{ref}}^T \frac{C_{p}^{ig}(T)}{T} dT + \sum_i x_i\left(1
             - \frac{V}{F}\right)\frac{H_{vap, i}(T)}{T}

        Returns
        -------
        S : float
            Entropy of the mixture with respect to the reference temperature,
            [J/mol/K]

        Notes
        -----
        The object must be flashed before this routine can be used. It
        depends on the properties T, P, zs, V_over_F, HeatCapacityGases,
        EnthalpyVaporizations, VaporPressures, and xs.

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


dipole = <NUM_LIT> <EOL>polarizability = <NUM_LIT> <EOL>MW = <NUM_LIT> <EOL>ih = [<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>, <NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:5>, <NUM_LIT:6>, <NUM_LIT:7>, <NUM_LIT:10>]<EOL>jh = [<NUM_LIT>, <NUM_LIT:1>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:5>, <NUM_LIT:0.5>, <NUM_LIT:10>]<EOL>Nh = [<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL>-<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>, <EOL>-<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <EOL>-<NUM_LIT>]<EOL>delta = rho/<NUM_LIT><EOL>tau = <NUM_LIT>/T<EOL>g = (<NUM_LIT:1> + sum([Nh[h]*delta**ih[h]*tau**jh[h] for h in range(<NUM_LIT:11>)])<EOL>+ <NUM_LIT>*delta*(T/<NUM_LIT> - <NUM_LIT:1>)**-<NUM_LIT>)<EOL>A = N_A*dipole**<NUM_LIT:2>*(rho/MW)*g/epsilon_0/k/T<EOL>B = N_A*polarizability*(rho/MW)/<NUM_LIT>/epsilon_0<EOL>epsilon = (<NUM_LIT:1.> + A + <NUM_LIT>*B + (<NUM_LIT> + <NUM_LIT>*A + <NUM_LIT>*B + A**<NUM_LIT:2> + <NUM_LIT>*A*B + <NUM_LIT>*B**<NUM_LIT:2><EOL>)**<NUM_LIT:0.5>)/(<NUM_LIT> - <NUM_LIT>*B)<EOL>return epsilon<EOL>

r'''Calculate the relative permittivity of pure water as a function of.
    temperature and density. Assumes the 1997 IAPWS [1]_ formulation.

    .. math::
        \epsilon(\rho, T) =\frac{1 + A + 5B + (9 + 2A + 18B + A^2 + 10AB +
        9B^2)^{0.5}}{4(1-B)}

        A(\rho, T) = \frac{N_A\mu^2\rho g}{M\epsilon_0 kT}

        B(\rho) = \frac{N_A\alpha\rho}{3M\epsilon_0}

        g(\delta,\tau) = 1 + \sum_{i=1}^{11}n_i\delta^{I_i}\tau^{J_i}
        + n_{12}\delta\left(\frac{647.096}{228}\tau^{-1} - 1\right)^{-1.2}

        \delta = \rho/(322 \text{ kg/m}^3)

        \tau = T/647.096\text{K}

    Parameters
    ----------
    T : float
        Temperature of water [K]
    rho : float
        Mass density of water at T and P [kg/m^3]

    Returns
    -------
    epsilon : float
        Relative permittivity of water at T and rho, [-]

    Notes
    -----
    Validity:

    273.15 < T < 323.15 K for 0 < P < iceVI melting pressure at T or 1000 MPa,
    whichever is smaller.

    323.15 < T < 873.15 K 0 < p < 600 MPa.

    Coefficients:

    ih = [1, 1, 1, 2, 3, 3, 4, 5, 6, 7, 10];
    jh = [0.25, 1, 2.5, 1.5, 1.5, 2.5, 2, 2, 5, 0.5, 10];
    Nh = [0.978224486826, -0.957771379375, 0.237511794148, 0.714692244396,
          -0.298217036956, -0.108863472196, 0.949327488264E-1,
          -.980469816509E-2, 0.165167634970E-4, 0.937359795772E-4,
          -0.12317921872E-9];
    polarizability = 1.636E-40
    dipole = 6.138E-30

    Examples
    --------
    >>> permittivity_IAPWS(373., 958.46)
    55.56584297721836

    References
    ----------
    .. [1] IAPWS. 1997. Release on the Static Dielectric Constant of Ordinary
       Water Substance for Temperatures from 238 K to 873 K and Pressures up
       to 1000 MPa.


methods = []<EOL>Tmins, Tmaxs = [], []<EOL>if self.CASRN in CRC_Permittivity_data.index:<EOL><INDENT>methods.append(CRC_CONSTANT)<EOL>_, self.CRC_CONSTANT_T, self.CRC_permittivity, A, B, C, D, Tmin, Tmax = _CRC_Permittivity_data_values[CRC_Permittivity_data.index.get_loc(self.CASRN)].tolist()<EOL>self.CRC_Tmin = Tmin<EOL>self.CRC_Tmax = Tmax<EOL>self.CRC_coeffs = [<NUM_LIT:0> if np.isnan(x) else x for x in [A, B, C, D] ]<EOL>if not np.isnan(Tmin):<EOL><INDENT>Tmins.append(Tmin); Tmaxs.append(Tmax)<EOL><DEDENT>if self.CRC_coeffs[<NUM_LIT:0>]:<EOL><INDENT>methods.append(CRC)<EOL><DEDENT><DEDENT>self.all_methods = set(methods)<EOL>if Tmins and Tmaxs:<EOL><INDENT>self.Tmin = min(Tmins)<EOL>self.Tmax = max(Tmaxs)<EOL><DEDENT>

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

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


if method == CRC:<EOL><INDENT>A, B, C, D = self.CRC_coeffs<EOL>epsilon = A + B*T + C*T**<NUM_LIT:2> + D*T**<NUM_LIT:3><EOL><DEDENT>elif method == CRC_CONSTANT:<EOL><INDENT>epsilon = self.CRC_permittivity<EOL><DEDENT>elif method in self.tabular_data:<EOL><INDENT>epsilon = self.interpolate(T, method)<EOL><DEDENT>return epsilon<EOL>

r'''Method to calculate permittivity of a liquid at temperature `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 relative permittivity, [K]
        method : str
            Name of the method to use

        Returns
        -------
        epsilon : float
            Relative permittivity of the liquid at T, [-]


try:<EOL><INDENT>d = _VDISaturationDict[CASRN]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>props, Ts = d[prop], d['<STR_LIT:T>']<EOL><DEDENT>except:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>Ts = [T for p, T in zip(props, Ts) if p]<EOL>props = [p for p in props if p]<EOL>if prop == '<STR_LIT>':<EOL><INDENT>Ts.append(d['<STR_LIT>'])<EOL>props.append(<NUM_LIT:0>)<EOL><DEDENT>return Ts, props<EOL>

r'''This function retrieves the tabular data available for a given chemical
    and a given property. Lookup is based on CASRNs. Length of data returned
    varies between chemicals. All data is at saturation condition from [1]_.

    Function has data for 58 chemicals.

    Parameters
    ----------
    CASRN : string
        CASRN [-]
    prop : string
        Property [-]

    Returns
    -------
    Ts : list
        Temperatures where property data is available, [K]
    props : list
        Properties at each temperature, [various]

    Notes
    -----
    The available properties are 'P', 'Density (l)', 'Density (g)', 'Hvap',
    'Cp (l)', 'Cp (g)', 'Mu (l)', 'Mu (g)', 'K (l)', 'K (g)', 'Pr (l)',
    'Pr (g)', 'sigma', 'Beta', 'Volume (l)', and 'Volume (g)'.

    Data is available for all properties and all chemicals; surface tension
    data was missing for mercury, but added as estimated from the a/b
    coefficients listed in Jasper (1972) to simplify the function.

    Examples
    --------
    >>> VDI_tabular_data('67-56-1', 'Mu (g)')
    ([337.63, 360.0, 385.0, 410.0, 435.0, 460.0, 500.0], [1.11e-05, 1.18e-05, 1.27e-05, 1.36e-05, 1.46e-05, 1.59e-05, 2.04e-05])

    References
    ----------
    .. [1] Gesellschaft, VDI, ed. VDI Heat Atlas. 2E. Berlin : Springer, 2010.


def Yen_Woods_saturation(T, Tc, Vc, Zc):

Tr = T/Tc<EOL>A = <NUM_LIT> - <NUM_LIT>*Zc + <NUM_LIT>*Zc**<NUM_LIT:2> - <NUM_LIT>*Zc**<NUM_LIT:3><EOL>if Zc <= <NUM_LIT>:<EOL><INDENT>B = -<NUM_LIT> + <NUM_LIT>*Zc + <NUM_LIT>*Zc**<NUM_LIT:2> - <NUM_LIT>*Zc**<NUM_LIT:3><EOL><DEDENT>else:<EOL><INDENT>B = <NUM_LIT> - <NUM_LIT>*Zc + <NUM_LIT>*Zc**<NUM_LIT:2> + <NUM_LIT>*Zc**<NUM_LIT:3><EOL><DEDENT>D = <NUM_LIT> - B<EOL>Vm = Vc/(<NUM_LIT:1> + A*(<NUM_LIT:1>-Tr)**(<NUM_LIT:1>/<NUM_LIT>) + B*(<NUM_LIT:1>-Tr)**(<NUM_LIT:2>/<NUM_LIT>) + D*(<NUM_LIT:1>-Tr)**(<NUM_LIT:4>/<NUM_LIT>))<EOL>return Vm<EOL>

r'''Calculates saturation liquid volume, using the Yen and Woods [1]_ CSP
    method and a chemical's critical properties.

    The molar volume of a liquid is given by:

    .. math::
        Vc/Vs = 1 + A(1-T_r)^{1/3} + B(1-T_r)^{2/3} + D(1-T_r)^{4/3}

        D = 0.93-B

        A = 17.4425 - 214.578Z_c + 989.625Z_c^2 - 1522.06Z_c^3

        B = -3.28257 + 13.6377Z_c + 107.4844Z_c^2-384.211Z_c^3
        \text{ if } Zc \le 0.26

        B = 60.2091 - 402.063Z_c + 501.0 Z_c^2 + 641.0 Z_c^3
        \text{ if } Zc \ge 0.26

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Vc : float
        Critical volume of fluid [m^3/mol]
    Zc : float
        Critical compressibility of fluid, [-]

    Returns
    -------
    Vs : float
        Saturation liquid volume, [m^3/mol]

    Notes
    -----
    Original equation was in terms of density, but it is converted here.

    No example has been found, nor are there points in the article. However,
    it is believed correct. For compressed liquids with the Yen-Woods method,
    see the `YenWoods_compressed` function.

    Examples
    --------
    >>> Yen_Woods_saturation(300, 647.14, 55.45E-6, 0.245)
    1.7695330765295693e-05

    References
    ----------
    .. [1] Yen, Lewis C., and S. S. Woods. "A Generalized Equation for Computer
       Calculation of Liquid Densities." AIChE Journal 12, no. 1 (1966):
       95-99. doi:10.1002/aic.690120119


return R*Tc/Pc*Zc**(<NUM_LIT:1> + (<NUM_LIT:1> - T/Tc)**(<NUM_LIT:2>/<NUM_LIT>))<EOL>

r'''Calculates saturation liquid volume, using Rackett CSP method and
    critical properties.

    The molar volume of a liquid is given by:

    .. math::
        V_s = \frac{RT_c}{P_c}{Z_c}^{[1+(1-{T/T_c})^{2/7} ]}

    Units are all currently in m^3/mol - this can be changed to kg/m^3

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    Zc : float
        Critical compressibility of fluid, [-]

    Returns
    -------
    Vs : float
        Saturation liquid volume, [m^3/mol]

    Notes
    -----
    Units are dependent on gas constant R, imported from scipy
    According to Reid et. al, underpredicts volume for compounds with Zc < 0.22

    Examples
    --------
    Propane, example from the API Handbook

    >>> Vm_to_rho(Rackett(272.03889, 369.83, 4248000.0, 0.2763), 44.09562)
    531.3223212651092

    References
    ----------
    .. [1] Rackett, Harold G. "Equation of State for Saturated Liquids."
       Journal of Chemical & Engineering Data 15, no. 4 (1970): 514-517.
       doi:10.1021/je60047a012


return R*Tc/Pc*(<NUM_LIT> - <NUM_LIT>*omega)**(<NUM_LIT:1> + (<NUM_LIT:1> - T/Tc)**(<NUM_LIT:2>/<NUM_LIT>))<EOL>

r'''Calculates saturation liquid volume, using Yamada and Gunn CSP method
    and a chemical's critical properties and acentric factor.

    The molar volume of a liquid is given by:

    .. math::
        V_s = \frac{RT_c}{P_c}{(0.29056-0.08775\omega)}^{[1+(1-{T/T_c})^{2/7}]}

    Units are in m^3/mol.

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

    Returns
    -------
    Vs : float
        saturation liquid volume, [m^3/mol]

    Notes
    -----
    This equation is an improvement on the Rackett equation.
    This is often presented as the Rackett equation.
    The acentric factor is used here, instead of the critical compressibility
    A variant using a reference fluid also exists

    Examples
    --------
    >>> Yamada_Gunn(300, 647.14, 22048320.0, 0.245)
    2.1882836429895796e-05

    References
    ----------
    .. [1] Gunn, R. D., and Tomoyoshi Yamada. "A Corresponding States
        Correlation of Saturated Liquid Volumes." AIChE Journal 17, no. 6
        (1971): 1341-45. doi:10.1002/aic.690170613
    .. [2] Yamada, Tomoyoshi, and Robert D. Gunn. "Saturated Liquid Molar
        Volumes. Rackett Equation." Journal of Chemical & Engineering Data 18,
        no. 2 (1973): 234-36. doi:10.1021/je60057a006


Tr = T/Tc<EOL>return Vc/(<NUM_LIT:1> + <NUM_LIT>*(<NUM_LIT:1>-Tr) + (<NUM_LIT> + <NUM_LIT>*omega)*(<NUM_LIT:1>-Tr)**(<NUM_LIT:1>/<NUM_LIT>))<EOL>

r'''Calculates saturation liquid density, using the Townsend and Hales
    CSP method as modified from the original Riedel equation. Uses
    chemical critical volume and temperature, as well as acentric factor

    The density of a liquid is given by:

    .. math::
        Vs = V_c/\left(1+0.85(1-T_r)+(1.692+0.986\omega)(1-T_r)^{1/3}\right)

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Vc : float
        Critical volume of fluid [m^3/mol]
    omega : float
        Acentric factor for fluid, [-]

    Returns
    -------
    Vs : float
        Saturation liquid volume, [m^3/mol]

    Notes
    -----
    The requirement for critical volume and acentric factor requires all data.

    Examples
    --------
    >>> Townsend_Hales(300, 647.14, 55.95E-6, 0.3449)
    1.8007361992619923e-05

    References
    ----------
    .. [1] Hales, J. L, and R Townsend. "Liquid Densities from 293 to 490 K of
       Nine Aromatic Hydrocarbons." The Journal of Chemical Thermodynamics
       4, no. 5 (1972): 763-72. doi:10.1016/0021-9614(72)90050-X


Tr = T/Tc<EOL>if Tr <= <NUM_LIT>:<EOL><INDENT>lnU0 = <NUM_LIT> - <NUM_LIT>*Tr + <NUM_LIT>*Tr**<NUM_LIT:2> - <NUM_LIT>*Tr**<NUM_LIT:3>+ <NUM_LIT>*Tr**<NUM_LIT:4> - <NUM_LIT>*Tr**<NUM_LIT:5> + <NUM_LIT>*Tr**<NUM_LIT:6><EOL>lnU1 = <NUM_LIT> - <NUM_LIT>*Tr + <NUM_LIT>*Tr**<NUM_LIT:2>-<NUM_LIT>*Tr**<NUM_LIT:3>+ <NUM_LIT>*Tr**<NUM_LIT:4> - <NUM_LIT>*Tr**<NUM_LIT:5> + <NUM_LIT>*Tr**<NUM_LIT:6><EOL><DEDENT>elif Tr > <NUM_LIT:1>:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>lnU0 = Bhirud_normal_lnU0_interp(Tr)<EOL>lnU1 = Bhirud_normal_lnU1_interp(Tr)<EOL><DEDENT>Unonpolar = exp(lnU0 + omega*lnU1)<EOL>Vm = Unonpolar*R*T/Pc<EOL>return Vm<EOL>

r'''Calculates saturation liquid density using the Bhirud [1]_ CSP method.
    Uses Critical temperature and pressure and acentric factor.

    The density of a liquid is given by:

    .. math::
        &\ln \frac{P_c}{\rho RT} = \ln U^{(0)} + \omega\ln U^{(1)}

        &\ln U^{(0)} = 1.396 44 - 24.076T_r+ 102.615T_r^2
        -255.719T_r^3+355.805T_r^4-256.671T_r^5 + 75.1088T_r^6

        &\ln U^{(1)} = 13.4412 - 135.7437 T_r + 533.380T_r^2-
        1091.453T_r^3+1231.43T_r^4 - 728.227T_r^5 + 176.737T_r^6

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

    Returns
    -------
    Vm : float
        Saturated liquid molar volume, [mol/m^3]

    Notes
    -----
    Claimed inadequate by others.

    An interpolation table for ln U values are used from Tr = 0.98 - 1.000.
    Has terrible behavior at low reduced temperatures.

    Examples
    --------
    Pentane

    >>> Bhirud_normal(280.0, 469.7, 33.7E5, 0.252)
    0.00011249654029488583

    References
    ----------
    .. [1] Bhirud, Vasant L. "Saturated Liquid Densities of Normal Fluids."
       AIChE Journal 24, no. 6 (November 1, 1978): 1127-31.
       doi:10.1002/aic.690240630


Tr = T/Tc<EOL>V_delta = (-<NUM_LIT> + <NUM_LIT>*Tr - <NUM_LIT>*Tr**<NUM_LIT:2><EOL>- <NUM_LIT>*Tr**<NUM_LIT:3>)/(Tr - <NUM_LIT>)<EOL>V_0 = <NUM_LIT:1> - <NUM_LIT>*(<NUM_LIT:1>-Tr)**(<NUM_LIT:1>/<NUM_LIT>) + <NUM_LIT>*(<NUM_LIT:1>-Tr)**(<NUM_LIT:2>/<NUM_LIT>)- <NUM_LIT>*(<NUM_LIT:1>-Tr) + <NUM_LIT>*(<NUM_LIT:1>-Tr)**(<NUM_LIT:4>/<NUM_LIT>)<EOL>return Vc*V_0*(<NUM_LIT:1>-omega*V_delta)<EOL>

r'''Calculate saturation liquid density using the COSTALD CSP method.

    A popular and accurate estimation method. If possible, fit parameters are
    used; alternatively critical properties work well.

    The density of a liquid is given by:

    .. math::
        V_s=V^*V^{(0)}[1-\omega_{SRK}V^{(\delta)}]

        V^{(0)}=1-1.52816(1-T_r)^{1/3}+1.43907(1-T_r)^{2/3}
        - 0.81446(1-T_r)+0.190454(1-T_r)^{4/3}

        V^{(\delta)}=\frac{-0.296123+0.386914T_r-0.0427258T_r^2-0.0480645T_r^3}
        {T_r-1.00001}

    Units are that of critical or fit constant volume.

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Vc : float
        Critical volume of fluid [m^3/mol].
        This parameter is alternatively a fit parameter
    omega : float
        (ideally SRK) Acentric factor for fluid, [-]
        This parameter is alternatively a fit parameter.

    Returns
    -------
    Vs : float
        Saturation liquid volume

    Notes
    -----
    196 constants are fit to this function in [1]_.
    Range: 0.25 < Tr < 0.95, often said to be to 1.0

    This function has been checked with the API handbook example problem.

    Examples
    --------
    Propane, from an example in the API Handbook

    >>> Vm_to_rho(COSTALD(272.03889, 369.83333, 0.20008161E-3, 0.1532), 44.097)
    530.3009967969841

    References
    ----------
    .. [1] Hankinson, Risdon W., and George H. Thomson. "A New Correlation for
       Saturated Densities of Liquids and Their Mixtures." AIChE Journal
       25, no. 4 (1979): 653-663. doi:10.1002/aic.690250412


def Campbell_Thodos(T, Tb, Tc, Pc, M, dipole=None, hydroxyl=False):

Tr = T/Tc<EOL>Tbr = Tb/Tc<EOL>Pc = Pc/<NUM_LIT><EOL>s = Tbr * log(Pc)/(<NUM_LIT:1>-Tbr)<EOL>Lambda = Pc**(<NUM_LIT:1>/<NUM_LIT>)/(M**<NUM_LIT:0.5>*Tc**(<NUM_LIT:5>/<NUM_LIT>))<EOL>alpha = <NUM_LIT> - <NUM_LIT>*s<EOL>beta = <NUM_LIT>*s - <NUM_LIT> + <NUM_LIT>*Lambda**(<NUM_LIT>)<EOL>if dipole:<EOL><INDENT>theta = Pc*dipole**<NUM_LIT:2>/Tc**<NUM_LIT:2><EOL>alpha -= <NUM_LIT> * theta**<NUM_LIT><EOL>beta += <NUM_LIT> * theta**<NUM_LIT><EOL><DEDENT>if hydroxyl:<EOL><INDENT>beta = <NUM_LIT>*s - <NUM_LIT> + <NUM_LIT>*Lambda**(<NUM_LIT>) + <NUM_LIT>*theta**<NUM_LIT><EOL>alpha = (<NUM_LIT>*Tbr - <NUM_LIT> + <NUM_LIT>/Tbr**<NUM_LIT>)*Pc**<NUM_LIT><EOL><DEDENT>Zra = alpha + beta*(<NUM_LIT:1>-Tr)<EOL>Vs = R*Tc/(Pc*<NUM_LIT>)*Zra**(<NUM_LIT:1>+(<NUM_LIT:1>-Tr)**(<NUM_LIT:2>/<NUM_LIT>))<EOL>return Vs<EOL>

r'''Calculate saturation liquid density using the Campbell-Thodos [1]_
    CSP method.

    An old and uncommon estimation method.

    .. math::
        V_s = \frac{RT_c}{P_c}{Z_{RA}}^{[1+(1-T_r)^{2/7}]}

        Z_{RA} = \alpha + \beta(1-T_r)

        \alpha = 0.3883-0.0179s

        s = T_{br} \frac{\ln P_c}{(1-T_{br})}

        \beta = 0.00318s-0.0211+0.625\Lambda^{1.35}

        \Lambda = \frac{P_c^{1/3}} { M^{1/2} T_c^{5/6}}

    For polar compounds:

    .. math::
        \theta = P_c \mu^2/T_c^2

        \alpha = 0.3883 - 0.0179s - 130540\theta^{2.41}

        \beta = 0.00318s - 0.0211 + 0.625\Lambda^{1.35} + 9.74\times
        10^6 \theta^{3.38}

    Polar Combounds with hydroxyl groups (water, alcohols)

    .. math::
        \alpha = \left[0.690T_{br} -0.3342 + \frac{5.79\times 10^{-10}}
        {T_{br}^{32.75}}\right] P_c^{0.145}

        \beta = 0.00318s - 0.0211 + 0.625 \Lambda^{1.35} + 5.90\Theta^{0.835}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tb : float
        Boiling temperature of the fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    M : float
        Molecular weight of the fluid [g/mol]
    dipole : float, optional
        Dipole moment of the fluid [debye]
    hydroxyl : bool, optional
        Swith to use the hydroxyl variant for polar fluids

    Returns
    -------
    Vs : float
        Saturation liquid volume

    Notes
    -----
    If a dipole is provided, the polar chemical method is used.
    The paper is an excellent read.
    Pc is internally converted to atm.

    Examples
    --------
    Ammonia, from [1]_.

    >>> Campbell_Thodos(T=405.45, Tb=239.82, Tc=405.45, Pc=111.7*101325, M=17.03, dipole=1.47)
    7.347363635885525e-05

    References
    ----------
    .. [1] Campbell, Scott W., and George Thodos. "Prediction of Saturated
       Liquid Densities and Critical Volumes for Polar and Nonpolar
       Substances." Journal of Chemical & Engineering Data 30, no. 1
       (January 1, 1985): 102-11. doi:10.1021/je00039a032.


def SNM0(T, Tc, Vc, omega, delta_SRK=None):

Tr = T/Tc<EOL>m = <NUM_LIT> + <NUM_LIT>*omega - <NUM_LIT>*omega*omega<EOL>alpha_SRK = (<NUM_LIT:1.> + m*(<NUM_LIT:1.> - Tr**<NUM_LIT:0.5>))**<NUM_LIT:2><EOL>tau = <NUM_LIT:1.> - Tr/alpha_SRK<EOL>rho0 = <NUM_LIT:1.> + <NUM_LIT>*tau**(<NUM_LIT:1>/<NUM_LIT>) + <NUM_LIT>*tau**(<NUM_LIT:2>/<NUM_LIT>) - <NUM_LIT>*tau + <NUM_LIT>*tau**(<NUM_LIT:4>/<NUM_LIT>)<EOL>V0 = <NUM_LIT:1.>/rho0<EOL>if not delta_SRK:<EOL><INDENT>return Vc*V0<EOL><DEDENT>else:<EOL><INDENT>return Vc*V0/(<NUM_LIT:1.> + delta_SRK*(alpha_SRK - <NUM_LIT:1.>)**(<NUM_LIT:1>/<NUM_LIT>))<EOL><DEDENT>

r'''Calculates saturated liquid density using the Mchaweh, Moshfeghian
    model [1]_. Designed for simple calculations.

    .. math::
        V_s = V_c/(1+1.169\tau^{1/3}+1.818\tau^{2/3}-2.658\tau+2.161\tau^{4/3}

        \tau = 1-\frac{(T/T_c)}{\alpha_{SRK}}

        \alpha_{SRK} = [1 + m(1-\sqrt{T/T_C}]^2

        m = 0.480+1.574\omega-0.176\omega^2

    If the fit parameter `delta_SRK` is provided, the following is used:

    .. math::
        V_s = V_C/(1+1.169\tau^{1/3}+1.818\tau^{2/3}-2.658\tau+2.161\tau^{4/3})
        /\left[1+\delta_{SRK}(\alpha_{SRK}-1)^{1/3}\right]

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tc : float
        Critical temperature of fluid [K]
    Vc : float
        Critical volume of fluid [m^3/mol]
    omega : float
        Acentric factor for fluid, [-]
    delta_SRK : float, optional
        Fitting parameter [-]

    Returns
    -------
    Vs : float
        Saturation liquid volume, [m^3/mol]

    Notes
    -----
    73 fit parameters have been gathered from the article.

    Examples
    --------
    Argon, without the fit parameter and with it. Tabulated result in Perry's
    is 3.4613e-05. The fit increases the error on this occasion.

    >>> SNM0(121, 150.8, 7.49e-05, -0.004)
    3.4402256402733416e-05
    >>> SNM0(121, 150.8, 7.49e-05, -0.004, -0.03259620)
    3.493288100008123e-05

    References
    ----------
    .. [1] Mchaweh, A., A. Alsaygh, Kh. Nasrifar, and M. Moshfeghian.
       "A Simplified Method for Calculating Saturated Liquid Densities."
       Fluid Phase Equilibria 224, no. 2 (October 1, 2004): 157-67.
       doi:10.1016/j.fluid.2004.06.054


return rho0 - k*(T-Tm)<EOL>

r'''Calculates liquid density of a molten element or salt at temperature
    above the melting point. Some coefficients are given nearly up to the
    boiling point.

    The mass density of the inorganic liquid is given by:

    .. math::
        \rho = \rho_{0} - k(T-T_m)

    Parameters
    ----------
    T : float
        Temperature of the liquid, [K]
    rho0 : float
        Mass density of the liquid at Tm, [kg/m^3]
    k : float
        Linear temperature dependence of the mass density, [kg/m^3/K]
    Tm : float
        The normal melting point, used in the correlation [K]

    Returns
    -------
    rho : float
        Mass density of molten metal or salt, [kg/m^3]

    Notes
    -----
    [1]_ has units of g/mL. While the individual densities could have been
    converted to molar units, the temperature coefficient could only be
    converted by refitting to calculated data. To maintain compatibility with
    the form of the equations, this was not performed.

    This linear form is useful only in small temperature ranges.
    Coefficients for one compound could be used to predict the temperature
    dependence of density of a similar compound.

    Examples
    --------
    >>> CRC_inorganic(300, 2370.0, 2.687, 239.08)
    2206.30796

    References
    ----------
    .. [1] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
        Chemistry and Physics, 95E. [Boca Raton, FL]: CRC press, 2014.


def COSTALD_compressed(T, P, Psat, Tc, Pc, omega, Vs):

a = -<NUM_LIT><EOL>b = <NUM_LIT><EOL>d = -<NUM_LIT><EOL>f = <NUM_LIT><EOL>g = <NUM_LIT><EOL>h = <NUM_LIT><EOL>j = <NUM_LIT><EOL>k = <NUM_LIT><EOL>tau = <NUM_LIT:1> - T/Tc<EOL>e = exp(f + g*omega + h*omega**<NUM_LIT:2>)<EOL>C = j + k*omega<EOL>B = Pc*(-<NUM_LIT:1> + a*tau**(<NUM_LIT:1>/<NUM_LIT>) + b*tau**(<NUM_LIT:2>/<NUM_LIT>) + d*tau + e*tau**(<NUM_LIT:4>/<NUM_LIT>))<EOL>return Vs*(<NUM_LIT:1> - C*log((B + P)/(B + Psat)))<EOL>

r'''Calculates compressed-liquid volume, using the COSTALD [1]_ CSP
    method and a chemical's critical properties.

    The molar volume of a liquid is given by:

    .. math::
        V = V_s\left( 1 - C \ln \frac{B + P}{B + P^{sat}}\right)

        \frac{B}{P_c} = -1 + a\tau^{1/3} + b\tau^{2/3} + d\tau + e\tau^{4/3}

        e = \exp(f + g\omega_{SRK} + h \omega_{SRK}^2)

        C = j + k \omega_{SRK}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    P : float
        Pressure of fluid [Pa]
    Psat : float
        Saturation pressure of the fluid [Pa]
    Tc : float
        Critical temperature of fluid [K]
    Pc : float
        Critical pressure of fluid [Pa]
    omega : float
        (ideally SRK) Acentric factor for fluid, [-]
        This parameter is alternatively a fit parameter.
    Vs : float
        Saturation liquid volume, [m^3/mol]

    Returns
    -------
    V_dense : float
        High-pressure liquid volume, [m^3/mol]

    Notes
    -----
    Original equation was in terms of density, but it is converted here.

    The example is from DIPPR, and exactly correct.
    This is DIPPR Procedure 4C: Method for Estimating the Density of Pure
    Organic Liquids under Pressure.

    Examples
    --------
    >>> COSTALD_compressed(303., 9.8E7, 85857.9, 466.7, 3640000.0, 0.281, 0.000105047)
    9.287482879788506e-05

    References
    ----------
    .. [1]  Thomson, G. H., K. R. Brobst, and R. W. Hankinson. "An Improved
       Correlation for Densities of Compressed Liquids and Liquid Mixtures."
       AIChE Journal 28, no. 4 (July 1, 1982): 671-76. doi:10.1002/aic.690280420


if not none_and_length_check([xs, Vms]):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return mixing_simple(xs, Vms)<EOL>

r'''Calculate mixture liquid density using the Amgat mixing rule.
    Highly inacurate, but easy to use. Assumes idea liquids with
    no excess volume. Average molecular weight should be used with it to obtain
    density.

    .. math::
        V_{mix} = \sum_i x_i V_i

    or in terms of density:

    .. math::

        \rho_{mix} = \sum\frac{x_i}{\rho_i}

    Parameters
    ----------
    xs : array
        Mole fractions of each component, []
    Vms : array
        Molar volumes of each fluids at conditions [m^3/mol]

    Returns
    -------
    Vm : float
        Mixture liquid volume [m^3/mol]

    Notes
    -----
    Units are that of the given volumes.
    It has been suggested to use this equation with weight fractions,
    but the results have been less accurate.

    Examples
    --------
    >>> Amgat([0.5, 0.5], [4.057e-05, 5.861e-05])
    4.9590000000000005e-05


def Rackett_mixture(T, xs, MWs, Tcs, Pcs, Zrs):

if not none_and_length_check([xs, MWs, Tcs, Pcs, Zrs]):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>Tc = mixing_simple(xs, Tcs)<EOL>Zr = mixing_simple(xs, Zrs)<EOL>MW = mixing_simple(xs, MWs)<EOL>Tr = T/Tc<EOL>bigsum = sum(xs[i]*Tcs[i]/Pcs[i]/MWs[i] for i in range(len(xs)))<EOL>return (R*bigsum*Zr**(<NUM_LIT:1.> + (<NUM_LIT:1.> - Tr)**(<NUM_LIT:2>/<NUM_LIT>)))*MW<EOL>

r'''Calculate mixture liquid density using the Rackett-derived mixing rule
    as shown in [2]_.

    .. math::
        V_m = \sum_i\frac{x_i T_{ci}}{MW_i P_{ci}} Z_{R,m}^{(1 + (1 - T_r)^{2/7})} R \sum_i x_i MW_i

    Parameters
    ----------
    T : float
        Temperature of liquid [K]
    xs: list
        Mole fractions of each component, []
    MWs : list
        Molecular weights of each component [g/mol]
    Tcs : list
        Critical temperatures of each component [K]
    Pcs : list
        Critical pressures of each component [Pa]
    Zrs : list
        Rackett parameters of each component []

    Returns
    -------
    Vm : float
        Mixture liquid volume [m^3/mol]

    Notes
    -----
    Model for pure compounds in [1]_ forms the basis for this model, shown in
    [2]_. Molecular weights are used as weighing by such has been found to
    provide higher accuracy in [2]_. The model can also be used without
    molecular weights, but results are somewhat different.

    As with the Rackett model, critical compressibilities may be used if
    Rackett parameters have not been regressed.

    Critical mixture temperature, and compressibility are all obtained with
    simple mixing rules.

    Examples
    --------
    Calculation in [2]_ for methanol and water mixture. Result matches example.

    >>> Rackett_mixture(T=298., xs=[0.4576, 0.5424], MWs=[32.04, 18.01], Tcs=[512.58, 647.29], Pcs=[8.096E6, 2.209E7], Zrs=[0.2332, 0.2374])
    2.625288603174508e-05

    References
    ----------
    .. [1] Rackett, Harold G. "Equation of State for Saturated Liquids."
       Journal of Chemical & Engineering Data 15, no. 4 (1970): 514-517.
       doi:10.1021/je60047a012
    .. [2] Danner, Ronald P, and Design Institute for Physical Property Data.
       Manual for Predicting Chemical Process Design Data. New York, N.Y, 1982.


def COSTALD_mixture(xs, T, Tcs, Vcs, omegas):

cmps = range(len(xs))<EOL>if not none_and_length_check([xs, Tcs, Vcs, omegas]):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>sum1 = sum([xi*Vci for xi, Vci in zip(xs, Vcs)])<EOL>sum2 = sum([xi*Vci**(<NUM_LIT:2>/<NUM_LIT>) for xi, Vci in zip(xs, Vcs)])<EOL>sum3 = sum([xi*Vci**(<NUM_LIT:1>/<NUM_LIT>) for xi, Vci in zip(xs, Vcs)])<EOL>Vm = <NUM_LIT>*(sum1 + <NUM_LIT>*sum2*sum3)<EOL>VijTcij = [[(Tcs[i]*Tcs[j]*Vcs[i]*Vcs[j])**<NUM_LIT:0.5> for j in cmps] for i in cmps]<EOL>omega = mixing_simple(xs, omegas)<EOL>Tcm = sum([xs[i]*xs[j]*VijTcij[i][j]/Vm for j in cmps for i in cmps])<EOL>return COSTALD(T, Tcm, Vm, omega)<EOL>

r'''Calculate mixture liquid density using the COSTALD CSP method.

    A popular and accurate estimation method. If possible, fit parameters are
    used; alternatively critical properties work well.

    The mixing rules giving parameters for the pure component COSTALD
    equation are:

    .. math::
        T_{cm} = \frac{\sum_i\sum_j x_i x_j (V_{ij}T_{cij})}{V_m}

        V_m = 0.25\left[ \sum x_i V_i + 3(\sum x_i V_i^{2/3})(\sum_i x_i V_i^{1/3})\right]

        V_{ij}T_{cij} = (V_iT_{ci}V_{j}T_{cj})^{0.5}

        \omega = \sum_i z_i \omega_i

    Parameters
    ----------
    xs: list
        Mole fractions of each component
    T : float
        Temperature of fluid [K]
    Tcs : list
        Critical temperature of fluids [K]
    Vcs : list
        Critical volumes of fluids [m^3/mol].
        This parameter is alternatively a fit parameter
    omegas : list
        (ideally SRK) Acentric factor of all fluids, [-]
        This parameter is alternatively a fit parameter.

    Returns
    -------
    Vs : float
        Saturation liquid mixture volume

    Notes
    -----
    Range: 0.25 < Tr < 0.95, often said to be to 1.0
    No example has been found.
    Units are that of critical or fit constant volume.

    Examples
    --------
    >>> COSTALD_mixture([0.4576, 0.5424], 298.,  [512.58, 647.29],[0.000117, 5.6e-05], [0.559,0.344] )
    2.706588773271354e-05

    References
    ----------
    .. [1] Hankinson, Risdon W., and George H. Thomson. "A New Correlation for
       Saturated Densities of Liquids and Their Mixtures." AIChE Journal
       25, no. 4 (1979): 653-663. doi:10.1002/aic.690250412


return R*T/P<EOL>

r'''Calculates ideal gas molar volume.
    The molar volume of an ideal gas is given by:

    .. math::
        V = \frac{RT}{P}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    P : float
        Pressure of fluid [Pa]

    Returns
    -------
    V : float
        Gas volume, [m^3/mol]

    Examples
    --------
    >>> ideal_gas(298.15, 101325.)
    0.02446539540458919


rhos = (<NUM_LIT> - <NUM_LIT>*(T/Tt))*(rhol)<EOL>return rhos<EOL>

r'''Calculates solid density at T using the simple relationship
    by a member of the DIPPR.

    The molar volume of a solid is given by:

    .. math::
        \frac{1}{V_m} = \left( 1.28 - 0.16 \frac{T}{T_t}\right)
        \frac{1}{{Vm}_L(T_t)}

    Parameters
    ----------
    T : float
        Temperature of fluid [K]
    Tt : float
        Triple temperature of fluid [K]
    rhol : float
        Liquid density, [m^3/mol]

    Returns
    -------
    rhos : float
        Solid volume, [m^3/mol]

    Notes
    -----
    Works to the next solid transition temperature or to approximately 0.3Tt.

    Examples
    --------
    >>> Goodman(281.46, 353.43, 7.6326)
    8.797191839062899

    References
    ----------
    .. [1] Goodman, Benjamin T., W. Vincent Wilding, John L. Oscarson, and
       Richard L. Rowley. "A Note on the Relationship between Organic Solid
       Density and Liquid Density at the Triple Point." Journal of Chemical &
       Engineering Data 49, no. 6 (2004): 1512-14. doi:10.1021/je034220e.


methods = []<EOL>methods_P = []<EOL>Tmins, Tmaxs = [], []<EOL>if has_CoolProp and self.CASRN in coolprop_dict:<EOL><INDENT>methods.append(COOLPROP); methods_P.append(COOLPROP)<EOL>self.CP_f = coolprop_fluids[self.CASRN]<EOL>Tmins.append(self.CP_f.Tt); Tmaxs.append(self.CP_f.Tc)<EOL><DEDENT>if self.CASRN in CRC_inorg_l_data.index:<EOL><INDENT>methods.append(CRC_INORG_L)<EOL>_, self.CRC_INORG_L_MW, self.CRC_INORG_L_rho, self.CRC_INORG_L_k, self.CRC_INORG_L_Tm, self.CRC_INORG_L_Tmax = _CRC_inorg_l_data_values[CRC_inorg_l_data.index.get_loc(self.CASRN)].tolist()<EOL>Tmins.append(self.CRC_INORG_L_Tm); Tmaxs.append(self.CRC_INORG_L_Tmax)<EOL><DEDENT>if self.CASRN in Perry_l_data.index:<EOL><INDENT>methods.append(PERRYDIPPR)<EOL>_, C1, C2, C3, C4, self.DIPPR_Tmin, self.DIPPR_Tmax = _Perry_l_data_values[Perry_l_data.index.get_loc(self.CASRN)].tolist()<EOL>self.DIPPR_coeffs = [C1, C2, C3, C4]<EOL>Tmins.append(self.DIPPR_Tmin); Tmaxs.append(self.DIPPR_Tmax)<EOL><DEDENT>if self.CASRN in VDI_PPDS_2.index:<EOL><INDENT>methods.append(VDI_PPDS)<EOL>_, MW, Tc, rhoc, A, B, C, D = _VDI_PPDS_2_values[VDI_PPDS_2.index.get_loc(self.CASRN)].tolist()<EOL>self.VDI_PPDS_coeffs = [A, B, C, D]<EOL>self.VDI_PPDS_MW = MW<EOL>self.VDI_PPDS_Tc = Tc<EOL>self.VDI_PPDS_rhoc = rhoc<EOL>Tmaxs.append(self.VDI_PPDS_Tc)<EOL><DEDENT>if self.CASRN in _VDISaturationDict:<EOL><INDENT>methods.append(VDI_TABULAR)<EOL>Ts, props = VDI_tabular_data(self.CASRN, '<STR_LIT>')<EOL>self.VDI_Tmin = Ts[<NUM_LIT:0>]<EOL>self.VDI_Tmax = Ts[-<NUM_LIT:1>]<EOL>self.tabular_data[VDI_TABULAR] = (Ts, props)<EOL>Tmins.append(self.VDI_Tmin); Tmaxs.append(self.VDI_Tmax)<EOL><DEDENT>if self.Tc and self.CASRN in COSTALD_data.index:<EOL><INDENT>methods.append(HTCOSTALDFIT)<EOL>self.COSTALD_Vchar = float(COSTALD_data.at[self.CASRN, '<STR_LIT>'])<EOL>self.COSTALD_omega_SRK = float(COSTALD_data.at[self.CASRN, '<STR_LIT>'])<EOL>Tmins.append(<NUM_LIT:0>); Tmaxs.append(self.Tc)<EOL><DEDENT>if self.Tc and self.Pc and self.CASRN in COSTALD_data.index and not np.isnan(COSTALD_data.at[self.CASRN, '<STR_LIT>']):<EOL><INDENT>methods.append(RACKETTFIT)<EOL>self.RACKETT_Z_RA = float(COSTALD_data.at[self.CASRN, '<STR_LIT>'])<EOL>Tmins.append(<NUM_LIT:0>); Tmaxs.append(self.Tc)<EOL><DEDENT>if self.CASRN in CRC_inorg_l_const_data.index:<EOL><INDENT>methods.append(CRC_INORG_L_CONST)<EOL>self.CRC_INORG_L_CONST_Vm = float(CRC_inorg_l_const_data.at[self.CASRN, '<STR_LIT>'])<EOL><DEDENT>if all((self.Tc, self.Vc, self.Zc)):<EOL><INDENT>methods.append(YEN_WOODS_SAT)<EOL>Tmins.append(<NUM_LIT:0>); Tmaxs.append(self.Tc)<EOL><DEDENT>if all((self.Tc, self.Pc, self.Zc)):<EOL><INDENT>methods.append(RACKETT)<EOL>Tmins.append(<NUM_LIT:0>); Tmaxs.append(self.Tc)<EOL><DEDENT>if all((self.Tc, self.Pc, self.omega)):<EOL><INDENT>methods.append(YAMADA_GUNN)<EOL>methods.append(BHIRUD_NORMAL)<EOL>Tmins.append(<NUM_LIT:0>); Tmaxs.append(self.Tc)<EOL><DEDENT>if all((self.Tc, self.Vc, self.omega)):<EOL><INDENT>methods.append(TOWNSEND_HALES)<EOL>methods.append(HTCOSTALD)<EOL>methods.append(MMSNM0)<EOL>if self.CASRN in SNM0_data.index:<EOL><INDENT>methods.append(MMSNM0FIT)<EOL>self.SNM0_delta_SRK = float(SNM0_data.at[self.CASRN, '<STR_LIT>'])<EOL><DEDENT>Tmins.append(<NUM_LIT:0>); Tmaxs.append(self.Tc)<EOL><DEDENT>if all((self.Tc, self.Vc, self.omega, self.Tb, self.MW)):<EOL><INDENT>methods.append(CAMPBELL_THODOS)<EOL>Tmins.append(<NUM_LIT:0>); Tmaxs.append(self.Tc)<EOL><DEDENT>if all((self.Tc, self.Pc, self.omega)):<EOL><INDENT>methods_P.append(COSTALD_COMPRESSED)<EOL>if self.eos:<EOL><INDENT>methods_P.append(EOS)<EOL><DEDENT><DEDENT>if Tmins and Tmaxs:<EOL><INDENT>self.Tmin, self.Tmax = min(Tmins), max(Tmaxs)<EOL><DEDENT>self.all_methods = set(methods)<EOL>self.all_methods_P = set(methods_P)<EOL>

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

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


if method == RACKETT:<EOL><INDENT>Vm = Rackett(T, self.Tc, self.Pc, self.Zc)<EOL><DEDENT>elif method == YAMADA_GUNN:<EOL><INDENT>Vm = Yamada_Gunn(T, self.Tc, self.Pc, self.omega)<EOL><DEDENT>elif method == BHIRUD_NORMAL:<EOL><INDENT>Vm = Bhirud_normal(T, self.Tc, self.Pc, self.omega)<EOL><DEDENT>elif method == TOWNSEND_HALES:<EOL><INDENT>Vm = Townsend_Hales(T, self.Tc, self.Vc, self.omega)<EOL><DEDENT>elif method == HTCOSTALD:<EOL><INDENT>Vm = COSTALD(T, self.Tc, self.Vc, self.omega)<EOL><DEDENT>elif method == YEN_WOODS_SAT:<EOL><INDENT>Vm = Yen_Woods_saturation(T, self.Tc, self.Vc, self.Zc)<EOL><DEDENT>elif method == MMSNM0:<EOL><INDENT>Vm = SNM0(T, self.Tc, self.Vc, self.omega)<EOL><DEDENT>elif method == MMSNM0FIT:<EOL><INDENT>Vm = SNM0(T, self.Tc, self.Vc, self.omega, self.SNM0_delta_SRK)<EOL><DEDENT>elif method == CAMPBELL_THODOS:<EOL><INDENT>Vm = Campbell_Thodos(T, self.Tb, self.Tc, self.Pc, self.MW, self.dipole)<EOL><DEDENT>elif method == HTCOSTALDFIT:<EOL><INDENT>Vm = COSTALD(T, self.Tc, self.COSTALD_Vchar, self.COSTALD_omega_SRK)<EOL><DEDENT>elif method == RACKETTFIT:<EOL><INDENT>Vm = Rackett(T, self.Tc, self.Pc, self.RACKETT_Z_RA)<EOL><DEDENT>elif method == PERRYDIPPR:<EOL><INDENT>A, B, C, D = self.DIPPR_coeffs<EOL>Vm = <NUM_LIT:1.>/EQ105(T, A, B, C, D)<EOL><DEDENT>elif method == CRC_INORG_L:<EOL><INDENT>rho = CRC_inorganic(T, self.CRC_INORG_L_rho, self.CRC_INORG_L_k, self.CRC_INORG_L_Tm)<EOL>Vm = rho_to_Vm(rho, self.CRC_INORG_L_MW)<EOL><DEDENT>elif method == VDI_PPDS:<EOL><INDENT>A, B, C, D = self.VDI_PPDS_coeffs<EOL>tau = <NUM_LIT:1.> - T/self.VDI_PPDS_Tc<EOL>rho = self.VDI_PPDS_rhoc + A*tau**<NUM_LIT> + B*tau**(<NUM_LIT:2>/<NUM_LIT>) + C*tau + D*tau**(<NUM_LIT:4>/<NUM_LIT>)<EOL>Vm = rho_to_Vm(rho, self.VDI_PPDS_MW)<EOL><DEDENT>elif method == CRC_INORG_L_CONST:<EOL><INDENT>Vm = self.CRC_INORG_L_CONST_Vm<EOL><DEDENT>elif method == COOLPROP:<EOL><INDENT>Vm = <NUM_LIT:1.>/CoolProp_T_dependent_property(T, self.CASRN, '<STR_LIT>', '<STR_LIT:l>')<EOL><DEDENT>elif method in self.tabular_data:<EOL><INDENT>Vm = self.interpolate(T, method)<EOL><DEDENT>return Vm<EOL>

r'''Method to calculate low-pressure liquid molar volume 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 molar volume, [K]
        method : str
            Name of the method to use

        Returns
        -------
        Vm : float
            Molar volume of the liquid at T and a low pressure, [m^3/mol]


if method == COSTALD_COMPRESSED:<EOL><INDENT>Vm = self.T_dependent_property(T)<EOL>Psat = self.Psat(T) if hasattr(self.Psat, '<STR_LIT>') else self.Psat<EOL>Vm = COSTALD_compressed(T, P, Psat, self.Tc, self.Pc, self.omega, Vm)<EOL><DEDENT>elif method == COOLPROP:<EOL><INDENT>Vm = <NUM_LIT:1.>/PropsSI('<STR_LIT>', '<STR_LIT:T>', T, '<STR_LIT:P>', P, self.CASRN)<EOL><DEDENT>elif method == EOS:<EOL><INDENT>self.eos[<NUM_LIT:0>] = self.eos[<NUM_LIT:0>].to_TP(T=T, P=P)<EOL>Vm = self.eos[<NUM_LIT:0>].V_l<EOL><DEDENT>elif method in self.tabular_data:<EOL><INDENT>Vm = self.interpolate_P(T, P, method)<EOL><DEDENT>return Vm<EOL>

r'''Method to calculate pressure-dependent liquid molar volume 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 molar volume, [K]
        P : float
            Pressure at which to calculate molar volume, [K]
        method : str
            Name of the method to use

        Returns
        -------
        Vm : float
            Molar volume of the liquid at T and P, [m^3/mol]


methods = [SIMPLE]        <EOL>if none_and_length_check([self.Tcs, self.Vcs, self.omegas, self.CASs]):<EOL><INDENT>methods.append(COSTALD_MIXTURE)<EOL>if all([i in COSTALD_data.index for i in self.CASs]):<EOL><INDENT>self.COSTALD_Vchars = [COSTALD_data.at[CAS, '<STR_LIT>'] for CAS in self.CASs]<EOL>self.COSTALD_omegas = [COSTALD_data.at[CAS, '<STR_LIT>'] for CAS in self.CASs]<EOL>methods.append(COSTALD_MIXTURE_FIT)<EOL><DEDENT><DEDENT>if none_and_length_check([self.MWs, self.Tcs, self.Pcs, self.Zcs, self.CASs]):<EOL><INDENT>methods.append(RACKETT)<EOL>if all([CAS in COSTALD_data.index for CAS in self.CASs]):<EOL><INDENT>Z_RAs = [COSTALD_data.at[CAS, '<STR_LIT>'] for CAS in self.CASs]<EOL>if not any(np.isnan(Z_RAs)):<EOL><INDENT>self.Z_RAs = Z_RAs<EOL>methods.append(RACKETT_PARAMETERS)<EOL><DEDENT><DEDENT><DEDENT>if len(self.CASs) > <NUM_LIT:1> and '<STR_LIT>' in self.CASs:<EOL><INDENT>wCASs = [i for i in self.CASs if i != '<STR_LIT>'] <EOL>if all([i in _Laliberte_Density_ParametersDict for i in wCASs]):<EOL><INDENT>methods.append(LALIBERTE)<EOL>self.wCASs = wCASs<EOL>self.index_w = self.CASs.index('<STR_LIT>')<EOL><DEDENT><DEDENT>self.all_methods = set(methods)<EOL>

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

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


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

if method == SIMPLE:<EOL><INDENT>Vms = [i(T, P) for i in self.VolumeLiquids]<EOL>return Amgat(zs, Vms)<EOL><DEDENT>elif method == COSTALD_MIXTURE:<EOL><INDENT>return COSTALD_mixture(zs, T, self.Tcs, self.Vcs, self.omegas)<EOL><DEDENT>elif method == COSTALD_MIXTURE_FIT:<EOL><INDENT>return COSTALD_mixture(zs, T, self.Tcs, self.COSTALD_Vchars, self.COSTALD_omegas)<EOL><DEDENT>elif method == RACKETT:<EOL><INDENT>return Rackett_mixture(T, zs, self.MWs, self.Tcs, self.Pcs, self.Zcs)<EOL><DEDENT>elif method == RACKETT_PARAMETERS:<EOL><INDENT>return Rackett_mixture(T, zs, self.MWs, self.Tcs, self.Pcs, self.Z_RAs)<EOL><DEDENT>elif method == LALIBERTE:<EOL><INDENT>ws = list(ws) ; ws.pop(self.index_w)<EOL>rho = Laliberte_density(T, ws, self.wCASs)<EOL>MW = mixing_simple(zs, self.MWs)<EOL>return rho_to_Vm(rho, MW)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Method to calculate molar volume 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
        -------
        Vm : float
            Molar volume of the liquid mixture at the given conditions,
            [m^3/mol]


methods_P = [IDEAL]<EOL>if all((self.Tc, self.Pc, self.omega)):<EOL><INDENT>methods_P.extend([TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT,<EOL>PITZER_CURL])<EOL>if self.eos:<EOL><INDENT>methods_P.append(EOS)<EOL><DEDENT><DEDENT>if self.CASRN in CRC_virial_data.index:<EOL><INDENT>methods_P.append(CRC_VIRIAL)<EOL>self.CRC_VIRIAL_coeffs = _CRC_virial_data_values[CRC_virial_data.index.get_loc(self.CASRN)].tolist()[<NUM_LIT:1>:]<EOL><DEDENT>if has_CoolProp and self.CASRN in coolprop_dict:<EOL><INDENT>methods_P.append(COOLPROP)<EOL>self.CP_f = coolprop_fluids[self.CASRN]<EOL><DEDENT>self.all_methods_P = set(methods_P)<EOL>

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

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


if method == EOS:<EOL><INDENT>self.eos[<NUM_LIT:0>] = self.eos[<NUM_LIT:0>].to_TP(T=T, P=P)<EOL>Vm = self.eos[<NUM_LIT:0>].V_g<EOL><DEDENT>elif method == TSONOPOULOS_EXTENDED:<EOL><INDENT>B = BVirial_Tsonopoulos_extended(T, self.Tc, self.Pc, self.omega, dipole=self.dipole)<EOL>Vm = ideal_gas(T, P) + B<EOL><DEDENT>elif method == TSONOPOULOS:<EOL><INDENT>B = BVirial_Tsonopoulos(T, self.Tc, self.Pc, self.omega)<EOL>Vm = ideal_gas(T, P) + B<EOL><DEDENT>elif method == ABBOTT:<EOL><INDENT>B = BVirial_Abbott(T, self.Tc, self.Pc, self.omega)<EOL>Vm = ideal_gas(T, P) + B<EOL><DEDENT>elif method == PITZER_CURL:<EOL><INDENT>B = BVirial_Pitzer_Curl(T, self.Tc, self.Pc, self.omega)<EOL>Vm = ideal_gas(T, P) + B<EOL><DEDENT>elif method == CRC_VIRIAL:<EOL><INDENT>a1, a2, a3, a4, a5 = self.CRC_VIRIAL_coeffs<EOL>t = <NUM_LIT>/T - <NUM_LIT:1.><EOL>B = (a1 + a2*t + a3*t**<NUM_LIT:2> + a4*t**<NUM_LIT:3> + a5*t**<NUM_LIT:4>)/<NUM_LIT><EOL>Vm = ideal_gas(T, P) + B<EOL><DEDENT>elif method == IDEAL:<EOL><INDENT>Vm = ideal_gas(T, P)<EOL><DEDENT>elif method == COOLPROP:<EOL><INDENT>Vm = <NUM_LIT:1.>/PropsSI('<STR_LIT>', '<STR_LIT:T>', T, '<STR_LIT:P>', P, self.CASRN)<EOL><DEDENT>elif method in self.tabular_data:<EOL><INDENT>Vm = self.interpolate_P(T, P, method)<EOL><DEDENT>return Vm<EOL>

r'''Method to calculate pressure-dependent gas molar volume 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 molar volume, [K]
        P : float
            Pressure at which to calculate molar volume, [K]
        method : str
            Name of the method to use

        Returns
        -------
        Vm : float
            Molar volume of the gas at T and P, [m^3/mol]


methods = [SIMPLE, IDEAL]     <EOL>if self.eos:<EOL><INDENT>methods.append(EOS)<EOL><DEDENT>self.all_methods = set(methods)<EOL>


if method == SIMPLE:<EOL><INDENT>Vms = [i(T, P) for i in self.VolumeGases]<EOL>return mixing_simple(zs, Vms)<EOL><DEDENT>elif method == IDEAL:<EOL><INDENT>return ideal_gas(T, P)<EOL><DEDENT>elif method == EOS:<EOL><INDENT>self.eos[<NUM_LIT:0>] = self.eos[<NUM_LIT:0>].to_TP_zs(T=T, P=P, zs=zs)<EOL>return self.eos[<NUM_LIT:0>].V_g<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>

r'''Method to calculate molar volume 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
        -------
        Vm : float
            Molar volume of the gas mixture at the given conditions, [m^3/mol]