本文整理汇总了Python中pymatgen.io.vaspio.Poscar.comment方法的典型用法代码示例。如果您正苦于以下问题:Python Poscar.comment方法的具体用法?Python Poscar.comment怎么用?Python Poscar.comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.vaspio.Poscar
的用法示例。
在下文中一共展示了Poscar.comment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scaleCell
# 需要导入模块: from pymatgen.io.vaspio import Poscar [as 别名]
# 或者: from pymatgen.io.vaspio.Poscar import comment [as 别名]
def scaleCell(path,volume):
poscar = os.path.join(path,'POSCAR')
refcar = os.path.join(path,'REFCAR')
potcar = Potcar()
assert os.path.isfile(poscar)
struct = read_structure(poscar)
struct.scale_lattice(volume)
species = [ pot.element for pot in potcar.from_file('POTCAR') ]
reprule = { old:new for old,new in zip(struct.composition.elements,species) }
struct.replace_species(reprule)
p = Poscar(struct)
with open(poscar) as f:
poscomment = f.readline().strip()
p.comment = poscomment
p.write_file(poscar,vasp4_compatible=True)
if os.path.isfile(refcar):
tmp = os.path.join(path,'POSCARtmp')
# copy Poscar to temporary file and refcar to poscar
copyfile(poscar,tmp)
copyfile(refcar,poscar)
struct = read_structure(poscar)
struct.scale_lattice(volume)
species = [ pot.element for pot in potcar.from_file('POTCAR') ]
reprule = { old:new for old,new in zip(struct.composition.elements,species) }
struct.replace_species(reprule)
r = Poscar(struct)
with open(poscar) as f:
poscomment = f.readline().strip()
r.comment = poscomment
r.write_file(poscar,vasp4_compatible=True)
with open(refcar) as f:
poscomment = f.readline().strip()
r.comment = poscomment
r.write_file(refcar,vasp4_compatible=True)
# replace poscar with its original
move(tmp,poscar)
else:
print 'No REFCAR found.'