def apply_transformation(self, structure, matrix): """ Make a supercell of structure using matrix Args: structure (Slab): Slab to make supercell of matrix (3x3 np.ndarray): supercell matrix Returns: (Slab) The supercell of structure """ modified_substrate_structure = structure.copy() # Apply scaling modified_substrate_structure.make_supercell(matrix) # Reduce vectors new_lattice = modified_substrate_structure.lattice.matrix.copy() new_lattice[:2, :] = reduce_vectors( *modified_substrate_structure.lattice.matrix[:2, :]) modified_substrate_structure = Slab( lattice=Lattice(new_lattice), species=modified_substrate_structure.species, coords=modified_substrate_structure.cart_coords, miller_index=modified_substrate_structure.miller_index, oriented_unit_cell=modified_substrate_structure.oriented_unit_cell, shift=modified_substrate_structure.shift, scale_factor=modified_substrate_structure.scale_factor, coords_are_cartesian=True, energy=modified_substrate_structure.energy, reorient_lattice=modified_substrate_structure.reorient_lattice, to_unit_cell=True) return modified_substrate_structure
def runTest(self): # Film VO2 film = SpacegroupAnalyzer(self.get_structure("VO2"), symprec=0.1).get_conventional_standard_structure() # Substrate TiO2 substrate = SpacegroupAnalyzer(self.get_structure("TiO2"), symprec=0.1).get_conventional_standard_structure() z = ZSLGenerator(film, substrate) self.assertAlmostEqual(fast_norm([3, 2, 1]), 3.7416573867739413) self.assertArrayEqual(reduce_vectors([1, 0, 0], [2, 2, 0]), [[1, 0, 0], [0, 2, 0]]) self.assertEqual(vec_area([1, 0, 0], [0, 2, 0]), 2) self.assertArrayEqual(list(get_factors(18)), [1, 2, 3, 6, 9, 18]) self.assertTrue(z.is_same_vectors([[1.01, 0, 0], [0, 2, 0]], [[1, 0, 0], [0, 2.01, 0]])) self.assertFalse(z.is_same_vectors([[1.01, 2, 0], [0, 2, 0]], [[1, 0, 0], [0, 2.01, 0]])) matches = list(z.generate()) self.assertEqual(len(matches), 82)
def get_shear_reduced_slab(slab): """ Reduce the vectors of the slab plane according to the algorithm in substrate_analyzer, then make a new Slab with a Lattice with those reduced vectors. Args: slab (Slab): Slab to reduce Returns: Slab object of identical structure to the input slab but rduced in-plane lattice vectors """ original_vectors = [slab.lattice.matrix[0], slab.lattice.matrix[1]] reduced_vectors = reduce_vectors(slab.lattice.matrix[0], slab.lattice.matrix[1]) new_lattice = Lattice( [reduced_vectors[0], reduced_vectors[1], slab.lattice.matrix[2]]) return Slab(lattice=new_lattice, species=slab.species, coords=slab.cart_coords, miller_index=slab.miller_index, oriented_unit_cell=slab.oriented_unit_cell, shift=slab.shift, scale_factor=slab.scale_factor, coords_are_cartesian=True, energy=slab.energy, reorient_lattice=slab.reorient_lattice, to_unit_cell=True)
def runTest(self): # Film VO2 film = SpacegroupAnalyzer( self.get_structure("VO2"), symprec=0.1).get_conventional_standard_structure() # Substrate TiO2 substrate = SpacegroupAnalyzer( self.get_structure("TiO2"), symprec=0.1).get_conventional_standard_structure() z = ZSLGenerator() self.assertAlmostEqual(fast_norm([3, 2, 1]), 3.7416573867739413) self.assertArrayEqual(reduce_vectors([1, 0, 0], [2, 2, 0]), [[1, 0, 0], [0, 2, 0]]) self.assertEqual(vec_area([1, 0, 0], [0, 2, 0]), 2) self.assertArrayEqual(list(get_factors(18)), [1, 2, 3, 6, 9, 18]) self.assertTrue( z.is_same_vectors([[1.01, 0, 0], [0, 2, 0]], [[1, 0, 0], [0, 2.01, 0]])) self.assertFalse( z.is_same_vectors([[1.01, 2, 0], [0, 2, 0]], [[1, 0, 0], [0, 2.01, 0]])) matches = list(z.generate(film, substrate)) self.assertEqual(len(matches), 82)