Fix: Fix ELF for kpar > 1#7307
Open
sunliang98 wants to merge 4 commits intodeepmodeling:developfrom
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes incorrect ELF output when running with kpar > 1 by preventing an unintended second reduction of rho during tau/ELF preparation, and instead reducing only kin_r across k-point/band pools.
Changes:
- Added
Charge::kin_r_mpi()to MPI-reduce onlykin_racross k-point/band parallel pools. - Updated
ElecStatePW::cal_tau()to callkin_r_mpi()instead of the broaderparallelK()/rho_mpi()path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
source/source_estate/module_charge/charge_mpi.cpp |
Adds Charge::kin_r_mpi() to reduce only kinetic energy density (kin_r) across pools. |
source/source_estate/module_charge/charge.h |
Declares the new kin_r_mpi() API on Charge. |
source/source_estate/elecstate_pw_cal_tau.cpp |
Switches cal_tau() to reduce only kin_r, avoiding re-reducing rho. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reminder
Linked Issue
Fix #7305
Unit Tests and/or Case Tests for my changes
What's changed?
Problem$|\nabla \sqrt{\rho}|^2$ , this led to incorrect ELF.
When running with
kpar > 1, ELF output was incorrect. The root cause was thatcal_tau()calledrho_mpi()again, which re‑reducedrhoacross k‑point pools and effectively scaled the density bykpar. Sincetau_vwdepends onFix
Added
Charge::kin_r_mpi()to reduce onlykin_racrosskpar/bndpar, and updatedElecStatePW::cal_tau()to call this new function. This avoids re‑reducingrhowhile keepingkin_rproperly reduced.Validation

ELF outputs computed with the updated code are consistent for
kpar=1/4.Any changes of core modules? (ignore if not applicable)