コード例 #1
0
def mb_ph_ops(hlat, perturb, omega, nimp, nocc, pemb, pcore, pvirt):
    """
    external ops for part-hole Green's function
    """
    nimp_sp = nimp * 2
    nsites_sp = hlat.shape[0] * 2
    nocc_sp = nocc * 2

    # transform h into imp+bath/ext(all) basis
    pall = N.hstack([pemb, pcore, pvirt])
    hall = N.dot(pall.T, N.dot(hlat, pall))
    hall_sp = _spinify(hall)

    # t1amp in (all) basis
    t1amp_ao = make_t1amp_ao(hlat, omega, perturb, nocc)
    t1amp_all = N.dot(pall.T, N.dot(t1amp_ao, pall))
    t1amp_all_sp = _spinify(t1amp_all)

    # mb_ext_operators
    sites_imp = range(0, nimp_sp * 2)
    sites_ext = range(nimp_sp * 2, nsites_sp)

    cops = []
    dops = []

    project = False

    if project:
        li_t1amp_ext_imp = _linear_orthonormal_basis(
            t1amp_all_sp[sites_ext, :][:, sites_imp], orient='c')
        print "retained %i out of %i vectors" % (li_t1amp_ext_imp.shape[1],
                                                 len(sites_imp))

        li_t1amp_imp_ext = _linear_orthonormal_basis(
            t1amp_all_sp[sites_imp, :][:, sites_ext], orient='r')
        print "retained %i out of %i vectors" % (li_t1amp_imp_ext.shape[0],
                                                 len(sites_imp))

        for i in xrange(li_t1amp_ext_imp.shape[1]):
            cops.append(models.ContractedC(sites_ext, li_t1amp_ext_imp[:, i]))

        for i in xrange(li_t1amp_imp_ext.shape[0]):
            dops.append(models.ContractedD(sites_ext, li_t1amp_imp_ext[i, :]))
    else:
        for imp in sites_imp:
            coeff_c = t1amp_all_sp[sites_ext, imp]
            cops.append(models.ContractedC(sites_ext, coeff_c))
            coeff_d = t1amp_all_sp[imp, sites_ext]
            dops.append(models.ContractedD(sites_ext, coeff_d))

    cd_coeffs = {}
    for i in sites_ext:
        for j in sites_ext:
            if abs(t1amp_all_sp[i, j]) > 1.e-8:
                cd_coeffs[i, j] = t1amp_all_sp[i, j]
    cdop = models.ContractedCD(cd_coeffs)

    ops = {"1": models.Unit(), "c": cops, "d": dops, "cd": cdop}

    return ops
コード例 #2
0
def hubbard_imp_ext_h(h0, u, nocc, nimp, nsites):
    nsites_sp = nsites * 2
    sites_imp = range(0, 4 * nimp)
    sites_ext = range(4 * nimp, 2 * nsites)

    t_dict = {}
    for i in xrange(nsites_sp):
        for j in xrange(nsites_sp):
            if abs(h0[i, j]) > 1.e-12:
                t_dict[i, j] = h0[i, j]

    t_dict[0, 0] = 0
    t_dict[1, 1] = 0

    u_dict = {}
    u_dict[0, 1] = u

    # h in imp+ext space
    hop = models.GeneralHubbard(t_dict, u_dict)

    t_imp = {}
    for i in sites_imp:
        for j in sites_imp:
            if abs(h0[i, j]) > 1.e-12:
                t_imp[i, j] = h0[i, j]

    t_imp[0, 0] = 0
    t_imp[1, 1] = 0

    t_ext = {}
    for i in sites_ext:
        for j in sites_ext:
            if abs(h0[i, j]) > 1.e-12:
                t_ext[i, j] = h0[i, j]

    hext = models.ContractedCD(t_ext)

    himp = models.GeneralHubbard(t_imp, u_dict)

    hcs_imp = []
    hds_imp = []
    hcs_ext = []
    hds_ext = []

    for i in sites_imp:
        imp_coeffs = utils.zeros(len(sites_imp))
        imp_coeffs[i] = 1.
        hcs_imp.append(models.ContractedC(sites_imp, imp_coeffs))
        hds_imp.append(models.ContractedD(sites_imp, imp_coeffs))
        hcs_ext.append(models.ContractedC(sites_ext, h0[sites_ext, i]))
        hds_ext.append(models.ContractedD(sites_ext, h0[i, sites_ext]))

    return hop, himp, hcs_imp, hds_imp, hcs_ext, hds_ext, hext
