Example #1
0
def getInfoForDensityCalculation(h5, it):
    p = share_fun.load_parms(h5, it);
    corr_id = getCorrIndex(p);
    dmft_id = getDMFTCorrIndex(p);
    N_LAYERS = int(p['N_LAYERS']); FLAVORS = int(p['FLAVORS']); SPINS = int(p['SPINS']); 
    NORB = int(p['NORB']); NCOR = int(p['NCOR']);
    se = h5['SolverData/selfenergy_asymp_coeffs'][:];
    se = se[se[:,0] == it][0, 1:].reshape(SPINS,2,-1);
    mu = float(p['MU']);
    Gcoefs = h5['SolverData/AvgDispersion'][:, 0, :] - mu;
    Gcoefs[:, corr_id] += se[:, 0, :];
    ret = dict({
        'G_asymp_coefs' : Gcoefs,
        'correction'    : zeros(SPINS)
        });
    ret1 = dict({
        'G_asymp_coefs' : Gcoefs[:,corr_id],
        'correction'    : zeros(SPINS)
        });

    if float(p['U']) != 0 and it > 0:
        approx_dens = fun.getDensityFromGmat(h5['ImpurityGreen/'+str(it)][:], float(p['BETA']), ret1);
        try: correct_dens = -h5['SolverData/Gtau/%d'%it][:, -1, :];
        except: correct_dens = None;
        if correct_dens is None: d = 0;
        else:
            d = zeros((SPINS, NCOR));
            for L in range(N_LAYERS): d[:, dmft_id] = correct_dens[:, dmft_id] - approx_dens[:, dmft_id];
    else: d = 0;
    ret['correction'] = zeros((SPINS, NORB));
#    ret['correction'][:, corr_id] = d; # correction not needed
    return ret;
Example #2
0
def get_self_energy_hdf5(h5, nparms, nwn):
    NCOR = int(nparms['NCOR']); SPINS = int(nparms['SPINS']);
    oit = h5['iter'][0];
    oparms  = load_parms(h5, oit);
    try: MU  = float(str(h5['parms/%d/MU'%(oit+1)][...]));
    except: MU  = float(str(h5['parms/%d/MU'%oit][...]));
    eMU = MU - h5['StaticCoulomb/%d'%oit][:];
    ose = h5['SelfEnergy/%d'%oit][:];
    own = (2*arange(size(ose, 1))+1)*pi/float(oparms['BETA']);
    oSPINS = int(oparms['SPINS']);
    assert NCOR == int(oparms['NCOR']);
    otail = h5['SolverData/selfenergy_asymp_coeffs'][-1, 1:].reshape(oSPINS, 2, -1);
    return extrapolate_self_energy(own, ose, otail, nwn, SPINS)
Example #3
0
def getDensity(h5, it = None):
    if it is None: it = h5['iter'][0];
    parms    = load_parms(h5, it);
    N_LAYERS = int(parms['N_LAYERS']);
    SPINS    = int(parms['SPINS']);
    NCOR     = int(parms['NCOR']);
    U        = float(parms['U']);
    n_f = h5['log_density'][0 if it == 0 else it-1, 4:].reshape(SPINS, -1)[:, :NCOR];
    if U != 0 and it > 0:
        if int(val_def(parms, 'FIXED_HARTREE', 0)) > 0:
            n_f = h5['log_density'][0, 4:].reshape(SPINS, -1)[:, :NCOR];
        dmft_id = system.getDMFTCorrIndex(parms);
        gtau = h5['SolverData/Gtau/'+str(it)][:]
        n_f[:, dmft_id]  = -gtau[:, -1, dmft_id];
    return n_f;
