示例#1
0
    def test_kpath_generation(self):
        triclinic = [1, 2]
        monoclinic = range(3, 16)
        orthorhombic = range(16, 75)
        tetragonal = range(75, 143)
        rhombohedral = range(143, 168)
        hexagonal = range(168, 195)
        cubic = range(195, 231)

        species = ['K', 'La', 'Ti']
        coords = [[.345, 5, .77298], [.1345, 5.1, .77298], [.7, .8, .9]]
        for i in range(230):
            sg_num = i + 1
            if sg_num in triclinic:
                lattice = Lattice([[3.0233057319441246, 0, 0], [0, 7.9850357844548681, 0], [0, 0, 8.1136762279561818]])
            elif sg_num in monoclinic:
                lattice = Lattice.monoclinic(2, 9, 1, 99)
            elif sg_num in orthorhombic:
                lattice = Lattice.orthorhombic(2, 9, 1)
            elif sg_num in tetragonal:
                lattice = Lattice.tetragonal(2, 9)
            elif sg_num in rhombohedral:
                lattice = Lattice.hexagonal(2, 95)
            elif sg_num in hexagonal:
                lattice = Lattice.hexagonal(2, 9)
            elif sg_num in cubic:
                lattice = Lattice.cubic(2)

            struct = Structure.from_spacegroup(sg_num, lattice, species, coords)
            kpath = HighSymmKpath(struct)  # Throws error if something doesn't work, causing test to fail.

        struct_file_path = os.path.join(test_dir_structs, 'ICSD_170.cif')
        struct = Structure.from_file(struct_file_path)
        hkp = HighSymmKpath(struct)
        self.assertEqual(hkp.name, 'MCLC5')
示例#2
0
    def test_kpath_generation(self):
        triclinic = [1, 2]
        monoclinic = range(3, 16)
        orthorhombic = range(16, 75)
        tetragonal = range(75, 143)
        rhombohedral = range(143, 168)
        hexagonal = range(168, 195)
        cubic = range(195, 231)

        species = ["K", "La", "Ti"]
        coords = [[0.345, 5, 0.77298], [0.1345, 5.1, 0.77298], [0.7, 0.8, 0.9]]
        for i in range(230):
            sg_num = i + 1
            if sg_num in triclinic:
                lattice = Lattice(
                    [[3.0233057319441246, 1, 0], [0, 7.9850357844548681, 1], [0, 1.2, 8.1136762279561818]]
                )
            elif sg_num in monoclinic:
                lattice = Lattice.monoclinic(2, 9, 1, 99)
            elif sg_num in orthorhombic:
                lattice = Lattice.orthorhombic(2, 9, 1)
            elif sg_num in tetragonal:
                lattice = Lattice.tetragonal(2, 9)
            elif sg_num in rhombohedral:
                lattice = Lattice.hexagonal(2, 95)
            elif sg_num in hexagonal:
                lattice = Lattice.hexagonal(2, 9)
            elif sg_num in cubic:
                lattice = Lattice.cubic(2)

            struct = Structure.from_spacegroup(sg_num, lattice, species, coords)
            kpath = KPathSeek(struct)  # Throws error if something doesn't work, causing test to fail.
示例#3
0
 def test_kpath_generation(self):
     triclinic = [1, 2]
     monoclinic = range(3, 16)
     orthorhombic = range(16, 75)
     tetragonal = range(75, 143)
     rhombohedral = range(143, 168)
     hexagonal = range(168, 195)
     cubic = range(195, 231)
     
     species = ['K', 'La', 'Ti']
     coords = [[.345, 5, .77298], [.1345, 5.1, .77298], [.7, .8, .9]]
     for i in range(230):
         sg_num = i + 1
         if sg_num in triclinic:
             lattice = Lattice([[3.0233057319441246,0,0], [0,7.9850357844548681,0], [0,0,8.1136762279561818]])
         elif sg_num in monoclinic:
             lattice = Lattice.monoclinic(2, 9, 1, 99)
         elif sg_num in orthorhombic:
             lattice = Lattice.orthorhombic(2, 9, 1)
         elif sg_num in tetragonal:
             lattice = Lattice.tetragonal(2, 9)
         elif sg_num in rhombohedral:
             lattice = Lattice.hexagonal(2, 95)
         elif sg_num in hexagonal:
             lattice = Lattice.hexagonal(2, 9)
         elif sg_num in cubic:
             lattice = Lattice.cubic(2)
     
         struct = Structure.from_spacegroup(sg_num, lattice, species, coords)
         kpath = HighSymmKpath(struct) #Throws error if something doesn't work, causing test to fail.
