Example #1
0
    def test_lattice_points_in_supercell(self):
        supercell = np.array([[1, 3, 5], [-3, 2, 3], [-5, 3, 1]])
        points = lattice_points_in_supercell(supercell)
        self.assertAlmostEqual(len(points), abs(np.linalg.det(supercell)))
        self.assertGreaterEqual(np.min(points), -1e-10)
        self.assertLessEqual(np.max(points), 1-1e-10)

        supercell = np.array([[-5, -5, -3], [0, -4, -2], [0, -5, -2]])
        points = lattice_points_in_supercell(supercell)
        self.assertAlmostEqual(len(points), abs(np.linalg.det(supercell)))
        self.assertGreaterEqual(np.min(points), -1e-10)
        self.assertLessEqual(np.max(points), 1-1e-10)
Example #2
0
 def sc_generator(s1, s2):
     s2_fc = np.array(s2.frac_coords)
     if fu == 1:
         cc = np.array(s1.cart_coords)
         for l, sc_m in self._get_lattices(s2.lattice, s1, fu):
             fc = l.get_fractional_coords(cc)
             fc -= np.floor(fc)
             yield fc, s2_fc, av_lat(l, s2.lattice), sc_m
     else:
         fc_init = np.array(s1.frac_coords)
         for l, sc_m in self._get_lattices(s2.lattice, s1, fu):
             fc = np.dot(fc_init, np.linalg.inv(sc_m))
             lp = lattice_points_in_supercell(sc_m)
             fc = (fc[:, None, :] + lp[None, :, :]).reshape((-1, 3))
             fc -= np.floor(fc)
             yield fc, s2_fc, av_lat(l, s2.lattice), sc_m
 def sc_generator(s1, s2):
     s2_fc = np.array(s2.frac_coords)
     if fu == 1:
         cc = np.array(s1.cart_coords)
         for l, sc_m in self._get_lattices(s2.lattice, s1, fu):
             fc = l.get_fractional_coords(cc)
             fc -= np.floor(fc)
             yield fc, s2_fc, av_lat(l, s2.lattice), sc_m
     else:
         fc_init = np.array(s1.frac_coords)
         for l, sc_m in self._get_lattices(s2.lattice, s1, fu):
             fc = np.dot(fc_init, np.linalg.inv(sc_m))
             lp = lattice_points_in_supercell(sc_m)
             fc = (fc[:, None, :] + lp[None, :, :]).reshape((-1, 3))
             fc -= np.floor(fc)
             yield fc, s2_fc, av_lat(l, s2.lattice), sc_m