def _update_pot(self, cache, grid): """Recompute an Hartree potential if invalid cache A cache instance in which the potential is stored. grid The integration grid. """ # This only works under a few circumstances if not isinstance(grid, BeckeMolGrid): raise TypeError("The BeckeHatree term only works for Becke-Lebedev molecular integration grids") if grid.mode != "keep": raise TypeError("The mode option of the molecular grid must be 'keep'.") pot, new = cache.load("pot_%s" % self.label, alloc=grid.size) if new: rho = cache["rho_full"] # Construct spherical decompositions of atomic densities, derive # hartree potentials and evaluate begin = 0 pot[:] = 0 for atgrid in grid.subgrids: end = begin + atgrid.size becke_weights = grid.becke_weights[begin:end] density_decomposition = atgrid.get_spherical_decomposition( rho[begin:end], becke_weights, lmax=self.lmax ) hartree_decomposition = solve_poisson_becke(density_decomposition) grid.eval_decomposition(hartree_decomposition, atgrid.center, pot) begin = end return pot
def _update_pot(self, cache, grid): """Recompute a Hartree potential if invalid. Parameters ---------- cache : Cache Storage for the potentials. grid : IntGrid A numerical integration grid. """ # This only works under a few circumstances if not isinstance(grid, BeckeMolGrid): raise TypeError('The BeckeHatree term only works for Becke-Lebedev molecular integration grids') if grid.mode != 'keep': raise TypeError('The mode option of the molecular grid must be \'keep\'.') pot, new = cache.load('pot_%s' % self.label, alloc=grid.size) if new: rho = cache['rho_full'] # Construct spherical decompositions of atomic densities, derive # hartree potentials and evaluate begin = 0 pot[:] = 0 for atgrid in grid.subgrids: end = begin + atgrid.size becke_weights = grid.becke_weights[begin:end] density_decomposition = atgrid.get_spherical_decomposition(rho[begin:end], becke_weights, lmax=self.lmax) hartree_decomposition = solve_poisson_becke(density_decomposition) grid.eval_decomposition(hartree_decomposition, atgrid.center, pot) begin = end return pot
def do_hartree_decomposition(self): if not self.local: if log.do_warning: log.warn( 'Skipping hartree decomposition because no local grids were found.' ) return for index in xrange(self.natom): key = ('hartree_decomposition', index) if key not in self.cache: self.do_density_decomposition() if log.do_medium: log('Computing hartree decomposition for atom %i' % index) density_decomposition = self.cache.load( 'density_decomposition', index) rho_splines = [ spline for foo, spline in sorted( density_decomposition.iteritems()) ] v_splines = solve_poisson_becke(rho_splines) hartree_decomposition = dict( ('spline_%05i' % j, spline) for j, spline in enumerate(v_splines)) self.cache.dump(key, hartree_decomposition, tags='o')
def do_hartree_decomposition(self): if not self.local: if log.do_warning: log.warn('Skipping hartree decomposition because no local grids were found.') return for index in xrange(self.natom): key = ('hartree_decomposition', index) if key not in self.cache: self.do_density_decomposition() if log.do_medium: log('Computing hartree decomposition for atom %i' % index) density_decomposition = self.cache.load('density_decomposition', index) rho_splines = [spline for foo, spline in sorted(density_decomposition.iteritems())] v_splines = solve_poisson_becke(rho_splines) hartree_decomposition = dict(('spline_%05i' % j, spline) for j, spline in enumerate(v_splines)) self.cache.dump(key, hartree_decomposition, tags='o')
def do_prosplines(self): for index in xrange(self.natom): # density key = ('spline_prodensity', index) if key not in self.cache: if log.medium: log('Storing proatom density spline for atom %i.' % index) spline = self.get_proatom_spline(index) self.cache.dump(key, spline, tags='o') # hartree potential key = ('spline_prohartree', index) if key not in self.cache: if log.medium: log('Computing proatom hartree potential spline for atom %i.' % index) rho_spline = self.cache.load('spline_prodensity', index) v_spline = solve_poisson_becke([rho_spline])[0] self.cache.dump(key, v_spline, tags='o')