partition_chem_env

Cartesian.partition_chem_env(follow_bonds=4)[source]
This function partitions the molecule into subsets of the
same chemical environment.
A chemical environment is specified by the number of
surrounding atoms of a certain kind around an atom with a certain atomic number represented by a tuple of a string and a frozenset of tuples.
The follow_bonds option determines how many branches the
algorithm follows to determine the chemical environment.

Example: A carbon atom in ethane has bonds with three hydrogen (atomic

number 1) and one carbon atom (atomic number 6).
If follow_bonds=1 these are the only atoms we are

interested in and the chemical environment is:

('C', frozenset([('H', 3), ('C', 1)]))
If follow_bonds=2 we follow every atom in the chemical
enviromment of follow_bonds=1 to their direct neighbours.

In the case of ethane this gives:

('C', frozenset([('H', 6), ('C', 1)]))

In the special case of ethane this is the whole molecule; in other cases you can apply this operation recursively and

stop after follow_bonds or after reaching the end of branches.
Parameters:follow_bonds (int) –
Returns:The output will look like this:
{ (element_symbol, frozenset([tuples]))  :
    set([indices]) }

A dictionary mapping from a chemical environment to
    the set of indices of atoms in this environment.
Return type:dict