fix: get_pchg_lcao.cpp with c^* c^T - #7821
Conversation
|
Unit Test of "get_pchg_k" fails because I haven't modified the reference file. I think we should first discuss whether the formula is correct, then decide whether to modify the reference file. |
AsTonyshment
left a comment
There was a problem hiding this comment.
Thanks for catching and fixing this issue! I originally added the LCAO multi-k partial-charge path in PR #4698 a couple of years ago (when this file was still named istate_charge.cpp); before that, the implementation only supported the Gamma point and used real-valued psi::Psi<double>, for which complex conjugation makes no difference. When extending it to the complex-valued multi-k path, I overlooked that psiMulPsiMpi uses a plain transpose and therefore requires explicit conjugation to form C^* W C^T. Your fix is correct.
Please also update tests/03_NAO_multik/get_pchg/result.ref and tests/03_NAO_multik/get_pchg_k/result.ref with the corrected results. After that, this looks good to me :)
Fix a bug in
get_pchg_lcao.cppSince
psiMulPsiMpiuses a plain transpose, the conjugate must be handled explicitly to form C^* C^T.Same treatment can be seen
source/elecstate/module_dm/cal_dm_psi.cpp:107-110. I think current code inget_pchg_lcao.cppis missed.