diff --git a/source/module_io/restart_exx_csr.hpp b/source/module_io/restart_exx_csr.hpp index 441ed24002..8d6401c6c4 100644 --- a/source/module_io/restart_exx_csr.hpp +++ b/source/module_io/restart_exx_csr.hpp @@ -40,9 +40,11 @@ namespace ModuleIO const SparseMatrix& matrix = csr.getMatrix(iR); for (auto& ijv : matrix.getElements()) { - const int& i = ijv.first.first; - const int& j = ijv.first.second; - Hexxs.at(is).at(ucell.iwt2iat[i]).at({ ucell.iwt2iat[j], { R[0], R[1], R[2] } })(ucell.iwt2iw[i], ucell.iwt2iw[j]) = ijv.second; + const int& npol = GlobalV::NPOL; + // GlobalV::NPOL has no counterpart in PARAM.inp + const int& i = ijv.first.first * npol; + const int& j = ijv.first.second * npol;s + Hexxs.at(is).at(ucell.iwt2iat[i]).at({ ucell.iwt2iat[j], { R[0], R[1], R[2] } })(ucell.iwt2iw[i] / npol, ucell.iwt2iw[j] / npol) = ijv.second; } } } @@ -64,8 +66,8 @@ namespace ModuleIO int iat2 = a2R_data.first.first; int nw1 = ucell.atoms[ucell.iat2it[iat1]].nw; int nw2 = ucell.atoms[ucell.iat2it[iat2]].nw; - int start1 = ucell.atoms[ucell.iat2it[iat1]].stapos_wf + ucell.iat2ia[iat1] * nw1; - int start2 = ucell.atoms[ucell.iat2it[iat2]].stapos_wf + ucell.iat2ia[iat2] * nw2; + int start1 = ucell.atoms[ucell.iat2it[iat1]].stapos_wf / GlobalV::NPOL + ucell.iat2ia[iat1] * nw1; + int start2 = ucell.atoms[ucell.iat2it[iat2]].stapos_wf / GlobalV::NPOL + ucell.iat2ia[iat2] * nw2; const TC& R = a2R_data.first.second; auto& matrix = a2R_data.second; @@ -73,8 +75,8 @@ namespace ModuleIO for (int i = 0;i < nw1;++i) { for (int j = 0;j < nw2;++j) { target[dR][start1 + i][start2 + j] = ((std::abs(matrix(i, j)) > sparse_threshold) ? matrix(i, j) : static_cast(0)); -} -} + } + } } } return target;