From: <bao...@us...> - 2006-05-22 15:33:21
|
Revision: 147 Author: baoilleach Date: 2006-05-22 08:32:53 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=147&view=rev Log Message: ----------- Merged changes from trunk revisions 139:146 Modified Paths: -------------- branches/cclib-0.5-prerelease/src/cclib/parser/adfparser.py branches/cclib-0.5-prerelease/src/cclib/parser/gamessparser.py branches/cclib-0.5-prerelease/test/parseADF.py branches/cclib-0.5-prerelease/test/testGeoOpt.py branches/cclib-0.5-prerelease/test/testSP.py Modified: branches/cclib-0.5-prerelease/src/cclib/parser/adfparser.py =================================================================== --- branches/cclib-0.5-prerelease/src/cclib/parser/adfparser.py 2006-05-22 15:16:25 UTC (rev 146) +++ branches/cclib-0.5-prerelease/src/cclib/parser/adfparser.py 2006-05-22 15:32:53 UTC (rev 147) @@ -81,6 +81,10 @@ self.progress.initialize(nstep) oldstep=0 + # Used to avoid extracting the final geometry twice in a GeoOpt + NOTFOUND, GETLAST, NOMORE = range(3) + finalgeometry= NOTFOUND + for line in inputfile: if self.progress and random.random()<cupdate: @@ -108,64 +112,55 @@ if line[1:6]=="ATOMS": # Find the number of atoms and their atomic numbers +# Also extract the starting coordinates (for a GeoOpt anyway) if self.progress and random.random()<cupdate: step=inputfile.tell() if step!=oldstep: self.progress.update(step,"Attributes") oldstep=step - self.logger.info("Creating attribute atomnos[]") + self.logger.info("Creating attribute atomnos[], atomcoords[]") self.atomnos=[] + self.atomcoords = [] underline=inputfile.next() #clear pointless lines label1=inputfile.next() # label2=inputfile.next() # line=inputfile.next() + atomcoords = [] while len(line)>1: #ensure that we are reading no blank lines info=line.split() self.atomnos.append(self.table.number[info[1]]) + atomcoords.append(map(float,info[2:5])) line=inputfile.next() + self.atomcoords.append(atomcoords) self.natom=len(self.atomnos) self.logger.info("Creating attribute natom: %d" % self.natom) -# if line[1:10]=='Cycle 1': -# # Extract SCF convergence information (QM calcs) -# if self.progress and random.random()<fupdate: -# step=inputfile.tell() -# if step!=oldstep: -# self.progress.update(step,"QM Convergence") -# oldstep=step -# -# if not hasattr(self,"scfvalues"): -# self.logger.info("Creating attribute scfvalues") -# self.scfvalues = [] -# newlist = [ [] for x in self.scftargets ] -# line = inputfile.next() -# while line.find("SCF Done")==-1: -# if line.find(' E=')==0: -# self.logger.debug(line) -# if line.find(" RMSDP")==0: -# parts = line.split() -# newlist[G03.SCFRMS].append(self.float(parts[0].split('=')[1])) -# newlist[G03.SCFMAX].append(self.float(parts[1].split('=')[1])) -# energy = 1.0 -# if len(parts)>4: -# energy = parts[2].split('=')[1] -# if energy=="": -# energy = self.float(parts[3]) -# else: -# energy = self.float(energy) -# # I moved the following line back a TAB to see the effect -# # (it was originally part of the above "if len(parts)") -# newlist[G03.SCFENERGY].append(energy) -# try: -# line = inputfile.next() -# except StopIteration: # May be interupted by EOF -# break -# self.scfvalues.append(newlist) -# + if line[51:65]=="Final Geometry": + finalgeometry = GETLAST + + if line[1:24]=="Coordinates (Cartesian)" and finalgeometry in [NOTFOUND, GETLAST]: + # Get the coordinates from each step of the GeoOpt + if not hasattr(self,"atomcoords"): + self.logger.info("Creating attribute atomcoords") + self.atomcoords = [] + equals = inputfile.next() + blank = inputfile.next() + title = inputfile.next() + title = inputfile.next() + hyphens = inputfile.next() + atomcoords = [] + line = inputfile.next() + while line!=hyphens: + atomcoords.append(map(float,line.split()[5:])) + line = inputfile.next() + self.atomcoords.append(atomcoords) + if finalgeometry==GETLAST: # Don't get any more coordinates + finalgeometry = NOMORE + if line[1:27]=='Geometry Convergence Tests': # Extract Geometry convergence information if not hasattr(self,"geotargets"): @@ -610,12 +605,15 @@ if self.progress: self.progress.update(nstep,"Done") - + if hasattr(self,"geovalues"): self.geovalues = Numeric.array(self.geovalues,"f") if hasattr(self,"scfenergies"): self.scfenergies = Numeric.array(self.scfenergies,"f") - self.parsed = True if hasattr(self,"moenergies"): self.nmo = len(self.moenergies[0]) + if hasattr(self,"atomcoords"): self.atomcoords = Numeric.array(self.atomcoords,"f") + self.parsed = True + + # Note to self: Needs to be added to the main parser Modified: branches/cclib-0.5-prerelease/src/cclib/parser/gamessparser.py =================================================================== --- branches/cclib-0.5-prerelease/src/cclib/parser/gamessparser.py 2006-05-22 15:16:25 UTC (rev 146) +++ branches/cclib-0.5-prerelease/src/cclib/parser/gamessparser.py 2006-05-22 15:32:53 UTC (rev 147) @@ -105,6 +105,7 @@ firststdorient = True # Used to decide whether to wipe the atomcoords clean + geooptfinished = False # Used to avoid extracting the final geometry twice for line in inputfile: @@ -167,13 +168,17 @@ line = inputfile.next() while line.strip(): temp = line.strip().split() - atomcoords.append([utils.convertor(float(x),"au","Ang") for x in temp[2:4]]) + atomcoords.append([utils.convertor(float(x),"au","Ang") for x in temp[2:5]]) atomnos.append(self.table.number[temp[0]]) # Use the element name line = inputfile.next() self.atomnos = Numeric.array(atomnos,"i") self.atomcoords.append(atomcoords) - if line[1:29]=="COORDINATES OF ALL ATOMS ARE": + if line[12:40]=="EQUILIBRIUM GEOMETRY LOCATED": + # Prevent extraction of the final geometry twice + geooptfinished = True + + if line[1:29]=="COORDINATES OF ALL ATOMS ARE" and not geooptfinished: # This is the standard orientation, which is the only coordinate # information available for all geometry optimisation cycles. # The input orientation will be overwritten if this is a geometry optimisation @@ -191,7 +196,7 @@ line = inputfile.next() while line.strip(): temp = line.strip().split() - atomcoords.append(map(float,temp[2:4])) + atomcoords.append(map(float,temp[2:5])) line = inputfile.next() self.atomcoords.append(atomcoords) @@ -438,6 +443,8 @@ if hasattr(self,"scfvalues"): self.scfvalues = [Numeric.array(x,"f") for x in self.scfvalues] if hasattr(self,"geovalues"): self.geovalues = Numeric.array(self.geovalues,"f") + if hasattr(self,"atomcoords"): + self.atomcoords = Numeric.array(self.atomcoords,"f") if not hasattr(self,"nmo"): self.logger.info("Creating attribute nmo with default value") self.nmo = self.nbasis Modified: branches/cclib-0.5-prerelease/test/parseADF.py =================================================================== --- branches/cclib-0.5-prerelease/test/parseADF.py 2006-05-22 15:16:25 UTC (rev 146) +++ branches/cclib-0.5-prerelease/test/parseADF.py 2006-05-22 15:32:53 UTC (rev 147) @@ -8,5 +8,4 @@ for file in ["dvb_gopt.adfout"]: t = ADF(file) t.parse() - - + print len(t.atomcoords) Modified: branches/cclib-0.5-prerelease/test/testGeoOpt.py =================================================================== --- branches/cclib-0.5-prerelease/test/testGeoOpt.py 2006-05-22 15:16:25 UTC (rev 146) +++ branches/cclib-0.5-prerelease/test/testGeoOpt.py 2006-05-22 15:32:53 UTC (rev 147) @@ -12,10 +12,10 @@ self.assertEquals(self.data.homos,array([34])) def testatomcoords(self): - """Are atomcoords consistent with natom, Angstroms and geovalues?""" + """Are atomcoords consistent with natom and Angstroms?""" coords = self.data.atomcoords self.assertEquals(self.data.natom,len(coords[0]),"len(atomcoords[0]) is %d but natom is %d" % (self.data.natom,len(coords[0]))) - self.assertEquals(len(self.data.geovalues),len(coords),"len(atomcoords) is %d but len(geovalues) is % d" % (len(coords),len(self.data.geovalues))) + # Find the minimum distance between two C atoms mindist = 999 for i in range(self.data.natom-1): @@ -25,7 +25,13 @@ # Find the distance in the final iteration dist = math.sqrt(sum((coords[-1][i]-coords[-1][j])**2)) mindist = min(mindist,dist) - self.assert_(abs(mindist-1.34)<0.02,"Mindist is %f (not 1.34)" % mindist) + self.assert_(abs(mindist-1.34)<0.03,"Mindist is %f (not 1.34)" % mindist) + + def testatomcoords_more(self): + """Are atomcoords consistent with geovalues?""" + coords = self.data.atomcoords + self.assertEquals(len(self.data.geovalues),len(coords),"len(atomcoords) is %d but len(geovalues) is %d" % (len(coords),len(self.data.geovalues))) + def testnatom(self): """Is the number of atoms equal to 20?""" @@ -83,7 +89,13 @@ """ADF does not have scf values...OK?""" self.assert_(True) + def testatomcoords_more(self): + """Are atomcoords consistent with geovalues?""" + coords = self.data.atomcoords + self.assertEquals(len(self.data.geovalues),len(coords)-1,"len(atomcoords)-1 is %d but len(geovalues) is %d" % (len(coords)-1,len(self.data.geovalues))) + names = [ "Gaussian", "PCGamess", "GAMESS", "ADF" ] + tests = [ GaussianGeoOptTest, PCGamessGeoOptTest, GamessUSGeoOptTest, ADFGeoOptTest ] Modified: branches/cclib-0.5-prerelease/test/testSP.py =================================================================== --- branches/cclib-0.5-prerelease/test/testSP.py 2006-05-22 15:16:25 UTC (rev 146) +++ branches/cclib-0.5-prerelease/test/testSP.py 2006-05-22 15:32:53 UTC (rev 147) @@ -9,6 +9,10 @@ """Are the dims of the overlap matrix consistent with nbasis?""" self.assertEquals(self.data.aooverlaps.shape,(self.data.nbasis,self.data.nbasis)) + def testatomcoords(self): + """Are the dimensions of atomcoords 1 x natom x 3?""" + self.assertEquals(self.data.atomcoords.shape,(1,self.data.natom,3)) + def testdimmocoeffs(self): """Are the dimensions of mocoeffs equal to 1 x nmo x nbasis?""" self.assertEquals(self.data.mocoeffs.shape,(1,self.data.nmo,self.data.nbasis)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |