Skip to content

Conversation

@A-006
Copy link
Collaborator

@A-006 A-006 commented Jan 5, 2026

Description

Fixes an overcounting bug in the local pseudopotential energy (E_local_pp) when using k-point parallelization (kpar > 1).

Problem

When kpar > 1, the real-space charge density and local pseudopotential are:

  • Distributed within each k-point pool (i.e., across processes in the same pool),
  • But duplicated across different k-point pools.

The previous implementation used Parallel_Reduce::reduce_all to sum E_local_pp, which aggregates values from all MPI processes across all pools. This caused the local pseudopotential energy to be overcounted by a factor of kpar, leading to incorrect total energies in both KS-DFT and OF-DFT calculations.

Solution

Replaced Parallel_Reduce::reduce_all with Parallel_Reduce::reduce_pool in:

  • source/elecstate/elecstate_energy_terms.cpp (KS-DFT)
  • source/esolver/esolver_of.cpp (OF-DFT)

reduce_pool performs reduction only within the current k-point pool communicator—where the real-space grid data is uniquely partitioned—ensuring the energy is summed exactly once.

@A-006 A-006 marked this pull request as draft January 5, 2026 03:55
@A-006 A-006 marked this pull request as ready for review January 5, 2026 05:29
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes labels Jan 5, 2026
@mohanchen mohanchen merged commit 06751a0 into deepmodeling:develop Jan 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants