From: <bao...@us...> - 2006-05-19 16:37:46
|
Revision: 129 Author: baoilleach Date: 2006-05-19 09:37:32 -0700 (Fri, 19 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=129&view=rev Log Message: ----------- Added ability to handle ISPHER, and also normalised the aonames somewhat...some more work needs to be done here. Modified Paths: -------------- trunk/src/cclib/parser/gamessparser.py Modified: trunk/src/cclib/parser/gamessparser.py =================================================================== --- trunk/src/cclib/parser/gamessparser.py 2006-05-19 09:03:53 UTC (rev 128) +++ trunk/src/cclib/parser/gamessparser.py 2006-05-19 16:37:32 UTC (rev 129) @@ -59,6 +59,34 @@ end = label[1:].replace("U","u").replace("G","g") return label[0] + end + def normalise_aonames(self,listoflines): + """Normalise the aonames attribute to agree with the other parsers. + + We want this to work even if there are 1000+ atoms. Our only assumption + is that all of the relevant information is in the first 17 characters + of the line. + + >>> t = GAMESS("dummyfile") + >>> data = [' 5 C 1 S ', ' 6 C 1 S ',\ + ' 7 C 1 S ', ' 56 C 1XXXX '] + >>> print t.normalise_aonames(data) + ['C1_1S', 'C1_2S', 'C1_3S', 'C1_1XXXX'] + """ + p = re.compile("(\d+)\s*([A-Z][a-z]?)\s*(\d+)\s*([A-Z]+)") + ans = [] + for line in listoflines: + m = p.search(line.strip()) + assert m, "Cannot pick out the aoname from this information: %s" % line + + g = m.groups() + i = 1 + aoname = "%s%s_%d%s" % (g[1],g[2],i,g[3]) + while aoname in ans: # Ensures unique aoname + i += 1 + aoname = "%s%s_%d%s" % (g[1],g[2],i,g[3]) + ans.append(aoname) + return ans + def parse(self): """Extract information from the logfile.""" inputfile = open(self.filename,"r") @@ -291,8 +319,8 @@ self.mosyms[0].extend(map(self.normalisesym,line.split())) for i in range(self.nbasis): line = inputfile.next() - if base==0: # Just do this the first time 'round - atomno=int(line.split()[2])-1 + # if base==0: # Just do this the first time 'round + # atomno=int(line.split()[2])-1 # atomorb[atomno].append(int(line.split()[0])-1) # What's the story with the previous line? temp = line[15:] # Strip off the crud at the start @@ -351,14 +379,21 @@ # The first is from Julien's Example and the second is from Alexander's # I think it happens if you use a polar basis function instead of a cartesian one self.logger.info("Creating attribute nbasis") - self.nbasis = int(line.split()[-1]) + self.nbasis = int(line.strip().split()[-1]) + elif line.find("SPHERICAL HARMONICS KEPT IN THE VARIATION SPACE")>=0: + # Note that this line is present if ISPHER=1, e.g. for C_bigbasis + if not hasattr(self,"nmo"): + self.logger.info("Creating attribute nmo") + self.nmo = int(line.strip().split()[-1]) + elif line.find("TOTAL NUMBER OF MOS IN VARIATION SPACE")==1: # Note that this line is not always present, so by default # NBsUse is set equal to NBasis (see below). - self.logger.info("Creating attribute nmo") - self.indep = int(line.split()[-1]) - + if not hasattr(self,"nmo"): + self.logger.info("Creating attribute nmo") + self.nmo = int(line.split()[-1]) + elif line.find("OVERLAP MATRIX")==0 or line.find("OVERLAP MATRIX")==1: # The first is for PC-GAMESS, the second for GAMESS # Read 1-electron overlap matrix @@ -369,6 +404,7 @@ else: self.logger.info("Reading additional aooverlaps...") base = 0 + aonames = [] while base<self.nbasis: blank = inputfile.next() line = inputfile.next() # Basis fn number @@ -377,11 +413,12 @@ line = inputfile.next() temp = line.split() if base==0: # Only do this for the first block - self.aonames.append("%s%s_%s" % (temp[1],temp[2],temp[3])) + aonames.append(line[:17]) for j in range(4,len(temp)): self.aooverlaps[base+j-4,i+base] = float(temp[j]) self.aooverlaps[i+base,base+j-4] = float(temp[j]) base += 5 + self.aonames = self.normalise_aonames(aonames) inputfile.close() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |