24小时热门版块排行榜    

查看: 436  |  回复: 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 的主题更新
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 070300,一志愿北航320求调剂 +3 Jerry0216 2026-03-22 5/250 2026-03-23 09:16 by 。。堂堂
[考研] 280分求调剂 一志愿085802 +4 PUMPT 2026-03-22 7/350 2026-03-22 22:13 by 星空星月
[考研] 0854电子信息求调剂 +3 α____ 2026-03-22 3/150 2026-03-22 21:28 by zhq0425
[考研] 石河子大学(211、双一流)硕博研究生长期招生公告 +3 李子目 2026-03-22 3/150 2026-03-22 21:01 by 怎么释怀
[考研] 328求调剂,英语六级551,有科研经历 +6 生物工程调剂 2026-03-17 10/500 2026-03-22 20:22 by edmund7
[考研] 一志愿上海交大生物与医药专硕324分,求调剂 +3 jiajunX 2026-03-22 3/150 2026-03-22 19:32 by brblmd
[考研] 一志愿中南化学(0703)总分337求调剂 +9 niko- 2026-03-19 10/500 2026-03-22 16:08 by ColorlessPI
[考研] 0703化学调剂 +4 妮妮ninicgb 2026-03-21 4/200 2026-03-21 18:39 by 学员8dgXkO
[考研] 一志愿深大,0703化学,总分302,求调剂 +4 七月-七七 2026-03-21 4/200 2026-03-21 18:20 by 学员8dgXkO
[考研] 材料 271求调剂 +5 展信悦_ 2026-03-21 5/250 2026-03-21 17:29 by 学员8dgXkO
[考研] 279求调剂 +5 红衣隐官 2026-03-21 5/250 2026-03-21 14:59 by lature00
[考研] 一志愿华中科技大学,080502,354分求调剂 +5 守候夕阳CF 2026-03-18 5/250 2026-03-21 01:06 by JourneyLucky
[考研] 考研调剂求学校推荐 +3 伯乐29 2026-03-18 5/250 2026-03-20 22:59 by JourneyLucky
[考研] 材料学硕297已过四六级求调剂推荐 +11 adaie 2026-03-19 11/550 2026-03-20 21:30 by laoshidan
[考研] 一志愿吉林大学材料学硕321求调剂 +11 Ymlll 2026-03-18 15/750 2026-03-20 19:40 by 丁丁*
[考研] 320求调剂0856 +3 不想起名字112 2026-03-19 3/150 2026-03-19 22:53 by 学员8dgXkO
[考研] 085601材料工程专硕求调剂 +10 慕寒mio 2026-03-16 10/500 2026-03-19 15:26 by 丁丁*
[考研] 286求调剂 +6 lemonzzn 2026-03-16 10/500 2026-03-19 14:31 by lemonzzn
[考研] 材料考研调剂 +3 xwt。 2026-03-19 3/150 2026-03-19 11:22 by w沐阳w
[考研] 有没有道铁/土木的想调剂南林,给自己招师弟中~ +3 TqlXswl 2026-03-16 7/350 2026-03-17 15:23 by TqlXswl
信息提示
请填处理意见