Exemplo n.º 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 = open(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':
        half_bw = np.array(cfg["General"]["half-bandwidth"], np.float)
        half_bw = half_bw[:, np.newaxis].repeat(2, 1)

        # set "crystal field" terms
        centers = np.zeros_like(half_bw)
        start = 0
        for atom_cfg in cfg["Atoms"].values():
            norb = atom_cfg["Nd"] + atom_cfg["Np"]
            if atom_cfg["crystalfield"] is not None:
                centers_atom = np.array(atom_cfg["crystalfield"], float)
                centers[start:start + norb, :] = centers_atom[:, None]
            start += norb

        mylattice = lattice.Bethe(beta, half_bw, centers)
    elif latt_type == 'nano':
        #GS:
        niw = 2 * cfg["QMC"]["Niw"]
        readleads = cfg["General"]["readleads"]
        leadsfile = open(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 = open(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
Exemplo n.º 2
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 as 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)
Exemplo n.º 3
0
# example:
#  ./permute_bands.py Hk.dat $(seq 1 5) $(seq 11 28) $(seq 6 10) $(seq 29 46)

import numpy as np
import w2dyn.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])
Exemplo n.º 4
0
        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("Spin-Orbit Hamiltonians not supported - adapt wien2k.py",
              file=sys.stderr)
        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))