def setUp(self):
     self.silicon = Structure(
         Lattice.from_lengths_and_angles([5.47, 5.47, 5.47],
                                         [90.0, 90.0, 90.0]),
         ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"],
         [[0.000000, 0.000000, 0.500000], [0.750000, 0.750000, 0.750000],
          [0.000000, 0.500000, 1.000000], [0.750000, 0.250000, 0.250000],
          [0.500000, 0.000000, 1.000000], [0.250000, 0.750000, 0.250000],
          [0.500000, 0.500000, 0.500000], [0.250000, 0.250000, 0.750000]],
         validate_proximity=False,
         to_unit_cell=False,
         coords_are_cartesian=False,
         site_properties=None)
     self.smi = StructureMotifInterstitial(self.silicon,
                                           "Si",
                                           motif_types=["tet", "oct"],
                                           op_threshs=[0.3, 0.5],
                                           dl=0.4,
                                           doverlap=1.0,
                                           facmaxdl=1.01)
     self.diamond = Structure(
         Lattice([[2.189, 0, 1.264], [0.73, 2.064, 1.264], [0, 0, 2.528]]),
         ["C0+", "C0+"], [[2.554, 1.806, 4.423], [0.365, 0.258, 0.632]],
         validate_proximity=False,
         to_unit_cell=False,
         coords_are_cartesian=True,
         site_properties=None)
     self.nacl = Structure(Lattice([[3.485, 0,
                                     2.012], [1.162, 3.286, 2.012],
                                    [0, 0, 4.025]]), ["Na1+", "Cl1-"],
                           [[0, 0, 0], [2.324, 1.643, 4.025]],
                           validate_proximity=False,
                           to_unit_cell=False,
                           coords_are_cartesian=True,
                           site_properties=None)
     self.cscl = Structure(Lattice([[4.209, 0, 0], [0, 4.209, 0],
                                    [0, 0, 4.209]]), ["Cl1-", "Cs1+"],
                           [[2.105, 2.105, 2.105], [0, 0, 0]],
                           validate_proximity=False,
                           to_unit_cell=False,
                           coords_are_cartesian=True,
                           site_properties=None)
     self.square_pyramid = Structure(
         Lattice([[100, 0, 0], [0, 100, 0], [0, 0, 100]]),
         ["C", "C", "C", "C", "C", "C"], [
         [0, 0, 0], [1, 0, 0], [-1, 0, 0], [0, 1, 0], [0, -1, 0], \
         [0, 0, 1]], validate_proximity=False, to_unit_cell=False,
         coords_are_cartesian=True, site_properties=None)
     self.trigonal_bipyramid = Structure(
         Lattice([[100, 0, 0], [0, 100, 0], [0, 0, 100]]),
         ["P", "Cl", "Cl", "Cl", "Cl", "Cl"], [
         [0, 0, 0], [0, 0, 2.14], [0, 2.02, 0], [1.74937, -1.01, 0], \
         [-1.74937, -1.01, 0], [0, 0, -2.14]], validate_proximity=False,
         to_unit_cell=False, coords_are_cartesian=True,
         site_properties=None)
 def setUp(self):
     self.silicon = Structure(
         Lattice.from_lengths_and_angles([5.47, 5.47, 5.47], [90.0, 90.0, 90.0]),
         ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"],
         [
             [0.000000, 0.000000, 0.500000],
             [0.750000, 0.750000, 0.750000],
             [0.000000, 0.500000, 1.000000],
             [0.750000, 0.250000, 0.250000],
             [0.500000, 0.000000, 1.000000],
             [0.250000, 0.750000, 0.250000],
             [0.500000, 0.500000, 0.500000],
             [0.250000, 0.250000, 0.750000],
         ],
         validate_proximity=False,
         to_unit_cell=False,
         coords_are_cartesian=False,
         site_properties=None,
     )
     self.smi = StructureMotifInterstitial(
         self.silicon,
         "Si",
         motif_types=["tet", "oct", "tetoct"],
         op_targets=[1.0, 1.0, 1.0],
         op_threshs=[0.5, 0.5, 0.5],
         dl=0.4,
         fac_max_radius=2.5,
         drel_overlap=0.5,
         write_timings=False,
     )
 def setUp(self):
     self.silicon = Structure(
         Lattice.from_lengths_and_angles([5.47, 5.47, 5.47],
                                         [90.0, 90.0, 90.0]),
         ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"],
         [[0.000000, 0.000000, 0.500000], [0.750000, 0.750000, 0.750000],
          [0.000000, 0.500000, 1.000000], [0.750000, 0.250000, 0.250000],
          [0.500000, 0.000000, 1.000000], [0.250000, 0.750000, 0.250000],
          [0.500000, 0.500000, 0.500000], [0.250000, 0.250000, 0.750000]],
         validate_proximity=False,
         to_unit_cell=False,
         coords_are_cartesian=False,
         site_properties=None)
     self.smi = StructureMotifInterstitial(self.silicon,
                                           "Si",
                                           motif_types=["tet", "oct"],
                                           op_threshs=[0.3, 0.5],
                                           dl=0.4,
                                           doverlap=1.0,
                                           facmaxdl=1.01)
 def setUp(self):
     self.silicon = Structure(
             Lattice.from_lengths_and_angles(
                     [5.47, 5.47, 5.47],
                     [90.0, 90.0, 90.0]),
             ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"],
             [[0.000000, 0.000000, 0.500000],
             [0.750000, 0.750000, 0.750000],
             [0.000000, 0.500000, 1.000000],
             [0.750000, 0.250000, 0.250000],
             [0.500000, 0.000000, 1.000000],
             [0.250000, 0.750000, 0.250000],
             [0.500000, 0.500000, 0.500000],
             [0.250000, 0.250000, 0.750000]],
             validate_proximity=False, to_unit_cell=False,
             coords_are_cartesian=False, site_properties=None)
     self.smi = StructureMotifInterstitial(self.silicon, "Si",
             motif_types=["tet", "oct"],
             op_threshs=[0.3, 0.5],
             dl=0.4, doverlap=1.0, facmaxdl=1.01)
     self.diamond = Structure(
         Lattice([[2.189, 0, 1.264], [0.73, 2.064, 1.264],
                  [0, 0, 2.528]]), ["C0+", "C0+"], [[2.554, 1.806, 4.423],
                                                    [0.365, 0.258, 0.632]],
         validate_proximity=False,
         to_unit_cell=False, coords_are_cartesian=True,
         site_properties=None)
     self.nacl = Structure(
         Lattice([[3.485, 0, 2.012], [1.162, 3.286, 2.012],
                  [0, 0, 4.025]]), ["Na1+", "Cl1-"], [[0, 0, 0],
                                                      [2.324, 1.643, 4.025]],
         validate_proximity=False,
         to_unit_cell=False, coords_are_cartesian=True,
         site_properties=None)
     self.cscl = Structure(
         Lattice([[4.209, 0, 0], [0, 4.209, 0], [0, 0, 4.209]]),
         ["Cl1-", "Cs1+"], [[2.105, 2.105, 2.105], [0, 0, 0]],
         validate_proximity=False, to_unit_cell=False,
         coords_are_cartesian=True, site_properties=None)
     self.square_pyramid = Structure(
         Lattice([[100, 0, 0], [0, 100, 0], [0, 0, 100]]),
         ["C", "C", "C", "C", "C", "C"], [
         [0, 0, 0], [1, 0, 0], [-1, 0, 0], [0, 1, 0], [0, -1, 0], \
         [0, 0, 1]], validate_proximity=False, to_unit_cell=False,
         coords_are_cartesian=True, site_properties=None)
     self.trigonal_bipyramid = Structure(
         Lattice([[100, 0, 0], [0, 100, 0], [0, 0, 100]]),
         ["P", "Cl", "Cl", "Cl", "Cl", "Cl"], [
         [0, 0, 0], [0, 0, 2.14], [0, 2.02, 0], [1.74937, -1.01, 0], \
         [-1.74937, -1.01, 0], [0, 0, -2.14]], validate_proximity=False,
         to_unit_cell=False, coords_are_cartesian=True,
         site_properties=None)
