def test_manager_iteration_2(self): ''' Compare the distances and direction vector between the reference and librascal sctrict neighbourlist ''' frame = self.frame structure = self.structure for pbc in self.pbcs: frame['pbc'] = pbc structure['pbc'] = pbc manager = get_neighbourlist(frame, self.nl_options) neighpos, neighlist, neightype, neighdist, neighdirVec = get_NL_strict_reference( self.cutoff, **structure) for ii, center in enumerate(manager): dists, dirVecs = [], [] for jj, neigh in enumerate(center): dist = np.linalg.norm(neigh.position - center.position) dists.append(dist) dirVecs.append((neigh.position - center.position) / dist) ref_dists, dists = np.array(neighdist[ii]), np.array(dists) ref_dirVecs, dirVecs = np.array(neighdirVec[ii]).reshape( (-1, 3)), np.array(dirVecs) # sort because the order is not the same ref_sort_ids, sort_ids = np.argsort(ref_dists), np.argsort( dists)
def test_manager_iteration(self): manager = get_neighbourlist(self.frame, self.nl_options) ii = 0 for center in manager: self.assertTrue(ii == center.atom_tag) self.assertTrue( self.structure["atom_types"][ii] == center.atom_type) self.assertTrue( np.allclose(self.structure["positions"][:, ii], center.position)) ii += 1
def test_manager_iteration_2(self): frame = self.frame structure = self.structure for pbc in self.pbcs: frame["pbc"] = pbc structure["pbc"] = pbc manager = get_neighbourlist(frame, self.nl_options) neighpos, neighlist, neightype, neighdist = get_NL_reference( self.cutoff, **structure) for center in manager: for neigh in center.pairs(): dist = np.linalg.norm(neigh.position - center.position)
def test_manager_iteration_2(self): frame = self.frame structure = self.structure for pbc in self.pbcs: frame['pbc'] = pbc structure['pbc'] = pbc manager = get_neighbourlist(frame, self.nl_options) neighpos, neighlist, neightype, neighdist = get_NL_reference( self.cutoff, **structure) for ii, center in enumerate(manager): for jj, neigh in enumerate(center): dist = np.linalg.norm(neigh.position - center.position)