def translate_sites(self, lattice):
     s = Structure(lattice, [self.central_subsite.specie] + [site.specie for site in self.peripheral_subsites], [self.central_subsite.site.coords] + [site.site.coords for site in self.peripheral_subsites], coords_are_cartesian=True)
     trans = TranslateSitesTransformation(range(len(s)), -(lattice.get_fractional_coords(s[0].coords)))
     new_s = trans.apply_transformation(s)
     trans2 = TranslateSitesTransformation(range(len(s)), (-0.5, -0.5, -0.5))
     new_s = trans2.apply_transformation(Structure.from_sites(new_s.sites, to_unit_cell=True))
     self.peripheral_subsites = [SubStructureSite.from_coords_and_specie(site.coords, site.specie) for site in new_s.sites[1:]]
     self.central_subsite = SubStructureSite.from_coords_and_specie(new_s[0].coords, new_s[0].specie)
 def test_apply_transformation(self):
     t = TranslateSitesTransformation([0], [0.1, 0.2, 0.3])
     s = t.apply_transformation(self.struct)
     self.assertTrue(np.allclose(s[0].frac_coords, [0.1, 0.2, 0.3]))
     inv_t = t.inverse
     s = inv_t.apply_transformation(s)
     self.assertTrue(np.allclose(s[0].frac_coords, [0, 0, 0]))
 def test_apply_transformation(self):
     t = TranslateSitesTransformation([0], [0.1, 0.2, 0.3])
     s = t.apply_transformation(self.struct)
     self.assertTrue(np.allclose(s[0].frac_coords, [0.1, 0.2, 0.3]))
     inv_t = t.inverse
     s = inv_t.apply_transformation(s)
     self.assertTrue(np.allclose(s[0].frac_coords, [0, 0, 0]))
     str(t)
예제 #4
0
 def test_apply_transformation_site_by_site(self):
     t = TranslateSitesTransformation([0, 1], [[0.1, 0.2, 0.3], [-0.075, -0.075, -0.075]])
     s = t.apply_transformation(self.struct)
     self.assertTrue(np.allclose(s[0].frac_coords, [0.1, 0.2, 0.3]))
     self.assertTrue(np.allclose(s[1].frac_coords, [0.3, 0.3, 0.3]))
     inv_t = t.inverse
     s = inv_t.apply_transformation(s)
     self.assertAlmostEqual(s[0].distance_and_image_from_frac_coords([0, 0, 0])[0], 0)
     self.assertArrayAlmostEqual(s[1].frac_coords, [0.375, 0.375, 0.375])
 def test_apply_transformation(self):
     t = TranslateSitesTransformation([0, 1], [0.1, 0.2, 0.3])
     s = t.apply_transformation(self.struct)
     self.assertTrue(np.allclose(s[0].frac_coords, [0.1, 0.2, 0.3]))
     self.assertTrue(np.allclose(s[1].frac_coords, [0.475, 0.575, 0.675]))
     inv_t = t.inverse
     s = inv_t.apply_transformation(s)
     self.assertAlmostEqual(s[0].distance_and_image_from_frac_coords([0, 0, 0])[0], 0)
     self.assertTrue(np.allclose(s[1].frac_coords, [0.375, 0.375, 0.375]))
예제 #6
0
 def test_apply_transformation_site_by_site(self):
     t = TranslateSitesTransformation(
         [0, 1], [[0.1, 0.2, 0.3], [-0.075, -0.075, -0.075]])
     s = t.apply_transformation(self.struct)
     self.assertTrue(np.allclose(s[0].frac_coords, [0.1, 0.2, 0.3]))
     self.assertTrue(np.allclose(s[1].frac_coords, [0.3, 0.3, 0.3]))
     inv_t = t.inverse
     s = inv_t.apply_transformation(s)
     self.assertTrue(np.allclose(s[0].frac_coords, [0, 0, 0]))
     self.assertTrue(np.allclose(s[1].frac_coords, [0.375, 0.375, 0.375]))
     str(t)
예제 #7
0
 def test_apply_transformation_site_by_site(self):
     t = TranslateSitesTransformation([0, 1], [[0.1, 0.2, 0.3],
                                               [-0.075, -0.075, -0.075]])
     s = t.apply_transformation(self.struct)
     self.assertTrue(np.allclose(s[0].frac_coords, [0.1, 0.2, 0.3]))
     self.assertTrue(np.allclose(s[1].frac_coords, [0.3, 0.3, 0.3]))
     inv_t = t.inverse
     s = inv_t.apply_transformation(s)
     self.assertTrue(np.allclose(s[0].frac_coords, [0, 0, 0]))
     self.assertTrue(np.allclose(s[1].frac_coords, [0.375, 0.375, 0.375]))
     str(t)
예제 #8
0
def move_all_atoms(structure, disp_ion):
    """
    Create structures with displaced ions
    """
    yield 'calc_00_0', structure
    atoms = [i for i in range(len(structure))]
    for atom in atoms:
        for direction in range(3):
            displacement = [0.] * 3
            displacement[direction] = disp_ion

            for orientation in ['+', '-']:
                transform = TranslateSitesTransformation(
                    [atom], displacement, vector_in_frac_coords=True)
                structure_displaced = transform.apply_transformation(structure)
                yield 'calc_%02d_%s%d' % (atom + 1, orientation,
                                          direction + 1), structure_displaced
                displacement[direction] = -displacement[direction]