コード例 #3
0
ファイル: run_greens.py プロジェクト: hungpham2017/LRDMET
def ph_greens():
    # main loop for general density-density (ph) response functions
    utils.dtype = N.complex128

    nimp = 1
    nimp_sp = 2 * nimp
    nocc = 10
    nsites = 20
    nsites_sp = nsites * 2
    ndim = 2
    sz = 0
    # sites numbered in order as imp+bath ... ext
    sites_imp = range(0, 2 * nimp_sp)
    sites_ext = range(2 * nimp_sp, nsites_sp)
    ncore = 2 * nocc - 2 * nimp
    cocc = range(2 * nimp_sp, 2 * nimp_sp + ncore)
    vocc = range(2 * nimp_sp + ncore, nsites_sp)

    N.set_printoptions(precision=3)

    t = -1.  # hopping
    delta = 0.0  #25 # broadening

    #    for u in [0.0,4.0,10.0]:
    for u in [0.0, 0.5, 1.0, 2.0, 4.0, 8.0]:  #,1.0,4.0,8.0]:

        # Single impurity Anderson model
        mu = 0.
        hlat, hall, hlat_sp, hall_sp, e0 = models_embed.si_anderson_imp_ext_ni_h(
            t, nocc, nimp, nsites)
        hop, himp, hcs_imp, hds_imp, hcs_ext, hds_ext, hext = models_embed.si_anderson_imp_ext_h(
            hall_sp, u, nocc, nimp, nsites)

        #        single site Hubbard in DMET basis
        #        mu=u/2
        #        hlat,hall,hlat_sp,hall_sp,e0=models_embed.hubbard_imp_ext_ni_h(t,u,nocc,nimp,nsites)
        #        hop,himp,hcs_imp,hds_imp,hcs_ext,hds_ext,hext=models_embed.hubbard_imp_ext_h(hall_sp,u,nocc,nimp,nsites)

        # g.s embedding basis
        pemb, pcore, pvirt = embed.embed(hlat, nimp, nocc)

        # perturbation operator
        perturb = utils.zeros([nsites, nsites])
        perturb[0, 0] = 1.

        p_coeffs = {}
        p_coeffs[0, 0] = 1.
        p_coeffs[1, 1] = 1.
        perturbop = models.ContractedCD(p_coeffs)

        fd = file("ph_siam.out." + str(u), "w")
        for omega in N.arange(0, 4, 0.01):

            if abs(omega - 2.0) < 0.00001:
                continue

            ops_dict = response_embed.mb_ph_ops(hlat, perturb,
                                                omega + 1j * delta, nimp, nocc,
                                                pemb, pcore, pvirt)
            configs_dict = response_embed.mb_configs(nsites, nimp, nimp_sp,
                                                     2 * nocc - nimp_sp, 0)
            neutral_ops_configs = response_embed.mb_ph_ops_configs(
                ops_dict, configs_dict)

            # basis is setup, now build matrix representations
            perturb_mat = opbasis_ni.oimp_matrix_form(perturbop,
                                                      neutral_ops_configs,
                                                      cocc, vocc)

            # h, neutral configs
            himp_mat = opbasis_ni.oimp_matrix_form(himp, neutral_ops_configs,
                                                   cocc, vocc)
            himp_ext_mat = opbasis_ni.himp_ext_matrix_form(
                hcs_imp, hds_ext, hds_imp, hcs_ext, neutral_ops_configs, cocc,
                vocc)
            hext_mat = opbasis_ni.hext_matrix_form(hext, neutral_ops_configs,
                                                   cocc, vocc, e0)

            #print 'himp_mat size: ',himp_mat.shape
            #print 'himp_mat',himp_mat[:,0]
            #print 'hext_mat size: ',hext_mat.shape
            #print 'himp_ext_mat size: ',himp_ext_mat.shape

            hmat = himp_mat + himp_ext_mat + hext_mat

            #print 'total size hmat: ',hmat.shape

            unit_mat = opbasis_ni.oimp_matrix_form(models.Unit(),
                                                   neutral_ops_configs, cocc,
                                                   vocc)

            # get neutral ground-state energy
            es, cs = la.peigh(hmat, unit_mat)
            e0 = es[0]
            psi0 = cs[:, 0]
            # all matrices setup, solve linear response (complex)
            psi1 = la.solve_perturb(omega - 1j * delta,
                                    unit_mat,
                                    hmat,
                                    e0,
                                    psi0,
                                    perturb_mat,
                                    project=True)

            ph_gf = N.dot(N.conj(psi1), N.dot(perturb_mat, psi0))

            ph_gf0 = _second_order_energy(hlat, nocc, perturb,
                                          omega + 1j * delta)

            #print 'hlat size: ',hlat.shape
            #print 'hlat: '
            #print hlat

            #print omega, ph_gf.imag,ph_gf0.imag
            print omega, ph_gf, 2 * ph_gf0
            print >> fd, omega - mu, ph_gf.imag, ph_gf0.imag, ph_gf.real, 2 * ph_gf0.real