Skip to content

Fix: DFT+U force&stress with orbital_corr of some elements are -1 #6049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ void DFTU<OperatorLCAO<TK, TR>>::cal_force_stress(const bool cal_force,
{
force.zero_out();
}
// calculate atom_index for adjs_all, induced by omp parallel
int atom_index = 0;
std::vector<int> atom_index_all(this->ucell->nat, -1);
for (int iat0 = 0; iat0 < this->ucell->nat; iat0++)
{
int T0=0;
int I0=0;
ucell->iat2iait(iat0, &I0, &T0);
if(this->dftu->orbital_corr[T0] == -1)
{
continue;
}
atom_index_all[iat0] = atom_index;
atom_index++;
}

// 1. calculate <psi|beta> for each pair of atoms
// loop over all on-site atoms
Expand All @@ -62,7 +77,7 @@ void DFTU<OperatorLCAO<TK, TR>>::cal_force_stress(const bool cal_force,
continue;
}
const int tlp1 = 2 * target_L + 1;
AdjacentAtomInfo& adjs = this->adjs_all[iat0];
AdjacentAtomInfo& adjs = this->adjs_all[atom_index_all[iat0]];

std::vector<std::unordered_map<int, std::vector<double>>> nlm_tot;
nlm_tot.resize(adjs.adj_num + 1);
Expand Down
Loading