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))
with h5py.File("GPARAMBANDS.h5", "r") as f: num_elec = f['/nelectron'][0] ismear = f["/ismear"][0] delta = f["/delta"][0] kpts = f["/kpoints"][()] comm = MPI.COMM_WORLD rank = comm.Get_rank() if rank == 0: print("num of electrons = {}".format(num_elec)) gmodel = get_gmodel() #kpts = gmodel.k_uniform_mesh((6, 6, 6)) nk = len(kpts) wklist = [1. / nk for k in kpts] bnd_es, bnd_vs = mpiget_bndev(kpts, gmodel, mode="risb") if rank == 0: bnd_es2 = get_risb_bndes() for ik in range(nk): if numpy.max(numpy.abs(bnd_es2[0][ik] - bnd_es[0][ik])) > 1.e-6: print(ik) print(bnd_es2[0][ik]) print(bnd_es[0][ik]) efermi = get_fermi_level(bnd_es, wklist, num_elec, delta=delta, ismear=ismear) print("lda fermi level = {}".format(efermi))