示例#1
0
 def __init__(self, data):
     self.molecule = Molecule(atoms=data['atoms'])
     self.grid = Grid(data)
     self.setA()
     reference = self.grid.get_properties(property_name=data['property'],\
             theory='%s_%s' % (data['theory'], data['basis']))
     LeastSquaresBasic.__init__(self, A=self.A, b=reference)
示例#2
0
 def update_grid(self, grid):
     self.grid = grid
     b = grid.get_values()
     A = self.get_A()
     try:
         saved_solution = self.copy_solution()
     except AttributeError:
         pass
     LeastSquaresBasic.__init__(self, A=A, b=b)
     try:
         self.set_solution(saved_solution)
     except NameError:
         pass
示例#3
0
 def solve(self, method='svd', truncate=0):
     solution = LeastSquaresBasic.solve(self, method, truncate)
     if not len(solution) == len(self.molecule.sites_names_noneq):
         raise ValueError('Number of charges in solution (%i) does not match number of sites (%i):\n%r' % 
                 (len(solution), len(self.molecule.sites_names_noneq), self.molecule.sites_names_noneq))
     self.clear_charges()
     for q, name in zip(solution, self.molecule.sites_names_noneq):
         self.set_charge(name, q)
     self.molecule.charges_to_sites(self.charges)