class StructureMotifInterstitialTest(PymatgenTest):
    def setUp(self):
        self.silicon = Structure(
            Lattice.from_lengths_and_angles([5.47, 5.47, 5.47], [90.0, 90.0, 90.0]),
            ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"],
            [
                [0.000000, 0.000000, 0.500000],
                [0.750000, 0.750000, 0.750000],
                [0.000000, 0.500000, 1.000000],
                [0.750000, 0.250000, 0.250000],
                [0.500000, 0.000000, 1.000000],
                [0.250000, 0.750000, 0.250000],
                [0.500000, 0.500000, 0.500000],
                [0.250000, 0.250000, 0.750000],
            ],
            validate_proximity=False,
            to_unit_cell=False,
            coords_are_cartesian=False,
            site_properties=None,
        )
        self.smi = StructureMotifInterstitial(
            self.silicon,
            "Si",
            motif_types=["tet", "oct", "tetoct"],
            op_targets=[1.0, 1.0, 1.0],
            op_threshs=[0.5, 0.5, 0.5],
            dl=0.4,
            fac_max_radius=2.5,
            drel_overlap=0.5,
            write_timings=False,
        )

    def test_all(self):
        self.assertIsInstance(self.smi, StructureMotifInterstitial)

        self.assertEqual(len(self.smi.enumerate_defectsites()), 1)
        self.assertIsInstance(self.smi.enumerate_defectsites()[0], PeriodicSite)
        self.assertEqual("Si", self.smi.enumerate_defectsites()[0].species_string)

        self.assertEqual("tet", self.smi.get_motif_type(0))

        elem_cn_dict = self.smi.get_coordinating_elements_cns(0)
        self.assertEqual(len(list(elem_cn_dict.keys())), 1)
        self.assertEqual(list(elem_cn_dict.keys())[0], "Si")
        self.assertEqual(elem_cn_dict["Si"], 4)

        structs = self.smi.make_supercells_with_defects(np.array([1, 1, 1]))
        self.assertEqual(len(structs), 2)
        self.assertIsInstance(structs[0], Structure)

    def tearDown(self):
        del self.smi
        del self.silicon
