From: <bao...@us...> - 2006-03-09 09:04:26
|
Revision: 12 Author: baoilleach Date: 2006-03-09 01:03:51 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=12&view=rev Log Message: ----------- Changed half of the attribute names to the new names. Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-08 17:12:33 UTC (rev 11) +++ trunk/src/cclib/parser/g03parser.py 2006-03-09 09:03:51 UTC (rev 12) @@ -22,23 +22,8 @@ from logfileparser import Logfile # import the superclass class G03(Logfile): - """A Gaussian 03 log file - - Attributes: - filename -- the name of the log file - logger -- a logging object - NAtoms -- the number of atoms in the molecule - atomicNo[] -- the atomic numbers of the atoms - - scfenergy[] -- the SCF energies - - Class Methods: - float(a) -- convert a string to a float - - Methods: - parse() -- extract general info from the logfile - """ - SCFRMS,SCFMAX,SCFENERGY = range(3) # Used to index self.scftarget[] + """A Gaussian 98/03 log file""" + SCFRMS,SCFMAX,SCFENERGY = range(3) # Used to index self.scftargets[] def __init__(self,filename): # Call the __init__ method of the superclass @@ -63,67 +48,60 @@ return 'G03("%s")' % (self.filename) def parse(self): - """Extract general info from the logfile. - - Creates the following instance attributes: - NAtoms, atomicNo[], - scfProgress[], SCF_target_rms, SCF_target_energy, SCF_target_max, - geoProgress[], scfenergy[] - evalue [[]] - """ + """Extract information from the logfile.""" inputfile = open(self.filename,"r") for line in inputfile: if line[1:8]=="NAtoms=": # Find the number of atoms - NAtoms = int(line.split()[1]) - if hasattr(self,"NAtoms"): - assert self.NAtoms==NAtoms + natom = int(line.split()[1]) + if hasattr(self,"natom"): + assert self.natom==natom else: # I wonder whether this code will ever be executed - self.NAtoms = NAtoms - self.logger.info("Creating attribute NAtoms: %d" % self.NAtoms) + self.natom = natom + self.logger.info("Creating attribute natom: %d" % self.natom) - if not hasattr(self,"atomicNo") and (line.find("Z-Matrix orientation")>=0 + if not hasattr(self,"atomnos") and (line.find("Z-Matrix orientation")>=0 or line[25:45]=="Standard orientation" or line[26:43]=="Input orientation"): # Extract the atomic numbers of the atoms - self.logger.info("Creating attribute atomicNo[]") - self.atomicNo = [] + self.logger.info("Creating attribute atomnos[]") + self.atomnos = [] hyphens = inputfile.next() colmNames = inputfile.next(); colmNames = inputfile.next() hyphens = inputfile.next() line = inputfile.next() while line!=hyphens: - self.atomicNo.append(int(line.split()[1])) + self.atomnos.append(int(line.split()[1])) line = inputfile.next() - NAtoms = len(self.atomicNo) - if hasattr(self,"NAtoms"): - assert self.NAtoms==NAtoms + natom = len(self.atomnos) + if hasattr(self,"natom"): + assert self.natom==natom else: - self.NAtoms = NAtoms - self.logger.info("Creating attribute NAtoms: %d" % self.NAtoms) + self.natom = natom + self.logger.info("Creating attribute natom: %d" % self.natom) # Find the targets for the SCF convergence (QM calcs) # We assume that the targets don't change, although it's # easy enough to store all of the targets if line[1:44]=='Requested convergence on RMS density matrix': - if not hasattr(self,"scftarget"): - self.logger.info("Creating attribute scftarget[]") - self.scftarget = [None]*3 - self.scftarget[G03.SCFRMS] = self.float(line.split('=')[1].split()[0]) + if not hasattr(self,"scftargets"): + self.logger.info("Creating attribute scftargets[]") + self.scftargets = [None]*3 + self.scftargets[G03.SCFRMS] = self.float(line.split('=')[1].split()[0]) if line[1:44]=='Requested convergence on MAX density matrix': - self.scftarget[G03.SCFMAX] = self.float(line.strip().split('=')[1][:-1]) + self.scftargets[G03.SCFMAX] = self.float(line.strip().split('=')[1][:-1]) if line[1:44]=='Requested convergence on energy': - self.scftarget[G03.SCFENERGY] = self.float(line.strip().split('=')[1][:-1]) + self.scftargets[G03.SCFENERGY] = self.float(line.strip().split('=')[1][:-1]) if line[1:10]=='Cycle 1': # Extract SCF convergence information (QM calcs) - if not hasattr(self,"scfvalue"): - self.logger.info("Creating attribute scfvalue[[]]") - self.scfvalue = [] - newlist = [ [] for x in self.scftarget ] + 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: @@ -147,18 +125,18 @@ line = inputfile.next() except StopIteration: # May be interupted by EOF break - self.scfvalue.append(newlist) + self.scfvalues.append(newlist) if line[1:4]=='It=': # Extract SCF convergence information (AM1 calcs) - self.logger.info("Creating attributes scftarget[],scfvalue[[]]") - self.scftarget = [1E-7] # This is the target value for the rms - self.scfvalue = [[]] + self.logger.info("Creating attributes scftargets[],scfvalues[[]]") + self.scftargets = [1E-7] # This is the target value for the rms + self.scfvalues = [[]] line = inputfile.next() while line.find(" Energy")==-1: self.logger.debug(line) parts = line.strip().split() - self.scfvalue[0].append(self.float(parts[-1][:-1])) + self.scfvalues[0].append(self.float(parts[-1][:-1])) line = inputfile.next() if line[1:9]=='SCF Done': @@ -166,18 +144,18 @@ # a loop when extract SCF convergence information self.logger.debug(line) self.logger.debug("SCF Done") - if hasattr(self,"scfenergy"): - self.scfenergy.append(line.split()[4]) + if hasattr(self,"scfenergies"): + self.scfenergies.append(line.split()[4]) else: - self.scfenergy = [line.split()[4]] - self.logger.info("Creating attribute scfenergy[]") + self.scfenergies = [line.split()[4]] + self.logger.info("Creating attribute scfenergies[]") if line[49:59]=='Converged?': # Extract Geometry convergence information - if not hasattr(self,"geotarget"): - self.logger.info("Creating attributes geotarget[],geovalue[[]]") - self.geovalue = [] - self.geotarget = [None]*4 + if not hasattr(self,"geotargets"): + self.logger.info("Creating attributes geotargets[],geovalues[[]]") + self.geovalues = [] + self.geotargets = [None]*4 newlist = [0]*4 for i in range(4): line = inputfile.next() @@ -189,13 +167,13 @@ self.logger.error("Problem parsing the value for geometry optimisation: %s is not a number." % parts[2]) else: newlist[i] = value - self.geotarget[i] = self.float(parts[3]) - self.geovalue.append(newlist) + self.geotargets[i] = self.float(parts[3]) + self.geovalues.append(newlist) - if line[1:19]=='Orbital symmetries' and not hasattr(self,"orbsym"): + if line[1:19]=='Orbital symmetries' and not hasattr(self,"mosyms"): # Extracting orbital symmetries - self.logger.info("Creating attribute orbsym[[]]") - self.orbsym = [[]] + self.logger.info("Creating attribute mosyms[[]]") + self.mosyms = [[]] line = inputfile.next() unres = False if line.find("Alpha Orbitals")==1: @@ -204,24 +182,24 @@ i = 0 while len(line)>18 and line[17]=='(': if line.find('Virtual')>=0: - self.HOMO = [i-1] # 'HOMO' indexes the HOMO in the arrays + self.homos = [i-1] # 'HOMO' indexes the HOMO in the arrays self.logger.info("Creating attribute HOMO[]") parts = line[17:].split() for x in parts: - self.orbsym[0].append(x.strip('()')) + self.mosyms[0].append(x.strip('()')) i+= 1 line = inputfile.next() if unres: line = inputfile.next() # Repeat with beta orbital information i = 0 - self.orbsym.append([]) + self.mosyms.append([]) while len(line)>18 and line[17]=='(': if line.find('Virtual')>=0: - self.HOMO.append(i-1) # 'HOMO' indexes the HOMO in the arrays + self.homos.append(i-1) # 'HOMO' indexes the HOMO in the arrays parts = line[17:].split() for x in parts: - self.orbsym[1].append(x.strip('()')) + self.mosyms[1].append(x.strip('()')) i+= 1 line = inputfile.next() @@ -235,11 +213,11 @@ # If there aren't any symmetries, # this is a good way to find the HOMO HOMO = len(self.evalue[0])-1 - if hasattr(self,"HOMO"): - assert HOMO==self.HOMO[0] + if hasattr(self,"homos"): + assert HOMO==self.homos[0] else: - self.logger.info("Creating attribute HOMO[]") - self.HOMO = [HOMO] + self.logger.info("Creating attribute homos[]") + self.homos = [HOMO] part = line[28:] i = 0 while i*10+4<len(part): @@ -255,12 +233,12 @@ # If there aren't any symmetries, # this is a good way to find the HOMO HOMO = len(self.evalue[1])-1 - if len(self.HOMO)==2: - # It already has a self.HOMO (with the Alpha value) + if len(self.homos)==2: + # It already has a self.homos (with the Alpha value) # but does it already have a Beta value? - assert HOMO==self.HOMO[1] + assert HOMO==self.homos[1] else: - self.HOMO.append(HOMO) + self.homos.append(HOMO) part = line[28:] i = 0 while i*10+4<len(part): @@ -271,12 +249,12 @@ if line[1:14]=="Harmonic freq": # Start of the IR/Raman frequency section - self.vibsym = [] - self.ir = [] + self.vibsyms = [] + self.vibirs = [] self.vibfreq = [] - self.logger.info("Creating attribute vibsym[]") - self.logger.info("Creating attribute vibfreq[]") - self.logger.info("Creating attribute ir[]") + self.logger.info("Creating attribute vibsyms[]") + self.logger.info("Creating attribute vibfreqs[]") + self.logger.info("Creating attribute vibirs[]") line = inputfile.next() while len(line[:15].split())>0: # Get past the three/four line title of the columns @@ -284,19 +262,19 @@ line = inputfile.next() # The line with symmetries while len(line[:15].split())==0: self.logger.debug(line) - self.vibsym.extend(line.split()) # Adding new symmetry + self.vibsyms.extend(line.split()) # Adding new symmetry line = inputfile.next() self.vibfreq.extend(map(self.float,line[15:].split())) # Adding new frequencies [inputfile.next() for i in [0,1]] # Skip two lines line = inputfile.next() - self.ir.extend(map(self.float,line[15:].split())) # Adding IR intensities + self.vibirs.extend(map(self.float,line[15:].split())) # Adding IR intensities line = inputfile.next() if line.find("Raman")>=0: if not hasattr(self,"raman"): - self.raman = [] + self.vibramans = [] self.logger.info("Creating attribute raman[]") line = inputfile.next() - self.raman.extend(map(self.float,line[15:].split())) # Adding Raman intensities + self.vibramans.extend(map(self.float,line[15:].split())) # Adding Raman intensities line = inputfile.next() while len(line[:15].split())>0: line = inputfile.next() @@ -482,7 +460,7 @@ for line in inputfile: if line.find(" Cartesian coordinates:")==0: coords = [] - for i in range(self.NAtoms): + for i in range(self.natom): line = inputfile.next() parts = line.strip().split() # Conversion from a.u. to Angstrom This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-09 09:54:09
|
Revision: 13 Author: baoilleach Date: 2006-03-09 01:54:04 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=13&view=rev Log Message: ----------- Updated all of the variable names in the G03 parser. (Need to fix the variable types next...) Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-09 09:03:51 UTC (rev 12) +++ trunk/src/cclib/parser/g03parser.py 2006-03-09 09:54:04 UTC (rev 13) @@ -183,7 +183,7 @@ while len(line)>18 and line[17]=='(': if line.find('Virtual')>=0: self.homos = [i-1] # 'HOMO' indexes the HOMO in the arrays - self.logger.info("Creating attribute HOMO[]") + self.logger.info("Creating attribute homos[]") parts = line[17:].split() for x in parts: self.mosyms[0].append(x.strip('()')) @@ -205,14 +205,14 @@ if line[1:6]=="Alpha" and line.find("eigenvalues")>=0: # Extract the alpha electron eigenvalues - self.logger.info("Creating attribute evalue[[]]") - self.evalue = [[]] + self.logger.info("Creating attribute moenergies[[]]") + self.moenergies = [[]] HOMO = -2 while line.find('Alpha')==1: if line.split()[1]=="virt." and HOMO==-2: # If there aren't any symmetries, # this is a good way to find the HOMO - HOMO = len(self.evalue[0])-1 + HOMO = len(self.moenergies[0])-1 if hasattr(self,"homos"): assert HOMO==self.homos[0] else: @@ -222,17 +222,17 @@ i = 0 while i*10+4<len(part): x = part[i*10:(i+1)*10] - self.evalue[0].append(self.float(x)*27.2114) # from a.u. (hartrees) to eV + self.moenergies[0].append(self.float(x)*27.2114) # from a.u. (hartrees) to eV i += 1 line = inputfile.next() if line.find('Beta')==2: - self.evalue.append([]) + self.moenergies.append([]) HOMO = -2 while line.find('Beta')==2: if line.split()[1]=="virt." and HOMO==-2: # If there aren't any symmetries, # this is a good way to find the HOMO - HOMO = len(self.evalue[1])-1 + HOMO = len(self.moenergies[1])-1 if len(self.homos)==2: # It already has a self.homos (with the Alpha value) # but does it already have a Beta value? @@ -243,7 +243,7 @@ i = 0 while i*10+4<len(part): x = part[i*10:(i+1)*10] - self.evalue[1].append(self.float(x)*27.2114) # from a.u. (hartrees) to eV + self.moenergies[1].append(self.float(x)*27.2114) # from a.u. (hartrees) to eV i += 1 line = inputfile.next() @@ -251,7 +251,7 @@ # Start of the IR/Raman frequency section self.vibsyms = [] self.vibirs = [] - self.vibfreq = [] + self.vibfreqs = [] self.logger.info("Creating attribute vibsyms[]") self.logger.info("Creating attribute vibfreqs[]") self.logger.info("Creating attribute vibirs[]") @@ -264,15 +264,15 @@ self.logger.debug(line) self.vibsyms.extend(line.split()) # Adding new symmetry line = inputfile.next() - self.vibfreq.extend(map(self.float,line[15:].split())) # Adding new frequencies + self.vibfreqs.extend(map(self.float,line[15:].split())) # Adding new frequencies [inputfile.next() for i in [0,1]] # Skip two lines line = inputfile.next() self.vibirs.extend(map(self.float,line[15:].split())) # Adding IR intensities line = inputfile.next() if line.find("Raman")>=0: - if not hasattr(self,"raman"): + if not hasattr(self,"vibramans"): self.vibramans = [] - self.logger.info("Creating attribute raman[]") + self.logger.info("Creating attribute vibramans[]") line = inputfile.next() self.vibramans.extend(map(self.float,line[15:].split())) # Adding Raman intensities line = inputfile.next() @@ -283,23 +283,20 @@ if line[1:14]=="Excited State": # Extract the electronic transitions if not hasattr(self,"etenergy"): - self.etenergy = [] - self.etwavelen = [] - self.etosc = [] - self.etsym = [] - self.etcis = [] - self.logger.info("Creating attributes etenergy[], etwavelen[], etosc[], etsym[], etcis[]") + self.etenergies = [] + self.etoscs = [] + self.etsyms = [] + self.etsecs = [] + self.logger.info("Creating attributes etenergies[], etoscs[], etsyms[], etsecs[]") # Need to deal with lines like: # (restricted calc) # Excited State 1: Singlet-BU 5.3351 eV 232.39 nm f=0.1695 # (unrestricted calc) (first excited state is 2!) # Excited State 2: ?Spin -A 0.1222 eV 10148.75 nm f=0.0000 parts = line[36:].split() - self.logger.debug(parts) - self.etenergy.append(convertor(self.float(parts[0]),"eV","cm-1")) - self.etwavelen.append(self.float(parts[2])) - self.etosc.append(self.float(parts[4].split("=")[1])) - self.etsym.append(line[21:36].split()) + self.etenergies.append(convertor(self.float(parts[0]),"eV","cm-1")) + self.etoscs.append(self.float(parts[4].split("=")[1])) + self.etsyms.append(line[21:36].split()) line = inputfile.next() @@ -330,13 +327,13 @@ sqr = -sqr CIScontrib.append([(fromMO,frommoindex),(toMO,tomoindex),sqr]) line = inputfile.next() - self.etcis.append(CIScontrib) + self.etsecs.append(CIScontrib) if line[1:52]=="<0|r|b> * <b|rxdel|0> (Au), Rotatory Strengths (R)": # Extract circular dichroism data - self.rotatory = [] - self.logger.info("Creating attribute rotatory[]") + self.etrotats = [] + self.logger.info("Creating attribute etrotats[]") inputfile.next() inputfile.next() line = inputfile.next() @@ -349,43 +346,43 @@ # (for unrestricted calculations) pass else: - self.rotatory.append(R) + self.etrotats.append(R) line = inputfile.next() temp = line.strip().split() parts = line.strip().split() if line[1:7]=="NBasis" or line[4:10]=="NBasis": # Extract the number of basis sets - NBasis = int(line.split('=')[1].split()[0]) + nbasis = int(line.split('=')[1].split()[0]) # Has to deal with lines like: - # NBasis= 434 NAE= 97 NBE= 97 NFC= 34 NFV= 0 + # NBasis = 434 NAE= 97 NBE= 97 NFC= 34 NFV= 0 # NBasis = 148 MinDer = 0 MaxDer = 0 # Although the former is in every file, it doesn't occur before # the overlap matrix is printed - if hasattr(self,"NBasis"): - assert NBasis==self.NBasis + if hasattr(self,"nbasis"): + assert nbasis==self.nbasis else: - self.NBasis = NBasis - self.logger.info("Creating attribute NBasis: %d" % self.NBasis) + self.nbasis= nbasis + self.logger.info("Creating attribute nbasis: %d" % self.nbasis) if line[1:7]=="NBsUse": # Extract the number of linearly-independent basis sets - NBsUse = int(line.split('=')[1].split()[0]) - if hasattr(self,"NBsUse"): - assert NBsUse==self.NBsUse + nindep = int(line.split('=')[1].split()[0]) + if hasattr(self,"nindep"): + assert nindep==self.nindep else: - self.NBsUse = NBsUse - self.logger.info("Creating attribute NBsUse: %d" % self.NBsUse) + self.nindep = nindep + self.logger.info("Creating attribute nindep: %d" % self.nindep) if line[7:22]=="basis functions,": -# For AM1 calculations, set NBasis by a second method -# (NBsUse may not always be explicitly stated) - NBasis = int(line.split()[0]) - if hasattr(self,"NBasis"): - assert NBasis==self.NBasis +# For AM1 calculations, set nbasis by a second method +# (nindep may not always be explicitly stated) + nbasis = int(line.split()[0]) + if hasattr(self,"nbasis"): + assert nbasis==self.nbasis else: - self.NBasis = NBasis - self.logger.info("Creating attribute NBasis: %d" % self.NBasis) + self.nbasis = nbasis + self.logger.info("Creating attribute nbasis: %d" % self.nbasis) if line[1:4]=="***" and (line[5:12]=="Overlap" or line[8:15]=="Overlap"): @@ -393,20 +390,20 @@ # Has to deal with lines such as: # *** Overlap *** # ****** Overlap ****** - self.logger.info("Creating attribute overlap[x,y]") + self.logger.info("Creating attribute aooverlaps[x,y]") import time; oldtime = time.time() - self.overlap = Numeric.zeros( (self.NBasis,self.NBasis), "float") - # Overlap integrals for basis fn#1 are in overlap[0] + self.aooverlaps = Numeric.zeros( (self.nbasis,self.nbasis), "float") + # Overlap integrals for basis fn#1 are in aooverlaps[0] base = 0 colmNames = inputfile.next() - while base<self.NBasis: - for i in range(self.NBasis-base): # Fewer lines this time + while base<self.nbasis: + for i in range(self.nbasis-base): # Fewer lines this time line = inputfile.next() parts = line.split() for j in range(len(parts)-1): # Some lines are longer than others k = float(parts[j].replace("D","E")) - self.overlap[base+j,i+base] = k - self.overlap[i+base,base+j] = k + self.aooverlaps[base+j,i+base] = k + self.aooverlaps[i+base,base+j] = k base += 5 colmNames = inputfile.next() self.logger.info("Took %f seconds" % (time.time()-oldtime)) @@ -415,20 +412,20 @@ import time; oldtime = time.time() if line[5:40]=="Beta Molecular Orbital Coefficients": beta = True - # Need to add an extra dimension to self.mocoeff - self.mocoeff = Numeric.resize(self.mocoeff,(2,NBsUse,NBasis)) + # Need to add an extra dimension to self.mocoeffs + self.mocoeffs = Numeric.resize(self.mocoeffs,(2,nindep,nbasis)) else: beta = False - self.logger.info("Creating attributes orbitals[], mocoeff[][]") - self.orbitals = [] - self.mocoeff = Numeric.zeros((NBsUse,NBasis),"float") + self.logger.info("Creating attributes aonames[], mocoeffs[][]") + self.aonames = [] + self.mocoeffs = Numeric.zeros((nindep,nbasis),"float") base = 0 - for base in range(0,NBsUse,5): + for base in range(0,nindep,5): colmNames = inputfile.next() symmetries = inputfile.next() eigenvalues = inputfile.next() - for i in range(NBasis): + for i in range(nbasis): line = inputfile.next() if base==0 and not beta: # Just do this the first time 'round # Changed below from :12 to :11 to deal with Elmar Neumann's example @@ -436,18 +433,17 @@ if len(parts)>1: # New atom atomname = "%s%s" % (parts[2],parts[1]) orbital = line[11:20].strip() - self.orbitals.append("%s_%s" % (atomname,orbital)) + self.aonames.append("%s_%s" % (atomname,orbital)) part = line[21:].replace("D","E").rstrip() temp = [] for j in range(0,len(part),10): temp.append(float(part[j:j+10])) if beta: - self.mocoeff[1,base:base+len(part)/10,i] = temp + self.mocoeffs[1,base:base+len(part)/10,i] = temp else: - self.mocoeff[base:base+len(part)/10,i] = temp + self.mocoeffs[base:base+len(part)/10,i] = temp self.logger.info("Took %f seconds" % (time.time()-oldtime)) - inputfile.close() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-10 10:04:41
|
Revision: 15 Author: baoilleach Date: 2006-03-10 02:04:34 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=15&view=rev Log Message: ----------- Very slight improvements in the section dealing with the progress. Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-09 19:54:18 UTC (rev 14) +++ trunk/src/cclib/parser/g03parser.py 2006-03-10 10:04:34 UTC (rev 15) @@ -19,6 +19,7 @@ """ import math,sys,logging,copy,re,os,time # How many of these are necessary? import Numeric +import random # For sometimes running the progress updater from logfileparser import Logfile # import the superclass class G03(Logfile): @@ -57,16 +58,16 @@ nstep=inputfile.tell() inputfile.seek(0) self.progress.initialize(nstep) - self.oldstep=0 + oldstep=0 for line in inputfile: - if self.progress: + if self.progress and random.random()<0.05: - step=inputfile.tell() - if not (step==self.oldstep): + step = inputfile.tell() + if step!=oldstep: self.progress.update(step) - self.oldstep=step + oldstep = step if line[1:8]=="NAtoms=": # Find the number of atoms This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-16 18:39:38
|
Revision: 25 Author: baoilleach Date: 2006-03-16 10:39:29 -0800 (Thu, 16 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=25&view=rev Log Message: ----------- Changed datatypes of more lists to Numeric arrays Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-16 18:38:51 UTC (rev 24) +++ trunk/src/cclib/parser/g03parser.py 2006-03-16 18:39:29 UTC (rev 25) @@ -20,7 +20,7 @@ import re,time import Numeric import random # For sometimes running the progress updater -from logfileparser import Logfile # import the superclass +from logfileparser import Logfile,convertor class G03(Logfile): """A Gaussian 98/03 log file""" @@ -222,7 +222,7 @@ i = 0 while i*10+4<len(part): x = part[i*10:(i+1)*10] - self.moenergies[0].append(self.float(x)*27.2114) # from a.u. (hartrees) to eV + self.moenergies[0].append(convertor(self.float(x),"hartree","eV")) i += 1 line = inputfile.next() if line.find('Beta')==2: @@ -243,9 +243,10 @@ i = 0 while i*10+4<len(part): x = part[i*10:(i+1)*10] - self.moenergies[1].append(self.float(x)*27.2114) # from a.u. (hartrees) to eV + self.moenergies[1].append(convertor(self.float(x),"hartree","eV")) i += 1 - line = inputfile.next() + line = inputfile.next() + self.moenergies = Numeric.array(self.moenergies,"f") if line[1:14]=="Harmonic freq": # Start of the IR/Raman frequency section @@ -279,6 +280,9 @@ while len(line[:15].split())>0: line = inputfile.next() line = inputfile.next() # Should be the line with symmetries + self.vibfreqs = Numeric.array(self.vibfreqs,"f") + self.vibirs = Numeric.array(self.vibirs,"f") + self.vibramans = Numeric.array(self.vibramans,"f") if line[1:14]=="Excited State": # Extract the electronic transitions @@ -328,8 +332,11 @@ CIScontrib.append([(fromMO,frommoindex),(toMO,tomoindex),sqr]) line = inputfile.next() self.etsecs.append(CIScontrib) + self.etenergies = Numeric.array(self.etenergies,"f") + self.etoscs = Numeric.array(self.etosc,"f") + if line[1:52]=="<0|r|b> * <b|rxdel|0> (Au), Rotatory Strengths (R)": # Extract circular dichroism data self.etrotats = [] @@ -350,6 +357,7 @@ line = inputfile.next() temp = line.strip().split() parts = line.strip().split() + self.etrotats = Numeric.array(self.etrotats,"f") if line[1:7]=="NBasis" or line[4:10]=="NBasis": # Extract the number of basis sets @@ -385,13 +393,12 @@ self.logger.info("Creating attribute nbasis: %d" % self.nbasis) if line[1:4]=="***" and (line[5:12]=="Overlap" - or line[8:15]=="Overlap"): + or line[8:15]=="Overlap"): # Extract the molecular orbital overlap matrix # Has to deal with lines such as: # *** Overlap *** # ****** Overlap ****** self.logger.info("Creating attribute aooverlaps[x,y]") - # oldtime = time.time() self.aooverlaps = Numeric.zeros( (self.nbasis,self.nbasis), "float") # Overlap integrals for basis fn#1 are in aooverlaps[0] base = 0 @@ -406,10 +413,10 @@ self.aooverlaps[i+base,base+j] = k base += 5 colmNames = inputfile.next() - # self.logger.info("Took %f seconds" % (time.time()-oldtime)) + self.aooverlaps = Numeric.array(self.aooverlaps,"f") + if line[5:35]=="Molecular Orbital Coefficients" or line[5:41]=="Alpha Molecular Orbital Coefficients" or line[5:40]=="Beta Molecular Orbital Coefficients": - # oldtime = time.time() if line[5:40]=="Beta Molecular Orbital Coefficients": beta = True # Need to add an extra dimension to self.mocoeffs @@ -418,7 +425,7 @@ beta = False self.logger.info("Creating attributes aonames[], mocoeffs[][]") self.aonames = [] - self.mocoeffs = Numeric.zeros((nindep,nbasis),"float") + self.mocoeffs = Numeric.zeros((1,nindep,nbasis),"float") base = 0 for base in range(0,nindep,5): @@ -443,14 +450,15 @@ self.mocoeffs[1,base:base+len(part)/10,i] = temp else: self.mocoeffs[base:base+len(part)/10,i] = temp - # self.logger.info("Took %f seconds" % (time.time()-oldtime)) inputfile.close() - # Convert from lists to arrays (it's easier this way in most cases) + + self.geovalues = Numeric.array(self.geovalues,"f") + self.homos = Numeric.array(self.homos,"d") self.scfenergies = Numeric.array(self.scfenergies,"f") self.scfvalues = Numeric.array(self.scftargets,"f") - scf.geovalues = Numeric.array(self.scfvalues,"f") + # Note to self: Needs to be added to the main parser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-18 21:42:52
|
Revision: 26 Author: baoilleach Date: 2006-03-18 13:42:45 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=26&view=rev Log Message: ----------- Finished transition to Numeric arrays Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-16 18:39:29 UTC (rev 25) +++ trunk/src/cclib/parser/g03parser.py 2006-03-18 21:42:45 UTC (rev 26) @@ -182,7 +182,7 @@ i = 0 while len(line)>18 and line[17]=='(': if line.find('Virtual')>=0: - self.homos = [i-1] # 'HOMO' indexes the HOMO in the arrays + self.homos = Numeric.array([i-1],"d") # 'HOMO' indexes the HOMO in the arrays self.logger.info("Creating attribute homos[]") parts = line[17:].split() for x in parts: @@ -196,7 +196,8 @@ self.mosyms.append([]) while len(line)>18 and line[17]=='(': if line.find('Virtual')>=0: - self.homos.append(i-1) # 'HOMO' indexes the HOMO in the arrays + self.homos.resize([2]) # Extend the array to two elements + self.homos[1] = i-1 # 'HOMO' indexes the HOMO in the arrays parts = line[17:].split() for x in parts: self.mosyms[1].append(x.strip('()')) @@ -217,7 +218,7 @@ assert HOMO==self.homos[0] else: self.logger.info("Creating attribute homos[]") - self.homos = [HOMO] + self.homos = Numeric.array([HOMO],"d") part = line[28:] i = 0 while i*10+4<len(part): @@ -238,7 +239,8 @@ # but does it already have a Beta value? assert HOMO==self.homos[1] else: - self.homos.append(HOMO) + self.homos.resize([2]) + self.homos[1] = HOMO part = line[28:] i = 0 while i*10+4<len(part): @@ -282,7 +284,7 @@ line = inputfile.next() # Should be the line with symmetries self.vibfreqs = Numeric.array(self.vibfreqs,"f") self.vibirs = Numeric.array(self.vibirs,"f") - self.vibramans = Numeric.array(self.vibramans,"f") + if hasattr(self,"vibramans"): self.vibramans = Numeric.array(self.vibramans,"f") if line[1:14]=="Excited State": # Extract the electronic transitions @@ -333,7 +335,7 @@ line = inputfile.next() self.etsecs.append(CIScontrib) self.etenergies = Numeric.array(self.etenergies,"f") - self.etoscs = Numeric.array(self.etosc,"f") + self.etoscs = Numeric.array(self.etoscs,"f") @@ -449,15 +451,14 @@ if beta: self.mocoeffs[1,base:base+len(part)/10,i] = temp else: - self.mocoeffs[base:base+len(part)/10,i] = temp + self.mocoeffs[0,base:base+len(part)/10,i] = temp inputfile.close() - self.geovalues = Numeric.array(self.geovalues,"f") - self.homos = Numeric.array(self.homos,"d") - self.scfenergies = Numeric.array(self.scfenergies,"f") - self.scfvalues = Numeric.array(self.scftargets,"f") + if hasattr(self,"geovalues"): self.geovalues = Numeric.array(self.geovalues,"f") + if hasattr(self,"scfenergies"): self.scfenergies = Numeric.array(self.scfenergies,"f") + if hasattr(self,"scfvalues"): self.scfvalues = Numeric.array(self.scftargets,"f") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-19 19:51:15
|
Revision: 28 Author: baoilleach Date: 2006-03-19 11:51:04 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=28&view=rev Log Message: ----------- Corrected 'type' errors. Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-18 21:43:47 UTC (rev 27) +++ trunk/src/cclib/parser/g03parser.py 2006-03-19 19:51:04 UTC (rev 28) @@ -144,11 +144,10 @@ if line[1:9]=='SCF Done': # Note: this needs to follow the section where 'SCF Done' is used to terminate # a loop when extracting SCF convergence information - if hasattr(self,"scfenergies"): - self.scfenergies.append(line.split()[4]) - else: - self.scfenergies = [line.split()[4]] + if not hasattr(self,"scfenergies"): self.logger.info("Creating attribute scfenergies[]") + self.scfenergies = [] + self.scfenergies.append(self.float(line.split()[4])) if line[49:59]=='Converged?': # Extract Geometry convergence information @@ -182,7 +181,7 @@ i = 0 while len(line)>18 and line[17]=='(': if line.find('Virtual')>=0: - self.homos = Numeric.array([i-1],"d") # 'HOMO' indexes the HOMO in the arrays + self.homos = Numeric.array([i-1],"i") # 'HOMO' indexes the HOMO in the arrays self.logger.info("Creating attribute homos[]") parts = line[17:].split() for x in parts: @@ -218,7 +217,7 @@ assert HOMO==self.homos[0] else: self.logger.info("Creating attribute homos[]") - self.homos = Numeric.array([HOMO],"d") + self.homos = Numeric.array([HOMO],"i") part = line[28:] i = 0 while i*10+4<len(part): @@ -337,8 +336,6 @@ self.etenergies = Numeric.array(self.etenergies,"f") self.etoscs = Numeric.array(self.etoscs,"f") - - if line[1:52]=="<0|r|b> * <b|rxdel|0> (Au), Rotatory Strengths (R)": # Extract circular dichroism data self.etrotats = [] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-05-16 17:02:41
|
Revision: 119 Author: baoilleach Date: 2006-05-16 10:01:46 -0700 (Tue, 16 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=119&view=rev Log Message: ----------- Added atomcoords which stores the input orientation at all stages of a geometry optimisation. Needed to add a flag to indicate when the GeoOpt was over to avoid extracting the final geometry twice. Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-05-13 21:05:51 UTC (rev 118) +++ trunk/src/cclib/parser/g03parser.py 2006-05-16 17:01:46 UTC (rev 119) @@ -64,6 +64,8 @@ self.progress.initialize(nstep) oldstep=0 + optfinished = False # Flag that indicates whether it has reached the end of a geoopt + for line in inputfile: if self.progress and random.random()<cupdate: @@ -89,30 +91,39 @@ self.natom = natom self.logger.info("Creating attribute natom: %d" % self.natom) - if not hasattr(self,"atomnos") and (line.find("Z-Matrix orientation")>=0 - or line[25:45]=="Standard orientation" - or line[26:43]=="Input orientation"): -# Extract the atomic numbers of the atoms + if line[1:23]=="Optimization completed": + optfinished = True + + if not optfinished and line[26:43]=="Input orientation": +# Extract the atomic numbers and coordinates of the atoms 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.atomnos = [] + if not hasattr(self,"atomcoords"): + self.logger.info("Creating attribute atomcoords[]") + self.atomcoords = [] + hyphens = inputfile.next() - colmNames = inputfile.next(); colmNames = inputfile.next() + colmNames = inputfile.next() + colmNames = inputfile.next() hyphens = inputfile.next() + + atomnos = [] + atomcoords = [] line = inputfile.next() while line!=hyphens: - self.atomnos.append(int(line.split()[1])) + broken = line.split() + atomnos.append(int(broken[1])) + atomcoords.append(map(float,broken[3:6])) line = inputfile.next() - natom = len(self.atomnos) - if hasattr(self,"natom"): - assert self.natom==natom - else: - self.natom = natom + self.atomcoords.append(atomcoords) + if not hasattr(self,"natom"): + self.atomnos = Numeric.array(atomnos,'f') + self.logger.info("Creating attribute atomnos[]") + self.natom = len(self.atomnos) self.logger.info("Creating attribute natom: %d" % self.natom) if line[1:44]=='Requested convergence on RMS density matrix': @@ -534,6 +545,7 @@ if hasattr(self,"geovalues"): self.geovalues = Numeric.array(self.geovalues,"f") if hasattr(self,"scfenergies"): self.scfenergies = Numeric.array(self.scfenergies,"f") if hasattr(self,"scfvalues"): self.scfvalues = [Numeric.array(x,"f") for x in self.scfvalues] + if hasattr(self,"atomcoords"): self.atomcoords = Numeric.array(self.atomcoords,"f") self.parsed = True This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-04-22 09:27:19
|
Revision: 80 Author: baoilleach Date: 2006-04-22 02:27:04 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=80&view=rev Log Message: ----------- Fixed bug (scfvalues was set equal to scf targets...ooops) and changed type of scfvalues to a list of arrays Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-04-22 09:24:03 UTC (rev 79) +++ trunk/src/cclib/parser/g03parser.py 2006-04-22 09:27:04 UTC (rev 80) @@ -513,7 +513,7 @@ if hasattr(self,"geovalues"): self.geovalues = Numeric.array(self.geovalues,"f") if hasattr(self,"scfenergies"): self.scfenergies = Numeric.array(self.scfenergies,"f") - if hasattr(self,"scfvalues"): self.scfvalues = Numeric.array(self.scftargets,"f") + if hasattr(self,"scfvalues"): self.scfvalues = [Numeric.array(x,"f") for x in self.scfvalues] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-04-26 01:20:20
|
Revision: 94 Author: atenderholt Date: 2006-04-25 18:20:18 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=94&view=rev Log Message: ----------- Minor change to progress parts of g03 parser Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-04-26 01:04:49 UTC (rev 93) +++ trunk/src/cclib/parser/g03parser.py 2006-04-26 01:20:18 UTC (rev 94) @@ -114,11 +114,6 @@ 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") @@ -126,6 +121,13 @@ newlist = [ [] for x in self.scftargets ] line = inputfile.next() while line.find("SCF Done")==-1: + + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"QM Convergence") + oldstep=step + if line.find(' E=')==0: self.logger.debug(line) if line.find(" RMSDP")==0: @@ -150,17 +152,19 @@ if line[1:4]=='It=': # Extract SCF convergence information (AM1 calcs) - if self.progress: - step=inputfile.tell() - if step!=oldstep: - self.progress.update(step,"AM1 Convergence") - oldstep=step self.logger.info("Creating attributes scftargets, scfvalues") self.scftargets = Numeric.array([1E-7],"f") # This is the target value for the rms self.scfvalues = [[]] line = inputfile.next() while line.find(" Energy")==-1: + + if self.progress: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"AM1 Convergence") + oldstep=step + parts = line.strip().split() self.scfvalues[0].append(self.float(parts[-1][:-1])) line = inputfile.next() @@ -488,6 +492,8 @@ symmetries = inputfile.next() eigenvalues = inputfile.next() for i in range(nbasis): + + line = inputfile.next() if base==0 and not beta: # Just do this the first time 'round # Changed below from :12 to :11 to deal with Elmar Neumann's example This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-05-03 08:44:23
|
Revision: 97 Author: baoilleach Date: 2006-05-03 01:44:14 -0700 (Wed, 03 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=97&view=rev Log Message: ----------- Normalising the symmetries from Gaussian Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-05-01 21:03:55 UTC (rev 96) +++ trunk/src/cclib/parser/g03parser.py 2006-05-03 08:44:14 UTC (rev 97) @@ -37,7 +37,21 @@ def __repr__(self): """Return a representation of the object.""" return 'G03("%s")' % (self.filename) + + def normalisesym(self,label): + """Use standard symmetry labels instead of Gaussian labels. + To normalise: + (1) replace any G or U by their lowercase equivalent + + >>> sym = G03("dummyfile").normalisesym + >>> labels = ['A1','AG','A1G'] + >>> map(sym,labels) + ['A1', 'Ag', 'A1g'] + """ + ans = label.replace("U","u").replace("G","g") + return ans + def parse(self,fupdate=0.05,cupdate=0.002): """Extract information from the logfile.""" inputfile = open(self.filename,"r") @@ -219,7 +233,7 @@ self.logger.info("Creating attribute homos[]") parts = line[17:].split() for x in parts: - self.mosyms[0].append(x.strip('()')) + self.mosyms[0].append(self.normalisesym(x.strip('()'))) i+= 1 line = inputfile.next() if unres: @@ -233,7 +247,7 @@ self.homos[1] = i-1 # 'HOMO' indexes the HOMO in the arrays parts = line[17:].split() for x in parts: - self.mosyms[1].append(x.strip('()')) + self.mosyms[1].append(self.normalisesym(x.strip('()'))) i+= 1 line = inputfile.next() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-05-09 01:11:48
|
Revision: 100 Author: atenderholt Date: 2006-05-08 18:11:45 -0700 (Mon, 08 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=100&view=rev Log Message: ----------- Fixed an off-by-one error in the gaussian parser's aooverlap section. It was parsing the AO numbers, but should be fixed now. Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-05-08 21:06:30 UTC (rev 99) +++ trunk/src/cclib/parser/g03parser.py 2006-05-09 01:11:45 UTC (rev 100) @@ -474,7 +474,7 @@ line = inputfile.next() parts = line.split() for j in range(len(parts)-1): # Some lines are longer than others - k = float(parts[j].replace("D","E")) + k = float(parts[j+1].replace("D","E")) self.aooverlaps[base+j,i+base] = k self.aooverlaps[i+base,base+j] = k base += 5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-05-17 16:22:22
|
Revision: 121 Author: baoilleach Date: 2006-05-17 09:22:09 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=121&view=rev Log Message: ----------- Fixed bug when creating the Numeric array for atomnos. Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-05-16 18:21:53 UTC (rev 120) +++ trunk/src/cclib/parser/g03parser.py 2006-05-17 16:22:09 UTC (rev 121) @@ -121,7 +121,7 @@ line = inputfile.next() self.atomcoords.append(atomcoords) if not hasattr(self,"natom"): - self.atomnos = Numeric.array(atomnos,'f') + self.atomnos = Numeric.array(atomnos,'i') self.logger.info("Creating attribute atomnos[]") self.natom = len(self.atomnos) self.logger.info("Creating attribute natom: %d" % self.natom) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |