def _ready_file(self, hf, config, git_revision, start_time): # generate HDF5 file and write important metadata hf.attrs["outfile-version"] = _aux.OUTPUT_VERSION hf.attrs["code-version"] = _aux.CODE_VERSION if git_revision is not None: hf.attrs["git-revision"] = git_revision hf.attrs["run-date"] = time.strftime("%c", start_time) # write configureation of current run hfgrp = hf.create_group(".config") for key, val in _flat_items(config): if val is None: continue hfgrp.attrs[key.lower()] = val # write environment of current run hfgrp = hf.create_group(".environment") for k, v in os.environ.iteritems(): if v is None: continue hfgrp.attrs[k] = v # write metadata for possible axes objects ax = hf.create_group(".axes") beta = config["General"]["beta"] qcfg = config["QMC"] ax.create_dataset("iw", data=_tf.matfreq(beta, "fermi", 2 * qcfg["Niw"])) ax.create_dataset("tau", data=np.linspace(0, beta, qcfg["Ntau"])) ax.create_dataset("tauf", data=np.linspace(0, beta, qcfg["Nftau"])) ax.create_dataset("taubin", data=_tf.tau_bins(beta, qcfg["Ntau"], 'centre')) ax.create_dataset("tausus", data=np.linspace(0, beta, qcfg["Ntau"] + 1)) ax.create_dataset("tau-g4", data=_tf.tau_bins(beta, qcfg["N4tau"], 'centre')) ax.create_dataset("iwb-g4", data=_tf.matfreq(beta, 'bose', 2 * qcfg["N4iwb"] + 1)) ax.create_dataset("iwf-g4", data=_tf.matfreq(beta, 'fermi', 2 * qcfg["N4iwf"])) ax.create_dataset("iwf-g2", data=_tf.matfreq(beta, 'fermi', 2 * (qcfg["N4iwf"] + qcfg["N4iwb"]))) ax.create_dataset("iwb-p2", data=_tf.matfreq(beta, 'bose', 2 * qcfg["N2iwb"] + 1)) ax.create_dataset("iwf-p3", data=_tf.matfreq(beta, 'fermi', 2 * qcfg["N3iwf"])) ax.create_dataset("iwb-p3", data=_tf.matfreq(beta, 'bose', 2 * qcfg["N3iwf"] + 1)) # create group for quantity metadata self._qtty_meta = hf.create_group(".quantities") # create start iteration hiter = hf.create_group("start") hiter.attrs["desc"] = "DMFT initial data" hf.flush() return hiter
log("Generating list of atoms ...") latt_type = cfg["General"]["DOS"] norbitals = mylattice.norbitals nspins = mylattice.nspins atom_list = config.atomlist_from_cfg(cfg, norbitals) epseq = cfg["General"]["EPSEQ"] equiv = atoms.check_equivalence( None, atom_list, lambda at1, at2: (at1.nd == at2.nd and at1.typ == at2.typ and at1.se_shift == at2.se_shift and interaction.similar(at1.dd_int, at2.dd_int, epseq))) log("Equivalence before G0 check: %s", equiv) # Compute G0 beta = cfg["General"]["beta"] iwf = tf.matfreq(beta, 'fermi', niw) paramag = cfg["General"]["magnetism"] == "para" eqmaxfreq = cfg["General"]["eqmaxfreq"] eqslice = slice(iwf.searchsorted(0), iwf.searchsorted(eqmaxfreq) + 1) siw_zero = np.zeros((iwf.size, mylattice.norbitals, mylattice.nspins, mylattice.norbitals, mylattice.nspins), complex) log("Checking equivalence of d-d blocks (checking %d frequencies) ...", eqslice.stop - eqslice.start) chk_lattice = mylattice if use_mpi: chk_lattice = mpi.MPILattice(chk_lattice) glociw_eq = chk_lattice.gloc(iwf[eqslice], mylattice.mu, siw_zero[eqslice]) equiv = atoms.check_equivalence( equiv, atom_list, lambda at1, at2: np.allclose(
def __init__(self, beta, lattice, ineq_list, niwf, nftau, dc_dp, dc_dp_orbitals, GW, GW_KAverage, natoms, dc=None, udd_full=None, udp_full=None, upp_full=None, paramag=False, siw_mixer=None, mu_mixer=None, mpi_comm=None): if beta < 0: raise ValueError("beta must be positive") if niwf <= 0 or niwf % 2 != 0: raise ValueError("niwf must be even") if nftau <= 1: raise ValueError("nftau must be greater than 1") if dc is None: dc = doublecounting.Zero() if siw_mixer is None: siw_mixer = mixing.FlatMixingDecorator(mixing.LinearMixer()) if mu_mixer is None: mu_mixer = mixing.LinearMixer() self.mpi_comm = mpi_comm self.beta = beta self.lattice = lattice self.ineq_list = ineq_list self.dc = dc self.udd_full = udd_full self.udp_full = udp_full self.upp_full = upp_full self.paramag = paramag if self.udp_full is None or upp_full is None: self.use_hartree = False else: self.use_hartree = udp_full.any() or upp_full.any() self.siw_mixer = siw_mixer self.mu_mixer = mu_mixer self._eye = lattice.eye self.niwf = niwf self.iwf = tf.matfreq(beta, 'fermi', niwf) if self.mpi_comm is not None: self.mpi_strategy = FrequencyDistribution(mpi_comm, self.niwf) self.my_slice = self.mpi_strategy.myslice else: self.my_slice = slice(None) self.my_iwf = self.iwf[self.my_slice] self.my_niwf = self.iwf.size self.nftau = nftau # build transformation yourself since it potentially only contains part # of the frequency axis self.tauf = np.arange(nftau) * self.beta / (nftau - 1.0) # Fixing d-p distance self.dc_dp = dc_dp self.dc_dp_orbitals = dc_dp_orbitals self.dc_dp_shift = None # GW Inclusion self.use_gw = GW self.use_gw_kaverage = GW_KAverage if self.use_gw == 1: try: dummy_try = self.lattice.nkpoints except: print( '********* GW MODULE IS NOT AVAILABLE FOR BETHE LATTICE *********' ) print('...exiting') exit() self.gw = gw.GWInclusion(self.lattice.norbitals, natoms, self.lattice.nkpoints, self.my_niwf, self.paramag, self.use_gw_kaverage) self.siw_gw = None self.smom_gw = None self.natoms = natoms
def __init__(self, hk, beta, niw, leadsw, w_hyb, nleads, check_herm=False, deltino=1e-1): #GS:def __init__(self, hk, leadsw, w_hyb, nleads, beta, check_herm=False): #GS: set up of Hk exactly as in KspaceHamiltonian. #GS: Moments of H(k) need not to be redifined, right (Angelo)?? Check Eq. B.18 of Angelo's PhD Thesis #GS: In the moments of G0 there is however also a contribution from V (Eq. B.21), which will have to be taken into account at some point KspaceHamiltonian.__init__(self, beta, hk, check_herm=True) print("norbitals, nspins, nflavours = ", self.norbitals, self.nspins, self.nflavours) print("total # of Matsubara (positive + negative) = ", niw) # store the Delta(w) for the computation of the DOS self.leadsw = leadsw.transpose(5, 0, 1, 2, 3, 4) self.w = w_hyb self.deltino = deltino #GS: add also a check that # of k-points is really 1 (ask Angelo) #GS: we now call read_ImHyb as well as the transformation function to get leadsiw. We should then define moments from leadsiw #GSAV if nleads: #GSAV print "check: after read_ImHyb", leadsw.shape, nleads #GS: add a check that the dimension of the lead matrix is compatible with nflavours #GS: initialize self.leadsiw --> this is not optimal, as if readleads=False, then you would have no attribut leadsiw for the nano-class self.leadsiw, leadsmom = self.get_leadsiw(leadsw, w_hyb, nleads, beta, niw) self.iwleads = tr.matfreq(beta, 'fermi', niw) #GS: now transform each of these to matsubara and then fill self.leadsiw in #GS: leadsiw = tr.transform(tr.wre2mat(beta, w_hyb-hk[0,0,0,0,0].real, 'fermi', 800), leadsw) # <-- this is needed if ImDelta(w) is symmetric #GS!!!!!! leadsiw = tr.transform(tr.wre2mat(beta, w_hyb, 'fermi', niw), leadsw) #wre2mat wants the total # of Matsubara, positive + negative #GS: leadsiw = tr.wre2mat_quad(beta, w_hyb, leadsw, 'fermi', 2) # replace 10 with a parameter and don't forget to add hk (or hk.mean?) #GS: In order to use it as argument for the function transform, the frequency must be the last argument: #GS!!!!!! leadsiw = leadsiw.transpose(5, 0, 1, 2, 3, 4) # w, lead, band, spin, band, spin print("leadsiw -> ", self.leadsiw.shape) #GS: add hk[0:...] to the real part of leadsiw # leadsiw.real += hk[0,...].real #adding a (band, spin, band, spin) array to a (w, lead, band, spin, band, spin) one #GS:!!!!! leadsiw.real += hk.mean(0).real #here I am less sure about the right indices, but it seems to work. Ask Markus! #GS: add a check that the imaginary part of hk is zero..... #GS: leadsiw needs to be put in the right form, if spin_orbit=false #GS:!!!!! if not self.spinorbit: #GS: self.leadsiw = np.zeros_like(leadsiw) # in case of spin-independent Hamiltonians, we copy twice to the diagonal #GS:!!!!! self.leadsiw[:, :, :, :1, :, :1] = leadsiw #GS:!!!!! self.leadsiw[:, :, :, 1:2, :, 1:2] = leadsiw #GS:!!!!! else: #GS:!!!!! self.leadsiw=leadsiw #GS:!!!!else: #GS:!!!!! self.leadsiw = 0 # set "non-interacting moments": those from H(k) *and* from leadsiw self.hloc = self.hk.mean(0) self.hmom2 = np.einsum( "kasbt,kbtcu->ascu", self.hk, self.hk) / self.nkpoints - self.hloc**2 + leadsmom.sum(1) print("LMOM") print(leadsmom.sum(1))