def test_find_match2(self): sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, primitive_cell=True, scale=True, attempt_supercell=False) l = Lattice.orthorhombic(1, 2, 3) s1 = Structure(l, ['Si', 'Si'], [[0,0,0.1],[0,0,0.2]]) s2 = Structure(l, ['Si', 'Si'], [[0,0.1,0],[0,0.1,-0.95]]) s1, s2, fu, s1_supercell = sm._preprocess(s1, s2, False) match = sm._match(s1, s2, fu, s1_supercell = False, use_rms = True, break_on_match = False) scale_matrix = match[2] s2.make_supercell(scale_matrix) s2.translate_sites(range(len(s2)), match[3]) self.assertAlmostEqual(np.sum(s2.frac_coords), 0.3) self.assertAlmostEqual(np.sum(s2.frac_coords[:,:2]), 0)
def test_find_match1(self): sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, primitive_cell=True, scale=True, attempt_supercell=False) l = Lattice.orthorhombic(1, 2, 3) s1 = Structure(l, ['Si', 'Si', 'Ag'], [[0,0,0.1],[0,0,0.2],[.7,.4,.5]]) s2 = Structure(l, ['Si', 'Si', 'Ag'], [[0,0.1,0],[0,0.1,-0.95],[.7,.5,.375]]) s1, s2, fu, s1_supercell = sm._preprocess(s1, s2, False) match = sm._match(s1, s2, fu, s1_supercell = True, use_rms = True, break_on_match = False) scale_matrix = match[2] s2.make_supercell(scale_matrix) fc = s2.frac_coords + match[3] fc -= np.round(fc) self.assertAlmostEqual(np.sum(fc), 0.9) self.assertAlmostEqual(np.sum(fc[:,:2]), 0.1) cart_dist = np.sum(match[1] * (l.volume/3) ** (1/3)) self.assertAlmostEqual(cart_dist, 0.15)