def get_adsorbate_indices(self, atoms, position): """Returns the indices of the adsorbate at the supplied position""" dmin = 1000. for a in atoms: d = np.linalg.norm(a.position - position) if d < dmin: dmin = d ind = a.index mbl = 1.5 # max_bond_length nl = aseNeighborList([mbl / 2. for i in atoms], skin=0.0, self_interaction=False) nl.update(atoms) return list(set(self._get_indices_in_adsorbate(atoms, nl, ind, [])))
def get_all_adsorbate_indices(self, atoms): ac = atoms.copy() ads_ind = [a.index for a in ac if a.symbol in self.adsorbate_set] mbl = 1.5 # max_bond_length nl = aseNeighborList([mbl / 2. for i in ac], skin=0.0, self_interaction=False) nl.update(ac) adsorbates = [] while len(ads_ind) != 0: i = int(ads_ind[0]) mol_ind = self._get_indices_in_adsorbate(ac, nl, i) for ind in mol_ind: if int(ind) in ads_ind: ads_ind.remove(int(ind)) adsorbates.append(sorted(mol_ind)) return adsorbates