def run_Hubbard(nsite, nocc, U, hd): h, V = get_Hubbard(nsite, U, nocc) h += np.diag(hd) lat = lattice.LATTICE(h=h, V=V, nocc=nocc) mc = fci.FCI(lat) mc.kernel(rdm_level=1) pops = np.diag(mc.rdm1[0]).copy() pairs = np.zeros_like(hd) for i in range(nsite): pairs[i] = \ fci.FCI.get_rdm_elements(nsite, nocc, [[i,i,i,i]], \ mc.ci_coeff[0])[0] return mc.e_fci[0], mc.rdm1[0], pops, pairs
# print(rho_guess) # print(Ki_guess) bogil = HFB(h, V, m, Ki=Ki_guess, rho=rho_guess) print("G_before") print(bogil.G) bogil._do_hfb(1) print("G") print(bogil.G) print("H") print(bogil.H) E = bogil.calcEnergy(bogil.G, h, bogil.H) print(E) lat = lattice.LATTICE(h=h, V=V, e_nuc=0, nocc=1) mf = scf.RHF(lat) mf.kernel() print(mf.e_tot) print(mf.fock) print(mf.rdm1) print(mf.mo_coeff) # umf = scf.UHF(h=h, V=V, e_nuc =0, nocc=1, noccb=1, opt='diis') # umf.kernel() # print(umf.e_tot) # print(umf.fock) # print(umf.rdm1) # print(umf.mo_coeff) # bogil._do_hfb()
PE = TE @ TE.T Eimp = np.sum((2*hs0 + 2*np.einsum("pqrs,rs->pq", Vs, Ps) - \ np.einsum("psrq,rs->pq", Vs, Ps)) * Ps) Eimpbath = 2 * np.sum(hs_core * Ps) Ebath = np.sum((2 * mf.h + hcore) * PE) return Eimp, Eimpbath, Ebath if __name__ == "__main__": h, V, e_nuc = get_ao_ints(parse_xyz("geom/ch4.zmat"), "sto-3g", True) nbas = h.shape[0] nocc = 5 lat = lattice.LATTICE(h=h, V=V, e_nuc=e_nuc, nocc=nocc) mf = scf.RHF(lat) mf.kernel(verbose="mute") # one-frag embedding fragsites = [0, 2] Eimp, Eimpbath, Ebath = hf_in_hf_emb(mf, fragsites) print("Ehf = % .10f" % mf.e_scf) print("Eimp = % .10f" % Eimp) print("Eimpbath = % .10f" % Eimpbath) print("Ebath = % .10f" % Ebath) print("sum = % .10f" % (Eimp + Eimpbath + Ebath)) print()
B = B @ np.diag((np.diag(B.T @ B))**-0.5) T = np.zeros([nbas, nimp * 2]) T[fragsites, :nimp] = np.eye(nimp) T[cfragsites, nimp:] = B return T, TE if __name__ == "__main__": nbas = 6 nocc = 3 np.random.seed(17) h, V = get_random_hV(nbas) lat = lattice.LATTICE(h=h, V=V, nocc=nocc) # get random dV udim = nbas * (nbas - 1) + nbas * nbas u = np.random.rand(udim) dV = get_dV(u, nbas) mf = scf.RHF(lat) mf.kernel(verbose="mute") A, B = 1, 2 h = np.random.rand(nbas, nbas) h += h.T # N -> [A, B] -> [A] T_AB, TE_AB = schmidt_decomposition_dm(mf.rdm1, [A, B]) P_AB = T_AB.T @ mf.rdm1 @ T_AB