def get_wannier(self, supercell = [1,1,1], grid = [50,50,50]): ''' Evaluate the MLWF using a periodic grid ''' grids_coor, weights = periodic_grid(self.cell, grid, supercell = [1,1,1], order = 'C') kpts = self.cell.get_abs_kpts(self.kpt_latt_loc) ao_kpts = np.asarray([numint.eval_ao(self.cell, grids_coor, kpt = kpt) for kpt in kpts]) u_mo = [] for k_id in range(self.num_kpts_loc): mo_included = self.mo_coeff_kpts[k_id][:,self.band_included_list] mo_in_window = self.lwindow[k_id] C_opt = mo_included[:,mo_in_window].dot(self.U_matrix_opt[k_id].T) C_tildle = C_opt.dot(self.U_matrix[k_id].T) kpt = kpts[k_id] ao = numint.eval_ao(self.cell, grids_coor, kpt = kpt) u_ao = np.einsum('x,xi->xi', np.exp(-1j*np.dot(grids_coor, kpt)), ao, optimize = True) u_mo.append(np.einsum('xi,in->xn', u_ao, C_tildle, optimize = True)) u_mo = np.asarray(u_mo) WF0 = libwannier90.get_WF0s(self.kpt_latt_loc.shape[0],self.kpt_latt_loc, supercell, grid, u_mo) # Fix the global phase following the pw2wannier90 procedure max_index = (WF0*WF0.conj()).real.argmax(axis=0) norm_wfs = np.diag(WF0[max_index,:]) norm_wfs = norm_wfs/np.absolute(norm_wfs) WF0 = WF0/norm_wfs/self.num_kpts_loc # Check the 'reality' following the pw2wannier90 procedure for WF_id in range(self.num_wann_loc): ratio_max = np.abs(WF0[np.abs(WF0[:,WF_id].real) >= 0.01,WF_id].imag/WF0[np.abs(WF0[:,WF_id].real) >= 0.01,WF_id].real).max(axis=0) print('The maximum imag/real for wannier function ', WF_id,' : ', ratio_max) return WF0
def get_wannier(self, supercell=[1, 1, 1], grid=[50, 50, 50]): ''' Evaluate the MLWF using a periodic grid ''' grids_coor, weights = periodic_grid(self.real_lattice_loc, grid, supercell=[1, 1, 1], order='C') kpts = self.abs_kpts band_list = np.asarray(self.band_included_list) u_mo = [] for k_id in range(self.num_kpts_loc): unk = self.wave.get_unk_list(spin=self.spin, kpt=k_id + 1, band_list=band_list + 1, ngrid=grid).reshape( len(self.band_included_list), -1).T unk = np.einsum('xn,nm,ml->xl', unk, self.U_matrix_opt[k_id].T, self.U_matrix[k_id].T) u_mo.append(unk) u_mo = np.asarray(u_mo) WF0 = libwannier90.get_WF0s(self.kpt_latt_loc.shape[0], self.kpt_latt_loc, supercell, grid, u_mo) # Fix the global phase following the pw2wannier90 procedure max_index = (WF0 * WF0.conj()).real.argmax(axis=0) norm_wfs = np.diag(WF0[max_index, :]) norm_wfs = norm_wfs / np.absolute(norm_wfs) WF0 = WF0 / norm_wfs / self.num_kpts_loc # Check the 'reality' following the pw2wannier90 procedure for WF_id in range(self.num_wann_loc): ratio_max = np.abs( WF0[np.abs(WF0[:, WF_id].real) >= 0.01, WF_id].imag / WF0[np.abs(WF0[:, WF_id].real) >= 0.01, WF_id].real).max( axis=0) print('The maximum imag/real for wannier function ', WF_id, ' : ', ratio_max) return WF0