示例#4
0
    def test_sulfide_type(self):
        # NaS2 -> polysulfide
        latt = Lattice.tetragonal(9.59650, 11.78850)
        species = ["Na"] * 2 + ["S"] * 2
        coords = [
            [0.00000, 0.00000, 0.17000],
            [0.27600, 0.25000, 0.12500],
            [0.03400, 0.25000, 0.29600],
            [0.14700, 0.11600, 0.40000],
        ]
        struct = Structure.from_spacegroup(122, latt, species, coords)
        self.assertEqual(sulfide_type(struct), "polysulfide")

        # NaCl type NaS -> sulfide
        latt = Lattice.cubic(5.75)
        species = ["Na", "S"]
        coords = [[0.00000, 0.00000, 0.00000], [0.50000, 0.50000, 0.50000]]
        struct = Structure.from_spacegroup(225, latt, species, coords)
        self.assertEqual(sulfide_type(struct), "sulfide")

        # Na2S2O3 -> None (sulfate)
        latt = Lattice.monoclinic(6.40100, 8.10000, 8.47400, 96.8800)
        species = ["Na"] * 2 + ["S"] * 2 + ["O"] * 3
        coords = [
            [0.29706, 0.62396, 0.08575],
            [0.37673, 0.30411, 0.45416],
            [0.52324, 0.10651, 0.21126],
            [0.29660, -0.04671, 0.26607],
            [0.17577, 0.03720, 0.38049],
            [0.38604, -0.20144, 0.33624],
            [0.16248, -0.08546, 0.11608],
        ]
        struct = Structure.from_spacegroup(14, latt, species, coords)
        self.assertEqual(sulfide_type(struct), None)

        # Na3PS3O -> sulfide
        latt = Lattice.orthorhombic(9.51050, 11.54630, 5.93230)
        species = ["Na"] * 2 + ["S"] * 2 + ["P", "O"]
        coords = [
            [0.19920, 0.11580, 0.24950],
            [0.00000, 0.36840, 0.29380],
            [0.32210, 0.36730, 0.22530],
            [0.50000, 0.11910, 0.27210],
            [0.50000, 0.29400, 0.35500],
            [0.50000, 0.30300, 0.61140],
        ]
        struct = Structure.from_spacegroup(36, latt, species, coords)
        self.assertEqual(sulfide_type(struct), "sulfide")

        # test for unphysical cells
        struct.scale_lattice(struct.volume * 10)
        self.assertEqual(sulfide_type(struct), "sulfide")
示例#5
0
    def setUp(self):
        self.lattice = Lattice.cubic(10.0)
        self.cubic = self.lattice
        self.tetragonal = Lattice.tetragonal(10, 20)
        self.orthorhombic = Lattice.orthorhombic(10, 20, 30)
        self.monoclinic = Lattice.monoclinic(10, 20, 30, 66)
        self.hexagonal = Lattice.hexagonal(10, 20)
        self.rhombohedral = Lattice.rhombohedral(10, 77)

        family_names = ["cubic", "tetragonal", "orthorhombic", "monoclinic",
                        "hexagonal", "rhombohedral"]

        self.families = {}
        for name in family_names:
            self.families[name] = getattr(self, name)
示例#6
0
    def setUp(self):
        self.lattice = Lattice.cubic(10.0)
        self.cubic = self.lattice
        self.tetragonal = Lattice.tetragonal(10, 20)
        self.orthorhombic = Lattice.orthorhombic(10, 20, 30)
        self.monoclinic = Lattice.monoclinic(10, 20, 30, 66)
        self.hexagonal = Lattice.hexagonal(10, 20)
        self.rhombohedral = Lattice.rhombohedral(10, 77)

        family_names = ["cubic", "tetragonal", "orthorhombic", "monoclinic",
                        "hexagonal", "rhombohedral"]

        self.families = {}
        for name in family_names:
            self.families[name] = getattr(self, name)
示例#7
0
 def test_from_structure(self):
     latt = Lattice.monoclinic(9.78746, 4.75058, 8.95892, 115.9693)
     structure = Structure.from_spacegroup(
         15,
         latt,
         ["Os", "O", "O"],
         [
             [0, 0.25583, 0.75],
             [0.11146, 0.46611, 0.91631],
             [0.11445, 0.04564, 0.69518],
         ],
     )
     velocities = np.random.randn(20, 3) * 0.1
     structure.add_site_property("velocities", velocities)
     ld = LammpsData.from_structure(structure=structure, ff_elements=["O", "Os", "Na"])
     i = random.randint(0, 19)
     a = latt.matrix[0]
     va = velocities[i].dot(a) / np.linalg.norm(a)
     self.assertAlmostEqual(va, ld.velocities.loc[i + 1, "vx"])
     self.assertAlmostEqual(velocities[i, 1], ld.velocities.loc[i + 1, "vy"])
     np.testing.assert_array_almost_equal(ld.masses["mass"], [22.989769, 190.23, 15.9994])
     np.testing.assert_array_equal(ld.atoms["type"], [2] * 4 + [3] * 16)