Skip to content

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

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
Fisherd99:develop
Aug 18, 2026
Merged

fix: get_pchg_lcao.cpp with c^* c^T#7821
mohanchen merged 2 commits 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 :)

@Fisherd99

Copy link
Copy Markdown
Author

OK. I've updated the two reference files. Furthermore, I think LTS branch should also need this fix.

@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Aug 18, 2026
@mohanchen

Copy link
Copy Markdown
Collaborator

You can also propose a PR to LTS

@mohanchen
mohanchen merged commit 4cf51c6 into deepmodeling:develop Aug 18, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants