From: <ate...@us...> - 2006-05-10 21:58:20
|
Revision: 107 Author: atenderholt Date: 2006-05-10 14:58:18 -0700 (Wed, 10 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=107&view=rev Log Message: ----------- Trying again Added Paths: ----------- trunk/src/cclib/method/ trunk/src/cclib/method/__init__.py trunk/src/cclib/method/calculationmethod.py trunk/src/cclib/method/density.py Removed Paths: ------------- trunk/src/cclib/method/calculationmethod.py trunk/src/cclib/method/density.py trunk/src/cclib/methods/ Copied: trunk/src/cclib/method (from rev 105, trunk/src/cclib/methods) Copied: trunk/src/cclib/method/__init__.py (from rev 106, trunk/src/cclib/methods/__init__.py) =================================================================== --- trunk/src/cclib/method/__init__.py (rev 0) +++ trunk/src/cclib/method/__init__.py 2006-05-10 21:58:18 UTC (rev 107) @@ -0,0 +1 @@ +from density import Density Deleted: trunk/src/cclib/method/calculationmethod.py =================================================================== --- trunk/src/cclib/methods/calculationmethod.py 2006-05-10 19:29:45 UTC (rev 105) +++ trunk/src/cclib/method/calculationmethod.py 2006-05-10 21:58:18 UTC (rev 107) @@ -1,52 +0,0 @@ -""" -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 logging, sys -import Numeric - -class Method(object): - """Abstract class for logfile objects. - - Subclasses: - Density - - Attributes: - """ - def __init__(self,parser,progress=None, - loglevel=logging.INFO,logname="Log"): - """Initialise the Logfile object. - - Typically called by subclasses in their own __init__ methods. - """ - self.parser = parser - self.progress = progress - self.loglevel = loglevel - self.logname = logname - - # Set up the logger - self.logger = logging.getLogger('%s %s' % (self.logname,self.parser)) - self.logger.setLevel(self.loglevel) - handler = logging.StreamHandler(sys.stdout) - handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s")) - self.logger.addHandler(handler) - - -if __name__=="__main__": - import doctest,calculationmethod - doctest.testmod(calculationmethod,verbose=False) Copied: trunk/src/cclib/method/calculationmethod.py (from rev 106, trunk/src/cclib/methods/calculationmethod.py) =================================================================== --- trunk/src/cclib/method/calculationmethod.py (rev 0) +++ trunk/src/cclib/method/calculationmethod.py 2006-05-10 21:58:18 UTC (rev 107) @@ -0,0 +1,52 @@ +""" +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 logging, sys +import Numeric + +class Method(object): + """Abstract class for logfile objects. + + Subclasses: + Density + + Attributes: + """ + def __init__(self,parser,progress=None, + loglevel=logging.INFO,logname="Log"): + """Initialise the Logfile object. + + Typically called by subclasses in their own __init__ methods. + """ + self.parser = parser + self.progress = progress + self.loglevel = loglevel + self.logname = logname + + # Set up the logger + self.logger = logging.getLogger('%s %s' % (self.logname,self.parser)) + self.logger.setLevel(self.loglevel) + handler = logging.StreamHandler(sys.stdout) + handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s")) + self.logger.addHandler(handler) + + +if __name__=="__main__": + import doctest,calculationmethod + doctest.testmod(calculationmethod,verbose=False) Deleted: trunk/src/cclib/method/density.py =================================================================== --- trunk/src/cclib/methods/density.py 2006-05-10 19:29:45 UTC (rev 105) +++ trunk/src/cclib/method/density.py 2006-05-10 21:58:18 UTC (rev 107) @@ -1,72 +0,0 @@ -""" -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 calculationmethod import Method - -class Density(Method): - """Calculate the density matrix""" - def __init__(self,*args): - - # Call the __init__ method of the superclass - super(Density, self).__init__(logname="Density",*args) - - def __str__(self): - """Return a string representation of the object.""" - return "Density matrix of" % (self.parser) - - def __repr__(self): - """Return a representation of the object.""" - return 'Density matrix("%s")' % (self.parser) - - def calculate(self,fupdate=0.05,cupdate=0.002): - """Calculate the density matrix given the results of a parser""" - - if not self.parser.parsed: - self.parser.parse() - - #do we have the needed info in the parser? - if not hasattr(self.parser,"mocoeffs") - and not hasattr(self.parser,"aooverlaps") - and not hasattr(self.parser,"nbasis") - and not hasattr(self.parser,"homos"): - self.logger.error("Missing mocoeffs or aooverlaps") - return False #let the caller of function know we didn't finish - - self.logger.info("Creating attribute density: array[3]") - size=self.parser.nbasis - beta=(len(self.parser.mocoeffs)==2) - - if beta: - self.density=Numeric.zeros([2,size,size],"f") - else: - self.density=Numeric.zeros([1,size,size],"f") - - for i in range(self.parser.homos[0]+1): - col=Numeric.reshape(self.parser.mocoeffs[0][i],(size,1)) - colt=Numeric.reshape(col,(1,size)) - - tempdensity=Numeric.matrixmultipy(col,colt) - density[0]=Numeric.add(density[0],tempdensity) - -if __name__=="__main__": - import doctest,g03parser - doctest.testmod(g03parser,verbose=False) Copied: trunk/src/cclib/method/density.py (from rev 106, trunk/src/cclib/methods/density.py) =================================================================== --- trunk/src/cclib/method/density.py (rev 0) +++ trunk/src/cclib/method/density.py 2006-05-10 21:58:18 UTC (rev 107) @@ -0,0 +1,74 @@ +""" +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 calculationmethod import Method + +class Density(Method): + """Calculate the density matrix""" + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(Density, self).__init__(logname="Density",*args) + + def __str__(self): + """Return a string representation of the object.""" + return "Density matrix of" % (self.parser) + + def __repr__(self): + """Return a representation of the object.""" + return 'Density matrix("%s")' % (self.parser) + + def calculate(self,fupdate=0.05,cupdate=0.002): + """Calculate the density matrix given the results of a parser""" + + if not self.parser.parsed: + self.parser.parse() + + #do we have the needed info in the parser? + if not hasattr(self.parser,"mocoeffs") + and not hasattr(self.parser,"aooverlaps") + and not hasattr(self.parser,"nbasis") + and not hasattr(self.parser,"homos"): + self.logger.error("Missing mocoeffs or aooverlaps") + return False #let the caller of function know we didn't finish + + self.logger.info("Creating attribute density: array[3]") + size=self.parser.nbasis + beta=(len(self.parser.mocoeffs)==2) + + if beta: + self.density=Numeric.zeros([2,size,size],"f") + else: + self.density=Numeric.zeros([1,size,size],"f") + + for spin in range(len(self.parser.mocoeffs)): + + for i in range(self.parser.homos[spin]+1): + col=Numeric.reshape(self.parser.mocoeffs[spin][i],(size,1)) + colt=Numeric.reshape(col,(1,size)) + + tempdensity=Numeric.matrixmultipy(col,colt) + density[spin]=Numeric.add(density[spin],tempdensity) + +if __name__=="__main__": + import doctest,g03parser + doctest.testmod(g03parser,verbose=False) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |