Skip to content

Commit 6ddad71

Browse files
committed
MPI final: operator outside chain + rank-0 contributeHk
DeltaPOperator created but NOT added to ops chain (avoids chain traversal crash on non-root MPI ranks with distributed k-points). HK correction applied from iter_finish on rank 0 only. NP=1: full constraint works NP=2: measurement works, constraint pending HK path fix
1 parent baea4a8 commit 6ddad71

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,19 @@ void ESolver_KS_LCAO<TK, TR>::deltap_update_lambda(UnitCell& ucell, const int it
14111411
std::unordered_map<int, std::vector<std::complex<double>>> hk_corr;
14121412
dp->compute_hk_correction(ucell, psi, lambda, hk_corr);
14131413
dp_op->set_hk_correction(hk_corr);
1414+
1415+
// Apply HK correction on rank 0 only (operator not in chain for MPI)
1416+
#ifdef __MPI
1417+
if (this->pv.comm() != MPI_COMM_NULL) {
1418+
int rank = 0;
1419+
MPI_Comm_rank(this->pv.comm(), &rank);
1420+
if (rank == 0)
1421+
#endif
1422+
for (int ik = 0; ik < this->kv.get_nks(); ++ik)
1423+
dp_op->contributeHk(ik);
1424+
#ifdef __MPI
1425+
}
1426+
#endif
14141427
}
14151428
}
14161429

0 commit comments

Comments
 (0)