def check_sanity(self): lib.StreamObject.check_sanity(self) cell = self.cell if cell.dimension < 3: raise RuntimeError( 'FFTDF method does not support low-dimension ' 'PBC system. DF, MDF or AFTDF methods should ' 'be used.\nSee also examples/pbc/31-low_dimensional_pbc.py') if not cell.has_ecp(): logger.warn( self, 'FFTDF integrals are found in all-electron ' 'calculation. It often causes huge error.\n' 'Recommended methods are DF or MDF. In SCF calculation, ' 'they can be initialized as\n' ' mf = mf.density_fit()\nor\n' ' mf = mf.mix_density_fit()') if cell.ke_cutoff is None: ke_cutoff = tools.gs_to_cutoff(cell.lattice_vectors(), self.gs).min() else: ke_cutoff = numpy.min(cell.ke_cutoff) ke_guess = estimate_ke_cutoff(cell, cell.precision) if ke_cutoff < ke_guess * .8: gs_guess = tools.cutoff_to_gs(cell.lattice_vectors(), ke_guess) logger.warn( self, 'ke_cutoff/gs (%g / %s) is not enough for FFTDF ' 'to get integral accuracy %g.\nCoulomb integral error ' 'is ~ %.2g Eh.\nRecomended ke_cutoff/gs are %g / %s.', ke_cutoff, self.gs, cell.precision, error_for_ke_cutoff(cell, ke_cutoff), ke_guess, gs_guess) return self
def __init__(self, cell, kpts=numpy.zeros((1, 3))): self.cell = cell self.stdout = cell.stdout self.verbose = cell.verbose self.max_memory = cell.max_memory self.kpts = kpts # default is gamma point self.kpts_band = None self.auxbasis = None if cell.dimension == 0: self.eta = 0.2 self.gs = cell.gs else: ke_cutoff = tools.gs_to_cutoff(cell.lattice_vectors(), cell.gs) ke_cutoff = ke_cutoff[:cell.dimension].min() self.eta = min( aft.estimate_eta_for_ke_cutoff(cell, ke_cutoff, cell.precision), estimate_eta(cell, cell.precision)) ke_cutoff = aft.estimate_ke_cutoff_for_eta(cell, self.eta, cell.precision) self.gs = tools.cutoff_to_gs(cell.lattice_vectors(), ke_cutoff) self.gs[cell.dimension:] = cell.gs[cell.dimension:] # Not input options self.exxdiv = None # to mimic KRHF/KUHF object in function get_coulG self.auxcell = None self.blockdim = 240 self.linear_dep_threshold = LINEAR_DEP_THR self._j_only = False # If _cderi_to_save is specified, the 3C-integral tensor will be saved in this file. self._cderi_to_save = tempfile.NamedTemporaryFile(dir=lib.param.TMPDIR) # If _cderi is specified, the 3C-integral tensor will be read from this file self._cderi = None self._keys = set(self.__dict__.keys())
def eta(self): if self._eta is not None: return self._eta else: cell = self.cell if cell.dimension == 0: return 0.2 ke_cutoff = tools.gs_to_cutoff(cell.lattice_vectors(), self.gs) ke_cutoff = ke_cutoff[:cell.dimension].min() return aft.estimate_eta_for_ke_cutoff(cell, ke_cutoff, cell.precision)
def check_sanity(self): lib.StreamObject.check_sanity(self) cell = self.cell if not cell.has_ecp(): logger.warn( self, 'FFTDF integrals are found in all-electron ' 'calculation. It often causes huge error.\n' 'Recommended methods are DF or MDF. In SCF calculation, ' 'they can be initialized as\n' ' mf = mf.density_fit()\nor\n' ' mf = mf.mix_density_fit()') if cell.dimension > 0: if cell.ke_cutoff is None: ke_cutoff = tools.gs_to_cutoff(cell.lattice_vectors(), self.gs) ke_cutoff = ke_cutoff[:cell.dimension].min() else: ke_cutoff = numpy.min(cell.ke_cutoff) ke_guess = estimate_ke_cutoff(cell, cell.precision) if ke_cutoff < ke_guess * .8: gs_guess = tools.cutoff_to_gs(cell.lattice_vectors(), ke_guess) logger.warn( self, 'ke_cutoff/gs (%g / %s) is not enough for FFTDF ' 'to get integral accuracy %g.\nCoulomb integral error ' 'is ~ %.2g Eh.\nRecomended ke_cutoff/gs are %g / %s.', ke_cutoff, self.gs, cell.precision, error_for_ke_cutoff(cell, ke_cutoff), ke_guess, gs_guess) else: gs_guess = numpy.copy(self.gs) if cell.dimension < 3: err = numpy.exp(-0.87278467 * min(self.gs[cell.dimension:]) - 2.99944305) err *= cell.nelectron if err > cell.precision * 10: gz = numpy.log( cell.nelectron / cell.precision) / 0.8727847 - 3.4366358 gs_guess[cell.dimension:] = int(gz) logger.warn( self, 'gs %s of AFTDF may not be enough to get ' 'integral accuracy %g for %dD PBC system.\n' 'Coulomb integral error is ~ %.2g Eh.\n' 'Recomended gs is %s.', self.gs, cell.precision, cell.dimension, err, gs_guess) return self
def __init__(self, cell, kpts=numpy.zeros((1,3))): self.cell = cell self.stdout = cell.stdout self.verbose = cell.verbose self.max_memory = cell.max_memory self.gs = cell.gs # For nuclear attraction integrals using Ewald-like technique. # Set to 0 to swith off Ewald tech and use the regular reciprocal space # method (solving Poisson equation of nuclear charges in reciprocal space). if cell.dimension == 0: self.eta = 0.2 else: ke_cutoff = tools.gs_to_cutoff(cell.lattice_vectors(), self.gs) ke_cutoff = ke_cutoff[:cell.dimension].min() self.eta = max(estimate_eta_for_ke_cutoff(cell, ke_cutoff, cell.precision), estimate_eta(cell, cell.precision)) self.kpts = kpts self.blockdim = 240 # to mimic molecular DF object # Not input options self.exxdiv = None # to mimic KRHF/KUHF object in function get_coulG self._keys = set(self.__dict__.keys())