Fix DFT-D4 calculations for charged systems#7532
Merged
Merged
Conversation
There was a problem hiding this comment.
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 andnelec, and pass it todftd4_new_structureinstead ofnullptr. - 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.
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.
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.