def __init__(self, mf, frozen=None): self.mol = mf.mol self._scf = mf self.verbose = self.mol.verbose self.stdout = self.mol.stdout self.max_memory = mf.max_memory self.frozen = frozen #TODO: implement frozen orbs if not (self.frozen is None or self.frozen == 0): raise NotImplementedError # DF-GW must use density fitting integrals if getattr(mf, 'with_df', None): self.with_df = mf.with_df else: self.with_df = df.DF(mf.mol) self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True) self._keys.update(['with_df']) ################################################## # don't modify the following attributes, they are not input options self._nocc = None self._nmo = None # self.mo_energy: GW quasiparticle energy, not scf mo_energy self.mo_energy = None self.mo_coeff = mf.mo_coeff self.mo_occ = mf.mo_occ self.sigma = None keys = set(('eta', 'linearized')) self._keys = set(self.__dict__.keys()).union(keys)
def __init__(self, mf, frozen=None, auxbasis=None): self.mol = mf.mol self._scf = mf self.verbose = self.mol.verbose self.stdout = self.mol.stdout self.max_memory = mf.max_memory self.frozen = frozen # DF-RPA must use density fitting integrals if getattr(mf, 'with_df', None): self.with_df = mf.with_df else: self.with_df = df.DF(mf.mol) if auxbasis: self.with_df.auxbasis = auxbasis else: self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True) self._keys.update(['with_df']) ################################################## # don't modify the following attributes, they are not input options self._nocc = None self._nmo = None self.mo_energy = mf.mo_energy self.mo_coeff = mf.mo_coeff self.mo_occ = mf.mo_occ self.e_corr = None self.e_hf = None self.e_tot = None
def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): mp2.MP2.__init__(self, mf, frozen, mo_coeff, mo_occ) if getattr(mf, 'with_df', None): self.with_df = mf.with_df else: self.with_df = df.DF(mf.mol) self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True) self._keys.update(['with_df'])
def __init__(self, mf, frozen=0, mo_coeff=None, mo_occ=None): mp2.MP2.__init__(self, mf, frozen, mo_coeff, mo_occ) if getattr(mf, 'with_df', None): self.with_df = mf.with_df else: self.with_df = df.DF(mf.mol) self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True) self._keys.update(['with_df'])
def __init__(self, mf, frozen=0, mo_coeff=None, mo_occ=None): ccsd.CCSD.__init__(self, mf, frozen, mo_coeff, mo_occ) if hasattr(mf, 'with_df') and mf.with_df: self.with_df = mf.with_df else: self.with_df = df.DF(mf.mol) self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True) self._keys.update(['with_df'])
def __init__(self, mf, frozen=None, auxbasis=None): ''' Args: mf : RHF instance frozen : number of frozen orbitals or list of frozen orbitals auxbasis : name of auxiliary basis set, otherwise determined automatically ''' if not isinstance(mf, scf.rhf.RHF): raise TypeError('Class initialization with non-RHF object') self.mo_coeff = mf.mo_coeff self.mo_energy = mf.mo_energy self.nocc = np.count_nonzero(mf.mo_occ) self.nmo = self.mo_coeff.shape[1] self.e_scf = mf.e_tot self._scf = mf # Process the frozen core option correctly as an integer or a list. # self.frozen_mask sets a flag for each orbital if it is frozen (True) or not (False). # Only occupied orbitals can be frozen. self.frozen_mask = np.zeros(self.nmo, dtype=bool) if frozen is None: pass elif lib.isinteger(frozen): if frozen > self.nocc: raise ValueError('only occupied orbitals can be frozen') self.frozen_mask[:frozen] = True elif lib.isintsequence(frozen): if max(frozen) > self.nocc - 1: raise ValueError('only occupied orbitals can be frozen') self.frozen_mask[frozen] = True else: raise TypeError('frozen must be an integer or a list of integers') # mask for occupied orbitals that are not frozen self.occ_mask = np.zeros(self.nmo, dtype=bool) self.occ_mask[:self.nocc] = True self.occ_mask[self.frozen_mask] = False self.mol = mf.mol if not auxbasis: auxbasis = df.make_auxbasis(self.mol, mp2fit=True) self.auxmol = df.make_auxmol(self.mol, auxbasis) self.verbose = self.mol.verbose self.stdout = self.mol.stdout self.max_memory = self.mol.max_memory self._intsfile = None self.e_corr = None # Spin component scaling factors self.ps = 1.0 self.pt = 1.0 self.cphf_max_cycle = 100 self.cphf_tol = mf.conv_tol
def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None): uagf2.UAGF2.__init__(self, mf, frozen=frozen, mo_energy=mo_energy, mo_coeff=mo_coeff, mo_occ=mo_occ) if getattr(mf, 'with_df', None) is not None: self.with_df = mf.with_df else: self.with_df = df.DF(mf.mol) self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True) self.allow_lowmem_build = True self._keys.update(['_with_df', 'allow_lowmem_build'])
def __init__(self, mf): self.mol = mf.mol self.verbose = self.mol.verbose self.stdout = self.mol.stdout self.max_memory = mf.max_memory self._scf = mf if hasattr(mf, 'with_df') and mf.with_df: self.with_df = None else: self.with_df = df.DF(mol) self.with_df.auxbasis = df.make_auxbasis(mol, mp2fit=True) self.emp2 = None self.t2 = None
mol.verbose = 0 mol.atom = [[8, (0., 0., 0.)], [1, (0., -0.757, 0.587)], [1, (0., 0.757, 0.587)]] mol.basis = 'cc-pvdz' mol.build() mf = scf.RHF(mol).run() pt = DFMP2(mf) emp2, t2 = pt.kernel() print(emp2 - -0.204004830285) pt.with_df = df.DF(mol) pt.with_df.auxbasis = 'weigend' emp2, t2 = pt.kernel() print(emp2 - -0.204254500453) mf = scf.density_fit(scf.RHF(mol), 'weigend') mf.kernel() pt = DFMP2(mf) emp2, t2 = pt.kernel() print(emp2 - -0.203986171133) pt.with_df = df.DF(mol) pt.with_df.auxbasis = df.make_auxbasis(mol, mp2fit=True) emp2, t2 = pt.kernel() print(emp2 - -0.203738031827) pt.frozen = 2 emp2, t2 = pt.kernel() print(emp2 - -0.14433975122418313)
[8 , (0. , 0. , 0.)], [1 , (0. , -0.757 , 0.587)], [1 , (0. , 0.757 , 0.587)]] mol.basis = 'cc-pvdz' mol.build() mf = scf.RHF(mol).run() pt = DFMP2(mf) emp2, t2 = pt.kernel() print(emp2 - -0.204004830285) pt.with_df = df.DF(mol) pt.with_df.auxbasis = 'weigend' emp2, t2 = pt.kernel() print(emp2 - -0.204254500453) mf = scf.density_fit(scf.RHF(mol), 'weigend') mf.kernel() pt = DFMP2(mf) emp2, t2 = pt.kernel() print(emp2 - -0.203986171133) pt.with_df = df.DF(mol) pt.with_df.auxbasis = df.make_auxbasis(mol, mp2fit=True) emp2, t2 = pt.kernel() print(emp2 - -0.203738031827) pt.frozen = 2 emp2, t2 = pt.kernel() print(emp2 - -0.14433975122418313)
# future use, specify the filename in the attribute mf.with_df._cderi_to_save # mf = scf.RHF(mol).density_fit() mf.with_df._cderi_to_save = 'saved_cderi.h5' mf.kernel() # # To load the precomputed CD tensors in another calculation. # See also example/df/40-precompute_df_integrals.py # # mf = scf.RHF(mol).density_fit() # mf.with_df._cderi = '/path/to/saved/tensor/file' # mf.kernel() # # _cderi can be generated in the DF object without the DF-SCF calculations # mydf = df.DF(mol) mydf.auxbasis = df.make_auxbasis(mol) mydf._cderi_to_save = 'saved_cderi.h5' mydf.build() # # DF integral tensor can also be generated through the call to cholesky_eri # function # cderi = df.incore.cholesky_eri(mol, auxbasis='weigend') df.outcore.cholesky_eri(mol, 'saved_cderi.h5', dataname='j3c', auxbasis=df.make_auxbasis(mol))
from pyscf import gto, scf, df # # If auxbasis is not specified, default optimal auxiliary basis (if possible) # or even-tempered gaussian functions will be generated as auxbasis # mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis={'N1':'ccpvdz', 'N2':'tzp'}) mf = scf.RHF(mol).density_fit() mf.kernel() print('Default auxbasis', mf.with_df.auxmol.basis) # # The default basis is generated in the function df.make_auxbasis. It returns # a basis dict for the DF auxiliary basis. In the real calculations, you can # first generate the default basis then make modification. # auxbasis = df.make_auxbasis(mol) print(mf.with_df.auxmol.basis == auxbasis) auxbasis['N2'] = 'ccpvdz jkfit' mf = scf.RHF(mol).density_fit(auxbasis=auxbasis) mf.kernel() # # Input with key argument auxbasis='xxx' in .density_fit function # This auxbasis will be used for all elements in the system. # mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis='ccpvdz') mf = scf.RHF(mol).density_fit(auxbasis='weigend') mf.kernel() # # The DF basis can be assigned to with_df.auxbasis attribute.
from pyscf import gto, scf, df # # If auxbasis is not specified, default optimal auxiliary basis (if possible) # or even-tempered gaussian functions will be generated as auxbasis # mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis={'N1': 'ccpvdz', 'N2': 'tzp'}) mf = scf.RHF(mol).density_fit() mf.kernel() print('Default auxbasis', mf.with_df.auxmol.basis) # # The default basis is generated in the function df.make_auxbasis. It returns # a basis dict for the DF auxiliary basis. In the real calculations, you can # first generate the default basis then make modification. # auxbasis = df.make_auxbasis(mol) print(mf.with_df.auxmol.basis == auxbasis) auxbasis['N2'] = 'ccpvdz jkfit' mf = scf.RHF(mol).density_fit(auxbasis=auxbasis) mf.kernel() # # Input with key argument auxbasis='xxx' in .density_fit function # This auxbasis will be used for all elements in the system. # mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis='ccpvdz') mf = scf.RHF(mol).density_fit(auxbasis='weigend') mf.kernel() # # The DF basis can be assigned to with_df.auxbasis attribute.
def __init__(self, mf, frozen=None, auxbasis=None): ''' Args: mf : UHF instance frozen : number of frozen orbitals or list of frozen orbitals auxbasis : name of auxiliary basis set, otherwise determined automatically ''' if not isinstance(mf, scf.uhf.UHF): raise TypeError('Class initialization with non-UHF object') # UHF quantities are stored as numpy arrays self.mo_coeff = np.array(mf.mo_coeff) self.mo_energy = np.array(mf.mo_energy) self.nocc = np.array( [np.count_nonzero(mf.mo_occ[0]), np.count_nonzero(mf.mo_occ[1])]) # UHF MO coefficient matrix shape: (2, number of AOs, number of MOs) self.nmo = self.mo_coeff.shape[2] self.e_scf = mf.e_tot self._scf = mf # Process the frozen core option correctly as either an integer or two lists (alpha, beta). # self.frozen_mask sets a flag for each orbital if it is frozen (True) or not (False). # Only occupied orbitals can be frozen. self.frozen_mask = np.zeros((2, self.nmo), dtype=bool) if frozen is None: pass elif lib.isinteger(frozen): if frozen > min(self.nocc): raise ValueError('only occupied orbitals can be frozen') self.frozen_mask[:, :frozen] = True else: try: if len(frozen) != 2: raise ValueError for s in 0, 1: if not lib.isintsequence(frozen[s]): raise TypeError except (TypeError, ValueError): raise TypeError( 'frozen must be an integer or two integer lists') if len(frozen[0]) != len(frozen[1]): raise ValueError('frozen orbital lists not of equal length') for s in 0, 1: self.frozen_mask[s, frozen[s]] = True # mask for occupied orbitals that are not frozen self.occ_mask = np.zeros((2, self.nmo), dtype=bool) for s in 0, 1: self.occ_mask[s, :self.nocc[s]] = True self.occ_mask[self.frozen_mask] = False self.mol = mf.mol if not auxbasis: auxbasis = df.make_auxbasis(self.mol, mp2fit=True) self.auxmol = df.make_auxmol(self.mol, auxbasis) self.verbose = self.mol.verbose self.stdout = self.mol.stdout self.max_memory = self.mol.max_memory # _intsfile will be a list with two elements for the alpha and beta integrals self._intsfile = [] self.e_corr = None # Spin component scaling factors self.ps = 1.0 self.pt = 1.0 self.cphf_max_cycle = 100 self.cphf_tol = mf.conv_tol