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


Python Kpoints.from_string方法代码示例

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


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

示例1: test_static_constructors

# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_string [as 别名]
    def test_static_constructors(self):
        kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        self.assertEqual(kpoints.kpts, [[3, 3, 3]])
        kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
        self.assertEqual(kpoints.kpts, [[2, 2, 2]])
        kpoints = Kpoints.automatic(100)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic)
        self.assertEqual(kpoints.kpts, [[100]])
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        kpoints = Kpoints.automatic_density(poscar.structure, 500)
        self.assertEqual(kpoints.kpts, [[1, 3, 3]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density(poscar.structure, 500, True)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000)
        self.assertEqual(kpoints.kpts, [[6, 10, 13]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)

        s = poscar.structure
        s.make_supercell(3)
        kpoints = Kpoints.automatic_density(s, 500)
        self.assertEqual(kpoints.kpts, [[1, 1, 1]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.from_string("""k-point mesh 
0
G
10 10 10
0.5 0.5 0.5
""")
        self.assertArrayAlmostEqual(kpoints.kpts_shift, [0.5, 0.5, 0.5])
开发者ID:ExpHP,项目名称:pymatgen,代码行数:35,代码来源:test_inputs.py

示例2: get_kpoints

# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_string [as 别名]
def get_kpoints(structure, min_distance=0, min_total_kpoints=1, 
                kppra=None, gap_distance=7, remove_symmetry=None, 
                include_gamma="auto", header="simple", incar=None):
    """
    Get kpoints object from JHU servlet, per Wisesa-McGill-Mueller
    methodology.  Refer to http://muellergroup.jhu.edu/K-Points.html
    and P. Wisesa, K. A. McGill, T. Mueller, Phys. Rev. B 93, 
    155109 (2016)

    Args:
        structure (Structure): structure object
        min_distance (float): The minimum allowed distance 
            between lattice points on the real-space superlattice 
        min_total_kpoints (int): The minimum allowed number of 
            total k-points in the Brillouin zone.
        kppra (float): minimum k-points per reciprocal atom.
        gap_distance (float): auto-detection threshold for
            non-periodicity (in slabs, nanowires, etc.)
        remove_symmetry (string): optional flag to control
            symmetry options, can be none, structural, 
            time_reversal, or all
        include_gamma (string or bool): whether to include
            gamma point
        header (string): "verbose" or "simple", denotes
            the verbosity of the header
        incar (Incar): incar object to upload
    """
    config = locals()
    config.pop("structure", "incar")

    # Generate PRECALC string
    precalc = ''.join(["{}={}\n".format(k, v) for k, v in config.items()])
    precalc = precalc.replace('_', '').upper()
    precalc = precalc.replace('REMOVESYMMETRY', 'REMOVE_SYMMETRY')
    precalc = precalc.replace('TIMEREVERSAL', 'TIME_REVERSAL')
    url = "http://muellergroup.jhu.edu:8080/PreCalcServer/PreCalcServlet"
    temp_dir_name = tempfile.mkdtemp()
    cwd = os.getcwd()
    os.chdir(temp_dir_name)

    precalc_file = open("PRECALC", 'w+')
    poscar_file = open("POSCAR", 'w+')
    incar_file = open("INCAR", 'w+')
    
    precalc_file.write(precalc)
    poscar_file.write(structure.to("POSCAR"))
    files = [("fileupload", precalc_file),
             ("fileupload", poscar_file)]
    if incar:
        incar_file.write(incar.get_string())
        files.append(("fileupload", incar_file))
    
    precalc_file.seek(0)
    poscar_file.seek(0)
    incar_file.seek(0)
    
    r = requests.post(url, files=files)
    
    precalc_file.close()
    poscar_file.close()
    incar_file.close()
    kpoints = Kpoints.from_string(r.text)
    os.chdir(cwd)

    shutil.rmtree(temp_dir_name)

    return kpoints
开发者ID:ExpHP,项目名称:pymatgen,代码行数:69,代码来源:jhu.py


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