Beispiel #6
0
class StructureMotifInterstitialTest(PymatgenTest):
    def setUp(self):
        self.silicon = Structure(
            Lattice.from_lengths_and_angles([5.47, 5.47, 5.47],
                                            [90.0, 90.0, 90.0]),
            ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"],
            [[0.000000, 0.000000, 0.500000], [0.750000, 0.750000, 0.750000],
             [0.000000, 0.500000, 1.000000], [0.750000, 0.250000, 0.250000],
             [0.500000, 0.000000, 1.000000], [0.250000, 0.750000, 0.250000],
             [0.500000, 0.500000, 0.500000], [0.250000, 0.250000, 0.750000]],
            validate_proximity=False,
            to_unit_cell=False,
            coords_are_cartesian=False,
            site_properties=None)
        self.smi = StructureMotifInterstitial(
            self.silicon,
            "Si",
            motif_types=["tet", "oct", "tetoct"],
            op_targets=[1.0, 1.0, 1.0],
            op_threshs=[0.5, 0.5, 0.5],
            dl=0.4,
            fac_max_radius=2.5,
            drel_overlap=0.5,
            write_timings=False)

    def test_all(self):
        self.assertIsInstance(self.smi, StructureMotifInterstitial)

        self.assertEqual(len(self.smi.enumerate_defectsites()), 1)
        self.assertIsInstance(self.smi.enumerate_defectsites()[0],
                              PeriodicSite)
        self.assertEqual("Si",
                         self.smi.enumerate_defectsites()[0].species_string)

        self.assertEqual("tet", self.smi.get_motif_type(0))

        elem_cn_dict = self.smi.get_coordinating_elements_cns(0)
        self.assertEqual(len(list(elem_cn_dict.keys())), 1)
        self.assertEqual(list(elem_cn_dict.keys())[0], "Si")
        self.assertEqual(elem_cn_dict["Si"], 4)

        structs = self.smi.make_supercells_with_defects(np.array([1, 1, 1]))
        self.assertEqual(len(structs), 2)
        self.assertIsInstance(structs[0], Structure)

    def tearDown(self):
        del self.smi
        del self.silicon
