Skip to content

fix: get_pchg_lcao.cpp with c^* c^T - #7821

Open
Fisherd99 wants to merge 1 commit into
deepmodeling:developfrom
Fisherd99:develop
Open

fix: get_pchg_lcao.cpp with c^* c^T#7821
Fisherd99 wants to merge 1 commit into
deepmodeling:developfrom
Fisherd99:develop

Conversation

@Fisherd99

Copy link
Copy Markdown

Fix a bug in get_pchg_lcao.cpp

Since psiMulPsiMpi uses 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 in get_pchg_lcao.cpp is missed.

@Fisherd99 Fisherd99 changed the title fix pchg with c^* c^T fix: get_pchg_lcao.cpp with c^* c^T Aug 14, 2026
@Fisherd99

Copy link
Copy Markdown
Author

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 AsTonyshment left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants