This list is closed, nobody may subscribe to it.
2006 |
Jan
|
Feb
|
Mar
(34) |
Apr
(46) |
May
(61) |
Jun
(32) |
Jul
(37) |
Aug
(55) |
Sep
(25) |
Oct
(44) |
Nov
(28) |
Dec
(23) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(27) |
Feb
(71) |
Mar
(55) |
Apr
(10) |
May
(18) |
Jun
(32) |
Jul
(36) |
Aug
(33) |
Sep
(25) |
Oct
(21) |
Nov
(22) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(9) |
Jul
(10) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
(6) |
Mar
|
Apr
(5) |
May
|
Jun
(1) |
Jul
(17) |
Aug
|
Sep
(1) |
Oct
(10) |
Nov
(2) |
Dec
|
2010 |
Jan
(2) |
Feb
(6) |
Mar
(7) |
Apr
(14) |
May
|
Jun
(2) |
Jul
(2) |
Aug
(3) |
Sep
(5) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
(6) |
Feb
|
Mar
(10) |
Apr
(9) |
May
|
Jun
(1) |
Jul
(2) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
(4) |
Feb
(1) |
Mar
(2) |
Apr
(11) |
May
|
Jun
|
Jul
(7) |
Aug
|
Sep
|
Oct
(18) |
Nov
(22) |
Dec
(6) |
2013 |
Jan
|
Feb
(21) |
Mar
(3) |
Apr
(3) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(5) |
Sep
(4) |
Oct
(1) |
Nov
(11) |
Dec
(4) |
From: <ate...@us...> - 2006-03-22 22:57:51
|
Revision: 40 Author: atenderholt Date: 2006-03-22 14:57:48 -0800 (Wed, 22 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=40&view=rev Log Message: ----------- Started work on ADF parser Modified Paths: -------------- trunk/src/cclib/parser/logfileparser.py Added Paths: ----------- trunk/src/cclib/parser/adfparser.py Added: trunk/src/cclib/parser/adfparser.py =================================================================== --- trunk/src/cclib/parser/adfparser.py (rev 0) +++ trunk/src/cclib/parser/adfparser.py 2006-03-22 22:57:48 UTC (rev 40) @@ -0,0 +1,543 @@ +""" +cclib is a parser for computational chemistry log files. + +See http://cclib.sf.net for more information. + +Copyright (C) 2006 Noel O'Boyle and Adam Tenderholt + + This program is free software; you can redistribute and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + +Contributions (monetary as well as code :-) are encouraged. +""" +import re,time +import Numeric +import random # For sometimes running the progress updater +from logfileparser import Logfile,convertor + +class ADF(Logfile): + """A Gaussian 98/03 log file""" + SCFRMS,SCFMAX,SCFENERGY = range(3) # Used to index self.scftargets[] + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(ADF, self).__init__(logname="ADF",*args) + + def __str__(self): + """Return a string representation of the object.""" + return "ADF log file %s" % (self.filename) + + def __repr__(self): + """Return a representation of the object.""" + return 'ADF("%s")' % (self.filename) + + def parse(self,fupdate=0.05,cupdate=0.002): + """Extract information from the logfile.""" + inputfile = open(self.filename,"r") + + if self.progress: + + inputfile.seek(0,2) #go to end of file + nstep=inputfile.tell() + inputfile.seek(0) + self.progress.initialize(nstep) + oldstep=0 + + for line in inputfile: + + if self.progress and random.random()<cupdate: + + step = inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Unsupported Information") + oldstep = step + + if line.find("INPUT FILE")>=0: +#check to make sure we aren't parsing Create jobs + line2=inputfile.next() + while line: + if line.find("Create")<0: + break + + if self.progress and random.random()<cupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Unsupported Information") + oldstep=step + + + if line[1:6]=="ATOMS": +# Find the number of atoms and their atomic numbers + 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=[] + + underline=inputfile.next() #clear pointless lines + label1=inputfile.next() # + label2=inputfile.next() # + line=inputfile.next() + while len(line)>1: #ensure that we are reading no blank lines + info=line.split() + self.atomnos.append(self.table.number[info[1]]) + line=inputfile.next() + + self.natom=len(self.atomnos) + self.logger.info("Creating attribute natom: %d" % self.natom) + +# if line[1:44]=='Requested convergence on RMS density matrix': +# # Find the targets for SCF convergence (QM calcs) +# if not hasattr(self,"scftargets"): +# self.logger.info("Creating attribute scftargets[]") +# self.scftargets = Numeric.array([0.0,0.0,0.0],'f') +# self.scftargets[G03.SCFRMS] = self.float(line.split('=')[1].split()[0]) +# if line[1:44]=='Requested convergence on MAX density matrix': +# self.scftargets[G03.SCFMAX] = self.float(line.strip().split('=')[1][:-1]) +# if line[1:44]=='Requested convergence on energy': +# self.scftargets[G03.SCFENERGY] = self.float(line.strip().split('=')[1][:-1]) +# +# 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[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: +# parts = line.strip().split() +# self.scfvalues[0].append(self.float(parts[-1][:-1])) +# line = inputfile.next() +# +# 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 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 +# if not hasattr(self,"geotargets"): +# self.logger.info("Creating attributes geotargets[],geovalues[[]]") +# self.geovalues = [] +# self.geotargets = Numeric.array( [0.0,0.0,0.0,0.0],"f") +# newlist = [0]*4 +# for i in range(4): +# line = inputfile.next() +# self.logger.debug(line) +# parts = line.split() +# try: +# value = self.float(parts[2]) +# except ValueError: +# self.logger.error("Problem parsing the value for geometry optimisation: %s is not a number." % parts[2]) +# else: +# newlist[i] = value +# self.geotargets[i] = self.float(parts[3]) +# self.geovalues.append(newlist) +# +# if line[1:19]=='Orbital symmetries' and not hasattr(self,"mosyms"): +# # Extracting orbital symmetries +# if self.progress and random.random()<fupdate: +# step=inputfile.tell() +# if step!=oldstep: +# self.progress.update(step,"MO Symmetries") +# oldstep=step +# +# self.logger.info("Creating attribute mosyms[[]]") +# self.mosyms = [[]] +# line = inputfile.next() +# unres = False +# if line.find("Alpha Orbitals")==1: +# unres = True +# line = inputfile.next() +# i = 0 +# while len(line)>18 and line[17]=='(': +# if line.find('Virtual')>=0: +# 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: +# self.mosyms[0].append(x.strip('()')) +# i+= 1 +# line = inputfile.next() +# if unres: +# line = inputfile.next() +# # Repeat with beta orbital information +# i = 0 +# self.mosyms.append([]) +# while len(line)>18 and line[17]=='(': +# if line.find('Virtual')>=0: +# 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('()')) +# i+= 1 +# line = inputfile.next() +# +# if line[1:6]=="Alpha" and line.find("eigenvalues")>=0: +# # Extract the alpha electron eigenvalues +# if self.progress and random.random()<fupdate: +# step=inputfile.tell() +# if step!=oldstep: +# self.progress.update(step,"Eigenvalues") +# oldstep=step +# +# 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.moenergies[0])-1 +# if hasattr(self,"homos"): +# assert HOMO==self.homos[0] +# else: +# self.logger.info("Creating attribute homos[]") +# self.homos = Numeric.array([HOMO],"i") +# part = line[28:] +# i = 0 +# while i*10+4<len(part): +# x = part[i*10:(i+1)*10] +# self.moenergies[0].append(convertor(self.float(x),"hartree","eV")) +# i += 1 +# line = inputfile.next() +# if line.find('Beta')==2: +# 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.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? +# assert HOMO==self.homos[1] +# else: +# self.homos.resize([2]) +# self.homos[1] = HOMO +# part = line[28:] +# i = 0 +# while i*10+4<len(part): +# x = part[i*10:(i+1)*10] +# self.moenergies[1].append(convertor(self.float(x),"hartree","eV")) +# i += 1 +# line = inputfile.next() +# self.moenergies = Numeric.array(self.moenergies,"f") +# +# if line[1:14]=="Harmonic freq": +# # Start of the IR/Raman frequency section +# if self.progress and random.random()<fupdate: +# step=inputfile.tell() +# if step!=oldstep: +# self.progress.update(step,"Frequency Information") +# oldstep=step +# +# self.vibsyms = [] +# self.vibirs = [] +# self.vibfreqs = [] +# 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 +# line = inputfile.next() +# line = inputfile.next() # The line with symmetries +# while len(line[:15].split())==0: +# self.logger.debug(line) +# self.vibsyms.extend(line.split()) # Adding new symmetry +# line = inputfile.next() +# 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,"vibramans"): +# self.vibramans = [] +# self.logger.info("Creating attribute vibramans[]") +# line = inputfile.next() +# self.vibramans.extend(map(self.float,line[15:].split())) # Adding Raman intensities +# line = inputfile.next() +# 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") +# if hasattr(self,"vibramans"): self.vibramans = Numeric.array(self.vibramans,"f") +# +# if line[1:14]=="Excited State": +# # Extract the electronic transitions +# if not hasattr(self,"etenergy"): +# 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.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() +# +# p = re.compile("(\d+)") +# CIScontrib = [] +# while line.find(" ->")>=0: # This is a contribution to the transition +# parts = line.split("->") +# self.logger.debug(parts) +# # Has to deal with lines like: +# # 32 -> 38 0.04990 +# # 35A -> 45A 0.01921 +# frommoindex = 0 # For restricted or alpha unrestricted +# fromMO = parts[0].strip() +# if fromMO[-1]=="B": +# frommoindex = 1 # For beta unrestricted +# fromMO = int(p.match(fromMO).group()) # extract the number +# +# t = parts[1].split() +# tomoindex = 0 +# toMO = t[0] +# if toMO[-1]=="B": +# tomoindex = 1 +# toMO = int(p.match(toMO).group()) +# +# percent = self.float(t[1]) +# sqr = percent**2*2 # The fractional contribution of this CI +# if percent<0: +# sqr = -sqr +# 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.etoscs,"f") +# +# if line[1:52]=="<0|r|b> * <b|rxdel|0> (Au), Rotatory Strengths (R)": +# # Extract circular dichroism data +# self.etrotats = [] +# self.logger.info("Creating attribute etrotats[]") +# inputfile.next() +# inputfile.next() +# line = inputfile.next() +# parts = line.strip().split() +# while len(parts)==5: +# try: +# R = self.float(parts[-1]) +# except ValueError: +# # nan or -nan if there is no first excited state +# # (for unrestricted calculations) +# pass +# else: +# self.etrotats.append(R) +# 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 +# nbasis = int(line.split('=')[1].split()[0]) +# # Has to deal with lines like: +# # 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 +# else: +# 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 +# nindep = int(line.split('=')[1].split()[0]) +# if hasattr(self,"nindep"): +# assert nindep==self.nindep +# else: +# 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 +# # (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) +# +# if line[1:4]=="***" and (line[5:12]=="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]") +# 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: +# +# if self.progress and random.random()<fupdate: +# step=inputfile.tell() +# if step!=oldstep: +# self.progress.update(step,"Overlap") +# oldstep=step +# +# 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.aooverlaps[base+j,i+base] = k +# self.aooverlaps[i+base,base+j] = k +# base += 5 +# colmNames = inputfile.next() +# 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": +# if line[5:40]=="Beta Molecular Orbital Coefficients": +# beta = True +# # 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 aonames[], mocoeffs[][]") +# self.aonames = [] +# self.mocoeffs = Numeric.zeros((1,nindep,nbasis),"float") +# +# base = 0 +# for base in range(0,nindep,5): +# +# if self.progress: +# step=inputfile.tell() +# if step!=oldstep and random.random() < fupdate: +# self.progress.update(step,"Coefficients") +# oldstep=step +# +# colmNames = inputfile.next() +# 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 +# parts = line[:11].split() +# if len(parts)>1: # New atom +# atomname = "%s%s" % (parts[2],parts[1]) +# orbital = line[11:20].strip() +# 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.mocoeffs[1,base:base+len(part)/10,i] = temp +# else: +# self.mocoeffs[0,base:base+len(part)/10,i] = temp + + inputfile.close() + + 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") + if hasattr(self,"scfvalues"): self.scfvalues = Numeric.array(self.scftargets,"f") + + + +# Note to self: Needs to be added to the main parser + def extractTrajectory(self): + """Extract trajectory information from a Gaussian logfile.""" + inputfile = open(self.filename,"r") + self.traj = [] + self.trajSummary = [] + for line in inputfile: + if line.find(" Cartesian coordinates:")==0: + coords = [] + for i in range(self.natom): + line = inputfile.next() + parts = line.strip().split() + # Conversion from a.u. to Angstrom + coords.append([ self.float(x)*0.5292 for x in [parts[3],parts[5],parts[7]] ]) + self.traj.append(coords) + if line==" Trajectory summary\n": + # self.trajSummaryHeader = inputfile.next().strip().split() + header = inputfile.next() + line = inputfile.next() + while line.find("Max Error")==-1: + parts = line.strip().split(" ") + self.trajSummary.append(parts) + line = inputfile.next() + inputfile.close() + assert len(self.traj)==len(self.trajSummary) + +if __name__=="__main__": + import doctest,parser + doctest.testmod(parser,verbose=False) Property changes on: trunk/src/cclib/parser/adfparser.py ___________________________________________________________________ Name: svn:executable + * Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-22 01:42:16 UTC (rev 39) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-22 22:57:48 UTC (rev 40) @@ -94,6 +94,7 @@ self.progress = progress self.loglevel = loglevel self.logname = logname + self.table = PeriodicTable() # Set up the logger self.logger = logging.getLogger('%s %s' % (self.logname,self.filename)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-03-22 00:06:43
|
Revision: 38 Author: atenderholt Date: 2006-03-21 16:06:38 -0800 (Tue, 21 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=38&view=rev Log Message: ----------- Work on the text progress Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py trunk/src/cclib/parser/logfileparser.py trunk/src/cclib/parser/textprogress.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-21 18:40:26 UTC (rev 37) +++ trunk/src/cclib/parser/g03parser.py 2006-03-22 00:06:38 UTC (rev 38) @@ -38,7 +38,7 @@ """Return a representation of the object.""" return 'G03("%s")' % (self.filename) - def parse(self): + def parse(self,fupdate=0.05,cupdate=0.002): """Extract information from the logfile.""" inputfile = open(self.filename,"r") @@ -52,15 +52,21 @@ for line in inputfile: - if self.progress and random.random()<0.05: + if self.progress and random.random()<cupdate: step = inputfile.tell() if step!=oldstep: - self.progress.update(step) + self.progress.update(step,"Unsupported Information") oldstep = step if line[1:8]=="NAtoms=": # Find the number of atoms + if self.progress and random.random()<fupdate: + step = inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Attributes") + oldstep=step + natom = int(line.split()[1]) if hasattr(self,"natom"): assert self.natom==natom @@ -73,6 +79,12 @@ or line[25:45]=="Standard orientation" or line[26:43]=="Input orientation"): # Extract the atomic numbers 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 = [] hyphens = inputfile.next() @@ -102,6 +114,12 @@ 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 = [] @@ -132,6 +150,12 @@ 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 = [[]] @@ -171,6 +195,12 @@ if line[1:19]=='Orbital symmetries' and not hasattr(self,"mosyms"): # Extracting orbital symmetries + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"MO Symmetries") + oldstep=step + self.logger.info("Creating attribute mosyms[[]]") self.mosyms = [[]] line = inputfile.next() @@ -205,6 +235,12 @@ if line[1:6]=="Alpha" and line.find("eigenvalues")>=0: # Extract the alpha electron eigenvalues + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Eigenvalues") + oldstep=step + self.logger.info("Creating attribute moenergies[[]]") self.moenergies = [[]] HOMO = -2 @@ -251,6 +287,12 @@ if line[1:14]=="Harmonic freq": # Start of the IR/Raman frequency section + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Frequency Information") + oldstep=step + self.vibsyms = [] self.vibirs = [] self.vibfreqs = [] @@ -403,6 +445,13 @@ base = 0 colmNames = inputfile.next() while base<self.nbasis: + + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Overlap") + oldstep=step + for i in range(self.nbasis-base): # Fewer lines this time line = inputfile.next() parts = line.split() @@ -428,6 +477,13 @@ base = 0 for base in range(0,nindep,5): + + if self.progress: + step=inputfile.tell() + if step!=oldstep and random.random() < fupdate: + self.progress.update(step,"Coefficients") + oldstep=step + colmNames = inputfile.next() symmetries = inputfile.next() eigenvalues = inputfile.next() @@ -452,7 +508,9 @@ inputfile.close() - + 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") if hasattr(self,"scfvalues"): self.scfvalues = Numeric.array(self.scftargets,"f") Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-21 18:40:26 UTC (rev 37) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-22 00:06:38 UTC (rev 38) @@ -97,7 +97,7 @@ # Set up the logger self.logger = logging.getLogger('%s %s' % (self.logname,self.filename)) - self.logger.setLevel(logging.INFO) + self.logger.setLevel(self.loglevel) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s")) self.logger.addHandler(handler) Modified: trunk/src/cclib/parser/textprogress.py =================================================================== --- trunk/src/cclib/parser/textprogress.py 2006-03-21 18:40:26 UTC (rev 37) +++ trunk/src/cclib/parser/textprogress.py 2006-03-22 00:06:38 UTC (rev 38) @@ -1,3 +1,5 @@ +import sys +import thread class TextProgress: @@ -7,29 +9,38 @@ self.text=None self.oldprogress=0 self.progress=0 + self.calls=0 def initialize(self,nstep,text=None): self.nstep=float(nstep) self.text=text + + #sys.stdout.write("\n") - def update(self,step): + def update(self,step,text=None): + + self.progress = int(step*100/self.nstep) - self.progress = int(step/self.nstep*100) - #print step,self.nstep - - if self.progress/10==self.oldprogress/10+1: #just went through an interval of ten, ie. from 39 to 41, so update + if self.progress/2>=self.oldprogress/2+1 or self.text!=text: #just went through at least an interval of ten, ie. from 39 to 41, so update - str="[" - for i in range(self.progress/10): - str+="=" - for i in range(self.progress/10,10): - str+="-" - - str+="]" + str="\r[" + prog=self.progress/10 + str+=prog*"="+(10-prog)*"-" + str+="] %3i"%(self.progress)+"%" - print str + if text: + str+=" Parsing "+text + + sys.stdout.write("\r"+70*" ") + sys.stdout.flush() + sys.stdout.write(str) + sys.stdout.flush() + self.oldprogress=self.progress - self.oldprogress=self.progress + if(self.progress>=100 and text=="Done"): + print " " + + return This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-03-21 17:55:34
|
Revision: 35 Author: atenderholt Date: 2006-03-21 09:55:25 -0800 (Tue, 21 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=35&view=rev Log Message: ----------- metadata added Added Paths: ----------- trunk/data/ADF/basicADF2004.01/metadata.txt Added: trunk/data/ADF/basicADF2004.01/metadata.txt =================================================================== --- trunk/data/ADF/basicADF2004.01/metadata.txt (rev 0) +++ trunk/data/ADF/basicADF2004.01/metadata.txt 2006-03-21 17:55:25 UTC (rev 35) @@ -0,0 +1,3 @@ +ADF v.2004.01 build 200410211341 +Redhat 9 +Original unoptimized cartesian coordinates from file created in molden This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-19 20:11:49
|
Revision: 33 Author: baoilleach Date: 2006-03-19 12:11:38 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=33&view=rev Log Message: ----------- This test is included in the new ones instead Removed Paths: ------------- trunk/test/easyparse.py Deleted: trunk/test/easyparse.py =================================================================== --- trunk/test/easyparse.py 2006-03-19 20:10:58 UTC (rev 32) +++ trunk/test/easyparse.py 2006-03-19 20:11:38 UTC (rev 33) @@ -1,10 +0,0 @@ -import os -from cclib.parser import G03 - -t = G03(os.path.join("..","data","Gaussian","dvb_gopt.out")) -t.parse() - -for x in ['scftargets','geotargets','scfvalues','geovalues']: - print x - t.__getattribute__(x)+1 - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-19 20:11:10
|
Revision: 32 Author: baoilleach Date: 2006-03-19 12:10:58 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=32&view=rev Log Message: ----------- Adding a couple of tests Added Paths: ----------- trunk/test/parseGAMESS.py trunk/test/parseGaussian.py trunk/test/testall.py Added: trunk/test/parseGAMESS.py =================================================================== --- trunk/test/parseGAMESS.py (rev 0) +++ trunk/test/parseGAMESS.py 2006-03-19 20:10:58 UTC (rev 32) @@ -0,0 +1,17 @@ +import os +from cclib.parser import GAMESS + +os.chdir(os.path.join("..","data","GAMESS")) + +for file in ["ex.out","WinGAMESS.log","exam01.out"]: + t = GAMESS(file) + t.parse() + +os.chdir("basicPCGAMESS") + +for file in ["dvb_gopt.out","dvb_sp.out","dvb_ir.out","dvb_raman.out", + "dvb_un_sp.out"]: + t = GAMESS(file) + t.parse() + + Property changes on: trunk/test/parseGAMESS.py ___________________________________________________________________ Name: svn:executable + * Added: trunk/test/parseGaussian.py =================================================================== --- trunk/test/parseGaussian.py (rev 0) +++ trunk/test/parseGaussian.py 2006-03-19 20:10:58 UTC (rev 32) @@ -0,0 +1,13 @@ +import os +from cclib.parser import G03 + +os.chdir(os.path.join("..","data","Gaussian")) + +os.chdir("basicGaussian03") + +for file in ["dvb_gopt.out","dvb_sp.out","dvb_ir.out","dvb_raman.out", + "dvb_un_sp.out"]: + t = G03(file) + t.parse() + + Property changes on: trunk/test/parseGaussian.py ___________________________________________________________________ Name: svn:executable + * Added: trunk/test/testall.py =================================================================== --- trunk/test/testall.py (rev 0) +++ trunk/test/testall.py 2006-03-19 20:10:58 UTC (rev 32) @@ -0,0 +1,27 @@ +import os +from cclib.parser import GAMESS,G03 + +os.chdir(os.path.join("..","data")) + +testfiles = [G03(os.path.join("Gaussian","basicGaussian03","dvb_gopt.out")), + GAMESS(os.path.join("GAMESS","basicPCGAMESS","dvb_gopt_a.out"))] + +for testfile in testfiles: + testfile.logger.setLevel(0) + testfile.parse() + +attribs = ['natom','homos','nbasis'] +for attrib in attribs: + print attrib, + for testfile in testfiles: + print testfile.__getattribute__(attrib), + print + +print "Energy of optimised molecule", +for testfile in testfiles: + print testfile.scfenergies[-1], +print +print "Energy of HOMO", +for testfile in testfiles: + print testfile.moenergies[0,testfile.homos[0]], +print Property changes on: trunk/test/testall.py ___________________________________________________________________ Name: svn:executable + * 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:53:06
|
Revision: 29 Author: baoilleach Date: 2006-03-19 11:52:56 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=29&view=rev Log Message: ----------- Now the gamessparser can parse (correctly or not) all of the dvb test files. Modified Paths: -------------- trunk/src/cclib/parser/gamessparser.py Modified: trunk/src/cclib/parser/gamessparser.py =================================================================== --- trunk/src/cclib/parser/gamessparser.py 2006-03-19 19:51:04 UTC (rev 28) +++ trunk/src/cclib/parser/gamessparser.py 2006-03-19 19:52:56 UTC (rev 29) @@ -77,32 +77,28 @@ opttol = float(x.split('=')[1]) self.geotargets = Numeric.array([opttol,3./opttol]) - if line.find("EQUILIBRIUM GEOMETRY LOCATED")>=0: -# This is necessary if a frequency calculation follows a geometry optimisation - endofopt = True - - if not endofopt and line.find("FINAL")==1: + if line.find("FINAL")==1: if not hasattr(self,"scfenergies"): self.logger.info("Creating attribute scfenergies[]") self.scfenergies = [] -# Here is an example from Neil Berry: +# Has to deal with such lines as: # FINAL R-B3LYP ENERGY IS -382.0507446475 AFTER 10 ITERATIONS -# but in some cases the energy can be in position [3] not [4] so let's -# take the number after the "IS" +# FINAL ENERGY IS -379.7594673378 AFTER 9 ITERATIONS +# ...so take the number after the "IS" temp = line.split() self.scfenergies.append(temp[temp.index("IS")+1]) - if not endofopt and line.find("MAXIMUM GRADIENT")>0: + if line.find("MAXIMUM GRADIENT")>0: if not hasattr(self,"geovalues"): self.logger.info("Creating attribute geovalues[]") self.geovalues = [] temp = line.strip().split() self.geovalues.append([float(temp[3]),float(temp[7])]) - - if line.find("DENSITY CONV=")==5: - self.scftargets[0] = float(line.strip().split()[-1]) + if not hasattr(self,"scftargets"): + self.logger.info("Creating attribute scftargets") + self.scftargets = Numeric.array([float(line.strip().split()[-1])]) if line.find("ITER EX DEM")==1: # This is the section with the SCF information @@ -127,7 +123,38 @@ self.scfvalues.append(den) if line.find("NORMAL COORDINATE ANALYSIS IN THE HARMONIC APPROXIMATION")>=0: - # Start of the frequency section +# GAMESS has... +# MODES 1 TO 6 ARE TAKEN AS ROTATIONS AND TRANSLATIONS. +# +# FREQUENCIES IN CM**-1, IR INTENSITIES IN DEBYE**2/AMU-ANGSTROM**2, +# REDUCED MASSES IN AMU. +# +# 1 2 3 4 5 +# FREQUENCY: 52.49 41.45 17.61 9.23 10.61 +# REDUCED MASS: 3.92418 3.77048 5.43419 6.44636 5.50693 +# IR INTENSITY: 0.00013 0.00001 0.00004 0.00000 0.00003 + +# whereas PC-GAMESS has... +# MODES 1 TO 6 ARE TAKEN AS ROTATIONS AND TRANSLATIONS. +# +# FREQUENCIES IN CM**-1, IR INTENSITIES IN DEBYE**2/AMU-ANGSTROM**2 +# +# 1 2 3 4 5 +# FREQUENCY: 5.89 1.46 0.01 0.01 0.01 +# IR INTENSITY: 0.00000 0.00000 0.00000 0.00000 0.00000 + +# If Raman is present we have (for PC-GAMESS)... +# MODES 1 TO 6 ARE TAKEN AS ROTATIONS AND TRANSLATIONS. +# +# FREQUENCIES IN CM**-1, IR INTENSITIES IN DEBYE**2/AMU-ANGSTROM**2 +# RAMAN INTENSITIES IN ANGSTROM**4/AMU, DEPOLARIZATIONS ARE DIMENSIONLESS +# +# 1 2 3 4 5 +# FREQUENCY: 5.89 1.46 0.04 0.03 0.01 +# IR INTENSITY: 0.00000 0.00000 0.00000 0.00000 0.00000 +# RAMAN INTENSITY: 12.675 1.828 0.000 0.000 0.000 +# DEPOLARIZATION: 0.750 0.750 0.124 0.009 0.750 + self.logger.info("Creating attributes vibfreqs, vibirs") self.vibfreqs = [] self.vibirs = [] @@ -143,22 +170,32 @@ numAtom += 1 line = inputfile.next() - # Print out the following lines which may contain some useful info: - # e.g. WARNING, MODE 7 HAS BEEN CHOSEN AS A VIBRATION line = inputfile.next() while line.find("FREQUENCIES IN CM**-1")==-1: line = inputfile.next() - line = inputfile.next() - - blank = inputfile.next() + while line!=blank: + line = inputfile.next() + freqNo = inputfile.next() while freqNo.find("SAYVETZ")==-1: freq = inputfile.next().strip().split() self.vibfreqs.extend(map(float,freq[1:])) - reducedMass = inputfile.next() - irIntensity = inputfile.next().strip().split() + line = inputfile.next() + if line.find("REDUCED")>=0: # skip the reduced mass (not always present) + line = inputfile.next() + irIntensity = line.strip().split() self.vibirs.extend(map(float,irIntensity[2:])) - blank = inputfile.next() + line = inputfile.next() + if line.find("RAMAN")>=0: + if not hasattr(self,"vibramans"): + self.logger.info("Creating attribute vibramans") + self.vibramans = [] + ramanIntensity = line.strip().split() + self.vibramans.extend(map(float,ramanIntensity[2:])) + depolar = inputfile.next() + line = inputfile.next() + assert line==blank + # Skip XYZ data for each atom plus # the Sayvetz stuff at the end for j in range(numAtom*3+10): @@ -177,24 +214,22 @@ # Take the last one of either in the file if not hasattr(self,"moenergies"): self.logger.info("Creating attributes moenergies, mosyms") - self.moenergies = [] + self.moenergies = [[]] self.mosyms = [] if not hasattr(self,"nindep"): self.logger.info("Creating attribute nindep with default value") self.nindep = self.nbasis self.mocoeffs = Numeric.zeros((1,self.nindep,self.nbasis),"f") line = inputfile.next() - blank = inputfile.next() # blank line - base = 0 - while line.find("END OF RHF")==-1: + for base in range(0,self.nindep,5): + blank = inputfile.next() line = inputfile.next() # Eigenvector no line = inputfile.next() - self.moenergies.extend(map(float,line.split())) + self.moenergies[0].extend([convertor(float(x),"hartree","eV") for x in line.split()]) line = inputfile.next() self.mosyms.extend(line.split()) - line = inputfile.next() - i=0 - while line!=blank and line.find("END OF RHF")==-1: + 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 # atomorb[atomno].append(int(line.split()[0])-1) @@ -204,16 +239,46 @@ while j*11+4<len(temp): self.mocoeffs[0,base+j,i] = float(temp[j*11:(j+1)*11]) j+=1 + line = inputfile.next() + if line.find("END OF RHF")==-1: # implies unrestricted +# If it's restricted we have +# ...... END OF RHF CALCULATION ...... +# If it's unrestricted we have... +# +# ----- BETA SET ----- +# +# ------------ +# EIGENVECTORS +# ------------ +# +# 1 2 3 4 5 + + self.mocoeffs.resize((2,self.nindep,self.nbasis)) + for i in range(5): line = inputfile.next() - i+=1 - base+=5 + for base in range(0,self.nindep,5): + blank = inputfile.next() + line = inputfile.next() # Eigenvector no + line = inputfile.next() + self.moenergies.extend(map(float,line.split())) + line = inputfile.next() + self.mosyms.extend(line.split()) + for i in range(self.nbasis): + line = inputfile.next() + temp = line[15:] # Strip off the crud at the start + j = 0 + while j*11+4<len(temp): + self.mocoeffs[1,base+j,i] = float(temp[j*11:(j+1)*11]) + j+=1 + line = inputfile.next() + assert line.find("END OF")>=0 self.moenergies = Numeric.array(self.moenergies,"f") if line.find("NUMBER OF OCCUPIED ORBITALS")>=0: if not hasattr(self,"homos"): self.logger.info("Creating attribute homos") temp = line.strip().split('=') - self.homos = Numeric.array(int(temp[-1])-1,"d") + self.homos = Numeric.array([int(temp[-1])-1],"i") if line.find("TOTAL NUMBER OF ATOMS")==1: self.logger.info("Creating attribute natom") @@ -234,8 +299,11 @@ 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 - self.logger.info("Creating attribute aooverlaps") - self.aooverlaps = Numeric.zeros((self.nbasis,self.nbasis), "f") + if not hasattr(self,"aooverlaps"): + self.logger.info("Creating attribute aooverlaps") + self.aooverlaps = Numeric.zeros((self.nbasis,self.nbasis), "f") + else: + self.logger.info("Reading additional aooverlaps...") base = 0 while base<self.nbasis: blank = inputfile.next() 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-03-18 21:43:55
|
Revision: 27 Author: baoilleach Date: 2006-03-18 13:43:47 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=27&view=rev Log Message: ----------- Adding the GAMESS parser. Currently passes simple unit tests. Modified Paths: -------------- trunk/src/cclib/parser/__init__.py Added Paths: ----------- trunk/src/cclib/parser/gamessparser.py Modified: trunk/src/cclib/parser/__init__.py =================================================================== --- trunk/src/cclib/parser/__init__.py 2006-03-18 21:42:45 UTC (rev 26) +++ trunk/src/cclib/parser/__init__.py 2006-03-18 21:43:47 UTC (rev 27) @@ -1 +1,2 @@ from g03parser import G03 +from gamessparser import GAMESS Added: trunk/src/cclib/parser/gamessparser.py =================================================================== --- trunk/src/cclib/parser/gamessparser.py (rev 0) +++ trunk/src/cclib/parser/gamessparser.py 2006-03-18 21:43:47 UTC (rev 27) @@ -0,0 +1,270 @@ +""" +cclib is a parser for computational chemistry log files. + +See http://cclib.sf.net for more information. + +Copyright (C) 2006 Noel O'Boyle and Adam Tenderholt + + This program is free software; you can redistribute and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + +Contributions (monetary as well as code :-) are encouraged. +""" +import re,time +import Numeric +import random # For sometimes running the progress updater +from logfileparser import Logfile,convertor + +class GAMESS(Logfile): + """A GAMESS log file.""" + SCFRMS,SCFMAX,SCFENERGY = range(3) # Used to index self.scftargets[] + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(GAMESS, self).__init__(logname="GAMESS",*args) + + def __str__(self): + """Return a string representation of the object.""" + return "GAMESS log file %s" % (self.filename) + + def __repr__(self): + """Return a representation of the object.""" + return 'GAMESS("%s")' % (self.filename) + + def parse(self): + """Extract information from the logfile.""" + inputfile = open(self.filename,"r") + + if self.progress: + + inputfile.seek(0,2) #go to end of file + nstep=inputfile.tell() + inputfile.seek(0) + self.progress.initialize(nstep) + oldstep=0 + + + endofopt = False + + for line in inputfile: + + if self.progress and random.random()<0.05: + + step = inputfile.tell() + if step!=oldstep: + self.progress.update(step) + oldstep = step + + if line.find("OPTTOL")>=0: + # Two possibilities: + # OPTTOL = 1.000E-04 RMIN = 1.500E-03 + # INPUT CARD> $STATPT OPTTOL=0.0001 NSTEP=100 $END + if not hasattr(self,"geotargets"): + self.logger.info("Creating attribute geotargets[]") + temp = line.split() + for i,x in enumerate(temp): + if x.find("OPTTOL")>=0: + if x=="OPTTOL": + opttol = float(temp[i+2]) + else: + opttol = float(x.split('=')[1]) + self.geotargets = Numeric.array([opttol,3./opttol]) + + if line.find("EQUILIBRIUM GEOMETRY LOCATED")>=0: +# This is necessary if a frequency calculation follows a geometry optimisation + endofopt = True + + if not endofopt and line.find("FINAL")==1: + if not hasattr(self,"scfenergies"): + self.logger.info("Creating attribute scfenergies[]") + self.scfenergies = [] +# Here is an example from Neil Berry: +# FINAL R-B3LYP ENERGY IS -382.0507446475 AFTER 10 ITERATIONS +# but in some cases the energy can be in position [3] not [4] so let's +# take the number after the "IS" + temp = line.split() + self.scfenergies.append(temp[temp.index("IS")+1]) + + if not endofopt and line.find("MAXIMUM GRADIENT")>0: + if not hasattr(self,"geovalues"): + self.logger.info("Creating attribute geovalues[]") + self.geovalues = [] + temp = line.strip().split() + self.geovalues.append([float(temp[3]),float(temp[7])]) + + + + if line.find("DENSITY CONV=")==5: + self.scftargets[0] = float(line.strip().split()[-1]) + + if line.find("ITER EX DEM")==1: +# This is the section with the SCF information + if not hasattr(self,"scfvalues"): + self.logger.info("Creating attribute scfvalues") + self.scfvalues = [] + line = inputfile.next() + den = [] + while line!='\n': +# The SCF information is terminated by a blank line + try: + temp = int(line[0:4]) + except ValueError: +# Occurs for: +# * * * INITIATING DIIS PROCEDURE * * * +# CONVERGED TO SWOFF, SO DFT CALCULATION IS NOW SWITCHED ON +# DFT CODE IS SWITCHING BACK TO THE FINER GRID + pass + else: + den.append(float(line.split()[5])) + line = inputfile.next() + self.scfvalues.append(den) + + if line.find("NORMAL COORDINATE ANALYSIS IN THE HARMONIC APPROXIMATION")>=0: + # Start of the frequency section + self.logger.info("Creating attributes vibfreqs, vibirs") + self.vibfreqs = [] + self.vibirs = [] + + # Need to get past the list of atomic weights + hyphens = inputfile.next() + blank = inputfile.next() + line = inputfile.next() + blank = inputfile.next() + line = inputfile.next() + numAtom = 0 + while line!="\n": + numAtom += 1 + line = inputfile.next() + + # Print out the following lines which may contain some useful info: + # e.g. WARNING, MODE 7 HAS BEEN CHOSEN AS A VIBRATION + line = inputfile.next() + while line.find("FREQUENCIES IN CM**-1")==-1: + line = inputfile.next() + line = inputfile.next() + + blank = inputfile.next() + freqNo = inputfile.next() + while freqNo.find("SAYVETZ")==-1: + freq = inputfile.next().strip().split() + self.vibfreqs.extend(map(float,freq[1:])) + reducedMass = inputfile.next() + irIntensity = inputfile.next().strip().split() + self.vibirs.extend(map(float,irIntensity[2:])) + blank = inputfile.next() + # Skip XYZ data for each atom plus + # the Sayvetz stuff at the end + for j in range(numAtom*3+10): + line = inputfile.next() + blank = inputfile.next() + freqNo = inputfile.next() + self.vibfreqs = Numeric.array(self.vibfreqs,"f") + self.vibirs = Numeric.array(self.vibirs,"f") + + + if line.find("EIGENVECTORS")==10 or line.find("MOLECULAR OBRITALS")==10: + # The details returned come from the *final* report of evalues and + # the last list of symmetries in the log file + # This is fine for GeoOpt and SP, but may be weird for TD and Freq(?) + + # Take the last one of either in the file + if not hasattr(self,"moenergies"): + self.logger.info("Creating attributes moenergies, mosyms") + self.moenergies = [] + self.mosyms = [] + if not hasattr(self,"nindep"): + self.logger.info("Creating attribute nindep with default value") + self.nindep = self.nbasis + self.mocoeffs = Numeric.zeros((1,self.nindep,self.nbasis),"f") + line = inputfile.next() + blank = inputfile.next() # blank line + base = 0 + while line.find("END OF RHF")==-1: + line = inputfile.next() # Eigenvector no + line = inputfile.next() + self.moenergies.extend(map(float,line.split())) + line = inputfile.next() + self.mosyms.extend(line.split()) + line = inputfile.next() + i=0 + while line!=blank and line.find("END OF RHF")==-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 + j = 0 + while j*11+4<len(temp): + self.mocoeffs[0,base+j,i] = float(temp[j*11:(j+1)*11]) + j+=1 + line = inputfile.next() + i+=1 + base+=5 + self.moenergies = Numeric.array(self.moenergies,"f") + + if line.find("NUMBER OF OCCUPIED ORBITALS")>=0: + if not hasattr(self,"homos"): + self.logger.info("Creating attribute homos") + temp = line.strip().split('=') + self.homos = Numeric.array(int(temp[-1])-1,"d") + + if line.find("TOTAL NUMBER OF ATOMS")==1: + self.logger.info("Creating attribute natom") + self.natom = int(line.split()[-1]) + + if line.find("NUMBER OF CARTESIAN GAUSSIAN BASIS")==1 or line.find("TOTAL NUMBER OF BASIS FUNCTIONS")==1: + # 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]) + + 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 nindep") + self.indep = 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 + self.logger.info("Creating attribute aooverlaps") + self.aooverlaps = Numeric.zeros((self.nbasis,self.nbasis), "f") + base = 0 + while base<self.nbasis: + blank = inputfile.next() + line = inputfile.next() # Basis fn number + blank = inputfile.next() + for i in range(self.nbasis-base): # Fewer lines each time + line = inputfile.next() + temp = line.split() + 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 + + inputfile.close() + + if not hasattr(self,"geotargets"): + self.logger.info("Creating attribute geotargets[] with default values") + opttol = 1e-4 + self.geotargets = Numeric.array([opttol,3./opttol]) + if not hasattr(self,"scftargets"): + self.logger.info("Creating attribute scftargets[] with default values") + self.scftargets = Numeric.array([1e-5]) + if hasattr(self,"geovalues"): self.geovalues = Numeric.array(self.geovalues,"f") + if not hasattr(self,"nindep"): + self.logger.info("Creating attribute nindep with default value") + self.nindep = self.nbasis + + + +if __name__=="__main__": + import doctest,parser + doctest.testmod(parser,verbose=False) Property changes on: trunk/src/cclib/parser/gamessparser.py ___________________________________________________________________ Name: svn:executable + * 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-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-16 18:38:59
|
Revision: 24 Author: baoilleach Date: 2006-03-16 10:38:51 -0800 (Thu, 16 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=24&view=rev Log Message: ----------- Added hartree_to_eV method to convertor Modified Paths: -------------- trunk/src/cclib/parser/logfileparser.py Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-15 22:01:17 UTC (rev 23) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-16 18:38:51 UTC (rev 24) @@ -27,6 +27,7 @@ 64524.8 """ _convertor = {"eV_to_cm-1": lambda x: x*8065.6, + "hartree_to_eV": lambda x: x*27.2114, "nm_to_cm-1": lambda x: 1e7/x, "cm-1_to_nm": lambda x: 1e7/x} @@ -67,7 +68,7 @@ homos -- molecular orbital index of HOMO(s) (array[1]) mocoeffs -- molecular orbital coefficients (array[3]) moenergies -- orbital energies (array[2], eV) - mosyms -- orbital symmetries (array[2]) + mosyms -- orbital symmetries (list[2]) natom -- number of atoms (integer) nbasis -- number of basis functions (integer) nindep -- number of linearly-independent basis functions (integer) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-15 22:01:27
|
Revision: 23 Author: baoilleach Date: 2006-03-15 14:01:17 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=23&view=rev Log Message: ----------- A simple test to enure that Numeric arrays are used instead of lists Added Paths: ----------- trunk/test/easyparse.py Added: trunk/test/easyparse.py =================================================================== --- trunk/test/easyparse.py (rev 0) +++ trunk/test/easyparse.py 2006-03-15 22:01:17 UTC (rev 23) @@ -0,0 +1,10 @@ +import os +from cclib.parser import G03 + +t = G03(os.path.join("..","data","Gaussian","dvb_gopt.out")) +t.parse() + +for x in ['scftargets','geotargets','scfvalues','geovalues']: + print x + t.__getattribute__(x)+1 + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-15 21:59:50
|
Revision: 22 Author: baoilleach Date: 2006-03-15 13:59:43 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=22&view=rev Log Message: ----------- Conversion from lists to Numeric arrays in G03 Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py trunk/src/cclib/parser/logfileparser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-15 20:54:26 UTC (rev 21) +++ trunk/src/cclib/parser/g03parser.py 2006-03-15 21:59:43 UTC (rev 22) @@ -28,7 +28,7 @@ def __init__(self,*args): # Call the __init__ method of the superclass - super(G03, self).__init__(*args,logname="G03") + super(G03, self).__init__(logname="G03",*args) def __str__(self): """Return a string representation of the object.""" @@ -155,7 +155,7 @@ if not hasattr(self,"geotargets"): self.logger.info("Creating attributes geotargets[],geovalues[[]]") self.geovalues = [] - self.geotargets = [None]*4 + self.geotargets = Numeric.array( [0.0,0.0,0.0,0.0],"f") newlist = [0]*4 for i in range(4): line = inputfile.next() @@ -447,6 +447,12 @@ inputfile.close() + # Convert from lists to arrays (it's easier this way in most cases) + 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 def extractTrajectory(self): """Extract trajectory information from a Gaussian logfile.""" Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-15 20:54:26 UTC (rev 21) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-15 21:59:43 UTC (rev 22) @@ -71,6 +71,7 @@ natom -- number of atoms (integer) nbasis -- number of basis functions (integer) nindep -- number of linearly-independent basis functions (integer) + scfenergies -- the electronic energy of the molecule (array[1], a.u.) scftargets -- targets for convergence of the SCF (array[1]) scfvalues -- current values for convergence of the SCF (array[2], same units as scftargets) vibfreqs -- vibrational frequencies (array, 1/cm) @@ -94,7 +95,7 @@ self.logname = logname # Set up the logger - self.logger = logging.getLogger('%s.%s' % (self.logname,self.filename)) + self.logger = logging.getLogger('%s %s' % (self.logname,self.filename)) self.logger.setLevel(logging.INFO) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-15 20:24:30
|
Revision: 20 Author: baoilleach Date: 2006-03-15 12:24:24 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=20&view=rev Log Message: ----------- Corrected mispelling in logfile, and tidied up imports in g03parser Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py trunk/src/cclib/parser/logfileparser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-15 20:18:56 UTC (rev 19) +++ trunk/src/cclib/parser/g03parser.py 2006-03-15 20:24:24 UTC (rev 20) @@ -17,7 +17,7 @@ Contributions (monetary as well as code :-) are encouraged. """ -import math,sys,logging,copy,re,os,time # How many of these are necessary? +import re,time import Numeric import random # For sometimes running the progress updater from logfileparser import Logfile # import the superclass @@ -398,7 +398,7 @@ # *** Overlap *** # ****** Overlap ****** self.logger.info("Creating attribute aooverlaps[x,y]") - import time; oldtime = time.time() + # oldtime = time.time() self.aooverlaps = Numeric.zeros( (self.nbasis,self.nbasis), "float") # Overlap integrals for basis fn#1 are in aooverlaps[0] base = 0 @@ -413,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.logger.info("Took %f seconds" % (time.time()-oldtime)) if line[5:35]=="Molecular Orbital Coefficients" or line[5:41]=="Alpha Molecular Orbital Coefficients" or line[5:40]=="Beta Molecular Orbital Coefficients": - import time; oldtime = time.time() + # oldtime = time.time() if line[5:40]=="Beta Molecular Orbital Coefficients": beta = True # Need to add an extra dimension to self.mocoeffs @@ -450,7 +450,7 @@ 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)) + # self.logger.info("Took %f seconds" % (time.time()-oldtime)) inputfile.close() Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-15 20:18:56 UTC (rev 19) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-15 20:24:24 UTC (rev 20) @@ -84,7 +84,7 @@ """ def __init__(self,filename,progress=None, loglevel=logging.INFO,logname="Log"): - """Initialise the logging object. + """Initialise the Logfile object. Typically called by subclasses in their own __init__ methods. """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-15 20:19:05
|
Revision: 19 Author: baoilleach Date: 2006-03-15 12:18:56 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=19&view=rev Log Message: ----------- Moved logging stuff from G03 into Logfile. Also, added variable types and units to attribute list in Logfile. Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py trunk/src/cclib/parser/logfileparser.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-11 17:41:38 UTC (rev 18) +++ trunk/src/cclib/parser/g03parser.py 2006-03-15 20:18:56 UTC (rev 19) @@ -28,18 +28,8 @@ def __init__(self,*args): # Call the __init__ method of the superclass - super(G03, self).__init__(*args) + super(G03, self).__init__(*args,logname="G03") - # Set up the logger...will move this into superclass - # through a function call with G03 as a parameter. - # Note: all loggers with the same name share the logger. - # Here, loggers with different filenames are different - self.logger = logging.getLogger('G03.%s' % self.filename) - self.logger.setLevel(logging.INFO) - handler = logging.StreamHandler(sys.stdout) - handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s")) - self.logger.addHandler(handler) - def __str__(self): """Return a string representation of the object.""" return "Gaussian 03 log file %s" % (self.filename) Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-11 17:41:38 UTC (rev 18) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-15 20:18:56 UTC (rev 19) @@ -17,14 +17,14 @@ Contributions (monetary as well as code :-) are encouraged. """ -import math,sys,logging,copy,re,os,time # How many of these are necessary? +import logging, sys import Numeric def convertor(value,fromunits,tounits): """Convert from one set of units to another. - >>> convertor(8,"eV","cm-1") - 64000 + >>> print "%.1f" % convertor(8,"eV","cm-1") + 64524.8 """ _convertor = {"eV_to_cm-1": lambda x: x*8065.6, "nm_to_cm-1": lambda x: 1e7/x, @@ -51,43 +51,67 @@ """Abstract class for logfile objects. Subclasses: - G03 + G03 Attributes: - aonames -- list of "Ru_3p", etc. - aooverlaps -- the atomic orbital overlap matrix - atomnos -- atomic numbers - etenergies -- energy of electronic transitions (i.e. UV-Vis, CD) - etoscs -- oscillator strength of electronic transition - etrotats -- rotatory strength(?) of electronic transitions (for CD) - etsecs -- singly-excited configurations comprising each electronic transition - etsyms -- symmetry of electronic transition - geotargets -- targets for convergence of the geometry - geovalues -- current values for convergence of the geometry - homos -- location of HOMO(s) - mocoeffs -- molecular orbital coefficients - moenergies -- orbital energies - mosyms -- orbital symmetries - natom -- number of atoms - nbasis -- number of basis functions - nindep -- number of linearly-independent basis functions - progress -- class (or None) for handling progress info - scftargets -- targets for convergence of the SCF - scfvalues -- current values for convergence of the SCF - vibfreqs -- vibrational frequencies - vibirs -- IR intensity - vibramans -- Raman intensity - vibsyms -- symmetry of vibrations + aonames -- "Ru_3p" (list) + aooverlaps -- atomic orbital overlap matrix (array[2]) + atomnos -- atomic numbers (array) + etenergies -- energy of electronic transitions (array[1], 1/cm) + etoscs -- oscillator strength of electronic transition (array[1], ??) + etrotats -- rotatory strength of electronic transitions (array[1], ??) + etsecs -- singly-excited configurations comprising each electronic transition (??) + etsyms -- symmetry of electronic transition (list) + geotargets -- targets for convergence of the geometry (array[1]) + geovalues -- current values for convergence of the geometry (array[1], same units as geotargets) + homos -- molecular orbital index of HOMO(s) (array[1]) + mocoeffs -- molecular orbital coefficients (array[3]) + moenergies -- orbital energies (array[2], eV) + mosyms -- orbital symmetries (array[2]) + natom -- number of atoms (integer) + nbasis -- number of basis functions (integer) + nindep -- number of linearly-independent basis functions (integer) + scftargets -- targets for convergence of the SCF (array[1]) + scfvalues -- current values for convergence of the SCF (array[1], same units as scftargets) + vibfreqs -- vibrational frequencies (array, 1/cm) + vibirs -- IR intensity (array, ??) + vibramans -- Raman intensity (array, ??) + vibsyms -- symmetry of vibrations (list) + (1) The term 'array' currently refers to a Numeric array + (2) The number of dimensions of an array is given in square brackets + (3) Python indexes arrays/lists starting at zero. So if homos==[10], then + the 11th molecular orbital is the HOMO """ - def __init__(self,filename,progress=None): + def __init__(self,filename,progress=None, + loglevel=logging.INFO,logname="Log"): + """Initialise the logging object. + + Typically called by subclasses in their own __init__ methods. + """ self.filename = filename self.progress = progress + self.loglevel = loglevel + self.logname = logname + # Set up the logger + self.logger = logging.getLogger('%s.%s' % (self.logname,self.filename)) + self.logger.setLevel(logging.INFO) + handler = logging.StreamHandler(sys.stdout) + handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s")) + self.logger.addHandler(handler) + def float(self,number): - """Convert a string to a float avoiding the problem with Ds.""" + """Convert a string to a float avoiding the problem with Ds. + + >>> t = Logfile("dummyfile") + >>> t.float("123.2323E+02") + 12323.23 + >>> t.float("123.2323D+02") + 12323.23 + """ number = number.replace("D","E") return float(number) if __name__=="__main__": - import doctest,parser - doctest.testmod(parser,verbose=False) + import doctest,logfileparser + doctest.testmod(logfileparser,verbose=False) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-11 17:41:43
|
Revision: 18 Author: baoilleach Date: 2006-03-11 09:41:38 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=18&view=rev Log Message: ----------- Ignore build and dist (created by setup.py). Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Name: svn:ignore + build dist This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-11 17:39:04
|
Revision: 17 Author: baoilleach Date: 2006-03-11 09:38:55 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=17&view=rev Log Message: ----------- Ignore *.pyc files. Property Changed: ---------------- trunk/src/cclib/ trunk/src/cclib/parser/ Property changes on: trunk/src/cclib ___________________________________________________________________ Name: svn:ignore + *.pyc Property changes on: trunk/src/cclib/parser ___________________________________________________________________ Name: svn:ignore + *.pyc 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:14:42
|
Revision: 16 Author: baoilleach Date: 2006-03-10 02:14:37 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=16&view=rev Log Message: ----------- In the hope of minor speedups I: (1) removed newtext in the arguments (not used) (2) removed the brackets in an if statement (unnecessary) (3) removed a float conversion as one of the numbers in the expression is already a float Modified Paths: -------------- trunk/src/cclib/parser/textprogress.py Modified: trunk/src/cclib/parser/textprogress.py =================================================================== --- trunk/src/cclib/parser/textprogress.py 2006-03-10 10:04:34 UTC (rev 15) +++ trunk/src/cclib/parser/textprogress.py 2006-03-10 10:14:37 UTC (rev 16) @@ -13,12 +13,12 @@ self.nstep=float(nstep) self.text=text - def update(self,step,newtext=None): + def update(self,step): - self.progress=int(float(step)/self.nstep*100) + self.progress = int(step/self.nstep*100) #print step,self.nstep - if(self.progress/10==self.oldprogress/10+1): #just went through an interval of ten, ie. from 39 to 41, so update + if self.progress/10==self.oldprogress/10+1: #just went through an interval of ten, ie. from 39 to 41, so update str="[" for i in range(self.progress/10): 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: <ate...@us...> - 2006-03-09 19:54:26
|
Revision: 14 Author: atenderholt Date: 2006-03-09 11:54:18 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=14&view=rev Log Message: ----------- Initial work on progress dialog support Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py trunk/src/cclib/parser/logfileparser.py Added Paths: ----------- trunk/src/cclib/parser/textprogress.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-09 09:54:04 UTC (rev 13) +++ trunk/src/cclib/parser/g03parser.py 2006-03-09 19:54:18 UTC (rev 14) @@ -24,10 +24,10 @@ class G03(Logfile): """A Gaussian 98/03 log file""" SCFRMS,SCFMAX,SCFENERGY = range(3) # Used to index self.scftargets[] - def __init__(self,filename): + def __init__(self,*args): # Call the __init__ method of the superclass - super(G03, self).__init__(filename) + super(G03, self).__init__(*args) # Set up the logger...will move this into superclass # through a function call with G03 as a parameter. @@ -50,8 +50,24 @@ def parse(self): """Extract information from the logfile.""" inputfile = open(self.filename,"r") + + if self.progress: + + inputfile.seek(0,2) #go to end of file + nstep=inputfile.tell() + inputfile.seek(0) + self.progress.initialize(nstep) + self.oldstep=0 + for line in inputfile: + if self.progress: + + step=inputfile.tell() + if not (step==self.oldstep): + self.progress.update(step) + self.oldstep=step + if line[1:8]=="NAtoms=": # Find the number of atoms natom = int(line.split()[1]) Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-09 09:54:04 UTC (rev 13) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-09 19:54:18 UTC (rev 14) @@ -71,6 +71,7 @@ natom -- number of atoms nbasis -- number of basis functions nindep -- number of linearly-independent basis functions + progress -- class (or None) for handling progress info scftargets -- targets for convergence of the SCF scfvalues -- current values for convergence of the SCF vibfreqs -- vibrational frequencies @@ -78,8 +79,9 @@ vibramans -- Raman intensity vibsyms -- symmetry of vibrations """ - def __init__(self,filename): + def __init__(self,filename,progress=None): self.filename = filename + self.progress = progress def float(self,number): """Convert a string to a float avoiding the problem with Ds.""" Added: trunk/src/cclib/parser/textprogress.py =================================================================== --- trunk/src/cclib/parser/textprogress.py (rev 0) +++ trunk/src/cclib/parser/textprogress.py 2006-03-09 19:54:18 UTC (rev 14) @@ -0,0 +1,35 @@ + +class TextProgress: + + def __init__(self): + + self.nstep=0 + self.text=None + self.oldprogress=0 + self.progress=0 + + def initialize(self,nstep,text=None): + + self.nstep=float(nstep) + self.text=text + + def update(self,step,newtext=None): + + self.progress=int(float(step)/self.nstep*100) + #print step,self.nstep + + if(self.progress/10==self.oldprogress/10+1): #just went through an interval of ten, ie. from 39 to 41, so update + + str="[" + for i in range(self.progress/10): + str+="=" + for i in range(self.progress/10,10): + str+="-" + + str+="]" + + print str + + self.oldprogress=self.progress + return + 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-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-08 17:12:42
|
Revision: 11 Author: baoilleach Date: 2006-03-08 09:12:33 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=11&view=rev Log Message: ----------- Added a docstring to the Logfile class with the names of parsed attributes. This will be our implementation guide. Modified Paths: -------------- trunk/src/cclib/parser/logfileparser.py Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-07 10:55:24 UTC (rev 10) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-08 17:12:33 UTC (rev 11) @@ -48,8 +48,36 @@ self.number[self.element[i]] = i class Logfile(object): - """Abstract class that contains the methods that act on data - parsed from various types of logfile.""" + """Abstract class for logfile objects. + + Subclasses: + G03 + + Attributes: + aonames -- list of "Ru_3p", etc. + aooverlaps -- the atomic orbital overlap matrix + atomnos -- atomic numbers + etenergies -- energy of electronic transitions (i.e. UV-Vis, CD) + etoscs -- oscillator strength of electronic transition + etrotats -- rotatory strength(?) of electronic transitions (for CD) + etsecs -- singly-excited configurations comprising each electronic transition + etsyms -- symmetry of electronic transition + geotargets -- targets for convergence of the geometry + geovalues -- current values for convergence of the geometry + homos -- location of HOMO(s) + mocoeffs -- molecular orbital coefficients + moenergies -- orbital energies + mosyms -- orbital symmetries + natom -- number of atoms + nbasis -- number of basis functions + nindep -- number of linearly-independent basis functions + scftargets -- targets for convergence of the SCF + scfvalues -- current values for convergence of the SCF + vibfreqs -- vibrational frequencies + vibirs -- IR intensity + vibramans -- Raman intensity + vibsyms -- symmetry of vibrations + """ def __init__(self,filename): self.filename = filename This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-07 10:49:16
|
Revision: 9 Author: baoilleach Date: 2006-03-07 02:49:05 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=9&view=rev Log Message: ----------- Removed MANIFEST -- this was needed to install datafiles, but I don't think it's necessary for setup.py. Removed Paths: ------------- trunk/MANIFEST Deleted: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-03-07 10:03:11 UTC (rev 8) +++ trunk/MANIFEST 2006-03-07 10:49:05 UTC (rev 9) @@ -1,3 +0,0 @@ -setup.py -src/cclib/__init__.py -src/cclib/parser.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-03-07 10:03:17
|
Revision: 8 Author: baoilleach Date: 2006-03-07 02:03:11 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=8&view=rev Log Message: ----------- "from cclib.parser import G03" works again now, thanks to the magic of __init__.py. Note that for every new parser, and line must be added to __init__.py. Modified Paths: -------------- trunk/src/cclib/__init__.py trunk/src/cclib/parser/__init__.py Modified: trunk/src/cclib/__init__.py =================================================================== --- trunk/src/cclib/__init__.py 2006-03-07 09:56:19 UTC (rev 7) +++ trunk/src/cclib/__init__.py 2006-03-07 10:03:11 UTC (rev 8) @@ -0,0 +1 @@ +import parser Modified: trunk/src/cclib/parser/__init__.py =================================================================== --- trunk/src/cclib/parser/__init__.py 2006-03-07 09:56:19 UTC (rev 7) +++ trunk/src/cclib/parser/__init__.py 2006-03-07 10:03:11 UTC (rev 8) @@ -0,0 +1 @@ +from G03 import G03 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |