24小时热门版块排行榜    

查看: 518  |  回复: 0

张张虫123

新虫 (初入文坛)

[求助] gaussian计算过程中,生成geom文件出错,如何修改小程序

各位大牛好!在使用gaussian进行量化计算,用fchk文件生成geom文件时,文件输出总为空白文件,无法得到坐标信息。究其原因,可能是因为服务器升级为gaussian16版本,而生成geom文件的小程序还是以gaussian09版本编写的,请问修改小程序的哪个部分可以解决这个问题呢?以下是小程序的源代码。拜托各位了!!!
# -*- coding: cp936 -*-
def parse_fchk(fchkfile):
    f = open(fchkfile,'r')
    line = f.readline()
    # geom
    while True:
        line = f.readline()
        if line == '':
            print 'can not geom'
            break
        if line.find('Current cartesian coordinates') != -1:
            break
    geom = []
    while True:
        line = f.readline()
        if line == '':
            print 'can not geom'
            break
        if line.find('Force Field') != -1:
            break
        ws = line.strip().split(None)
        geom += ws
    lt_xyz = []
    s3 = ' '*3
    for i in geom:
        # i = '-9.09973086E-01', i[-3:] = '-01', i[:-4] = '-9.09973086'
        s = '{:0=+3d}'.format(int(i[-3:]) + 1)
        s2 = (' {: =10.7f}' + 'E' + s).format(float(i[:-4])/10)
        s3 = s3 + s2
        if len(s3) >= 48:
            lt_xyz.append(s3 + '\n')
            s3 = ' '*3
    f.close()
    return lt_xyz

def readpara():
    lt_smep = []
    f = open('dat-input.dat')
    lines = f.readlines()
    f.close()
    lt_5f = [w.strip() for w in lines[5:10]]
    return lt_5f

try:
    lt_5f = readpara()
except:
    print 'Cound no find dat-input.dat'
   
datfile = raw_input('Please input the name of the fu.dat file : ')
f = open(datfile,'wb')
for i,v in enumerate(lt_5f):
    lt_xyz = parse_fchk(v)
    f.writelines(' rpts    ' + str(i+1) + '\n')
    f.writelines(lt_xyz)
f.close()
raw_input('completed')
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 张张虫123 的主题更新
信息提示
请填处理意见