Exemple #1
0
    def get_leadsiw(self, leadsw, w_hyb, nleads, beta, niw):
        norb = self.norbitals
        nsp = self.nspins
        if nleads:
            leadsiw = np.zeros((niw, nleads, norb, nsp, norb, nsp),
                               dtype=complex)
            #wre2mat wants the total # of Matsubara, positive + negative
            # we pass the hybridization spectral density to the transformation
            leadtrf = tr.transform(tr.wre2mat(beta, w_hyb, 'fermi', niw),
                                   -leadsw.imag / np.pi)
            leadtrf = leadtrf.transpose(
                5, 0, 1, 2, 3, 4)  # iw_n, lead, band, spin, band, spin
            if not self.spinorbit:
                #GS:            self.leadsiw = np.zeros_like(leadsiw)
                # in case of spin-independent Hamiltonians, we copy twice to the diagonal
                leadsiw[:, :, :, :1, :, :1] = leadtrf
                leadsiw[:, :, :, 1:2, :, 1:2] = leadtrf
            else:
                leadsiw = leadtrf
#           leadsiw.real += self.hk[0,...].real   #adding a (band, spin, band, spin) array to a (w, lead, band, spin, band, spin) one
#GS:!!!!!!  leadsiw.real += self.hk.mean(0).real  #here I am less sure about the right indices, but it seems to work. Ask Markus!
            leadsmom = tr.transform(tr.wre_int(beta, w_hyb),
                                    -leadsw.imag / np.pi)
            print("leadsmom = ", leadsmom.shape)
            leadsmom = leadsmom.transpose(5, 0, 1, 2, 3, 4)
#           print "leadsmom = ", leadsmom
        else:
            leadsiw = np.zeros((niw, 1, norb, nsp, norb, nsp), dtype=complex)
            leadsmom = np.zeros((1, norb, nsp, norb, nsp))
        return leadsiw, leadsmom
Exemple #2
0
    def get_giw(cls, config, problem, result):
        #typ = "legendre"  # FIXME: QMC config does not contain FTtype
        typ = config["General"]["FTType"]
        if config["QMC"]["offdiag"] == 1 and typ == "legendre":
            typ = "legendre_full"
        if typ == "none":
            giw = -result["giw-meas"]
        elif typ == "none_worm":
            giw = result["giw-worm"]
            giw = orbspin.extract_diagonal(giw.transpose(4,0,1,2,3)) \
                         .transpose(1,2,0)
        elif typ == "plain":
            ntau = config["QMC"]["Ntau"]
            tf_matrix = tf.tau2mat(problem.beta, ntau, 'fermi', problem.niw)
            giw = tf.transform(tf_matrix, result["gtau"], None)
        elif typ == "legendre":
            nleg = config["QMC"]["NLegOrder"]
            tf_matrix = -tf.leg2mat(nleg, problem.niw)
            giw = tf.transform(tf_matrix,
                               result["gleg"],
                               None,
                               onmismatch=tf.Truncate.tofirst,
                               warn=False)
        elif typ == "legendre_full":
            nleg = config["QMC"]["NLegOrder"]
            tf_matrix = -tf.leg2mat(nleg, problem.niw)
            nbands = result["gleg-full"].shape[0]
            giw = np.zeros(shape=(nbands, 2, nbands, 2, problem.niw),
                           dtype=complex)

            for b in range(0, nbands):
                for s in range(0, 2):
                    giw[b, s, :, :, :] = tf.transform(
                        tf_matrix,
                        result["gleg-full"][b, s, :, :, :],
                        None,
                        onmismatch=tf.Truncate.tofirst,
                        warn=False)

                    #### the old one
                    #tmp = tf.transform(tf_matrix, result["gleg-full"][b,s,:,:,:], None,
                    #onmismatch=tf.Truncate.tofirst, warn=False)
                    #for b2 in range(0,nbands):
                    #for s2 in range(0,2):
                    #for w in range(0,problem.niw):
                    #print "w", w
                    #giw[b,s,b2,s2,w] = tmp[b2,s2,w]

            giw = giw.reshape(nbands * 2, nbands * 2, problem.niw)

            giw_new = np.zeros_like(giw, dtype=complex)
            for i in range(0, problem.niw):
                tmp = giw[:, :, i]
                giw_new[:, :, i] = 0.5 * (tmp.transpose(1, 0) + tmp)

            giw = giw_new

        else:
            raise RuntimeError("Invalid transform type: `%s'" % typ)

        return giw  # copy not necessary here.
Exemple #3
0
    # Use hard legendre order cut-off    
    if options.maxorder:
        print >> err, "Hard cut of %d coefficients" % (gleg.shape[-1]-options.maxorder-1)
        gleg = gleg[...,:options.maxorder+1]
        gleg_error = gleg_error[...,:options.maxorder+1]
    
    # Use soft sigma cut-off
    if options.threshold:
        noisy = np.abs(gleg)/gleg_error < options.threshold
        print >> err, "Number of cut noisy coefficients:", 
        print >> err, ", ".join(map(str, np.sum(noisy, -1).flat))
        gleg[noisy] = 0.

    iw = 1j * hf["axes/iw"].value
        
    gliw, gliw_error = tf.transform(-tf.leg2mat(gleg.shape[-1], iw.size), 
                                    gleg, gleg_error)
    
    grp = iter.create_group("giw-smooth")
    grp.attrs["desc"] = "Smoothened Green's function from Legendre" 
    grp.attrs["axes"] = ["ineq", "band", "spin", "iw"]
    grp.create_dataset("value", data=gliw)
    grp.create_dataset("error", data=gliw_error)
    
    # Now, compute G0(iw) in order to find the self energy
    fiw = iter["fiw/value"].value 
    
    if "mu-imp" in iter:
        g0iw_inv = iw - iter["mu-imp/value"][...,np.newaxis] - fiw[::-1]
    else:
        g0iw_inv = iw + iter["mu/value"] - fiw[::-1]
        
Exemple #4
0
        # Checks for old run
        if not ineq_name.startswith("ineq-"):
            continue

        ineq_node = iter_node[ineq_name]

        if "gloctau" in ineq_node:  # replace with your quantity name
            print("WARNING: overriding")
            del ineq_node["gloctau"]

        gtau_mean = ineq_node["gtau/value"].value
        gtau_error = ineq_node["gtau/error"].value
        glociw = ineq_node["gloc/value"].value

        mat2tau_matrix = tf.mat2tau(beta, 'fermi', glociw.shape[-1], taus)
        gloctau = -tf.transform(mat2tau_matrix, glociw - 1 / iw) + .5

        num_dbands = gtau_mean.shape[0]
        d_part = slice(None, num_dbands)
        p_part = slice(num_dbands, None)
        if not np.allclose(gloctau.imag, 0):
            raise RuntimeError("Gloctau is not real????")
        if not np.allclose(gloctau[d_part], gtau_mean):
            print("WARNING: d-part of G(tau) does not match with impurity")

        gloctau = gloctau.real
        gloctau_err = np.empty_like(gloctau)
        gloctau_err[d_part] = gtau_error
        gloctau_err[p_part] = gloctau_err[d_part].mean(0)[None]

        gloctau_group = ineq_node.create_group("gloctau")