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 check_sanity(self): lib.StreamObject.check_sanity(self) cell = self.cell if not cell.has_ecp(): logger.warn( self, 'AFTDF 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.mesh_to_cutoff(cell.lattice_vectors(), self.mesh) ke_cutoff = ke_cutoff[:cell.dimension].min() else: ke_cutoff = numpy.min(cell.ke_cutoff) ke_guess = estimate_ke_cutoff(cell, cell.precision) mesh_guess = tools.cutoff_to_mesh(cell.lattice_vectors(), ke_guess) if ke_cutoff < ke_guess * KE_SCALING: logger.warn( self, 'ke_cutoff/mesh (%g / %s) is not enough for AFTDF ' 'to get integral accuracy %g.\nCoulomb integral error ' 'is ~ %.2g Eh.\nRecommended ke_cutoff/mesh are %g / %s.', ke_cutoff, self.mesh, cell.precision, error_for_ke_cutoff(cell, ke_cutoff), ke_guess, mesh_guess) else: mesh_guess = numpy.copy(self.mesh) if cell.dimension < 3: err = numpy.exp(-0.436392335 * min(self.mesh[cell.dimension:]) - 2.99944305) err *= cell.nelectron meshz = pbcgto.cell._mesh_inf_vaccum(cell) mesh_guess[cell.dimension:] = int(meshz) if err > cell.precision * 10: logger.warn( self, 'mesh %s of AFTDF may not be enough to get ' 'integral accuracy %g for %dD PBC system.\n' 'Coulomb integral error is ~ %.2g Eh.\n' 'Recommended mesh is %s.', self.mesh, cell.precision, cell.dimension, err, mesh_guess) if (cell.mesh[cell.dimension:] / (1. * meshz) > 1.1).any(): meshz = pbcgto.cell._mesh_inf_vaccum(cell) logger.warn( self, 'setting mesh %s of AFTDF too high in non-periodic direction ' '(=%s) can result in an unnecessarily slow calculation.\n' 'For coulomb integral error of ~ %.2g Eh in %dD PBC, \n' 'a recommended mesh for non-periodic direction is %s.', self.mesh, self.mesh[cell.dimension:], cell.precision, cell.dimension, mesh_guess[cell.dimension:]) return self
def check_sanity(self): lib.StreamObject.check_sanity(self) cell = self.cell if not cell.has_ecp(): logger.warn(self, 'AFTDF 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.mesh_to_cutoff(cell.lattice_vectors(), self.mesh) ke_cutoff = ke_cutoff[:cell.dimension].min() else: ke_cutoff = numpy.min(cell.ke_cutoff) ke_guess = estimate_ke_cutoff(cell, cell.precision) mesh_guess = tools.cutoff_to_mesh(cell.lattice_vectors(), ke_guess) if ke_cutoff < ke_guess * KE_SCALING: logger.warn(self, 'ke_cutoff/mesh (%g / %s) is not enough for AFTDF ' 'to get integral accuracy %g.\nCoulomb integral error ' 'is ~ %.2g Eh.\nRecommended ke_cutoff/mesh are %g / %s.', ke_cutoff, self.mesh, cell.precision, error_for_ke_cutoff(cell, ke_cutoff), ke_guess, mesh_guess) else: mesh_guess = numpy.copy(self.mesh) if cell.dimension < 3: err = numpy.exp(-0.436392335*min(self.mesh[cell.dimension:]) - 2.99944305) err *= cell.nelectron meshz = pbcgto.cell._mesh_inf_vaccum(cell) mesh_guess[cell.dimension:] = int(meshz) if err > cell.precision*10: logger.warn(self, 'mesh %s of AFTDF may not be enough to get ' 'integral accuracy %g for %dD PBC system.\n' 'Coulomb integral error is ~ %.2g Eh.\n' 'Recommended mesh is %s.', self.mesh, cell.precision, cell.dimension, err, mesh_guess) if (cell.mesh[cell.dimension:]/(1.*meshz) > 1.1).any(): meshz = pbcgto.cell._mesh_inf_vaccum(cell) logger.warn(self, 'setting mesh %s of AFTDF too high in non-periodic direction ' '(=%s) can result in an unnecessarily slow calculation.\n' 'For coulomb integral error of ~ %.2g Eh in %dD PBC, \n' 'a recommended mesh for non-periodic direction is %s.', self.mesh, self.mesh[cell.dimension:], cell.precision, cell.dimension, mesh_guess[cell.dimension:]) return self
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 check_sanity(self): lib.StreamObject.check_sanity(self) cell = self.cell if cell.dimension < 2: raise RuntimeError( 'FFTDF method does not support 0D/1D low-dimension ' 'PBC system. DF, MDF or AFTDF methods should ' 'be used.\nSee also examples/pbc/31-low_dimensional_pbc.py') if cell.dimension == 2 and self.low_dim_ft_type is None: raise RuntimeError( 'FFTDF method does not support low_dim_ft_type of None ' 'for 2D systems. Supported types include \'analytic_2d_1\'. ' '\nSee also examples/pbc/32-graphene.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.mesh_to_cutoff(cell.lattice_vectors(), self.mesh).min() else: ke_cutoff = numpy.min(cell.ke_cutoff) ke_guess = estimate_ke_cutoff(cell, cell.precision) if ke_cutoff < ke_guess * KE_SCALING: mesh_guess = tools.cutoff_to_mesh(cell.lattice_vectors(), ke_guess) logger.warn( self, 'ke_cutoff/mesh (%g / %s) is not enough for FFTDF ' 'to get integral accuracy %g.\nCoulomb integral error ' 'is ~ %.2g Eh.\nRecommended ke_cutoff/mesh are %g / %s.', ke_cutoff, self.mesh, cell.precision, error_for_ke_cutoff(cell, ke_cutoff), ke_guess, mesh_guess) return self