예제 #1
0
    def crystalAtoms(self,
                     start_layer=0,
                     end_layer=1,
                     coordinates='orth_surface',
                     sub_layers=False,
                     minimal=True,
                     ):
        atoms = self.crystal().atoms()

        if sub_layers:
            in_equal_layers = self.inequivalentLayers()
            repeats = int(np.ceil(end_layer/float(in_equal_layers)))
            atoms = atoms.repeat((1, 1, repeats + 1))
            atoms.positions -= self.crystal().unitCell()*(repeats)
            start_layer += in_equal_layers -1
            end_layer += in_equal_layers -1
            atoms = orderAtoms(atoms, (2, 1, 0))
            sl = slice(start_layer, end_layer)

            groups = groupAtoms(atoms)[::-1][sl]
            if len(groups) == 0:
                atoms = Atoms([], cell=atoms.get_cell(), pbc=atoms.get_pbc())
            else:
                atoms, indices = groups[0]
                for group, indices in groups[1:]:
                    atoms += group
        else:
            cell = atoms.unitCell()
            atoms = atoms.repeat((1, 1, end_layer-start_layer))
            atoms.positions += cell*start_layer

        return atoms
예제 #2
0
    def crystalAtoms(self,
                     start_layer=0,
                     end_layer=1,
                     coordinates='orth_surface',
                     vectors=((1,0),(0,1)),
                     sub_layers=False,
                     minimal=True,
                     ):
        sl = slice(start_layer, end_layer)
        if minimal:
            unit_cell = self.minimalCell('crystal')
        else:
            unit_cell = self.cell('crystal')
        catoms = self.crystal().atoms()
        catoms.purgeTags()
        atoms = makeSlabWithVectors(catoms, unit_cell, sl.stop)
        atoms = self.change(atoms, to=coordinates, fro='orth_crystal')
        unit_cell = self.crystal().change(unit_cell, to='orth_crystal', fro='crystal',
                                    difference=True,)[:2]
        unit_cell = self.change(unit_cell, to='orth_surface', fro='orth_crystal')

        if len(atoms)==0:
            return atoms

        if minimal:
            vectors = unit_cell
        else:
            vectors = np.array(vectors)
            vectors = np.dot(unit_cell.transpose(), vectors.transpose()).transpose()
            repeats = fitBoxIntoBox(unit_cell, vectors)
            atoms = atoms.repeat(list(repeats) + [1])

        out_vector = atoms.cell[2]
        out_vector[:2] = 0
        vectors = np.array([vectors[0], vectors[1], out_vector])

        atoms.set_cell(vectors)
        atoms.set_pbc([True, True, False])
        atoms = removeCopies(atoms)
        atoms.wrap()
        atoms = orderAtoms(atoms, (2, 1, 0))


        if sub_layers:
            groups = groupAtoms(atoms)[sl]
            if len(groups) == 0:
                return Atoms([], cell=atoms.get_cell(), pbc=atoms.get_pbc())

            atoms, indices = groups[0]
            for atoms_group, indices in groups[1:]:
                atoms += atoms_group

        return atoms
예제 #3
0
    def __init__(self,
                 crystal,
                 direction=1,
                 extra_atoms=Atoms([]),
                 parameters=DEFAULT,
                 ):
        self.__direction = int(np.sign(direction))
        self.__extra_atoms = extra_atoms

        atoms = crystal.atoms()
        groups = groupAtoms(atoms)
        self.__inequivalent_layers = len(groups)

        Surface.__init__(
                self,
                sub_systems=[crystal],
                parameters=parameters,
                )
예제 #4
0
    def inequivalentLayers(self):
        atoms = self.crystalAtoms()
        groups = groupAtoms(atoms)

        return len(groups)