class StructureMotifInterstitialTest(PymatgenTest):

    def setUp(self):
        self.silicon = Structure(
                Lattice.from_lengths_and_angles(
                        [5.47, 5.47, 5.47],
                        [90.0, 90.0, 90.0]),
                ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"],
                [[0.000000, 0.000000, 0.500000],
                [0.750000, 0.750000, 0.750000],
                [0.000000, 0.500000, 1.000000],
                [0.750000, 0.250000, 0.250000],
                [0.500000, 0.000000, 1.000000],
                [0.250000, 0.750000, 0.250000],
                [0.500000, 0.500000, 0.500000],
                [0.250000, 0.250000, 0.750000]],
                validate_proximity=False, to_unit_cell=False,
                coords_are_cartesian=False, site_properties=None)
        self.smi = StructureMotifInterstitial(self.silicon, "Si",
                motif_types=["tet", "oct"],
                op_threshs=[0.3, 0.5],
                dl=0.4, doverlap=1.0, facmaxdl=1.01)
        self.diamond = Structure(
            Lattice([[2.189, 0, 1.264], [0.73, 2.064, 1.264],
                     [0, 0, 2.528]]), ["C0+", "C0+"], [[2.554, 1.806, 4.423],
                                                       [0.365, 0.258, 0.632]],
            validate_proximity=False,
            to_unit_cell=False, coords_are_cartesian=True,
            site_properties=None)
        self.nacl = Structure(
            Lattice([[3.485, 0, 2.012], [1.162, 3.286, 2.012],
                     [0, 0, 4.025]]), ["Na1+", "Cl1-"], [[0, 0, 0],
                                                         [2.324, 1.643, 4.025]],
            validate_proximity=False,
            to_unit_cell=False, coords_are_cartesian=True,
            site_properties=None)
        self.cscl = Structure(
            Lattice([[4.209, 0, 0], [0, 4.209, 0], [0, 0, 4.209]]),
            ["Cl1-", "Cs1+"], [[2.105, 2.105, 2.105], [0, 0, 0]],
            validate_proximity=False, to_unit_cell=False,
            coords_are_cartesian=True, site_properties=None)
        self.square_pyramid = Structure(
            Lattice([[100, 0, 0], [0, 100, 0], [0, 0, 100]]),
            ["C", "C", "C", "C", "C", "C"], [
            [0, 0, 0], [1, 0, 0], [-1, 0, 0], [0, 1, 0], [0, -1, 0], \
            [0, 0, 1]], validate_proximity=False, to_unit_cell=False,
            coords_are_cartesian=True, site_properties=None)
        self.trigonal_bipyramid = Structure(
            Lattice([[100, 0, 0], [0, 100, 0], [0, 0, 100]]),
            ["P", "Cl", "Cl", "Cl", "Cl", "Cl"], [
            [0, 0, 0], [0, 0, 2.14], [0, 2.02, 0], [1.74937, -1.01, 0], \
            [-1.74937, -1.01, 0], [0, 0, -2.14]], validate_proximity=False,
            to_unit_cell=False, coords_are_cartesian=True,
            site_properties=None)


    def test_all(self):
        self.assertIsInstance(self.smi, StructureMotifInterstitial)

        self.assertEqual(len(self.smi.enumerate_defectsites()), 1)
        self.assertIsInstance(self.smi.enumerate_defectsites()[0], PeriodicSite)
        self.assertEqual("Si", self.smi.enumerate_defectsites()[0].species_string)

        self.assertEqual("tet", self.smi.get_motif_type(0))

        elem_cn_dict = self.smi.get_coordinating_elements_cns(0)
        self.assertEqual(len(list(elem_cn_dict.keys())), 1)
        self.assertEqual(list(elem_cn_dict.keys())[0], "Si")
        self.assertEqual(elem_cn_dict["Si"], 4)

        structs = self.smi.make_supercells_with_defects(np.array([1, 1, 1]))
        self.assertEqual(len(structs), 2)
        self.assertIsInstance(structs[0], Structure)

    def test_get_neighbors_of_site_with_index(self):
        self.assertAlmostEqual(len(get_neighbors_of_site_with_index(
            self.diamond, 0)), 4)
        self.assertAlmostEqual(len(get_neighbors_of_site_with_index(
            self.nacl, 0)), 6)
        self.assertAlmostEqual(len(get_neighbors_of_site_with_index(
            self.cscl, 0)), 8)

    def test_site_is_of_motif_type(self):
        for i in range(self.diamond.num_sites):
            self.assertEqual(site_is_of_motif_type(
                    self.diamond, i), "tetrahedral")
        for i in range(self.nacl.num_sites):
            self.assertEqual(site_is_of_motif_type(
                    self.nacl, i), "octahedral")
        for i in range(self.cscl.num_sites):
            self.assertEqual(site_is_of_motif_type(
                    self.cscl, i), "bcc")
        self.assertEqual(site_is_of_motif_type(
                self.square_pyramid, 0), "square pyramidal")
        for i in range(1, self.square_pyramid.num_sites):
            self.assertEqual(site_is_of_motif_type(
                    self.square_pyramid, i), "unrecognized")
        self.assertEqual(site_is_of_motif_type(
                self.trigonal_bipyramid, 0), "trigonal bipyramidal")
        for i in range(1, self.trigonal_bipyramid.num_sites):
            self.assertEqual(site_is_of_motif_type(
                    self.trigonal_bipyramid, i), "unrecognized")


    def tearDown(self):
        del self.smi
        del self.silicon
        del self.diamond
        del self.nacl
        del self.cscl