Beispiel #1
0
 def __init__(self, molecule=None, grid=None, truncate=0):
     LeastSquaresCharges.__init__(self, molecule=molecule, grid=grid)
     self.truncate = truncate
     self.hybrids = []
     for atom in self.molecule.atoms:
         if not atom.frame is None:
             self.hybrids.append(atom)
     self.num_charges = len(self.molecule.sites_noneq)
import openbabel
from os import path
import sys 
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )

from charges import LeastSquaresCharges
from Parser import GaussianCube
#from pybel import *
parser = GaussianCube(filename='../../../media/files/chloromethane_b3lyp_augccpvdz_3.75.cub')
data = parser.data.copy()
data['theory'] = 'b3lyp'
data['basis'] = 'augccpvdz'
ls = LeastSquaresCharges(data) 
ls.solve()
print ls.solution
mol = openbabel.OBMol()
conv = openbabel.OBConversion()
conv.SetInAndOutFormats("cube", "mol2")
conv.ReadFile(mol, '../../../media/files/chloromethane_b3lyp_augccpvdz_3.75.cub') 
#for i, _ in enumerate(data['atoms']):
#    a = mol.GetAtom(i+1)
#    a.SetPartialCharge(ls.solution[i])
#    print a.GetAtomicNum()
#    print a.GetPartialCharge()
a = mol.GetAtom(1)
a.GetPartialCharge()
for i, _ in enumerate(data['atoms']):
    a = mol.GetAtom(i+1)
    a.SetPartialCharge(ls.solution[i])
    print a.GetAtomicNum()
    print a.GetPartialCharge()
Beispiel #3
0
 def __init__(self, molecule=None, grid=None):
     LeastSquaresCharges.__init__(self, molecule=molecule, grid=grid)
     logger.info('Charge constraint using SVD')
Beispiel #4
0
 def __init__(self, molecule=None, grid=None):
     LeastSquaresCharges.__init__(self, molecule=molecule, grid=grid)
     logger.info('The total charge leakage will be distributed over all atoms')
Beispiel #5
0
 def solve(self):
     solution = LeastSquaresCharges.solve_normal(self)
     self._solution = solution[:-1]
     return self._solution
Beispiel #6
0
 def __init__(self, molecule=None, grid=None):
     LeastSquaresCharges.__init__(self, molecule=molecule, grid=grid)
     logger.info('Applying total charge constraint using Lagrange multiplier')
     self.update()
Beispiel #7
0
 def __init__(self, molecule=None, grid=None, eliminated=None):
     self.eliminated = eliminated
     logger.info('Applying total charge constraint by elimination.\nEliminated atom: %s' % eliminated)
     LeastSquaresCharges.__init__(self, molecule=molecule, grid=grid)
     self.setB()
     self.A -= self.B