代码拉取完成,页面将自动刷新
#!~/software/anaconda3/bin/python
import os
STRUPATH='$YourPath/InputPoscar/'
with open('results.dat', 'w') as f:
f.write('{0:<25s} {1:<25s} {2:<25s}\n'.format(
'# StructureName',
'Energy(eV)',
'Magnetism(Bohr mag/cell)'))
for root, dirs, files in os.walk(top=STRUPATH, topdown=True):
for file in files:
name = file.split('.')[0]
cmd1 = ("grep '!FINAL_ETOT_IS' " + name + "/OUT.ABACUS/running_scf.log | awk '{print $2} ' > tmpE")
cmd2 = ("grep 'total magnetism' " + name +
"/OUT.ABACUS/running_scf.log | tail -n 1 | awk '{print $6}' > tmpMag")
os.system(cmd1)
os.system(cmd2)
with open('tmpE', 'r') as f:
ele = f.readline()
if(ele == ''):
energy = 'NULL'
else:
energy = ele.split()[0]
with open('tmpMag', 'r') as f:
ele = f.readline()
if (ele == ''):
mag = 'NULL'
else:
mag = ele.split()[0]
with open('results.dat', 'a') as f:
f.write('{0:<25s} {1:<25s} {2:<25s}\n'.format(name, energy, mag))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。