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


Python Poscar.from_string方法代码示例

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


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

示例1: strout2poscar

# 需要导入模块: from pymatgen.io.vaspio import Poscar [as 别名]
# 或者: from pymatgen.io.vaspio.Poscar import from_string [as 别名]
    def strout2poscar(src='str.out'):
        """
        str.outをposcarの記述に変換し, Poscar objをreturn
        """
        with open(src, 'r') as rfile:
            lines = rfile.readlines()
        latt_tmp = [[float(x) for x in y.split()] for y in lines[0:3]]
        trans = [[float(x) for x in y.split()] for y in lines[3:6]]
        sites_tmp = [[float(x) for x in y.split()[0:3]] for y in lines[6:]]
        elements = [x.split()[3].split('+')[0].split('-')[0] for x in lines[6:]]
        num_atoms = [elements.count(e)
                     for e in sorted(set(elements), key=elements.index)]
        latt = np.dot(np.array(trans), np.array(latt_tmp))
        sites = np.dot(np.array(sites_tmp), np.array(latt_tmp))

        posc_str = "posc_orig\n"
        posc_str += "1.00\n"
        posc_str += "\n".join(["  ".join([str(f) for f in l]) for l in latt])
        posc_str += "\n"
        posc_str += "  ".join(sorted(set(elements), key=elements.index)) + "\n"
        posc_str += "  ".join([str(d) for d in num_atoms]) + "\n"
        posc_str += "Cartesian\n"
        posc_str += "\n".join(["  ".join([str(f) for f in s]) for s in sites])

        return Poscar.from_string(posc_str)
开发者ID:hackberry-tree,项目名称:00_workSpace,代码行数:27,代码来源:parse_atat.py

示例2: test_init

# 需要导入模块: from pymatgen.io.vaspio import Poscar [as 别名]
# 或者: from pymatgen.io.vaspio.Poscar import from_string [as 别名]
    def test_init(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        comp = poscar.struct.composition
        self.assertEqual(comp, Composition.from_formula("Fe4P4O16"))

        #Vasp 4 type with symbols at the end.
        poscar_string = """Test1
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
direct
0.000000 0.000000 0.000000 Si
0.750000 0.500000 0.750000 F"""
        poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.struct.composition, Composition.from_formula("SiF"))

        #Vasp 4 tyle file with default names, i.e. no element symbol found.
        poscar_string = """Test2
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
direct
0.000000 0.000000 0.000000
0.750000 0.500000 0.750000"""
        poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.struct.composition, Composition.from_formula("HHe"))

        #Vasp 4 tyle file with default names, i.e. no element symbol found.
        poscar_string = """Test3
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
Selective dynamics
direct
0.000000 0.000000 0.000000 T T T Si
0.750000 0.500000 0.750000 F F F O"""
        poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.selective_dynamics, [[True, True, True], [False, False, False]])
开发者ID:chenweis,项目名称:pymatgen,代码行数:47,代码来源:test_vaspio.py

示例3: from_poscar_string

# 需要导入模块: from pymatgen.io.vaspio import Poscar [as 别名]
# 或者: from pymatgen.io.vaspio.Poscar import from_string [as 别名]
    def from_poscar_string(poscar_string, transformations=[]):
        """
        Generates TransformedStructure from a poscar string. 

        Args:
            poscar_string:
                Input POSCAR string.
        """
        p = Poscar.from_string(poscar_string)
        if not p.true_names:
            raise ValueError("Transformation can be craeted only from POSCAR strings with proper VASP5 element symbols.")
        raw_string = re.sub("'", "\"", poscar_string)
        s = p.struct
        source_info = {'source': "uploaded POSCAR", 'datetime':str(datetime.datetime.now()), 'original_file':raw_string}
        return TransformedStructure(s, transformations, [source_info])
开发者ID:chenweis,项目名称:pymatgen,代码行数:17,代码来源:materials.py

示例4: get_minkowski_red

# 需要导入模块: from pymatgen.io.vaspio import Poscar [as 别名]
# 或者: from pymatgen.io.vaspio.Poscar import from_string [as 别名]
def get_minkowski_red(structure):
    """
    get a minkowski reduced structure
    """
    from pymatgen.io.vaspio import Poscar
    output = run_aconvasp_command(['aconvasp', '--kpath'], structure)
    started = False
    poscar_string = ""
    for line in output[0].split("\n"):
        if started or line.find("KPOINTS TO RUN") != -1:
            poscar_string = poscar_string + line + "\n"
        if line.find("STRUCTURE TO RUN") != -1:
            started = True
        if line.find("KPOINTS TO RUN") != -1:
            started = False
    return Poscar.from_string(poscar_string).struct
开发者ID:chenweis,项目名称:pymatgen,代码行数:18,代码来源:aconvasp_caller.py


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