#Transform 2 electron integral to MO Basis# ##--------------------------------------------------------------## if inp.integral_trans == 'incore': twoelecint_1 = np.einsum('zs,wxyz->wxys',hf_mo_coeff,v2e) twoelecint_2 = np.einsum('yr,wxys->wxrs',hf_mo_coeff,twoelecint_1) twoelecint_3 = np.einsum('xq,wxrs->wqrs',hf_mo_coeff,twoelecint_2) twoelecint_mo = np.einsum('wp,wqrs->pqrs',hf_mo_coeff,twoelecint_3) twoelecint_1 = None twoelecint_2 = None twoelecint_3 = None if inp.integral_trans == 'outcore': ao2mo.outcore.full(mol,hf_mo_coeff,'2eint.h5',aosym='s4',max_memory=8000,verbose=2) with load('2eint.h5') as twoelecint_mo: twoelecint_mo = ao2mo.restore(1,twoelecint_mo,nao) ##--------------------------------------------------------------## #Verify integrals# ##--------------------------------------------------------------## E_scf_mo_1 = 0 E_scf_mo_2 = 0 E_scf_mo_3 = 0 for i in range(0,n): E_scf_mo_1 += oneelecint_mo[i][i] for i in range(0,n): for j in range(0,n): E_scf_mo_2 += 2*twoelecint_mo[i][i][j][j] - twoelecint_mo[i][j][i][j]
return full(eri_or_mol, mo_coeffs, *args, **kwargs) else: return general(eri_or_mol, mo_coeffs, *args, **kwargs) if __name__ == '__main__': from pyscf import scf from pyscf import gto from pyscf.ao2mo import addons mol = gto.M( verbose = 0, atom = [ ["O" , (0. , 0. , 0.)], [1 , (0. , -0.757 , 0.587)], [1 , (0. , 0.757 , 0.587)]], basis = 'ccpvdz') mf = scf.RHF(mol) mf.scf() eri0 = full(mf._eri, mf.mo_coeff) mos = (mf.mo_coeff,)*4 print(numpy.allclose(eri0, full(mol, mf.mo_coeff))) print(numpy.allclose(eri0, general(mf._eri, mos))) print(numpy.allclose(eri0, general(mol, mos))) with load(full(mol, mf.mo_coeff, 'h2oeri.h5', dataname='dat1'), 'dat1') as eri1: print(numpy.allclose(eri0, eri1)) with load(general(mol, mos, 'h2oeri.h5', dataname='dat1'), 'dat1') as eri1: print(numpy.allclose(eri0, eri1))
'''2-electron integrals in AO basis''' return mol.intor('int2e', aosym='s4') get_mo_eri = general if __name__ == '__main__': from pyscf import scf from pyscf import gto from pyscf.ao2mo import addons mol = gto.M( verbose = 0, atom = [ ["O" , (0. , 0. , 0.)], [1 , (0. , -0.757 , 0.587)], [1 , (0. , 0.757 , 0.587)]], basis = 'ccpvdz') mf = scf.RHF(mol) mf.scf() eri0 = full(mf._eri, mf.mo_coeff) mos = (mf.mo_coeff,)*4 print(numpy.allclose(eri0, full(mol, mf.mo_coeff))) print(numpy.allclose(eri0, general(mf._eri, mos))) print(numpy.allclose(eri0, general(mol, mos))) with load(full(mol, mf.mo_coeff, 'h2oeri.h5', dataname='dat1'), 'dat1') as eri1: print(numpy.allclose(eri0, eri1)) with load(general(mol, mos, 'h2oeri.h5', dataname='dat1'), 'dat1') as eri1: print(numpy.allclose(eri0, eri1))