24小时热门版块排行榜    

Znn3bq.jpeg
查看: 439  |  回复: 0

fwang2011

金虫 (小有名气)


[资源] cclib 处理大于100个原子的系统 (GAMESS, parser)

前段时间自己遇到的问题,cclib处理大于100个原子的系统出错。

下面是俺的处理方法,共享:
Here is the root problem: cclib (the current released version) cannot parse the log file of system with natom >= 100.

In the log file for the Eigenvalues/MOs:
518  H 98  S   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  519  C 99  S   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  520  C 99  S   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  521  C 99  X   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  522  C 99  Y   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  523  C 99  Z   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  524  H  0  S   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  525  H  1  S   -0.000000   0.000000  -0.000000  -0.000000  -0.000000
  526  C  2  S   -0.000000   0.000000  -0.000000  -0.000000  -0.000000

The number of atoms are recorded as 0, 1, ...,  instead of 100/200/..., 101/201/..., which is however problematic in calculating CSPA.

My resolution is: introducing a switch to monitor this change. The corresponding code, in gamessparser.py is partially copied in the following:

LINE 714:
               p = re.compile("(\d+)\s*([A-Z][A-Z]?)\s*(\d+)\s*([A-Z]+)"
                oldatom ='0'
                i_atom = 0      #couter to translate to 0s to some hundreds, by C.W.
                flag_w = True   #Flag to whether
                for i in range(self.nbasis):
                    line = inputfile.next()

                    # If line is empty, break (ex. for FMO in exam37).
                    if not line.strip(): break

                    # Fill atombasis and aonames only first time around
                    if readatombasis and base == 0:
                        aonames = []
                        start = line[:17].strip()
                        m = p.search(start)
                        if m:
                            g = m.groups()
                            g2 = int(g[2])  #atom index from GAMESS's log file
                            if g2 == 0 and flag_w:                      #c.w.
                                i_atom = i_atom + 100           #c.w
                                flag_w = False
                            if g2 != 0:
                                flag_w = True
                            g2 = g2 + i_atom            #c.w.
                            aoname = "%s%s_%s" % (g[1].capitalize(), str(g2), g[3])     #c.w.
                          #  aoname = "%s%s_%s" % (g[1].capitalize(), g[2], g[3])
                            oldatom = str(g2)   #c.w.
                            atomno = g2 - 1     #c.w.
                         #   oldatom = g[2]
                         #  atomno = int(g[2])-1
                            orbno = int(g[0])-1

                        else: # For F orbitals, as shown above
                            g = [x.strip() for x in line.split()]
                            g2 = int(g[2])  #atom index from GAMESS's log file
                            if g2 == 0 and flag_w:                      #c.w.
                                i_atom = i_atom + 100           #c.w.
                                flag_w = False                  #c.w.
                            if g2 != 0: #c.w.
                                flag_w = True           #c.w.
                            g2 = g2 + i_atom            #c.w.
                           # aoname = "%s%s_%s" % (g[1].capitalize(), oldatom, g[2])
                            aoname = "%s%s_%s" % (g[1].capitalize(), oldatom, str(g2))
                            atomno = int(oldatom)-1
                            orbno = int(g[0])-1
                        self.atombasis[atomno].append(orbno)
                        self.aonames.append(aoname)
                    coeffs = line[15:] # Strip off the crud at the start.
                    j = 0
                    while j*11+4 < len(coeffs):
                        self.mocoeffs[0][base+j, i] = float(coeffs[j * 11j + 1) * 11])
                        j += 1

            line = inputfile.next()

Enjoy!
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 fwang2011 的主题更新
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 一志愿哈工大 085600 277 12材科基求调剂 5+5 chenny174 2026-04-10 28/1400 2026-04-12 15:33 by laoshidan
[考研] 290调剂生物0860 +24 哇哈哈,。 2026-04-11 26/1300 2026-04-12 15:21 by 1005715100
[考研] 0831一轮调剂失败求助 +9 小熊睿睿_s 2026-04-11 9/450 2026-04-12 14:18 by 昆工高欣
[考研] 人工智能320调剂08工类还有机会吗 +12 振—TZ 2026-04-10 12/600 2026-04-12 07:54 by wj165256
[考研] 0860004 求调剂 309分 +9 Yin DY 2026-04-08 9/450 2026-04-11 22:55 by dongdian1
[教师之家] 请问地理、遥感方面,可以做哪些横向项目啊,纵向完不成考核啊 +3 锦衣卫寒战 2026-04-07 5/250 2026-04-11 20:51 by 豫椒
[考研] 电子信息279求调剂,有书读就行 +8 wwwooden 2026-04-08 11/550 2026-04-11 20:22 by cq2548
[考研] 0854调剂 +4 长弓傲 2026-04-09 4/200 2026-04-11 09:18 by 猪会飞
[考研] 化学工程与技术324调剂 +23 孙常华 2026-04-09 25/1250 2026-04-11 00:07 by 骑牛渡寒江
[考研] 263能源动力专硕求调剂 +3 加大号饭盒袋 2026-04-10 3/150 2026-04-10 22:23 by 286640313
[考研] 计算机类求调剂,22408-274分 +7 上岸de小虫 2026-04-09 8/400 2026-04-10 19:56 by fxue1114
[考研] 一志愿沪9,326生物学求相关专业调剂 +4 刘墨墨 2026-04-09 4/200 2026-04-10 12:07 by pengliang8036
[考研] 初试分332,一志愿报考西北工业大学, +11 故人?? 2026-04-09 11/550 2026-04-09 21:54 by JineShine
[论文投稿] 求助文献原文 10+3 18500821399 2026-04-08 3/150 2026-04-09 16:56 by 北京莱茵润色
[考研] 327求调剂 +10 Xxjc1107. 2026-04-06 11/550 2026-04-09 01:21 by lature00
[考研] 一志愿985初试354分生物调剂 +3 031001 2026-04-06 3/150 2026-04-09 00:30 by Evan_Liu
[考研] 304求调剂 +16 c297914 2026-04-05 17/850 2026-04-08 13:00 by grayjzr
[考研] 生物医药调剂|SCI中科院三区一作+多项科研成果 +8 likangxing 2026-04-07 11/550 2026-04-08 00:02 by lys0704
[考研] 材料调剂 +11 一样YWY 2026-04-07 11/550 2026-04-07 15:13 by shdgaomin
[考研] 071000生物学调剂 +7 拉提桃 2026-04-06 7/350 2026-04-06 18:55 by 52305043001
信息提示
请填处理意见