diff --git a/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp b/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp index c1fcb65de7..fa453baf34 100644 --- a/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp +++ b/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp @@ -119,7 +119,8 @@ void OperatorEXXPW::construct_ace() const { for (int ik0 = 0; ik0 < nk_max; ik0++) { - int ik = ik0 + ispin * nk_max; + int ik = ik0 + ispin * wfcpw->nks / nspin_fac; + // printf("ik: %d\n", ik); int npwk = wfcpw->npwk[ik]; T* Xi_ace = Xi_ace_k[ik]; @@ -146,7 +147,12 @@ void OperatorEXXPW::construct_ace() const // ik fixed here, select band n for (int iq0 = 0; iq0 < nqs; iq0++) { - int iq = iq0 + ik; + // For nspin=2, iq should be in the same spin channel as ik + int iq; + + int nk = wfcpw->nks / 2; + iq = iq0 + ispin * nk; // iq in the same spin channel + // for \psi_nk, get the pw of iq and band m get_exx_potential(kv, wfcpw, rhopw_dev, pot, tpiba, gamma_extrapolation, ucell->omega, ik, iq); @@ -157,7 +163,6 @@ void OperatorEXXPW::construct_ace() const for (int m_iband = 0; m_iband < psi.get_nbands(); m_iband++) { double wg_mqb = 0; - bool skip = false; if (iq_pool == GlobalV::MY_POOL) { wg_mqb = (*wg)(iq_loc, m_iband); diff --git a/source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp b/source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp index 20a663b245..ac71563817 100644 --- a/source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp +++ b/source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp @@ -306,6 +306,8 @@ void OperatorEXXPW::act_op_kpar(const int nbands, setmem_complex_op()(psi_nk_real, 0, wfcpw->nrxx); setmem_complex_op()(psi_mq_real, 0, wfcpw->nrxx); int nqs = kv->get_nkstot_full(); + int nspin_fac = PARAM.inp.nspin == 2 ? 2 : 1; + int ispin = this->ik < (wfcpw->nks / nspin_fac) ? 0 : 1; // ik fixed here, select band n for (int iq = 0; iq < nqs; iq++) @@ -332,7 +334,7 @@ void OperatorEXXPW::act_op_kpar(const int nbands, if (iq_pool == GlobalV::MY_POOL) { - const T* psi_mq = get_pw(m_iband, iq_loc); + const T* psi_mq = get_pw(m_iband, iq_loc + ispin * wfcpw->nks / nspin_fac); wfcpw->recip_to_real(ctx, psi_mq, psi_mq_real, iq_loc); // send }