def test_init(self): from pyscf.pbc import dft cell_u = cell.copy() cell_u.spin = 2 self.assertTrue(isinstance(pscf.RKS (cell ), dft.rks.RKS )) self.assertTrue(isinstance(pscf.RKS (cell_u), dft.roks.ROKS )) self.assertTrue(isinstance(pscf.UKS (cell ), dft.uks.UKS )) self.assertTrue(isinstance(pscf.ROKS (cell ), dft.roks.ROKS )) self.assertTrue(isinstance(pscf.KS (cell ), dft.rks.RKS )) self.assertTrue(isinstance(pscf.KS (cell_u), dft.uks.UKS )) self.assertTrue(isinstance(pscf.KRKS (cell ), dft.krks.KRKS )) self.assertTrue(isinstance(pscf.KRKS (cell_u), dft.krks.KRKS )) self.assertTrue(isinstance(pscf.KUKS (cell ), dft.kuks.KUKS )) self.assertTrue(isinstance(pscf.KROKS(cell ), dft.kroks.KROKS)) self.assertTrue(isinstance(pscf.KKS (cell ), dft.krks.KRKS )) self.assertTrue(isinstance(pscf.KKS (cell_u), dft.kuks.KUKS )) self.assertTrue(isinstance(pscf.RHF (cell ), pscf.hf.RHF )) self.assertTrue(isinstance(pscf.RHF (cell_u), pscf.rohf.ROHF )) self.assertTrue(isinstance(pscf.KRHF (cell ), pscf.khf.KRHF )) self.assertTrue(isinstance(pscf.KRHF (cell_u), pscf.khf.KRHF )) self.assertTrue(isinstance(pscf.UHF (cell ), pscf.uhf.UHF )) self.assertTrue(isinstance(pscf.KUHF (cell_u), pscf.kuhf.KUHF )) self.assertTrue(isinstance(pscf.GHF (cell ), pscf.ghf.GHF )) self.assertTrue(isinstance(pscf.KGHF (cell_u), pscf.kghf.KGHF )) self.assertTrue(isinstance(pscf.ROHF (cell ), pscf.rohf.ROHF )) self.assertTrue(isinstance(pscf.ROHF (cell_u), pscf.rohf.ROHF )) self.assertTrue(isinstance(pscf.KROHF(cell ), pscf.krohf.KROHF)) self.assertTrue(isinstance(pscf.KROHF(cell_u), pscf.krohf.KROHF)) self.assertTrue(isinstance(pscf.HF (cell ), pscf.hf.RHF )) self.assertTrue(isinstance(pscf.HF (cell_u), pscf.uhf.UHF )) self.assertTrue(isinstance(pscf.KHF (cell ), pscf.khf.KRHF )) self.assertTrue(isinstance(pscf.KHF (cell_u), pscf.kuhf.KUHF ))
def init_scf(self, cell=None, method=None, verbose=None, damp=None, shift=None, kpts=None, grid_level=None, rho_cutoff=None, density_fit=None, auxbasis=None): """ Initializes the supersystem PySCF SCF object using given settings. Parameters ---------- cell : pyscf.pbc.gto.Cell object Concatenated supersystem Cell object fs_method : str Supersystem SCF method verbose : int PySCF verbosity parameter for output damp : float Damping parameter for SCF convergence shift : float Energy level shift parameter for convergence Returns ------- scf_obj : pyscf.pbc.SCF object SCF object for the supersystem """ import pyscf from pyscf.pbc import scf as pbcscf, df as pbcdf, dft as pbcdft if cell is None: cell = self.cell if method is None: method = self.fs_method if verbose is None: verbose = self.verbose if damp is None: damp = self.fs_damp if shift is None: shift = self.fs_shift if kpts is None: kpts = self.kpts if grid_level is None: grid_level = self.grid_level if rho_cutoff is None: rho_cutoff = self.rho_cutoff if density_fit is None: density_fit = self.density_fit if auxbasis is None: auxbasis = self.auxbasis # if self.pmem: # self.cell.max_memory = self.pmem nkpts = len(kpts) if self.unrestricted: if method in ('hf', 'hartree-fock'): scf_obj = pbcscf.KUHF(cell, kpts) else: scf_obj = pbcscf.KUKS(cell, kpts) scf_obj.xc = method elif cell.spin != 0: if method in ('hf', 'hartree-fock'): scf_obj = pbcscf.KROHF(cell, kpts) else: scf_obj = pbcscf.KROKS(cell, kpts) scf_obj.xc = method else: if method in ('hf', 'hartree-fock'): scf_obj = pbcscf.KRHF(cell, kpts) else: scf_obj = pbcscf.KRKS(cell, kpts) scf_obj.xc = method scf_obj.kpts = kpts scf_obj.verbose = verbose # build grids scf_obj.grids = pbcdft.gen_grid.BeckeGrids(cell) scf_obj.grids.level = grid_level scf_obj.grids.build() # density fitting (can be very time consuming) if density_fit == 'fftdf': DensityFit = pbcdf.FFTDF elif density_fit == 'mdf': DensityFit = pbcdf.MDF elif density_fit == 'pwdf': DensityFit = pbcdf.PWDF elif density_fit == 'gdf': DensityFit = pbcdf.GDF elif density_fit == 'aftdf': DensityFit = pbcdf.AFTDF else: DensityFit = pbcdf.DF scf_obj.with_df = DensityFit(cell) scf_obj.with_df.kpts = kpts scf_obj.with_df.auxbasis = auxbasis scf_obj.damp = damp self.smat = scf_obj.get_ovlp() return scf_obj
def init_env_scf(self, cell=None, env_method=None, kpts=None, rho_cutoff=None, verbose=None, damp=None, shift=None, grid_level=None, density_fit=None, auxbasis=None): """ Initializes the environment pyscf:pbc:scf object. Paramters --------- cell : pyscf:pbc:Cell object, optional env_method : str, optional Subsystem method for calculation (default is None). kpts : ndarray, optional Kpoints (in inv. bohr) to use (default is None). rho_cutoff : float, optional DFT density/rho cutoff parameter (default is None). verbose : int, optional Verbosity parameter (default is None). damp : float, optional Damping parameter (default is None). shift : float, optional level shift parameter for convergence (default is None). grid_level : int, optional Grid_level for DFT and Coulomb integration (default is None). density_fit : str, optional The default desnity fit method to use (default is None). auxbasis : str, optional Auxillary basis for density fitting (default is None). Returns ------- cSCF : pyscf.pbc.SCF object """ import numpy as np from pyscf.pbc import dft as pbcdft, scf as pbcscf, df as pbcdf if cell is None: cell = self.cell if env_method is None: env_method = self.env_method.lower() if kpts is None: kpts = self.kpts if rho_cutoff is None: rho_cutoff = self.rho_cutoff if verbose is None: verbose = self.verbose if damp is None: damp = self.damp if shift is None: shift = self.shift if grid_level is None: grid_level = self.grid_level if density_fit is None: density_fit = self.density_fit density_fit = density_fit.lower() if auxbasis is None: auxbasis = self.auxbasis if self.unrestricted: if env_method in ('hf', 'hartree-fock'): cSCF = pbcscf.KUHF(cell, kpts) else: cSCF = pbcscf.KUKS(cell, kpts) cSCF.xc = env_method elif cell.spin != 0: if env_method in ('hf', 'hartree-fock'): cSCF = pbcscf.KROHF(cell, kpts) else: cSCF = pbcscf.KROKS(cell, kpts) cSCF.xc = env_method else: if env_method in ('hf', 'hartree-fock'): cSCF = pbcscf.KRHF(cell, kpts) else: cSCF = pbcscf.KRKS(cell, kpts) cSCF.xc = env_method cSCF.kpts = kpts cSCF.verbose = verbose # grids should probably be for the supersystem # Keep this for now, although its probably expensive # to calculate the grids for each subsystem cSCF.grids = pbcdft.gen_grid.BeckeGrids(cell) cSCF.grids.level = grid_level cSCF.grids.build() # density fitting (can be very time consuming) if density_fit == 'fftdf': DensityFit = pbcdf.FFTDF elif density_fit == 'mdf': DensityFit = pbcdf.MDF elif density_fit == 'pwdf': DensityFit = pbcdf.PWDF elif density_fit == 'gdf': DensityFit = pbcdf.GDF elif density_fit == 'aftdf': DensityFit = pbcdf.AFTDF else: DensityFit = pbcdf.DF cSCF.with_df = DensityFit(cell) cSCF.with_df.kpts = kpts cSCF.with_df.auxbasis = auxbasis # # only for local and semi-local functional for now # cSCF.with_df.build(j_only=True) return cSCF