def wannier_den_matrix_lda_chk3(wannier_path="./"): '''produce the file `wannier_den_matrix.dat` for the feedback from g-risb to dft. ''' _, _, kpts, include_bands, wfwannier_list, bnd_es = mpiget_wannier_data( path=wannier_path) nktot = len(kpts) with h5py.File("GPARAMBANDS.h5", "r") as f: num_elec = f["/nelectron"][0] # set wk_list wklist = [1. / nktot for i in range(bnd_es.shape[1])] # get eigen-vector from interpolation bnd_es2 = [[]] bnd_ev2 = [[]] for ik in range(nktot): hk = wfwannier_list[0][ik].T.conj().dot(np.diag(bnd_es[0][ik])).dot( wfwannier_list[0][ik]) w, v = np.linalg.eigh(hk) bnd_es2[0].append(w) bnd_ev2[0].append(v) bnd_ev2 = np.asarray(bnd_ev2) with h5py.File("ev_lda_ref.h5", "w") as f: f["e"] = bnd_es2 f["v"] = bnd_ev2 efermi = get_fermi_level(bnd_es2, wklist, num_elec, ismear=-1) # set fermi weight ferwes = get_fermi_weight(efermi, bnd_es2, wklist, ismear=-1) # setup trivial wannier_den data. wan_den = [[]] for ik in range(nktot): dm = np.diag(ferwes[0][ik] * nktot / (2 + 0.j)) wan_den[0].append(bnd_ev2[0][ik].dot(dm).dot(bnd_ev2[0][ik].T.conj())) wan_den = np.asarray(wan_den) fwrt_wan_den(wan_den, wfwannier_list, include_bands)
def wannier_den_matrix_lda_chk(wannier_path="./"): '''produce the file `wannier_den_matrix.dat` for the feedback from g-risb to dft. ''' _, _, kpts, include_bands, _, bnd_es = mpiget_wannier_data( path=wannier_path) nktot = len(kpts) with h5py.File("GPARAMBANDS.h5", "r") as f: num_elec = f["/nelectron"][0] # chop bnd_es nbnd = bnd_es.shape[2] nwan = int(num_elec / 2 + 3) bnd_es = bnd_es[:, :, :nwan] # set wk_list wklist = [1. / nktot for i in range(bnd_es.shape[1])] efermi = get_fermi_level(bnd_es, wklist, num_elec, ismear=-1) # set fermi weight ferwes = get_fermi_weight(efermi, bnd_es, wklist, ismear=-1) # setup trivial wannier_den data. wan_den = [[]] wfwannier_list = [[]] vmat = np.zeros((nbnd, nwan), dtype=np.complex) np.fill_diagonal(vmat, 1.0) for ik in range(nktot): wfwannier_list[-1].append(vmat) wan_den[0].append(np.diag(ferwes[0][ik] * nktot / (2 + 0.j))) wan_den = np.asarray(wan_den) wfwannier_list = np.asarray(wfwannier_list) fwrt_wan_den(wan_den, wfwannier_list, include_bands)
def wannier_den_matrix_lda_chk2(wannier_path="./"): '''produce the file `wannier_den_matrix.dat` for the feedback from g-risb to dft. ''' _, _, kpts, include_bands, wfwannier_list, bnd_es = mpiget_wannier_data( path=wannier_path) nktot = len(kpts) with h5py.File("GPARAMBANDS.h5", "r") as f: num_elec = f["/nelectron"][0] # set wk_list wklist = [1. / nktot for i in range(bnd_es.shape[1])] efermi = get_fermi_level(bnd_es, wklist, num_elec, ismear=-1) # set fermi weight ferwes = get_fermi_weight(efermi, bnd_es, wklist, ismear=-1) # setup trivial wannier_den data. wan_den = [[]] for ik in range(nktot): dm = np.diag(ferwes[0][ik] * nktot / (2 + 0.j)) wan_den[0].append(wfwannier_list[0][ik].T.conj().dot(dm).dot( wfwannier_list[0][ik])) wan_den = np.asarray(wan_den) wrt_wan_den(wan_den, wfwannier_list, include_bands, fwannier="{}/wannier.dat".format(wannier_path))
def wannier_den_matrix(wannier_path="./"): '''produce the file `wannier_den_matrix.dat` for the feedback from g-risb to dft. ''' _, _, kpts, include_bands, wfwannier_list, bnd_es_in = \ mpiget_wannier_data(path=wannier_path) bnd_es, bnd_vs = mpiget_bndev(kpts, wfwannier_list=wfwannier_list, bnd_es_in=bnd_es_in, mode="risb") nktot = len(kpts) with h5py.File("GPARAMBANDS.h5", "r") as f: delta = f["/delta"][0] ismear = f["/ismear"][0] iso = f["/iso"][0] num_elec = f["/nelectron"][0] comm = MPI.COMM_WORLD rank = comm.Get_rank() # set wk_list wklist = [1. / nktot for i in range(bnd_es.shape[1])] if rank == 0: efermi = get_fermi_level(bnd_es, wklist, num_elec, delta=delta, \ ismear=ismear, iso=iso) else: efermi = None efermi = comm.bcast(efermi, root=0) ncpu = comm.Get_size() nk_cpu = nktot // ncpu if nk_cpu * ncpu < nktot: nk_cpu += 1 # reduce bnd_es to local part only if rank == 0: bnd_es = bnd_es[:nk_cpu] wklist = wklist[:nk_cpu] # set fermi weight ferwes = get_fermi_weight(efermi, bnd_es, wklist, delta=delta, ismear=ismear, iso=iso) # calculate wannier_den_matrix wan_den = get_wannier_den_matrix_risb(bnd_vs, ferwes, wklist, nktot) if rank == 0: wrt_wan_den(wan_den, wfwannier_list, include_bands, fwannier="{}/wannier.dat".format(wannier_path))
import h5py, glob, numpy from pyglib.estructure.fermi import get_fermi_level from pyglib.iface.ifwannier import get_risb_bndes with h5py.File("GPARAMBANDS.h5", "r") as f: num_elec = f['/nelectron'][0] ismear = f["/ismear"][0] delta = f["/delta"][0] print("num of electrons = {}".format(num_elec)) bnd_es = get_risb_bndes() nk = bnd_es.shape[1] wklist = [1. / nk for k in range(nk)] print(bnd_es[0][0]) with h5py.File("gband_es.h5", "w") as f: f["/gbnd_es"] = bnd_es efermi = get_fermi_level(bnd_es, wklist, num_elec, delta=delta, ismear=ismear) print("lda fermi level = {}".format(efermi))