diff --git a/source/module_elecstate/elecstate_lcao.cpp b/source/module_elecstate/elecstate_lcao.cpp index d93fa3bee1..09927617bd 100644 --- a/source/module_elecstate/elecstate_lcao.cpp +++ b/source/module_elecstate/elecstate_lcao.cpp @@ -150,7 +150,10 @@ void ElecStateLCAO>::psiToRho(const psi::Psicharge->kin_r[0], this->charge->nrxx); + for (int is = 0; is < GlobalV::NSPIN; is++) + { + ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx); + } Gint_inout inout1(this->loc->DM_R, this->charge->kin_r, Gint_Tools::job_type::tau); this->uhm->GK.cal_gint(&inout1); } @@ -222,7 +225,7 @@ void ElecStateLCAO::psiToRho(const psi::Psi& psi) { for (int is = 0; is < GlobalV::NSPIN; is++) { - ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[0], this->charge->nrxx); + ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx); } Gint_inout inout1(this->loc->DM, this->charge->kin_r, Gint_Tools::job_type::tau); this->uhm->GG.cal_gint(&inout1); diff --git a/source/module_elecstate/module_charge/charge_mixing.cpp b/source/module_elecstate/module_charge/charge_mixing.cpp index 1d2029465d..251b81280a 100755 --- a/source/module_elecstate/module_charge/charge_mixing.cpp +++ b/source/module_elecstate/module_charge/charge_mixing.cpp @@ -89,6 +89,7 @@ void Charge_Mixing::set_mixing(const std::string& mixing_mode_in, #endif // Note: we can not init tau_mdata here temporarily, since set_xc_type() is after it. + // you can find initalize tau_mdata in mix_reset(); // this->mixing->init_mixing_data(this->tau_mdata, this->rhopw->nrxx * GlobalV::NSPIN, sizeof(double)); return; } @@ -463,6 +464,7 @@ void Charge_Mixing::mix_reset() { this->mixing->reset(); this->rho_mdata.reset(); + // initailize tau_mdata if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) { if (GlobalV::SCF_THR_TYPE == 1) @@ -476,8 +478,9 @@ void Charge_Mixing::mix_reset() this->mixing->init_mixing_data(this->tau_mdata, this->rhopw->nrxx * GlobalV::NSPIN, sizeof(double)); } } + // reset for paw #ifdef USE_PAW - if(GlobalV::use_paw) this->mixing->init_mixing_data(this->nhat_mdata, this->rhopw->nrxx * GlobalV::NSPIN, sizeof(double)); + this->nhat_mdata.reset(); #endif } @@ -507,12 +510,16 @@ void Charge_Mixing::mix_rho(Charge* chr) if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) { kin_r123.resize(GlobalV::NSPIN * nrxx); + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + double* kin_r123_is = kin_r123.data() + is * nrxx; #ifdef _OPENMP #pragma omp parallel for schedule(static, 512) #endif - for(int ir = 0 ; ir < GlobalV::NSPIN * nrxx ; ++ir) - { - kin_r123[ir] = chr->kin_r[0][ir]; + for(int ir = 0 ; ir < nrxx ; ++ir) + { + kin_r123_is[ir] = chr->kin_r[is][ir]; + } } } #ifdef USE_PAW @@ -569,12 +576,16 @@ void Charge_Mixing::mix_rho(Charge* chr) if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) { + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + double* kin_r123_is = kin_r123.data() + is * nrxx; #ifdef _OPENMP #pragma omp parallel for schedule(static, 512) #endif - for(int ir = 0 ; ir < GlobalV::NSPIN * nrxx ; ++ir) - { - chr->kin_r_save[0][ir] = kin_r123[ir]; + for(int ir = 0 ; ir < nrxx ; ++ir) + { + chr->kin_r_save[is][ir] = kin_r123_is[ir]; + } } }