Skip to content

Fix DFT-D4 calculations for charged systems#7532

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Growl1234:dftd4
Jun 27, 2026
Merged

Fix DFT-D4 calculations for charged systems#7532
mohanchen merged 1 commit into
deepmodeling:developfrom
Growl1234:dftd4

Conversation

@Growl1234

Copy link
Copy Markdown

Fixes DFT-D4 calculations for charged systems.

Previously, ABACUS passed a null charge pointer when creating the DFTD4 structure, causing DFTD4 to assume a neutral system unconditionally. The total system charge is now computed from the pseudopotential valence charges and the final electron count, and passed explicitly to DFTD4.

The D4 test fixture now initializes the Si valence charge explicitly, and a charged-system regression test has been added. Neutral-system results should remain unchanged.

Copilot AI review requested due to automatic review settings June 27, 2026 04:05

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

This PR fixes DFT-D4 dispersion calculations for charged systems by explicitly computing and passing the system’s net charge into the DFTD4 structure creation, and extends unit tests to cover charged-system behavior.

Changes:

  • Compute total_charge_ from pseudopotential valence charges and nelec, and pass it to dftd4_new_structure instead of nullptr.
  • Add/adjust D4 unit test fixture initialization (Si valence zv, electron count).
  • Add a charged-system regression test for D4 energy.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
source/source_hamilt/module_vdw/vdwd4.h Adds stored total charge field for DFT-D4 structure creation.
source/source_hamilt/module_vdw/vdwd4.cpp Computes total charge and passes it to DFTD4 structure construction.
source/source_hamilt/module_vdw/test/vdw_test.cpp Initializes Si valence/electron count and adds charged-system D4 energy test.

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

Comment thread source/source_hamilt/module_vdw/vdwd4.cpp
Comment thread source/source_hamilt/module_vdw/vdwd4.h Outdated

@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 Refactor Refactor ABACUS codes Interfaces Interfaces with other packages labels Jun 27, 2026
@mohanchen mohanchen merged commit 43e4e78 into deepmodeling:develop Jun 27, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Interfaces Interfaces with other packages Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants