Exemplo n.º 1
0
def hf_in_hf_emb(mf, fragsites):
    mb = be.BE(mf, fragsites=fragsites)
    T = mb.T
    TE = mb.TE
    hs0 = xform_2(mf.h, T)
    hcore = xform_core(mf.V, TE)
    hs_core = xform_2(hcore, T)
    Vs = xform_4(mf.V, T)
    Ps = T.T @ mf.rdm1 @ T
    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
Exemplo n.º 2
0
def hfb_in_hfb_embedding(h_qp, V_qp, ABs, Ds):
    # form xform mat T^s = [[U^s, V^s], [V^t, U^t]]
    Ts = get_hfb_Ts(ABs)
    Renvs = [Ds[s]@Ds[s].T for s in [0, 1]]

    # Xform into Schmidt space
    hs_qp_sd, hcores_sd, Dcores_sd, Vs_qp_sd = [], [], [], []
    for s in [0, 1]:
        hcore = np.einsum("pqrs,sr->pq", V_qp, Renvs[s]+Renvs[1-s]) - \
            np.einsum("psrq,sr->pq", V_qp, Renvs[s])
        hcores_sd.append(xform_2(hcore, Ts[s]))

        Dcore = np.einsum("psqr,sr->pq", V_qp, Renvs[s])
        Dcores_sd.append(xform_2(Dcore, Ts[s]))

        hs_qp_sd.append(xform_2(h_qp, Ts[s])+hcores_sd[s]+Dcores_sd[s])
        Vs_qp_sd.append(xform_4(V_qp, Ts[s]))

        dumpMat(hs_qp_sd[s])

    for s in [0, 1]:
        Vs_qp_sd.append(xform_4(V_qp, Ts[s], Ts[1-s]))
Exemplo n.º 3
0
def energy_check_schmidt_space_quasiparticle(Eh_hf, EV_hf, EV_pr, ABs, Ds, Rs):
    nbas = ABs[0].shape[0]//2
    nimp = ABs[0].shape[1]

    # form xform mat T^s = [[U^s, V^s], [V^t, U^t]]
    Ts = get_hfb_Ts(ABs)

    # Xform into Schmidt space
    Ehs_hf_sd, EVs_hf_sd, EVs_pr_sd = [], [], []
    for s in [0, 1]:
        Ehs_hf_sd.append(xform_2(Eh_hf, Ts[s]))
        EVs_hf_sd.append(xform_4(EV_hf, Ts[s]))
        EVs_pr_sd.append(xform_4(EV_pr, Ts[s]))

    for s in [0, 1]:
        EVs_hf_sd.append(xform_4(EV_hf, Ts[s], Ts[1-s]))
        EVs_pr_sd.append(xform_4(EV_pr, Ts[s], Ts[1-s]))

    # embedding
    Rimps = [ABs[s]@ABs[s].T for s in [0, 1]]
    # for s in [0, 1]:
    #     dumpMat(Rimps[s], "Rimps[{:d}] {:.10f}".format(s, \
    #     np.trace(Rimps[s][:nbas, :nbas])))
    Rimps_sd = [xform_2(Rimps[s], Ts[s]) for s in [0, 1]]
    # for s in [0, 1]:
    #     dumpMat(Rimps_sd[s], "Rimps_sd[{:d}] {:.10f}".format(s, \
    #     np.trace(Rimps_sd[s][:nimp, :nimp])))
    Renvs = [Rs[s]-Rimps[s] for s in [0, 1]]
    hcores = [np.einsum("pqrs,sr->pq", EV_hf, Renvs[s]+Renvs[1-s])-\
        np.einsum("psrq,sr->pq", EV_hf, Renvs[s]) for s in [0, 1]]
    hcores_sd = [xform_2(np.einsum("pqrs,sr->pq", EV_hf, Renvs[s]+Renvs[1-s])-\
        np.einsum("psrq,sr->pq", EV_hf, Renvs[s]), Ts[s]) for s in [0, 1]]
    Dcores = [np.einsum("psqr,sr->pq", EV_pr, Renvs[s]) for s in [0, 1]]
    Dcores_sd = [xform_2(np.einsum("psqr,sr->pq", EV_pr, Renvs[s]), Ts[s]) \
        for s in [0, 1]]
    eimp_hf, eenv_hf, v_hf, eimp_pr, eenv_pr, v_pr = 0., 0., 0., 0., 0., 0.
    for s in [0, 1]:
        eimp_hf += np.sum(Ehs_hf_sd[s]*Rimps_sd[s]) + \
            0.5*np.sum((np.einsum("pqrs,sr->pq", EVs_hf_sd[s], Rimps_sd[s]) - \
                np.einsum("psrq,sr->pq", EVs_hf_sd[s], Rimps_sd[s]) + \
                np.einsum("pqrs,sr->pq", EVs_hf_sd[s+2], Rimps_sd[1-s])) * \
                Rimps_sd[s])
        eenv_hf += np.sum((Eh_hf+0.5*hcores[s])*Renvs[s])
        v_hf += np.sum(hcores_sd[s] * Rimps_sd[s])
        eimp_pr += \
            0.5*np.sum(np.einsum("psqr,sr->pq", EVs_pr_sd[s], Rimps_sd[s]) * \
            Rimps_sd[s])
        eenv_pr += 0.5*np.sum(Dcores[s]*Renvs[s])
        v_pr += np.sum(Dcores_sd[s] * Rimps_sd[s])
    print("  ### HF (Schmidt Basis) ###")
    print("E(imp)     = % .10f" % eimp_hf)
    print("E(env)     = % .10f" % eenv_hf)
    print("V(imp-env) = % .10f" % v_hf)
    print("Sum        = % .10f" % (eimp_hf+eenv_hf+v_hf))
    print()

    print("  ### Pair (Schmidt Basis) ###")
    print("E(imp)     = % .10f" % eimp_pr)
    print("E(env)     = % .10f" % eenv_pr)
    print("V(imp-env) = % .10f" % v_pr)
    print("Sum        = % .10f" % (eimp_pr+eenv_pr+v_pr))
    print()