def test_remove_lindep(self): mol = gto.M(verbose = 0, atom = [('H', 0, 0, i*.5) for i in range(4)], basis = ('sto-3g',[[0, [.002,1]]])) mf = addons.remove_linear_dep_(scf.RHF(mol), threshold=1e-8, lindep=1e-9).run() self.assertAlmostEqual(mf.e_tot, -1.6291001503057689, 7)
def run_kcell(cell, nk): abs_kpts = cell.make_kpts(nk, wrap_around=True) kmf = pbcscf.KRHF(cell, abs_kpts) kmf = remove_linear_dep_(kmf, threshold=1e-5, lindep=1e-6) kmf.conv_tol = 1e-12 ekpt = kmf.scf() mp = pyscf.pbc.mp.kmp2.KMP2(kmf).run() return ekpt, mp.e_corr
def test_from_pyscf_lindep(self): atom = gto.M(atom='Ne 0 0 0', basis='aug-ccpvtz', verbose=0) from pyscf.scf.addons import remove_linear_dep_ mf = scf.RHF(atom) remove_linear_dep_(mf, 0.1, 0.1) mf.chkfile = 'scf.chk' energy = mf.kernel() X = get_ortho_ao_mol(atom.intor('int1e_ovlp_sph'), 0.1) with h5py.File('scf.chk', 'r+') as fh5: fh5['scf/orthoAORot'] = X self.assertAlmostEqual(energy, -128.11089429105502) write_qmcpack('scf.chk', 'afqmc.h5', 1e-8, wfn_file='afqmc.h5', dense=True, real_chol=True, ortho_ao=True) etot, e1b, e2b = calculate_hf_energy('afqmc.h5', 'afqmc.h5') self.assertAlmostEqual(etot, -128.11089429105502)
def run_scf(chkfile): from pyscf import gto, scf from pyscf.scf.addons import remove_linear_dep_ mol = gto.M(atom="H 0 0 0; H 0 0 1.4", basis="ccecpccpvdz", ecp="ccecp", unit="bohr") mf = scf.RHF(mol) mf.chkfile = chkfile mf = remove_linear_dep_(mf) energy = mf.kernel()
def test_221(self): cell1 = cell.copy() cell1.basis = 'gth-dzv' cell1.build() nk = [2, 2, 1] abs_kpts = cell1.make_kpts(nk, wrap_around=True) kmf = pbcscf.KRHF(cell1, abs_kpts) kmf = remove_linear_dep_(kmf, threshold=1e-4, lindep=1e-6) ekpt = kmf.scf() mp = pyscf.pbc.mp.kmp2.KMP2(kmf).run() self.assertAlmostEqual(ekpt, -10.835614361742607, 8) self.assertAlmostEqual(mp.e_corr, -0.1522294774708119, 8)
def multislater(kind=0, nk=(1, 1, 1)): L = 3 mol = gto.Cell( atom="""H {0} {0} {0} H {1} {1} {1}""".format(0.0, L / 2), basis="cc-pvtz", spin=0, unit="bohr", ) mol.exp_to_discard = 0.1 mol.build(a=np.eye(3) * L) kpts = mol.make_kpts(nk) mf = scf.UKS(mol, (0, 0, 0)) mf.xc = "pbe" mf = multigrid(mf) mf = remove_linear_dep_(mf) mf.chkfile = "h_bcc.chkfile" mf = mf.run() runtest(mol, mf, kind=kind, do_mc=True)
for s in [0,1]: dm[s,p,p]=1 #Control the 3d occupancy for CrO... if (el=='Cr'): for i,d in enumerate(TM_3d_orbitals): #These are the 3d orbitals we want to fill to get the correct symmetry if ( ('xy' in aos[d]) or ('yz' in aos[d]) or ('z^2' in aos[d]) or ('x2-y2' in aos[d]) ): print('We are singly filling this d-orbital: '+np.str(aos[d]) ) dm[0,d,d]=1 m.chkfile=el+basis+"_r"+str(r)+"_s"+str(S[run])+"_"+method+"_"+str(run)+".chk" m.irrep_nelec = symm_dict[run] m.max_cycle=100 m = addons.remove_linear_dep_(m) m.conv_tol=1e-6 #Only need an initial guess for CrO and CuO... if (el=='Cr' or el=='Cu'): total_energy=m.kernel(dm) else: total_energy=m.kernel() #Compute the Mulliken orbital occupancies... m.analyze() assert(np.sum(m.mo_occ)==25) #Once we get past the vdz basis, just read-in the existing chk file... else: ##############################################################################################
deltax = eigvec[1:, idx] / eigvec[0, idx] return deltax if __name__ == '__main__': from pyscf import gto, scf, mcscf, fci, lo, ci, cc, lib from pyscf.scf import ROHF, ROKS, UHF, UKS, addons chkfile = '../ub3lyp_full/Cuvtz_r1.725_s1_UB3LYP_0.chk' mol = lib.chkfile.load_mol(chkfile) mol.verbose = 4 mf = UKS(mol) mf.__dict__.update(lib.chkfile.load(chkfile, 'scf')) mf.xc = 'B3LYP' mf.max_cycle = 100 mf = addons.remove_linear_dep_(mf) mf.conv_tol = 1e-5 mf.diis = scf.ADIIS() #3dpi - 2ppi constraint ''' id0 = list(mol.search_ao_label('Cu 3dyz')) + list(mol.search_ao_label('Cu 3dxz')) id1 = mol.search_ao_label('Cu 4s') orbital_indices = [[id0[0],id0[0]],[id1[0],id1[0]]] spin_labels = [[0,1],[0,1]] nelec_required = [1.,0.3] mf.chkfile = 'Cuvtz_r1.725_s1_UB3LYP_0c.chk' mf.irrep_nelec = {'A1':(5,5),'E1x':(3,3),'E1y':(3,2),'E2x':(1,1),'E2y':(1,1)} ''' #3dz2 - 2ppi