def get_angles_distribution(atoms, ang_grid=9): """ Method to get the distribution of bond angles in bins (default 9) with bonds defined from the get_neighbor_list(). """ conn = get_neighbor_list(atoms) if conn is None: conn = get_neighborlist(atoms) bins = [0] * ang_grid for atom in atoms: for i in conn[atom.index]: for j in conn[atom.index]: if j != i: a = atoms.get_angle(i, atom.index, j) for k in range(ang_grid): if (k + 1) * 180. / ang_grid > a > k * 180. / ang_grid: bins[k] += 1 # Removing dobbelt counting for i in range(ang_grid): bins[i] /= 2. return bins
def get_angles_distribution(atoms, ang_grid=9): """ Method to get the distribution of bond angles in bins (default 9) with bonds defined from the get_neighbor_list(). """ from math import pi conn = get_neighbor_list(atoms) if conn is None: conn = get_neighborlist(atoms) bins = [0] * ang_grid for atom in atoms: for i in conn[atom.index]: for j in conn[atom.index]: if j != i: a = atoms.get_angle([i, atom.index, j]) * 180 / pi for k in range(ang_grid): if (k + 1) * 180. / ang_grid > a > k * 180. / ang_grid: bins[k] += 1 # Removing dobbelt counting for i in range(ang_grid): bins[i] /= 2. return bins
def get_atoms_connections(atoms, max_conn=5): """ This method returns a list of the numbers of atoms with X number of neighbors. The method utilizes the neighbor list and hence inherit the restrictions for neighbors. """ conn = get_neighbor_list(atoms) if conn is None: conn = get_neighborlist(atoms) no_of_conn = [0] * max_conn for i in range(len(atoms)): no_of_conn[min(len(conn[i]), max_conn - 1)] += 1 return no_of_conn
def get_rings(atoms, rings=[5, 6, 7]): """ This method return a list of the number of atoms involved in rings in the structures. It uses the neighbor list hence inherit the restriction used for neighbors. """ conn = get_neighbor_list(atoms) if conn is None: conn = get_neighborlist(atoms) no_of_loops = [0] * 8 for s1 in range(len(atoms)): for s2 in conn[s1]: v12 = [s1] + [s2] for s3 in [s for s in conn[s2] if s not in v12]: v13 = v12 + [s3] if s1 in conn[s3]: no_of_loops[3] += 1 for s4 in [s for s in conn[s3] if s not in v13]: v14 = v13 + [s4] if s1 in conn[s4]: no_of_loops[4] += 1 for s5 in [s for s in conn[s4] if s not in v14]: v15 = v14 + [s5] if s1 in conn[s5]: no_of_loops[5] += 1 for s6 in [s for s in conn[s5] if s not in v15]: v16 = v15 + [s6] if s1 in conn[s6]: no_of_loops[6] += 1 for s7 in [s for s in conn[s6] if s not in v16]: # v17 = v16 + [s7] if s1 in conn[s7]: no_of_loops[7] += 1 to_return = [] for ring in rings: to_return.append(no_of_loops[ring]) return to_return
def get_connections_index(atoms, max_conn=5, no_count_types=None): """ This method returns a dictionary where each key value are a specific number of neighbors and list of atoms indices with that amount of neighbors respectively. The method utilizes the neighbor list and hence inherit the restrictions for neighbors. Option added to remove connections between defined atom types. Parameters ---------- atoms : Atoms object The connections will be counted using this supplied Atoms object max_conn : int Any atom with more connections than this will be counted as having max_conn connections. Default 5 no_count_types : list or None List of atomic numbers that should be excluded in the count. Default None (meaning all atoms count). """ conn = get_neighbor_list(atoms) if conn is None: conn = get_neighborlist(atoms) if no_count_types is None: no_count_types = [] conn_index = {} for i in range(len(atoms)): if atoms[i].number not in no_count_types: cconn = min(len(conn[i]), max_conn - 1) if cconn not in conn_index: conn_index[cconn] = [] conn_index[cconn].append(i) return conn_index