Beispiel #1
0
    def find_all_bonds(geometry, tol=0.2):
        """
        Finds all bonds present in a geometry.

        Parameters
        -----------
        geometry: sisl.Geometry
            the structure where the bonds should be found.
        tol: float
            the fraction that the distance between atoms is allowed to differ from
            the "standard" in order to be considered a bond.

        Return
        ---------
        np.ndarray of shape (nbonds, 2)
            each item of the array contains the 2 indices of the atoms that participate in the
            bond.
        """
        pt = PeriodicTable()

        bonds = []
        for at in geometry:
            neighs = geometry.close(at, R=[0.1, 3])[-1]

            for neigh in neighs[neighs > at]:
                summed_radius = pt.radius([
                    abs(geometry.atoms[at].Z),
                    abs(geometry.atoms[neigh % geometry.na].Z)
                ]).sum()
                bond_thresh = (1 + tol) * summed_radius
                if bond_thresh > fnorm(geometry[neigh] - geometry[at]):
                    bonds.append([at, neigh])

        return np.array(bonds, dtype=int)
Beispiel #2
0
def test_geom_category_no_r():
    hBN = honeycomb(1.42, Atom[5, 7]) * (10, 11, 1)

    B = AtomZ(5)
    B2 = AtomNeighbours(2, neighbour=B, R=1.43)
    N = AtomZ(7)
    N2 = AtomNeighbours(min=2, max=2, neighbour=N, R=(0.01, 1.43))
    PT = PeriodicTable()
    B3 = AtomNeighbours(3,
                        neighbour=B,
                        R=lambda atom: (0.01, PT.radius(atom.Z)))
    N3 = AtomNeighbours(3, neighbour=N, R=1.43)
    Nabove3 = AtomNeighbours(min=3, neighbour=N, R=1.43)

    assert B != N2
    assert N2 != N3

    n2 = AtomNeighbours(2, R=1.43)

    category = (B & B2) ^ (N & N2) ^ (B & B3) ^ (N & N3) ^ n2

    cat = category.categorize(hBN)