Example #1
0
    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
                ]))
Example #2
0
    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]))
Example #3
0
    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())
Example #4
0
    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())