Example #4
0
def smooth_selfenergy(it, h5, SelfEnergy, nf):
    parms = load_parms(h5, it);
    N_LAYERS = int(parms['N_LAYERS']); FLAVORS = int(parms['FLAVORS']); 
    SPINS = size(nf, 0);   # this SPINS may be different from parms['SPINS']
    NCOR = int(parms['NCOR']);

    # calculate asymptotic coeffs and smooth
    se_coefs = zeros((SPINS, 2, NCOR), dtype = float);
    for L in range(N_LAYERS): 
        st='SolverData/Observables/%d/L%d'%(it, L);
        try: nn = h5[st+'/nn'][:];
        except: nn = None;
        se_coefs[:, :, L::N_LAYERS] = get_asymp_selfenergy(parms, nf[:, L::N_LAYERS], nn);
    if int(val_def(parms, 'USE_SELFENERGY_TAIL', 0)) > 0:
        minorder = 0
        se_coefs = None

        for L in range(N_LAYERS): 
            st='SolverData/Observables/%d/L%d'%(it, L);
            se_tail = h5[st+'/SelfEnergyTail'][:]
            minorder = se_tail[0, 0]
            maxorder = se_tail[-1, 0]
            se_tail = se_tail[1:-1]
            if se_coefs is None: se_coefs = zeros((SPINS, maxorder-minorder+1, NCOR))
            for n in range(len(se_tail)):
                tail = se_tail[n].reshape(-1, 2)
                if SPINS == 1: tail = [mean(tail, 1)]
                for s in range(SPINS): 
                    se_coefs[s, n, L::N_LAYERS] = tail[s]
    elif int(parms.get('FIT_SELFENERGY_TAIL', 1)) > 0:
        n_max_freq = int(parms['N_MAX_FREQ'])
        n_cutoff = int(parms['N_CUTOFF'])
        n_fit_stop = n_cutoff + 5
        n_fit_start = n_cutoff - 5
        wn = (2*arange(n_max_freq)+1)*pi/float(parms['BETA'])
        for f in range(NCOR):
            for s in range(SPINS):
                x_fit = wn[n_fit_start:n_fit_stop]
                y_fit = x_fit*SelfEnergy[s, n_fit_start:n_fit_stop, f].imag
                p = polyfit(x_fit, y_fit, 0)
                se_coefs[s, 1, f] = -p[0]
    log_data(h5['SolverData'], 'selfenergy_asymp_coeffs', it, se_coefs.flatten(), data_type = float);
    list_NCutoff = ones((SPINS, NCOR), dtype = int)*int(parms['N_CUTOFF']);
    ind = SelfEnergy.imag > 0;
    SelfEnergy[ind] = real(SelfEnergy[ind]);
    return smooth(SelfEnergy, se_coefs, int(parms['N_MAX_FREQ']), float(parms['BETA']), list_NCutoff, minorder = 0);
