Skip to content

Fix: Fix missing EXX contribution in RT-TDDFT evolution steps#7344

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
AsTonyshment:td_exx
May 15, 2026
Merged

Fix: Fix missing EXX contribution in RT-TDDFT evolution steps#7344
mohanchen merged 2 commits into
deepmodeling:developfrom
AsTonyshment:td_exx

Conversation

@AsTonyshment
Copy link
Copy Markdown
Collaborator

Fix

Fix #7068.

Description

When running RT-TDDFT with hybrid functionals (EXX), a severe, unphysical energy jump (specifically in eband) occurs between the initial ground-state SCF and the first electron evolution step (istep = 1).

The root cause of this bug lies in the OperatorEXX::contributeHk function. In ABACUS, the two_level_step flag is reset to 0 at the beginning of each new ionic or evolution step. Originally, the code in contributeHk contained the following condition:

if (PARAM.inp.calculation != "nscf" && this->two_level_step != nullptr && *this->two_level_step == 0 && !this->restart) { return; }

Because RT-TDDFT uses Add_Hexx_Type::k (and thus relies on contributeHk to add the EXX matrix to the Hamiltonian), this condition erroneously triggered a return for all istep >= 1 evolution steps. As a result, the EXX contribution was completely omitted from the Hamiltonian for istep >= 1, leading to a catastrophic energy jump.

A similar issue in KSDFT BOMD (which uses OperatorEXX::contributeHR) was previously identified and fixed in PR #5403 (by Yuyang Ji @1041176461) by restricting this skip condition to the first step (this->istep == 0). However, contributeHk was overlooked during that fix.

Changes made

  • Updated the return condition in OperatorEXX::contributeHk to include this->istep == 0:
if (this->istep == 0 && PARAM.inp.calculation != "nscf" && this->two_level_step != nullptr && *this->two_level_step == 0 && !this->restart) { return; }

This ensures that the two-level SCF skip logic (converging pure GGA before turning on EXX) is strictly limited to the initial SCF phase (istep = 0). For all subsequent RT-TDDFT evolution steps (istep >= 1), the EXX contribution is correctly calculated and added to the Hamiltonian without being skipped.

Testing

  • Before fix, total energy jumps from -6.8862606 Ry to -5.1358612 Ry:
image
  • After fix, total energy stays the same:
image

Acknowledgments

Special thanks to Xinyuan Liang @xuan112358 for her valuable help in tracking down the root cause of this bug!

@AsTonyshment AsTonyshment requested review from Copilot and mohanchen and removed request for Copilot May 15, 2026 05:26
@AsTonyshment AsTonyshment requested a review from ESROAMER May 15, 2026 05:30
@AsTonyshment AsTonyshment requested review from Copilot and removed request for Copilot May 15, 2026 06:11
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes labels May 15, 2026
@mohanchen
Copy link
Copy Markdown
Collaborator

Nice fix!

@mohanchen mohanchen merged commit e5bff6d into deepmodeling:develop May 15, 2026
19 checks passed
@AsTonyshment AsTonyshment deleted the td_exx branch May 15, 2026 07:11
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.

RT-TDDFT calculations with hybrid functional PBE0 were very different when setting md_nsteps and estep_per_md

2 participants