Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions source/module_elecstate/elecstate_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ void ElecStateLCAO<std::complex<double>>::psiToRho(const psi::Psi<std::complex<d

if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
ModuleBase::GlobalFunc::ZEROS(this->charge->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);
}
Expand Down Expand Up @@ -222,7 +225,7 @@ void ElecStateLCAO<double>::psiToRho(const psi::Psi<double>& 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);
Expand Down
25 changes: 18 additions & 7 deletions source/module_elecstate/module_charge/charge_mixing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
}
}
}

Expand Down