Skip to content

Fix: Fix several bugs in KEDF get_energy functions - #7169

Merged
mohanchen merged 5 commits into
deepmodeling:developfrom
sunliang98:fix_ofdft
Mar 29, 2026
Merged

Fix: Fix several bugs in KEDF get_energy functions#7169
mohanchen merged 5 commits into
deepmodeling:developfrom
sunliang98:fix_ofdft

Conversation

@sunliang98

Copy link
Copy Markdown
Collaborator

Reminder

  • Have you linked an issue with this pull request?
  • Have you added adequate unit tests and/or case tests for your pull request?
  • Have you noticed possible changes of behavior below or in the linked issue?
  • Have you explained the changes of codes in core modules of ESolver, HSolver, ElecState, Hamilt, Operator or Psi? (ignore if not applicable)

Linked Issue

Fix #...

Unit Tests and/or Case Tests for my changes

  • A unit test is added for each new feature or bug fix.

What's changed?

These functions are currently unused, but this PR corrects the issues to ensure they work properly when called in the future.

Any changes of core modules? (ignore if not applicable)

  • Example: I have added a new virtual function in the esolver base class in order to ...

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes several KEDF-related get_energy implementations so the returned value matches the reduced/stored member energy, and makes small ML-related output/formatting adjustments to improve correctness/consistency when these codepaths are used in the future.

Changes:

  • Return reduced member energy (this->*_energy) from multiple KEDF get_energy functions instead of returning the unreduced local energy.
  • Add braces around if (PARAM.inp.of_ml_feg == 1) in ML KEDF / ML EXX parameter setup for clearer, safer control flow.
  • Adjust ML descriptor output pathing for p.npy (currently introduces a path-join bug; see comment).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
source/source_pw/module_ofdft/kedf_xwm.cpp Return reduced xwm_energy from get_energy.
source/source_pw/module_ofdft/kedf_wt.cpp Return reduced wt_energy from get_energy.
source/source_pw/module_ofdft/kedf_vw.cpp Return reduced vw_energy from get_energy.
source/source_pw/module_ofdft/kedf_tf.cpp Return reduced tf_energy from get_energy.
source/source_pw/module_ofdft/kedf_lkt.cpp Return reduced lkt_energy from get_energy.
source/source_pw/module_ofdft/kedf_ml.cpp Add braces around ML-FEG softplus branch in set_para.
source/source_io/module_ml/write_mlkedf_descriptors.cpp Change p.npy output path to use out_dir (currently missing /).
source/source_estate/module_pot/pot_ml_exx.cpp Add braces around ML-FEG softplus branch in set_para.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/source_io/module_ml/write_mlkedf_descriptors.cpp Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@mohanchen mohanchen 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.

LGTM

@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes labels Mar 28, 2026
@mohanchen
mohanchen merged commit a0840ed into deepmodeling:develop Mar 29, 2026
15 checks passed
@sunliang98
sunliang98 deleted the fix_ofdft branch April 8, 2026 08:02
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.

3 participants