diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dftu_lcao.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dftu_lcao.cpp old mode 100755 new mode 100644 index 3d940ba66d..7e89c63d1b --- a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dftu_lcao.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dftu_lcao.cpp @@ -47,9 +47,6 @@ void hamilt::DFTU>::initialize_HR(Grid_Driver* Grid ModuleBase::TITLE("DFTU", "initialize_HR"); ModuleBase::timer::tick("DFTU", "initialize_HR"); - auto* paraV = this->hR->get_paraV();// get parallel orbitals from HR - // TODO: if paraV is nullptr, AtomPair can not use paraV for constructor, I will repair it in the future. - this->adjs_all.clear(); this->adjs_all.reserve(this->ucell->nat); for (int iat0 = 0; iat0 < ucell->nat; iat0++) @@ -58,8 +55,9 @@ void hamilt::DFTU>::initialize_HR(Grid_Driver* Grid int T0, I0; ucell->iat2iait(iat0, &I0, &T0); const int target_L = this->dftu->orbital_corr[T0]; - if (target_L == -1) + if (target_L == -1) { continue; +} AdjacentAtomInfo adjs; GridD->Find_atom(*ucell, tau0, T0, I0, &adjs); @@ -92,8 +90,9 @@ template void hamilt::DFTU>::cal_nlm_all(const Parallel_Orbitals* paraV) { ModuleBase::TITLE("DFTU", "cal_nlm_all"); - if (this->precal_nlm_done) + if (this->precal_nlm_done) { return; +} ModuleBase::timer::tick("DFTU", "cal_nlm_all"); nlm_tot.resize(this->ucell->nat); const int npol = this->ucell->get_npol(); @@ -104,8 +103,9 @@ void hamilt::DFTU>::cal_nlm_all(const Parallel_Orbi int T0, I0; ucell->iat2iait(iat0, &I0, &T0); const int target_L = this->dftu->orbital_corr[T0]; - if (target_L == -1) + if (target_L == -1) { continue; +} const int tlp1 = 2 * target_L + 1; AdjacentAtomInfo& adjs = this->adjs_all[atom_index++]; @@ -144,7 +144,7 @@ void hamilt::DFTU>::cal_nlm_all(const Parallel_Orbi const int M1 = (m1 % 2 == 0) ? -m1 / 2 : (m1 + 1) / 2; ModuleBase::Vector3 dtau = tau0 - tau1; - intor_->snap(T1, L1, N1, M1, T0, dtau * this->ucell->lat0, 0 /*cal_deri*/, nlm); + intor_->snap(T1, L1, N1, M1, T0, dtau * this->ucell->lat0, false /*cal_deri*/, nlm); // select the elements of nlm with target_L for (int iw = 0; iw < this->ucell->atoms[T0].nw; iw++) { @@ -178,8 +178,9 @@ void hamilt::DFTU>::contributeHR() else { // will update this->dftu->locale and this->dftu->EU - if (this->current_spin == 0) + if (this->current_spin == 0) { this->dftu->EU = 0.0; +} } ModuleBase::timer::tick("DFTU", "contributeHR"); @@ -196,8 +197,9 @@ void hamilt::DFTU>::contributeHR() int T0, I0; ucell->iat2iait(iat0, &I0, &T0); const int target_L = this->dftu->orbital_corr[T0]; - if (target_L == -1) + if (target_L == -1) { continue; +} const int tlp1 = 2 * target_L + 1; AdjacentAtomInfo& adjs = this->adjs_all[atom_index++]; @@ -241,8 +243,9 @@ void hamilt::DFTU>::contributeHR() // save occ to dftu for (int i = 0; i < occ.size(); i++) { - if (this->nspin == 1) + if (this->nspin == 1) { occ[i] *= 0.5; +} this->dftu->locale[iat0][target_L][0][this->current_spin].c[i] = occ[i]; } } @@ -297,17 +300,20 @@ void hamilt::DFTU>::contributeHR() } // energy correction for NSPIN=1 - if (this->nspin == 1) + if (this->nspin == 1) { this->dftu->EU *= 2.0; +} // for readin onsite_dm, set initialed_locale to false to avoid using readin locale in next iteration - if (this->current_spin == this->nspin - 1 || this->nspin == 4) + if (this->current_spin == this->nspin - 1 || this->nspin == 4) { this->dftu->initialed_locale = false; +} // update this->current_spin: only nspin=2 iterate change it between 0 and 1 // the key point is only nspin=2 calculate spin-up and spin-down separately, // and won't calculate spin-up twice without spin-down - if (this->nspin == 2) + if (this->nspin == 2) { this->current_spin = 1 - this->current_spin; +} ModuleBase::timer::tick("DFTU", "contributeHR"); } @@ -488,7 +494,7 @@ void hamilt::DFTU>::cal_v_of_u(const std::vector>::cal_v_of_u(const std::vector