Пример #1
0
def lattice_from_cfg(cfg):
    latt_type = cfg["General"]["DOS"]
    beta = cfg["General"]["beta"]
    if latt_type == 'ReadIn' or latt_type == 'ReadInSO':
        has_spin_orbit = latt_type == 'ReadInSO'
        hkfile = file(cfg["General"]["HkFile"], "r")
        hk, _ = _input.read_hamiltonian(hkfile, has_spin_orbit)
        mylattice = lattice.KspaceHamiltonian(beta, hk)
    elif latt_type == 'Bethe' or latt_type == 'semicirc':
        # TODO: crystal field
        half_bw = np.array(cfg["General"]["half-bandwidth"], np.float)
        half_bw = half_bw[:, np.newaxis].repeat(2, 1)
        mylattice = lattice.Bethe(beta, half_bw)
    elif latt_type == 'nano':
    #GS:
        niw = 2*cfg["QMC"]["Niw"]
        readleads = cfg["General"]["readleads"]
        leadsfile = file(cfg["General"]["leadsfile"], "r")
        dos_deltino = cfg["General"]["dos_deltino"]
        beta = cfg["General"]["beta"]    # beta is needed for the Matsubara frequencies, in case leadsiw needs to be constructed
        hkfile = file(cfg["General"]["HkFile"], "r")
        has_spin_orbit = False
        hk, _ = _input.read_hamiltonian(hkfile, has_spin_orbit)
        norbitals = hk.shape[1]
        if readleads:
#AV:
#            leadsw, w_hyb, nleads = _input.read_ImHyb(leadsfile, norbitals,
#                                                      has_spin_orbit)
            leadsw, w_hyb, nleads = _input.read_Delta(leadsfile, norbitals,
                                                      has_spin_orbit)
        else:
            leadsw, w_hyb, nleads = None, None, 0
        mylattice = lattice.NanoLattice(hk, beta, niw, leadsw, w_hyb, nleads,
                                        deltino=dos_deltino)

    elif latt_type == 'EDcheck' or latt_type == 'readDelta':
        raise ValueError("Single-shot: use with `cthyb' instead")
    else:
        raise NotImplementedError("unknown lattice")
    return mylattice
Пример #2
0
        print >> sys.stderr, "error: quantity already present (-u to replace)"
        sys.exit(1)

    # HERE STARTS THE REAL WORK
    # Get quantities from iteration: use hf.py to find out their names.
    # "q/value" stores the mean, "q/error" stores the error, if present.
    # .value selects the whole quantity array, but you can also use
    # square brackets to select part of it.

    has_spin_orbit = cfg["General"]["DOS"] == 'ReadInSO'
    if has_spin_orbit:
        print >> sys.stderr, "Spin-Orbit Hamiltonians not supported - adapt wien2k.py"
        sys.exit()

    hkfile = file(cfg["General"]["HkFile"], "r")
    Hk, kpoints = _input.read_hamiltonian(hkfile, has_spin_orbit)
    beta = args.hf['.config'].attrs['general.beta']
    w = args.hf['.axes/iw'].value
    try:  # FIXME: this is wrong for DMFT iterations before last!
        mu_dmft = args.hf['finish/mu/value'].value
    except KeyError:
        warn("`finish/mu' not found, using iteration/mu instead")
        mu_dmft = iter['mu/value'].value
    mu_lda = args.hf['start/lda-mu/value'].value

    nat = len(cfg["Atoms"])
    nneq = len(
        [ineq for ineq in args.hf['start'].keys() if ineq[0:4] == u'ineq'])

    nw = len(w)
    Siw = np.zeros((0, 2, nw))
Пример #3
0
# imports
import numpy as np
import sys
from sys import exit, stderr as err
### here comes w2dynamics
auxdir = "/Users/andi/w2dynamics___patrik_alexander_merge___likegit/"
sys.path.insert(0, auxdir)
import optparse, re
import auxiliaries.input as io
import auxiliaries.transform as tf

### here comes the ls basis
hkfile = file("wannier90_hk_t2gbasis.dat_")
hk_ls, kpoints = io.read_hamiltonian(hkfile, spin_orbit=True)

nflav = hk_ls.shape[1] * 2
Nk = kpoints.shape[0]
hk_ls = hk_ls.reshape(Nk, nflav, nflav)
hkmean_ls = hk_ls.mean(0)

#### this would set random hermitian matrix of the form
####    (  A      B  )
####    (  B^dag  A  )     with A^dag = A and arbitrary B

#def get_rand():
#tmp = np.random.rand(nflav/2, nflav/2)*2 - np.ones((nflav/2, nflav/2))
#return tmp

