diff --git a/source/module_esolver/esolver_ks_lcao_elec.cpp b/source/module_esolver/esolver_ks_lcao_elec.cpp index 92b3d8c308..87a5d11973 100644 --- a/source/module_esolver/esolver_ks_lcao_elec.cpp +++ b/source/module_esolver/esolver_ks_lcao_elec.cpp @@ -568,7 +568,6 @@ namespace ModuleESolver toWannier90 myWannier(this->kv.nkstot, GlobalC::ucell.G, this->LOWF.wfc_k_grid); myWannier.init_wannier_lcao(this->GridT, this->pelec->ekb, - this->pw_rho, this->pw_wfc, this->pw_big, this->sf, diff --git a/source/module_io/to_wannier90.cpp b/source/module_io/to_wannier90.cpp index 510ddbe05d..f05d15c536 100644 --- a/source/module_io/to_wannier90.cpp +++ b/source/module_io/to_wannier90.cpp @@ -65,7 +65,7 @@ void toWannier90::init_wannier_pw(const ModuleBase::matrix& ekb, writeUNK(wfcpw, *psi, bigpw); outEIG(ekb); - cal_Mmn(*psi, rhopw, wfcpw); + cal_Mmn(*psi, wfcpw); cal_Amn(*psi, wfcpw); /* @@ -93,7 +93,6 @@ void toWannier90::init_wannier_pw(const ModuleBase::matrix& ekb, #ifdef __LCAO void toWannier90::init_wannier_lcao(const Grid_Technique& gt, const ModuleBase::matrix& ekb, - const ModulePW::PW_Basis* rhopw, const ModulePW::PW_Basis_K* wfcpw, const ModulePW::PW_Basis_Big* bigpw, const Structure_Factor& sf, @@ -118,7 +117,7 @@ void toWannier90::init_wannier_lcao(const Grid_Technique& gt, getUnkFromLcao(wfcpw, sf, kv, wfcpw->npwk_max); cal_Amn(this->unk_inLcao[0], wfcpw); - cal_Mmn(this->unk_inLcao[0], rhopw, wfcpw); + cal_Mmn(this->unk_inLcao[0], wfcpw); writeUNK(wfcpw, this->unk_inLcao[0], bigpw); outEIG(ekb); } @@ -699,7 +698,6 @@ void toWannier90::cal_Amn(const psi::Psi>& psi_pw, const Mo } void toWannier90::cal_Mmn(const psi::Psi>& psi_pw, - const ModulePW::PW_Basis* rhopw, const ModulePW::PW_Basis_K* wfcpw) { // test by jingan @@ -775,7 +773,7 @@ void toWannier90::cal_Mmn(const psi::Psi>& psi_pw, // std::complex *unk_L_r = new std::complex[wfcpw->nrxx]; // ToRealSpace(cal_ik,n,psi_pw,unk_L_r,phase_G); // mmn = unkdotb(unk_L_r,cal_ikb,m,psi_pw); - mmn = unkdotkb(rhopw, wfcpw, cal_ik, cal_ikb, n, m, phase_G, psi_pw); + mmn = unkdotkb(wfcpw, cal_ik, cal_ikb, n, m, phase_G, psi_pw); // delete[] unk_L_r; } else @@ -1622,8 +1620,7 @@ std::complex toWannier90::unkdotb(const std::complex *psir, return result; } */ -std::complex toWannier90::unkdotkb(const ModulePW::PW_Basis* rhopw, - const ModulePW::PW_Basis_K* wfcpw, +std::complex toWannier90::unkdotkb(const ModulePW::PW_Basis_K* wfcpw, const int& ik, const int& ikb, const int& iband_L, @@ -1633,13 +1630,14 @@ std::complex toWannier90::unkdotkb(const ModulePW::PW_Basis* rhopw, { // (1) set value std::complex result(0.0, 0.0); - std::complex *psir = new std::complex[wfcpw->nmaxgr]; - std::complex* phase = new std::complex[rhopw->nmaxgr]; + std::complex* psir = new std::complex[wfcpw->nmaxgr]; + std::complex* phase = new std::complex[wfcpw->nmaxgr]; + ModuleBase::GlobalFunc::ZEROS(phase, wfcpw->nmaxgr); // get the phase value in realspace - for (int ig = 0; ig < rhopw->npw; ig++) + for (int ig = 0; ig < wfcpw->npwk[ik]; ig++) { - if (rhopw->gdirect[ig] == G) // It should be used carefully. We cannot judge if two double are equal. + if (wfcpw->getgdirect(ik,ig) == G) // It should be used carefully. We cannot judge if two double are equal. { phase[ig] = std::complex(1.0, 0.0); break; @@ -1647,7 +1645,7 @@ std::complex toWannier90::unkdotkb(const ModulePW::PW_Basis* rhopw, } // (2) fft and get value - rhopw->recip2real(phase, phase); + wfcpw->recip2real(phase, phase, ik); wfcpw->recip2real(&psi_pw(ik, iband_L, 0), psir, ik); for (int ir = 0; ir < wfcpw->nrxx; ir++) @@ -1655,11 +1653,11 @@ std::complex toWannier90::unkdotkb(const ModulePW::PW_Basis* rhopw, psir[ir] *= phase[ir]; } - wfcpw->real2recip(psir, psir, ik); + wfcpw->real2recip(psir, psir, ikb); //ikb, not ik std::complex result_tem(0.0, 0.0); - for (int ig = 0; ig < psi_pw.get_ngk(ikb); ig++) + for (int ig = 0; ig npwk[ikb]; ig++) { result_tem = result_tem + conj(psir[ig]) * psi_pw(ikb, iband_R, ig); } diff --git a/source/module_io/to_wannier90.h b/source/module_io/to_wannier90.h index 0dffbcea8e..00f562ddb6 100644 --- a/source/module_io/to_wannier90.h +++ b/source/module_io/to_wannier90.h @@ -79,7 +79,6 @@ class toWannier90 #ifdef __LCAO void init_wannier_lcao(const Grid_Technique& gt, const ModuleBase::matrix& ekb, - const ModulePW::PW_Basis* rhopw, const ModulePW::PW_Basis_K* wfcpw, const ModulePW::PW_Basis_Big* bigpw, const Structure_Factor& sf, @@ -89,9 +88,7 @@ class toWannier90 void read_nnkp(const K_Vectors& kv); void outEIG(const ModuleBase::matrix& ekb); void cal_Amn(const psi::Psi>& psi_pw, const ModulePW::PW_Basis_K* wfcpw); - void cal_Mmn(const psi::Psi>& psi_pw, - const ModulePW::PW_Basis* rhopw, - const ModulePW::PW_Basis_K* wfcpw); + void cal_Mmn(const psi::Psi>& psi_pw, const ModulePW::PW_Basis_K* wfcpw); void produce_trial_in_pw(const psi::Psi>& psi_pw, const int& ik, const ModulePW::PW_Basis_K* wfcpw, @@ -115,8 +112,7 @@ class toWannier90 // void ToRealSpace(const int &ik, const int &ib, const ModuleBase::ComplexMatrix *evc, std::complex *psir, // const ModuleBase::Vector3 G); std::complex unkdotb(const std::complex *psir, const int // ikb, const int bandindex, const ModuleBase::ComplexMatrix *psi_pw); - std::complex unkdotkb(const ModulePW::PW_Basis* rhopw, - const ModulePW::PW_Basis_K* wfcpw, + std::complex unkdotkb(const ModulePW::PW_Basis_K* wfcpw, const int& ik, const int& ikb, const int& iband_L,