Skip to content

Fix: Fix RT-TDDFT segmentation fault caused by unconverged initial SCF#6954

Merged
mohanchen merged 1 commit intodeepmodeling:developfrom
AsTonyshment:fix_td_scf_nmax
Feb 8, 2026
Merged

Fix: Fix RT-TDDFT segmentation fault caused by unconverged initial SCF#6954
mohanchen merged 1 commit intodeepmodeling:developfrom
AsTonyshment:fix_td_scf_nmax

Conversation

@AsTonyshment
Copy link
Collaborator

Description

This PR fixes a critical segmentation fault in the RT-TDDFT module when the initial Ground State SCF calculation fails to converge within the specified scf_nmax.

Issue & Root Cause

Scenario:

  1. User sets a small scf_nmax.
  2. The initial GS SCF loop finishes without convergence (conv_esolver is false).
  3. The code proceeds to the first time-dependent evolution step.
  4. Crash: The program segfaults in Evolve_elec::solve_psi when accessing psi_laststep.

Root Cause:
In source/source_esolver/esolver_ks_lcao_tddft.cpp, the function store_h_s_psi (responsible for allocating and saving psi_laststep, Hk_laststep, Sk_laststep) was only called if conv_esolver was true.
When SCF failed to converge, psi_laststep remained a nullptr. Subsequently, calling psi_laststep->fix_k(ik) in the next step triggered a segmentation fault.

Fix

Modified ESolver_KS_LCAO_TDDFT::iter_finish to allow storing the wavefunction and Hamiltonian/Overlap matrices even if convergence is not reached, provided the iteration count has hit the limit (iter == this->maxniter).

@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes labels Feb 8, 2026
@mohanchen mohanchen merged commit 8929b2d into deepmodeling:develop Feb 8, 2026
14 checks passed
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.

2 participants