def test_previous_reconstructions(self): # Test to see if we generated all reconstruction # types correctly and nothing changes m = StructureMatcher() for n in self.rec_archive.keys(): if "base_reconstruction" in self.rec_archive[n].keys(): arch = self.rec_archive[ self.rec_archive[n]["base_reconstruction"]] sg = arch["spacegroup"]["symbol"] else: sg = self.rec_archive[n]["spacegroup"]["symbol"] if sg == "Fm-3m": rec = ReconstructionGenerator(self.Ni, 20, 20, n) el = self.Ni[0].species_string elif sg == "Im-3m": rec = ReconstructionGenerator(self.Fe, 20, 20, n) el = self.Fe[0].species_string elif sg == "Fd-3m": rec = ReconstructionGenerator(self.Si, 20, 20, n) el = self.Si[0].species_string slabs = rec.build_slabs() s = Structure.from_file(get_path(os.path.join("reconstructions", el + "_" + n + ".cif"))) self.assertTrue(any( [len(m.group_structures([s, slab])) == 1 for slab in slabs]))
def test_get_d(self): # Ensure that regardles of the size of the vacuum or slab # layer, the spacing between atomic layers should be the same recon = ReconstructionGenerator(self.Si, 10, 10, "diamond_100_2x1") recon2 = ReconstructionGenerator(self.Si, 20, 10, "diamond_100_2x1") self.assertAlmostEqual(recon.get_d(), recon2.get_d())
def test_get_d(self): # Ensure that regardles of the size of the vacuum or slab # layer, the spacing between atomic layers should be the same recon = ReconstructionGenerator(self.Si, 10, 10, "diamond_100_2x1") recon2 = ReconstructionGenerator(self.Si, 20, 10, "diamond_100_2x1") s1 = recon.get_unreconstructed_slabs()[0] s2 = recon2.get_unreconstructed_slabs()[0] self.assertAlmostEqual(get_d(s1), get_d(s2))
def test_build_slab(self): # First lets test a reconstruction where we only remove atoms recon = ReconstructionGenerator(self.Ni, 10, 10, "fcc_110_missing_row_1x2") slab = recon.get_unreconstructed_slabs()[0] recon_slab = recon.build_slabs()[0] self.assertTrue(recon_slab.reconstruction) self.assertEqual(len(slab), len(recon_slab) + 2) self.assertTrue(recon_slab.is_symmetric()) # Test if the ouc corresponds to the reconstructed slab recon_ouc = recon_slab.oriented_unit_cell ouc = slab.oriented_unit_cell self.assertEqual(ouc.lattice.b * 2, recon_ouc.lattice.b) self.assertEqual(len(ouc) * 2, len(recon_ouc)) # Test a reconstruction where we simply add atoms recon = ReconstructionGenerator(self.Ni, 10, 10, "fcc_111_adatom_t_1x1") slab = recon.get_unreconstructed_slabs()[0] recon_slab = recon.build_slabs()[0] self.assertEqual(len(slab), len(recon_slab) - 2) self.assertTrue(recon_slab.is_symmetric()) # If a slab references another slab, # make sure it is properly generated recon = ReconstructionGenerator(self.Ni, 10, 10, "fcc_111_adatom_ft_1x1") slab = recon.build_slabs()[0] self.assertTrue(slab.is_symmetric) # Test a reconstruction where it works on a specific # termination (Fd-3m (111)) recon = ReconstructionGenerator(self.Si, 10, 10, "diamond_111_1x2") slab = recon.get_unreconstructed_slabs()[0] recon_slab = recon.build_slabs()[0] self.assertEqual(len(slab), len(recon_slab) - 8) self.assertTrue(recon_slab.is_symmetric())
def test_build_slab(self): # First lets test a reconstruction where we only remove atoms recon = ReconstructionGenerator(self.Ni, 10, 10, "fcc_110_missing_row_1x2") slab = recon.get_unreconstructed_slab() recon_slab = recon.build_slab() self.assertTrue(recon_slab.reconstruction) self.assertEqual(len(slab), len(recon_slab) + 2) self.assertTrue(recon_slab.is_symmetric()) # Test a reconstruction where we simply add atoms recon = ReconstructionGenerator(self.Ni, 10, 10, "fcc_111_adatom_t_1x1") slab = recon.get_unreconstructed_slab() recon_slab = recon.build_slab() self.assertEqual(len(slab), len(recon_slab) - 2) self.assertTrue(recon_slab.is_symmetric()) # If a slab references another slab, # make sure it is properly generated recon = ReconstructionGenerator(self.Ni, 10, 10, "fcc_111_adatom_ft_1x1") slab = recon.build_slab() self.assertTrue(slab.is_symmetric) # Test a reconstruction where it works on a specific # termination (Fd-3m (111)) recon = ReconstructionGenerator(self.Si, 10, 10, "diamond_111_1x2") slab = recon.get_unreconstructed_slab() recon_slab = recon.build_slab() self.assertEqual(len(slab), len(recon_slab) - 8) self.assertTrue(recon_slab.is_symmetric())