From: <ate...@us...> - 2006-05-11 00:53:02
|
Revision: 112 Author: atenderholt Date: 2006-05-10 17:52:59 -0700 (Wed, 10 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=112&view=rev Log Message: ----------- Started CSPA method, still need atomresults and other possibilities Modified Paths: -------------- trunk/src/cclib/method/__init__.py Added Paths: ----------- trunk/src/cclib/method/cspa.py Modified: trunk/src/cclib/method/__init__.py =================================================================== --- trunk/src/cclib/method/__init__.py 2006-05-10 23:28:49 UTC (rev 111) +++ trunk/src/cclib/method/__init__.py 2006-05-11 00:52:59 UTC (rev 112) @@ -1 +1,2 @@ from density import Density +from cspa import CSPA Added: trunk/src/cclib/method/cspa.py =================================================================== --- trunk/src/cclib/method/cspa.py (rev 0) +++ trunk/src/cclib/method/cspa.py 2006-05-11 00:52:59 UTC (rev 112) @@ -0,0 +1,89 @@ +""" +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 CSPA(Method): + """The C-squared population analysis""" + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(CSPA, 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 'CSPA("%s")' % (self.parser) + + def calculate(self,fupdate=0.05): + """Perform a C-squared population analysis 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,"nbasis"): + self.logger.error("Missing mocoeffs or nbasis") + return False #let the caller of function know we didn't finish + + self.logger.info("Creating attribute aoresults: array[3]") + unrestricted=(len(self.parser.mocoeffs)==2) + nmocoeffs=len(self.parser.mocoeffs[0]) + nbasis=self.parser.nbasis + + #determine number of steps, and whether process involves beta orbitals + nstep=nmocoeffs + if unrestricted: + self.aoresults=Numeric.zeros([2,nmocoeffs,nbasis],"f") + nstep+=nmocoeffs + else: + self.aoresults=Numeric.zeros([1,nmocoeffs,nbasis],"f") + + #intialize progress if available + if self.progress: + self.progress.initialize(nstep) + + step=0 + for spin in range(len(self.parser.mocoeffs)): + + for i in range(nmocoeffs): + + if self.progress and random.random()<fupdate: + self.progress.update(step,"C^2 Population Analysis") + + submocoeffs=self.parser.mocoeffs[spin][i] + scale=Numeric.innerproduct(submocoeffs,submocoeffs) + tempcoeffs=Numeric.multiply(submocoeffs,submocoeffs) + self.aoresults[spin][i]=Numeric.divide(tempcoeffs,scale) + + step+=1 + + if self.progress: + self.progress.update(nstep,"Done") + +if __name__=="__main__": + import doctest,g03parser + doctest.testmod(g03parser,verbose=False) Property changes on: trunk/src/cclib/method/cspa.py ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-05-11 23:55:45
|
Revision: 113 Author: atenderholt Date: 2006-05-11 16:55:35 -0700 (Thu, 11 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=113&view=rev Log Message: ----------- More work on the Mulliken and C-sqared PAs Modified Paths: -------------- trunk/src/cclib/method/__init__.py trunk/src/cclib/method/cspa.py Added Paths: ----------- trunk/src/cclib/method/mpa.py Modified: trunk/src/cclib/method/__init__.py =================================================================== --- trunk/src/cclib/method/__init__.py 2006-05-11 00:52:59 UTC (rev 112) +++ trunk/src/cclib/method/__init__.py 2006-05-11 23:55:35 UTC (rev 113) @@ -1,2 +1,3 @@ from density import Density from cspa import CSPA +from mpa import MPA Modified: trunk/src/cclib/method/cspa.py =================================================================== --- trunk/src/cclib/method/cspa.py 2006-05-11 00:52:59 UTC (rev 112) +++ trunk/src/cclib/method/cspa.py 2006-05-11 23:55:35 UTC (rev 113) @@ -31,7 +31,7 @@ def __str__(self): """Return a string representation of the object.""" - return "Density matrix of" % (self.parser) + return "CSPA of" % (self.parser) def __repr__(self): """Return a representation of the object.""" @@ -84,6 +84,75 @@ if self.progress: self.progress.update(nstep,"Done") +#build list of groups of orbitals in each atom for atomresults + if hasattr(self.parser,"aonames"): + names=self.parser.aonames + elif hasattr(self.parser,"foonames"): + names=self.parser.fonames + + atoms=[] + indices=[] + + name=names[0].split('_')[0] + atoms.append(name) + indices.append([0]) + + for i in range(1,len(names)): + name=names[i].split('_')[0] + if name==atoms[-1]: + indices[-1].append(i) + else: + atoms.append(name) + indices.append([i]) + + self.logger.info("Creating atomresults: array[3]") + self.atomresults=self.partition(indices) + +#create array for mulliken charges + self.logger.info("Creating atomcharges: array[1]") + size=len(self.atomresults[0][0]) + self.atomcharges=Numeric.zeros([size],"f") + + for spin in range(len(self.atomresults)): + + for i in range(self.parser.homos[spin]+1): + + temp=Numeric.reshape(self.atomresults[spin][i],(size,)) + self.atomcharges=Numeric.add(self.atomcharges,temp) + + if not unrestricted: + self.atomcharges=Numeric.multiply(self.atomcharges,2) + + + return True + + def partition(self,indices): + + if not hasattr(self,"aoresults"): + self.calculate() + + natoms=len(indices) + nmocoeffs=len(self.aoresults[0]) + +#build results Numeric array[3] + if len(self.aoresults)==2: + results=Numeric.zeros([2,nmocoeffs,natoms],"f") + else: + results=Numeric.zeros([1,nmocoeffs,natoms],"f") + +#for each spin, splice Numeric array at ao index, and add to correct result row + for spin in range(len(results)): + + for i in range(natoms): #number of groups + + for j in range(len(indices[i])): #for each group + + temp=self.aoresults[spin,:,indices[i][j]] + results[spin,:,i]=Numeric.add(results[spin,:,i],temp) + + return results + + if __name__=="__main__": - import doctest,g03parser - doctest.testmod(g03parser,verbose=False) + import doctest,cspa + doctest.testmod(cspa,verbose=False) Added: trunk/src/cclib/method/mpa.py =================================================================== --- trunk/src/cclib/method/mpa.py (rev 0) +++ trunk/src/cclib/method/mpa.py 2006-05-11 23:55:35 UTC (rev 113) @@ -0,0 +1,167 @@ +""" +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 MPA(Method): + """The Mulliken population analysis""" + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(MPA, self).__init__(logname="MPA",*args) + + def __str__(self): + """Return a string representation of the object.""" + return "MPA of" % (self.parser) + + def __repr__(self): + """Return a representation of the object.""" + return 'MPA("%s")' % (self.parser) + + def calculate(self,fupdate=0.05): + """Perform a Mulliken population analysis 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") \ + or hasattr(self.parser, "fooverlaps") ) \ + and not hasattr(self.parser,"nbasis"): + self.logger.error("Missing mocoeffs, aooverlaps/fooverlaps or nbasis") + return False #let the caller of function know we didn't finish + + unrestricted=(len(self.parser.mocoeffs)==2) + nmocoeffs=len(self.parser.mocoeffs[0]) + nbasis=self.parser.nbasis + + #determine number of steps, and whether process involves beta orbitals + nstep=nmocoeffs + self.logger.info("Creating attribute aoresults: array[3]") + if unrestricted: + self.aoresults=Numeric.zeros([2,nmocoeffs,nbasis],"f") + nstep+=nmocoeffs + else: + self.aoresults=Numeric.zeros([1,nmocoeffs,nbasis],"f") + + #intialize progress if available + if self.progress: + self.progress.initialize(nstep) + + step=0 + for spin in range(len(self.parser.mocoeffs)): + + for i in range(nmocoeffs): + + if self.progress and random.random()<fupdate: + self.progress.update(step,"Mulliken Population Analysis") + + #X_{ai} = \sum_b c_{ai} c_{bi} S_{ab} + # = c_{ai} \sum_b c_{bi} S_{ab} + # = c_{ai} C(i) \cdot S(a) + # X = C(i) * [C(i) \cdot S] + # C(i) is 1xn and S is nxn, result of matrix mult is 1xn + + ci = self.parser.mocoeffs[spin][i] + if hasattr(self.parser,"aooverlaps"): + temp = Numeric.matrixmultiply(ci,self.parser.aooverlaps) + elif hasattr(self.parser,"fooverlaps"): + temp = Numeric.matrixmultiply(ci,self.parser.fooverlaps) + + self.aoresults[spin][i]=Numeric.multiply(ci,temp) + + step+=1 + + if self.progress: + self.progress.update(nstep,"Done") + +#build list of groups of orbitals in each atom for atomresults + if hasattr(self.parser,"aonames"): + names=self.parser.aonames + elif hasattr(self.parser,"foonames"): + names=self.parser.fonames + + atoms=[] + indices=[] + + name=names[0].split('_')[0] + atoms.append(name) + indices.append([0]) + + for i in range(1,len(names)): + name=names[i].split('_')[0] + if name==atoms[-1]: + indices[-1].append(i) + else: + atoms.append(name) + indices.append([i]) + + self.logger.info("Creating atomresults: array[3]") + self.atomresults=self.partition(indices) + +#create array for mulliken charges + self.logger.info("Creating atomcharges: array[1]") + size=len(self.atomresults[0][0]) + self.atomcharges=Numeric.zeros([size],"f") + + for spin in range(len(self.atomresults)): + + for i in range(self.parser.homos[spin]+1): + + temp=Numeric.reshape(self.atomresults[spin][i],(size,)) + self.atomcharges=Numeric.add(self.atomcharges,temp) + + if not unrestricted: + self.atomcharges=Numeric.multiply(self.atomcharges,2) + + return True + + def partition(self,indices): + + if not hasattr(self,"aoresults"): + self.calculate() + + natoms=len(indices) + nmocoeffs=len(self.aoresults[0]) + +#build results Numeric array[3] + if len(self.aoresults)==2: + results=Numeric.zeros([2,nmocoeffs,natoms],"f") + else: + results=Numeric.zeros([1,nmocoeffs,natoms],"f") + +#for each spin, splice Numeric array at ao index, and add to correct result row + for spin in range(len(results)): + + for i in range(natoms): #number of groups + + for j in range(len(indices[i])): #for each group + + temp=self.aoresults[spin,:,indices[i][j]] + results[spin,:,i]=Numeric.add(results[spin,:,i],temp) + + return results + +if __name__=="__main__": + import doctest,mpa + doctest.testmod(mpa,verbose=False) Property changes on: trunk/src/cclib/method/mpa.py ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-05-19 17:30:13
|
Revision: 130 Author: atenderholt Date: 2006-05-19 10:29:54 -0700 (Fri, 19 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=130&view=rev Log Message: ----------- Reworked cspa to use base population class, haven't tested because my cclib parser installation seems to be broken. Committing since it's not a high-profile change. Modified Paths: -------------- trunk/src/cclib/method/cspa.py Added Paths: ----------- trunk/src/cclib/method/population.py Modified: trunk/src/cclib/method/cspa.py =================================================================== --- trunk/src/cclib/method/cspa.py 2006-05-19 16:37:32 UTC (rev 129) +++ trunk/src/cclib/method/cspa.py 2006-05-19 17:29:54 UTC (rev 130) @@ -20,14 +20,14 @@ import re,time import Numeric import random # For sometimes running the progress updater -from calculationmethod import Method +from population import Population -class CSPA(Method): +class CSPA(Population): """The C-squared population analysis""" def __init__(self,*args): # Call the __init__ method of the superclass - super(CSPA, self).__init__(logname="Density",*args) + super(CSPA, self).__init__(logname="CSPA",*args) def __str__(self): """Return a string representation of the object.""" @@ -37,7 +37,7 @@ """Return a representation of the object.""" return 'CSPA("%s")' % (self.parser) - def calculate(self,fupdate=0.05): + def calculate(self,indices=None,fupdate=0.05): """Perform a C-squared population analysis given the results of a parser""" if not self.parser.parsed: @@ -84,75 +84,29 @@ if self.progress: self.progress.update(nstep,"Done") -#build list of groups of orbitals in each atom for atomresults - if hasattr(self.parser,"aonames"): - names=self.parser.aonames - elif hasattr(self.parser,"foonames"): - names=self.parser.fonames + retval=super(CSPA, self).partition(indices) - atoms=[] - indices=[] + if not retval: + self.logger.error("Error in partitioning results") + return False - name=names[0].split('_')[0] - atoms.append(name) - indices.append([0]) - - for i in range(1,len(names)): - name=names[i].split('_')[0] - if name==atoms[-1]: - indices[-1].append(i) - else: - atoms.append(name) - indices.append([i]) - - self.logger.info("Creating atomresults: array[3]") - self.atomresults=self.partition(indices) - #create array for mulliken charges - self.logger.info("Creating atomcharges: array[1]") - size=len(self.atomresults[0][0]) - self.atomcharges=Numeric.zeros([size],"f") + self.logger.info("Creating fragcharges: array[1]") + size=len(self.fragresults[0][0]) + self.fragcharges=Numeric.zeros([size],"f") - for spin in range(len(self.atomresults)): + for spin in range(len(self.fragresults)): for i in range(self.parser.homos[spin]+1): - temp=Numeric.reshape(self.atomresults[spin][i],(size,)) - self.atomcharges=Numeric.add(self.atomcharges,temp) + temp=Numeric.reshape(self.fragresults[spin][i],(size,)) + self.fragcharges=Numeric.add(self.fragcharges,temp) if not unrestricted: - self.atomcharges=Numeric.multiply(self.atomcharges,2) + self.fragcharges=Numeric.multiply(self.fragcharges,2) - return True - def partition(self,indices): - - if not hasattr(self,"aoresults"): - self.calculate() - - natoms=len(indices) - nmocoeffs=len(self.aoresults[0]) - -#build results Numeric array[3] - if len(self.aoresults)==2: - results=Numeric.zeros([2,nmocoeffs,natoms],"f") - else: - results=Numeric.zeros([1,nmocoeffs,natoms],"f") - -#for each spin, splice Numeric array at ao index, and add to correct result row - for spin in range(len(results)): - - for i in range(natoms): #number of groups - - for j in range(len(indices[i])): #for each group - - temp=self.aoresults[spin,:,indices[i][j]] - results[spin,:,i]=Numeric.add(results[spin,:,i],temp) - - return results - - if __name__=="__main__": import doctest,cspa doctest.testmod(cspa,verbose=False) Added: trunk/src/cclib/method/population.py =================================================================== --- trunk/src/cclib/method/population.py (rev 0) +++ trunk/src/cclib/method/population.py 2006-05-19 17:29:54 UTC (rev 130) @@ -0,0 +1,114 @@ +""" +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 Population(Method): + """A base class for all population-type methods""" + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(Population, self).__init__(logname="Population",*args) + self.fragresults=None + + def __str__(self): + """Return a string representation of the object.""" + return "Population" + + def __repr__(self): + """Return a representation of the object.""" + return "Population" + + +#create array for mulliken charges + self.logger.info("Creating atomcharges: array[1]") + size=len(self.atomresults[0][0]) + self.atomcharges=Numeric.zeros([size],"f") + + for spin in range(len(self.atomresults)): + + for i in range(self.parser.homos[spin]+1): + + temp=Numeric.reshape(self.atomresults[spin][i],(size,)) + self.atomcharges=Numeric.add(self.atomcharges,temp) + + if not unrestricted: + self.atomcharges=Numeric.multiply(self.atomcharges,2) + + return True + + def partition(self,indices=None): + + if not hasattr(self,"aoresults"): + self.calculate() + + if not indices: +#build list of groups of orbitals in each atom for atomresults + if hasattr(self.parser,"aonames"): + names=self.parser.aonames + elif hasattr(self.parser,"foonames"): + names=self.parser.fonames + + atoms=[] + indices=[] + + name=names[0].split('_')[0] + atoms.append(name) + indices.append([0]) + + for i in range(1,len(names)): + name=names[i].split('_')[0] + try: + index=atoms.index(name) + except ValueError: #not found in atom list + atoms.append(name) + indices.append([i]) + else: + indices[index].append(i) + + natoms=len(indices) + nmocoeffs=len(self.aoresults[0]) + +#build results Numeric array[3] + if len(self.aoresults)==2: + results=Numeric.zeros([2,nmocoeffs,natoms],"f") + else: + results=Numeric.zeros([1,nmocoeffs,natoms],"f") + +#for each spin, splice Numeric array at ao index, and add to correct result row + for spin in range(len(results)): + + for i in range(natoms): #number of groups + + for j in range(len(indices[i])): #for each group + + temp=self.aoresults[spin,:,indices[i][j]] + results[spin,:,i]=Numeric.add(results[spin,:,i],temp) + + self.logger.info("Saving partitioned results in fragresults: array[3]") + self.fragresults=results + + return True + +if __name__=="__main__": + import doctest,mpa + doctest.testmod(mpa,verbose=False) Property changes on: trunk/src/cclib/method/population.py ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-05-22 22:21:12
|
Revision: 148 Author: atenderholt Date: 2006-05-22 15:20:58 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=148&view=rev Log Message: ----------- Added overlap population analysis. Still need to do extensive testing. Modified Paths: -------------- trunk/src/cclib/method/__init__.py Added Paths: ----------- trunk/src/cclib/method/opa.py Modified: trunk/src/cclib/method/__init__.py =================================================================== --- trunk/src/cclib/method/__init__.py 2006-05-22 15:32:53 UTC (rev 147) +++ trunk/src/cclib/method/__init__.py 2006-05-22 22:20:58 UTC (rev 148) @@ -1,3 +1,4 @@ from density import Density from cspa import CSPA from mpa import MPA +from opa import OPA Added: trunk/src/cclib/method/opa.py =================================================================== --- trunk/src/cclib/method/opa.py (rev 0) +++ trunk/src/cclib/method/opa.py 2006-05-22 22:20:58 UTC (rev 148) @@ -0,0 +1,140 @@ +""" +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 OPA(Method): + """The overlap population analysis""" + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(OPA, self).__init__(logname="OPA",*args) + + def __str__(self): + """Return a string representation of the object.""" + return "OPA of" % (self.parser) + + def __repr__(self): + """Return a representation of the object.""" + return 'OPA("%s")' % (self.parser) + + def calculate(self,indices=None,fupdate=0.05): + """Perform an overlap population analysis 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") \ + or hasattr(self.parser, "fooverlaps") ) \ + and not hasattr(self.parser,"nbasis"): + self.logger.error("Missing mocoeffs, aooverlaps/fooverlaps or nbasis") + return False #let the caller of function know we didn't finish + + unrestricted=(len(self.parser.mocoeffs)==2) + nmocoeffs=len(self.parser.mocoeffs[0]) + nbasis=self.parser.nbasis + + if not indices: +#build list of groups of orbitals in each atom for atomresults + if hasattr(self.parser,"aonames"): + names=self.parser.aonames + elif hasattr(self.parser,"foonames"): + names=self.parser.fonames + + atoms=[] + indices=[] + + name=names[0].split('_')[0] + atoms.append(name) + indices.append([0]) + + for i in range(1,len(names)): + name=names[i].split('_')[0] + try: + index=atoms.index(name) + except ValueError: #not found in atom list + atoms.append(name) + indices.append([i]) + else: + indices[index].append(i) + + #determine number of steps, and whether process involves beta orbitals + nstep=nmocoeffs + nfrag=len(indices) #nfrag + self.logger.info("Creating attribute aoresults: array[3]") + if unrestricted: + self.results=Numeric.ones([2,nmocoeffs,nfrag,nfrag],"f") + nstep+=nmocoeffs + else: + self.results=Numeric.ones([1,nmocoeffs,nfrag,nfrag],"f") + + #intialize progress if available + if self.progress: + self.progress.initialize(nstep) + + step=0 + for spin in range(len(self.parser.mocoeffs)): + + for i in range(nmocoeffs): + + if self.progress and random.random()<fupdate: + self.progress.update(step,"Mulliken Population Analysis") + + # OP_{AB,i} = \sum_{a in A} \sum_{b in B} 2 c_{ai} c_{bi} S_{ab} + # = \sum_{a in A} c_{ai} \sum_{b in B} c_{bi} S_{ab} + # = \sum_{a in A} c_{ai} \sub_{b in B} C_{Bi} + # where C_{Bi} = C(i) times S(a) + + ci = self.parser.mocoeffs[spin][i] + + if hasattr(self.parser,"aooverlaps"): + temp = Numeric.multiply(ci,self.parser.aooverlaps) + elif hasattr(self.parser,"fooverlaps"): + temp = Numeric.multiply(ci,self.parser.fooverlaps) + + for A in range(len(indices)-1): + + for B in range(A+1,len(indices)): + + tempb=0 + for b in indices[B]: + tempb+=temp[:,b] + + tempresult=0 + for a in indices[A]: + tempresult+=ci[a]*tempb[a] + + self.results[spin][i][A][B]=2*tempresult + self.results[spin][i][B][A]=2*tempresult + + step+=1 + + if self.progress: + self.progress.update(nstep,"Done") + + return True + +if __name__=="__main__": + import doctest,opa + doctest.testmod(opa,verbose=False) Property changes on: trunk/src/cclib/method/opa.py ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-05-22 23:32:25
|
Revision: 149 Author: atenderholt Date: 2006-05-22 16:32:17 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=149&view=rev Log Message: ----------- Minor OPA changes, and a fix to textprogress. OPA is correct, although it is horribly slow. Need to fix. Modified Paths: -------------- trunk/src/cclib/method/opa.py trunk/src/cclib/progress/textprogress.py Modified: trunk/src/cclib/method/opa.py =================================================================== --- trunk/src/cclib/method/opa.py 2006-05-22 22:20:58 UTC (rev 148) +++ trunk/src/cclib/method/opa.py 2006-05-22 23:32:17 UTC (rev 149) @@ -99,7 +99,7 @@ for i in range(nmocoeffs): if self.progress and random.random()<fupdate: - self.progress.update(step,"Mulliken Population Analysis") + self.progress.update(step,"Overlap Population Analysis") # OP_{AB,i} = \sum_{a in A} \sum_{b in B} 2 c_{ai} c_{bi} S_{ab} # = \sum_{a in A} c_{ai} \sum_{b in B} c_{bi} S_{ab} Modified: trunk/src/cclib/progress/textprogress.py =================================================================== --- trunk/src/cclib/progress/textprogress.py 2006-05-22 22:20:58 UTC (rev 148) +++ trunk/src/cclib/progress/textprogress.py 2006-05-22 23:32:17 UTC (rev 149) @@ -30,7 +30,7 @@ str+="] %3i"%(self.progress)+"%" if text: - str+=" Parsing "+text + str+=" "+text sys.stdout.write("\r"+70*" ") sys.stdout.flush() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-05-23 01:28:54
|
Revision: 151 Author: atenderholt Date: 2006-05-22 18:28:46 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=151&view=rev Log Message: ----------- Added method for mayer's bond orders. I checked it against one known result, and it seems to work. Modified Paths: -------------- trunk/src/cclib/method/__init__.py trunk/src/cclib/method/density.py Added Paths: ----------- trunk/src/cclib/method/mbo.py Modified: trunk/src/cclib/method/__init__.py =================================================================== --- trunk/src/cclib/method/__init__.py 2006-05-23 00:16:35 UTC (rev 150) +++ trunk/src/cclib/method/__init__.py 2006-05-23 01:28:46 UTC (rev 151) @@ -2,3 +2,4 @@ from cspa import CSPA from mpa import MPA from opa import OPA +from mbo import MBO Modified: trunk/src/cclib/method/density.py =================================================================== --- trunk/src/cclib/method/density.py 2006-05-23 00:16:35 UTC (rev 150) +++ trunk/src/cclib/method/density.py 2006-05-23 01:28:46 UTC (rev 151) @@ -20,14 +20,15 @@ import re,time import Numeric import random # For sometimes running the progress updater +import logging from calculationmethod import Method class Density(Method): """Calculate the density matrix""" - def __init__(self,*args): + def __init__(self,parser,progress=None,loglevel=logging.INFO,logname="Log"): # Call the __init__ method of the superclass - super(Density, self).__init__(logname="Density",*args) + super(Density, self).__init__(parser, progress,loglevel,logname) def __str__(self): """Return a string representation of the object.""" Added: trunk/src/cclib/method/mbo.py =================================================================== --- trunk/src/cclib/method/mbo.py (rev 0) +++ trunk/src/cclib/method/mbo.py 2006-05-23 01:28:46 UTC (rev 151) @@ -0,0 +1,129 @@ +""" +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 density import Density + +class MBO(Density): + """Calculate the density matrix""" + def __init__(self,*args): + + # Call the __init__ method of the superclass + super(MBO, self).__init__(logname="MBO",*args) + + def __str__(self): + """Return a string representation of the object.""" + return "Mayer's bond order of" % (self.parser) + + def __repr__(self): + """Return a representation of the object.""" + return 'Mayer\'s bond order("%s")' % (self.parser) + + def calculate(self,indices=None,fupdate=0.05): + """Calculate Mayer's bond orders given the results of a parser""" + + if not self.parser.parsed: + self.parser.parse() + + super(MBO,self).calculate(fupdate) + + #do we have the needed info in the parser? + if not ( hasattr(self.parser,"aooverlaps") or hasattr(self.parser,"fooverlaps")): + self.logger.error("Missing overlap matrix") + return False #let the caller of function know we didn't finish + + if not indices: +#build list of groups of orbitals in each atom for atomresults + if hasattr(self.parser,"aonames"): + names=self.parser.aonames + elif hasattr(self.parser,"foonames"): + names=self.parser.fonames + + atoms=[] + indices=[] + + name=names[0].split('_')[0] + atoms.append(name) + indices.append([0]) + + for i in range(1,len(names)): + name=names[i].split('_')[0] + try: + index=atoms.index(name) + except ValueError: #not found in atom list + atoms.append(name) + indices.append([i]) + else: + indices[index].append(i) +#done building list + + self.logger.info("Creating attribute fragresults: array[3]") + size=len(indices) + unrestricted=(len(self.parser.mocoeffs)==2) + + #determine number of steps, and whether process involves beta orbitals + PS=[] + PS.append(Numeric.matrixmultiply(self.density[0],self.parser.aooverlaps)) + nstep=size**2 #approximately quadratic in size + if unrestricted: + self.fragresults=Numeric.zeros([2,size,size],"f") + PS.append(Numeric.matrixmultiply(self.density[1],self.parser.aooverlaps)) + else: + self.fragresults=Numeric.zeros([1,size,size],"f") + + #intialize progress if available + if self.progress: + self.progress.initialize(nstep) + + step=0 + for i in range(len(indices)): + + if self.progress and random.random() < fupdate: + self.progress.update(step,"Mayer's Bond Order") + + for j in range(i+1,len(indices)): + + tempsumA=0 + tempsumB=0 + + for a in indices[i]: + + for b in indices[j]: + + tempsumA+=2*PS[0][a][b]*PS[0][b][a] + if unrestricted: + tempsumB+=2*PS[1][a][b]*PS[1][b][a] + + self.fragresults[0][i,j]=tempsumA + self.fragresults[0][j,i]=tempsumA + + if unrestricted: + self.fragresults[1][i,j]=tempsumB + self.fragresults[1][j,i]=tempsumB + + if self.progress: + self.progress.update(nstep,"Done") + + return True + +if __name__=="__main__": + import doctest,g03parser + doctest.testmod(g03parser,verbose=False) Property changes on: trunk/src/cclib/method/mbo.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-06-20 20:58:42
|
Revision: 226 Author: baoilleach Date: 2006-06-20 13:58:31 -0700 (Tue, 20 Jun 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=226&view=rev Log Message: ----------- Pylint spacing recommendations Modified Paths: -------------- trunk/src/cclib/method/calculationmethod.py trunk/src/cclib/method/cspa.py trunk/src/cclib/method/mpa.py trunk/src/cclib/method/opa.py trunk/src/cclib/method/population.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-06-21 10:04:04
|
Revision: 227 Author: baoilleach Date: 2006-06-21 03:03:48 -0700 (Wed, 21 Jun 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=227&view=rev Log Message: ----------- Implementing pylint recommendations and setting the Rev keyword Modified Paths: -------------- trunk/src/cclib/method/mbo.py Property Changed: ---------------- trunk/src/cclib/method/__init__.py trunk/src/cclib/method/calculationmethod.py trunk/src/cclib/method/cspa.py trunk/src/cclib/method/density.py trunk/src/cclib/method/mbo.py trunk/src/cclib/method/mpa.py trunk/src/cclib/method/opa.py trunk/src/cclib/method/population.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-12-20 00:07:36
|
Revision: 450 http://svn.sourceforge.net/cclib/?rev=450&view=rev Author: atenderholt Date: 2006-12-19 16:07:32 -0800 (Tue, 19 Dec 2006) Log Message: ----------- Methods: Begin work on CDA method by creating class to convert from basis built on atomic orbitals to basis built from fragment molecular orbitals Modified Paths: -------------- trunk/src/cclib/method/__init__.py Added Paths: ----------- trunk/src/cclib/method/fragments.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2006-12-23 05:58:33
|
Revision: 453 http://svn.sourceforge.net/cclib/?rev=453&view=rev Author: atenderholt Date: 2006-12-22 21:58:31 -0800 (Fri, 22 Dec 2006) Log Message: ----------- FragmentAnalysis: convert aooverlaps into new molecular basis, resulting in the fooverlaps attribute; also has to update MPA to typecase a double into a float Modified Paths: -------------- trunk/src/cclib/method/fragments.py trunk/src/cclib/method/mpa.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ate...@us...> - 2007-03-26 18:53:02
|
Revision: 596 http://svn.sourceforge.net/cclib/?rev=596&view=rev Author: atenderholt Date: 2007-03-26 11:52:59 -0700 (Mon, 26 Mar 2007) Log Message: ----------- Change the MPA method to work with parsers that have different number of alpha and beta mocoeffs Modified Paths: -------------- trunk/src/cclib/method/mpa.py trunk/src/cclib/method/population.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <la...@us...> - 2007-05-19 22:41:55
|
Revision: 630 http://svn.sourceforge.net/cclib/?rev=630&view=rev Author: langner Date: 2007-05-19 15:41:53 -0700 (Sat, 19 May 2007) Log Message: ----------- Committing code for LPA (Lowdin Population Analysis) - was not added to svn repository in previous commit. Modified Paths: -------------- trunk/src/cclib/method/__init__.py Added Paths: ----------- trunk/src/cclib/method/lpa.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |