Exemple #1
0
def generateGraphFromSlabVinkFile(slab, covalent_radii_cut_off):
    all_distances = slab.get_all_distances(mic=True)
    atomic_numbers = slab.get_atomic_numbers()

    # so funciona se os atomos Si vierem antes dos de O (numeracao / aboria / grafo)

    mapping = {}
    for atom1, distances in enumerate(all_distances):
        if atomic_numbers[atom1] == 14:  # Si
            atom1_cr = covalent_radii[atomic_numbers[atom1]]
            for atom2, distance in enumerate(distances):
                if atom1 == atom2:
                    continue

                # so pega atomos de O
                if atomic_numbers[atom2] != 8:  # O
                    continue

                atom2_cr = covalent_radii[atomic_numbers[atom2]]
                # if the distance between two atoms is less than the sum of their covalent radii, they are considered bonded.
                if (distance <
                    ((atom1_cr + atom2_cr) * covalent_radii_cut_off)):
                    try:
                        mapping[atom1].append(atom2)
                    except KeyError:
                        mapping[atom1] = []
                        mapping[atom1].append(atom2)

                    try:
                        mapping[atom2].append(atom1)
                    except KeyError:
                        mapping[atom2] = []
                        mapping[atom2].append(atom1)

    graph = bg.Graph()
    for atom1 in slab:
        if atom1.symbol == 'Si':
            if not graph.has_node(atom1.index):
                graph.add_node(atom1.index)  # add nodes not bonded

            try:
                for n1_o in mapping[atom1.index]:
                    if atomic_numbers[n1_o] == 8:  # O
                        for n2_si in mapping[n1_o]:
                            if atomic_numbers[n2_si] == 14:  # Si
                                if atom1.index != n2_si:
                                    graph.add_edge(atom1.index, n2_si)
            except KeyError:
                pass

    # remove O atomos
    del slab[[atom.index for atom in slab if atom.symbol == 'O']]

    return graph
Exemple #2
0
def generateGraphFromSlab(slab, covalent_radii_cut_off):
    graph = bg.Graph()

    atomic_numbers = slab.get_atomic_numbers()
    all_distances = slab.get_all_distances(mic=True)
    for atom1, distances in enumerate(all_distances):
        if not graph.has_node(atom1):
            graph.add_node(atom1)  # add nodes not bonded

        atom1_cr = covalent_radii[atomic_numbers[atom1]]
        for atom2, distance in enumerate(distances):
            if atom1 != atom2:
                atom2_cr = covalent_radii[atomic_numbers[atom2]]
                # if the distance between two atoms is less than the sum of their covalent radii, they are considered bonded.
                if (distance <
                    ((atom1_cr + atom2_cr) * covalent_radii_cut_off)):
                    graph.add_edge(atom1, atom2)

    return graph