24小时热门版块排行榜    

查看: 566  |  回复: 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 的主题更新
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 龙 兔 虎 猫 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[找工作] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 2SluGOjKYlTo 2026-11-29 4/200 2026-12-01 13:35 by Cx9ypGz1A5gL
[考博] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 fGCGcltPuMrI 2026-11-29 5/250 2026-12-01 11:45 by r6WaeZMwCxBc
[硕博家园] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +3 fGCGcltPuMrI 2026-11-29 7/350 2026-12-01 11:01 by r6WaeZMwCxBc
[考研] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +8 1VHV9UkX7sid 2026-11-26 8/400 2026-11-27 22:05 by Uywcrj8sNxLZ
[考研] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 1VHV9UkX7sid 2026-11-26 6/300 2026-11-27 22:00 by Uywcrj8sNxLZ
[硕博家园] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 I5Uih4YWUbaa 2026-11-27 3/150 2026-11-27 19:55 by FlRlcTrDsDoO
[教师之家] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +6 Gp6vMAD5C53H 2026-11-26 7/350 2026-11-27 17:54 by HaAiYedD27eq
[找工作] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +5 Gp6vMAD5C53H 2026-11-26 6/300 2026-11-27 17:52 by HaAiYedD27eq
[博后之家] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 Gp6vMAD5C53H 2026-11-26 3/150 2026-11-27 17:52 by HaAiYedD27eq
[考博] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +4 mzU8LdVQMwOf 2026-11-26 4/200 2026-11-27 17:43 by HaAiYedD27eq
[硕博家园] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +4 Gp6vMAD5C53H 2026-11-26 5/250 2026-11-27 17:40 by HaAiYedD27eq
[找工作] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +6 mzU8LdVQMwOf 2026-11-26 8/400 2026-11-27 17:37 by HaAiYedD27eq
[找工作] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +5 mzU8LdVQMwOf 2026-11-26 5/250 2026-11-27 17:30 by HaAiYedD27eq
[找工作] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +6 1VHV9UkX7sid 2026-11-26 8/400 2026-11-27 17:18 by HaAiYedD27eq
[博后之家] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +5 1VHV9UkX7sid 2026-11-26 6/300 2026-11-27 17:18 by HaAiYedD27eq
[教师之家] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +6 1VHV9UkX7sid 2026-11-26 7/350 2026-11-27 17:15 by HaAiYedD27eq
[找工作] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +4 mzU8LdVQMwOf 2026-11-26 4/200 2026-11-27 13:26 by aTZfRIGzowsS
[考博] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 mzU8LdVQMwOf 2026-11-26 3/150 2026-11-27 13:05 by aTZfRIGzowsS
[考研] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +4 1VHV9UkX7sid 2026-11-26 4/200 2026-11-27 12:38 by aTZfRIGzowsS
[硕博家园] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 kTIKZRt5HnP0 2026-11-27 3/150 2026-11-27 10:44 by I5Uih4YWUbaa
信息提示
请填处理意见