用python写一个自动注册脚本_用来自动写SI的Python脚本

import os,sys

def treatGeo(geoName):

tc=''

electronicEnergies=[]

ttl=geoName

xyz=''

print(ttl)

print('LOG File Missing.')

print('')

return

with open(geoName+'.log') as f:

for line in f:

if 'Thermal correction to Gibbs Free Energy=' in line:

tc=line.replace('Thermal correction to Gibbs Free Energy=','').strip()

break

for postfix in ['_NoS.log','_ether.log','_PBE0.log']:

print('SP File Missing.')

print('')

return

with open(geoName+postfix) as f:

f=f.readlines()

for i in range(len(list(f))):

line=list(f)[-i]

if 'SCF Done' in line:

firstindex=line.index('=')

lastindex=line.upper().index('A.U.')

sp=line[firstindex:lastindex].strip()

electronicEnergies.append(sp)

break

with open(geoName+'!.gjf') as f:

flag=-416

for line in f:

if flag==1:

if 'Title Card Required' in line:

flag=0

if line.strip()=='':

flag+=1

#print('')

numImg=0

if 'TS' in geoName:

numImg=1

print('Imaginary frequency: '+str(numImg))

print('Thermodynamic correlation: '+tc)

print('Electronic Energy at M05-2X/BS1: '+electronicEnergies[0])

print('Electronic Energy at M05-2X/BS1 with implicit solvation: '+electronicEnergies[1])

print('Electronic Energy at PBE0-D3BJ/BS2: '+electronicEnergies[2])

print('')

for f in os.listdir('.'):

if '!' in f:

geoName=f.replace('!.gjf','')

treatGeo(geoName)

配合Rita的自动生成单点能gjf文件的程序Gjfenerator使用。Gjfenerator带来的使用习惯是每一个结构优化完后生成一个filename!.gjf用于储存构型,单点能文件以形如filename_NoS.gjf的格式存储。运行上述Python脚本即可自动提取SI的所需信息,不过仍然要手动修改几千个结构的标题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值