#A = get_rand() + 1.0j*get_rand()
#A += np.conjugate(np.transpose(A))
##A[...] = 0
Пример #4
0
            tempiterlist = iterlist
            iterlist = []
            for iterelement in tempiterlist:
                for i in range(0, element):
                    iterlist.append(iterelement + (i, ))
    for indices in iterlist:
        for index in indices:
            writefile.write("%5i" % (index + indexshift))
            writefile.write(" ")
        writefile.write("  ")
        writefile.write(str(arr[indices]))
        writefile.write('\n')
    writefile.close()


if __name__ == "__main__":
    ### here we need to add the path to the w2dynamics main directory
    auxdir = "/home/lv70961/sever2/programs/w2dynamics/"
    sys.path.insert(0, auxdir)
    ### in order to import the functions available in input.py and interatction.py and readwrite and custom errors
    import auxiliaries.input as io
    import dmft.interaction as ia

    hfile = file("Hk_LiOsO3_SOC.dat")
    hk, kpoints = io.read_hamiltonian(hfile, spin_orbit=True)
    print(hk.shape)
    hk1, kpoints1 = read_hk_wannier("Hk_LiOsO3_SOC.dat", spin=True)
    print(hk1.shape)
    print(np.allclose(hk, hk1))
    print(np.allclose(kpoints, kpoints1))
Пример #5
0
                if prefix_arg: repeats = int(prefix_arg)
                ref = -1
                sigma = complex(arg)
            else:
                raise ValueError("invalid prefix")
            folding += [ref] * repeats
            sigmas += [sigma - 1j * options.deltino] * repeats
    except Exception, e:
        parser.error("error parsing argument %s: %s" % (arg, e))

    print "Reading spectral functions A(w) ..."
    aws, ws = read_aw_files(*aw_files)

    if options.hk_file is not None:
        print "Reading Hamiltonian H(k) ..."
        hk = read_hamiltonian(file(options.hk_file, "r"))[0]
    else:
        print "Warning: setting Hamiltonian H(k) to zero (use -H)"
        if len(args) < 1: parser.error("expecting A(w) file as argument")
        hk = np.zeros((1, len(args), len(args)))

    nbands = hk.shape[1]
    if len(folding) != nbands:
        parser.error("expected %d arguments, got %d", nbands, len(folding))

    # Build the function that is used as argument for the root finding here.
    # In principle there are four levels added in reverse order
    #   3. spopt_cache - caches previously obtained G(w), Sigma(w) (find_sigma)
    #   2. spopt_complex - assembles complex Sigma(w) from real/imaginary part
    #   1. wrapper_folding - adds redundant/non-interacting bands to Sigma(w)
    #   0. get_gw_jac - computes G(w) for some full Sigma(w)
# example:
#  ./permute_bands.py Hk.dat $(seq 1 5) $(seq 11 28) $(seq 6 10) $(seq 29 46)

import numpy as np
import auxiliaries.input as inp
import sys

args = sys.argv[1:]
try:
    hk_file_name = args.pop(0)
except IndexError:
    print >> sys.stderr, "Usage:"
    print >> sys.stderr, "   ./permute_bands.py HK_FILE BAND1 BAND2 ... BANDn"
    sys.exit(1)

Hk, kpoints = inp.read_hamiltonian(file(hk_file_name, "r"))
nbands = Hk.shape[-1]

tp = np.array(map(int, args)) - 1
if tp.size != nbands:
    raise RuntimeError("not enough bands specified")
if np.any(np.sort(tp) != np.arange(nbands)):
    raise RuntimeError("did not specify permutation")

Hk_transposed = Hk[:, tp[:, None], tp[None, :]]
k_format = "%12.5e " * kpoints.shape[-1]
ham_format = "%12.5e %12.5e  " * Hk.shape[-1]

print "%d %d %d  # Generated-by permute_bands.py" % Hk.shape
for ik, Honek in enumerate(Hk_transposed):
    print k_format % tuple(kpoints[ik])
Пример #7
0
    exit()

if solver == 'triqs':
    from triqs_cthyb import Solver, version
elif solver == 'w2dyn':
    from w2dyn_cthyb import Solver

### the readin-function from w2dyn makes spin as fastest running index,
### but for triqs we need orbial to be fastest
#hk = hk.transpose(0,2,1,4,3)

iw_mesh = MeshImFreq(beta, 'Fermion', n_iw)

### the hamiltonian
hkfile = file(hkfilename)
hk, kpoints = read_hamiltonian(hkfile, spin_orbit=True)

### the lattice properties
Nk = kpoints.shape[0]
tmp = hk.shape[1]
N_size_hk = tmp * 2
print 'hk.shape', hk.shape
print 'Nk', Nk
print 'N_size_hk', N_size_hk
hk = hk.reshape(Nk, N_size_hk, N_size_hk)

lda_orb_names = [i for i in range(0, N_size_hk)]
gf_struct_full = [("bl", lda_orb_names)]
print 'gf_struct_full', gf_struct_full
iw_vec_full = array([iw.value * np.eye(N_size_hk) for iw in iw_mesh])