当前位置: 首页>>代码示例>>Python>>正文


Python Lattice.tetragonal方法代码示例

本文整理汇总了Python中pymatgen.Lattice.tetragonal方法的典型用法代码示例。如果您正苦于以下问题:Python Lattice.tetragonal方法的具体用法?Python Lattice.tetragonal怎么用?Python Lattice.tetragonal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymatgen.Lattice的用法示例。


在下文中一共展示了Lattice.tetragonal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from pymatgen import Lattice [as 别名]
# 或者: from pymatgen.Lattice import tetragonal [as 别名]
    def setUp(self):

        # trivial example, simple square lattice for testing
        structure = Structure(Lattice.tetragonal(5.0, 50.0), ['H'], [[0, 0, 0]])
        self.square_sg = StructureGraph.with_empty_graph(structure, edge_weight_name="", edge_weight_units="")
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(1, 0, 0))
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, 1, 0))
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))

        # body-centered square lattice for testing
        structure = Structure(Lattice.tetragonal(5.0, 50.0), ['H', 'He'], [[0, 0, 0], [0.5, 0.5, 0.5]])
        self.bc_square_sg = StructureGraph.with_empty_graph(structure, edge_weight_name="", edge_weight_units="")
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(1, 0, 0))
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, 1, 0))
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(-1, -1, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))

        # body-centered square lattice for testing
        # directions reversed, should be equivalent to as bc_square
        structure = Structure(Lattice.tetragonal(5.0, 50.0), ['H', 'He'], [[0, 0, 0], [0.5, 0.5, 0.5]])
        self.bc_square_sg_r = StructureGraph.with_empty_graph(structure, edge_weight_name="", edge_weight_units="")
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(1, 0, 0))
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, 1, 0))
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))
        self.bc_square_sg_r.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg_r.add_edge(1, 0, from_jimage=(-1, 0, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg_r.add_edge(1, 0, from_jimage=(-1, -1, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg_r.add_edge(1, 0, from_jimage=(0, -1, 0), to_jimage=(0, 0, 0))

        # MoS2 example, structure graph obtained from critic2
        # (not ground state, from mp-1023924, single layer)
        stdout_file = os.path.join(os.path.dirname(__file__), "..", "..", "..",
                                   'test_files/critic2/MoS2_critic2_stdout.txt')
        with open(stdout_file, 'r') as f:
            reference_stdout = f.read()
        self.structure = Structure.from_file(os.path.join(os.path.dirname(__file__), "..", "..", "..",
                                             'test_files/critic2/MoS2.cif'))
        c2o = Critic2Output(self.structure, reference_stdout)
        self.mos2_sg = c2o.structure_graph(edge_weight="bond_length", edge_weight_units="Å")

        latt = Lattice.cubic(4.17)
        species = ["Ni", "O"]
        coords = [[0, 0, 0],
                  [0.5, 0.5, 0.5]]
        self.NiO = Structure.from_spacegroup(225, latt, species, coords).get_primitive_structure()
开发者ID:matk86,项目名称:pymatgen,代码行数:53,代码来源:test_graphs.py

示例2: test_lattice_2_lmpbox

# 需要导入模块: from pymatgen import Lattice [as 别名]
# 或者: from pymatgen.Lattice import tetragonal [as 别名]
 def test_lattice_2_lmpbox(self):
     matrix = np.diag(np.random.randint(5, 14, size=(3,))) \
              + np.random.rand(3, 3) * 0.2 - 0.1
     init_latt = Lattice(matrix)
     frac_coords = np.random.rand(10, 3)
     init_structure = Structure(init_latt, ["H"] * 10, frac_coords)
     origin = np.random.rand(3) * 10 - 5
     box, symmop = lattice_2_lmpbox(lattice=init_latt, origin=origin)
     boxed_latt = box.to_lattice()
     np.testing.assert_array_almost_equal(init_latt.abc, boxed_latt.abc)
     np.testing.assert_array_almost_equal(init_latt.angles,
                                          boxed_latt.angles)
     cart_coords = symmop.operate_multi(init_structure.cart_coords) \
                   - origin
     boxed_structure = Structure(boxed_latt, ["H"] * 10, cart_coords,
                                 coords_are_cartesian=True)
     np.testing.assert_array_almost_equal(boxed_structure.frac_coords,
                                          frac_coords)
     tetra_latt = Lattice.tetragonal(5, 5)
     tetra_box, _ = lattice_2_lmpbox(tetra_latt)
     self.assertIsNone(tetra_box.tilt)
     ortho_latt = Lattice.orthorhombic(5, 5, 5)
     ortho_box, _ = lattice_2_lmpbox(ortho_latt)
     self.assertIsNone(ortho_box.tilt)
     rot_tetra_latt = Lattice([[5, 0, 0], [0, 2, 2], [0, -2, 2]])
     _, rotop = lattice_2_lmpbox(rot_tetra_latt)
     np.testing.\
         assert_array_almost_equal(rotop.rotation_matrix,
                                   [[1, 0, 0],
                                    [0, 2 ** 0.5 / 2, 2 ** 0.5 / 2],
                                    [0, -2 ** 0.5 / 2, 2 ** 0.5 / 2]])
开发者ID:ExpHP,项目名称:pymatgen,代码行数:33,代码来源:test_data.py

示例3: test_sulfide_type

# 需要导入模块: from pymatgen import Lattice [as 别名]
# 或者: from pymatgen.Lattice import tetragonal [as 别名]
    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")
开发者ID:adengz,项目名称:pymatgen,代码行数:49,代码来源:test_structure_analyzer.py


注:本文中的pymatgen.Lattice.tetragonal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。