Example #5
0
def getSpectraFromSelfEnergy(h5, se_filename, rham, rotmat, numk = None, setail_filename = None, it = 0):
    
    # prepare data
    w, se_refreq = ProcessSelfEnergy(se_filename, emin = -5, emax = 5, NFreq = 500);

    it = h5['iter'][0] - it;
    parms = load_parms(h5, it);
    print 'work on iteration ', it;
    if rham is not None: print 'new path for rham file is: ', rham; parms['RHAM'] = rham;
    if rotmat is not None: print 'new path for rot_mat file is ', rotmat; parms['ROT_MAT'] = rotmat;
    BETA = float(parms['BETA']);
    N_LAYERS = int(parms['N_LAYERS']);
    FLAVORS  = int(parms['FLAVORS']);
    SPINS = int(parms['SPINS']);
    NORB  = int(parms['NORB']);
    dmft_id = system.getDMFTCorrIndex(parms, all = False);
    dmft_id_len = len(dmft_id);

    # get the se tails
    tmp = h5['SolverData/selfenergy_asymp_coeffs'][:];
    se_tail = tmp[tmp[:,0] == it, 1:].reshape(SPINS, 2, -1)[:, :, ::N_LAYERS];
    if setail_filename is not None:
        print 'use the tail from external source: ', setail_filename;
        tmp = genfromtxt(setail_filename);
        se_tail[:, :, dmft_id] = array([tmp[:, s::SPINS] for s in range(SPINS)]); 
    print se_tail;

    # restore SelfEnergy
    se = zeros((SPINS, len(se_refreq), N_LAYERS*FLAVORS), dtype = complex);
    for s in range(SPINS):
        for f in range(N_LAYERS*FLAVORS):
            if f/N_LAYERS not in dmft_id: se[s,:,f] = se_tail[s, 0, f/N_LAYERS];
            else: 
                f1 = nonzero(f/N_LAYERS == dmft_id)[0][0];
                se[s, :, f] = se_refreq[:, SPINS*f1+s]*se_tail[s, 1, f/N_LAYERS] + se_tail[s, 0, f/N_LAYERS]; 

    # tight binding Hamiltonian
    if 'RHAM' in parms: 
        HR, R = getHamiltonian(parms['RHAM'], 4);
        if parms['DTYPE'] == '3bands': FLAVORS = 3;
        extra = { 'HR' : HR, 'R': R };

    # rotation matrix
    if int(val_def(parms, 'FORCE_DIAGONAL', 0)) > 0:
        print 'FORCE_DIAGONAL is used';
        ind = nonzero(sum(R**2, 1)==0)[0][0];
        H0 = HR[ind];
    else: H0 = None;
    rot_mat = getRotationMatrix(N_LAYERS, FLAVORS, val_def(parms, 'ROT_MAT', None), H0);


    # prepare for k-integrate
    parms['NUMK'] = 16 if numk is None else numk;
    bp, wf = grule(int(parms['NUMK']));
    broadening = 0.01;
    extra.update({
            'GaussianData' : [bp, wf],
            'rot_mat'      : rot_mat
            });
    delta = float(parms['DELTA']);
    mu    = float(parms['MU']);

    # running
    print 'generating interacting DOS with parameters'
    for k, v in parms.iteritems(): print '%s = %s'%(k, v);

    Gr = averageGreen(delta, mu, w+1j*broadening, se, parms, float(parms['ND']), float(parms['DENSITY']), 0, extra)[1];
    if SPINS == 1: savetxt(parms['ID']+'.idos', c_[w, -1/pi*Gr[0].imag], fmt = '%g');
    elif SPINS == 2:
        savetxt(parms['ID']+'_up.idos', c_[w, -1/pi*Gr[0].imag], fmt = '%g'); 
        savetxt(parms['ID']+'_dn.idos', c_[w, -1/pi*Gr[1].imag], fmt = '%g'); 
    
    # calculate original G(iwn), only consider one "LAYERS"
    Giwn_orig = h5['ImpurityGreen/%d'%it][:,:,::N_LAYERS];
    NMatsubara = size(Giwn_orig, 1);
    wn = (2*arange(NMatsubara) + 1)*pi/BETA;
    Giwn = zeros((NMatsubara, 2*FLAVORS*SPINS), dtype = float); # 2 for real and imag
    for f in range(FLAVORS):
        for s in range(SPINS):
            Giwn[:, 2*(SPINS*f+s)] = Giwn_orig[s, :, f].real;
            Giwn[:, 2*(SPINS*f+s)+1] = Giwn_orig[s, :, f].imag;
    savetxt(parms['ID']+'.gmat', c_[wn, Giwn]);

    # calculate G(iwn) for reference, only consider one "LAYERS"
    NMatsubara = 200;
    wn = (2*arange(NMatsubara) + 1)*pi/BETA;
    Giwn = zeros((NMatsubara, 2*FLAVORS*SPINS), dtype = float); # 2 for real and imag
    for f in range(FLAVORS):
        for s in range(SPINS):
            A = -1/pi * Gr[s, :, f*N_LAYERS].imag;
            for n in range(NMatsubara):
                tck_re = splrep(w, real(A / (1j*wn[n] - w)));
                tck_im = splrep(w, imag(A / (1j*wn[n] - w)));
                Giwn[n, 2*(SPINS*f+s)] = splint(w[0], w[-1], tck_re);
                Giwn[n, 2*(SPINS*f+s)+1] = splint(w[0], w[-1], tck_im);
    savetxt(parms['ID']+'.gmat.ref', c_[wn, Giwn]);