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