Skip to content

Commit

Permalink
TDDFPT| Davidson restart bug fix (cp2k#3821)
Browse files Browse the repository at this point in the history
  • Loading branch information
BelizSertcan authored Dec 20, 2024
1 parent 308a163 commit 973f3dd
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
20 changes: 8 additions & 12 deletions src/qs_tddfpt2_methods.F
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ SUBROUTINE kernel_info(log_unit, dft_control, tddfpt_control, xc_section)
END SUBROUTINE kernel_info

! **************************************************************************************************
!> \brief The energy cylculation has been moved to its own subroutine
!> \brief The energy calculation has been moved to its own subroutine
!> \param qs_env ...
!> \param nstates ...
!> \param work_matrices ...
Expand Down Expand Up @@ -887,8 +887,7 @@ SUBROUTINE tddfpt_energies(qs_env, nstates, work_matrices, &
INTEGER :: energy_unit, handle, iter, log_unit, &
niters, nocc, nstate_max, &
nstates_read, nvirt
LOGICAL :: do_admm, do_exck, do_soc, explicit, &
is_restarted
LOGICAL :: do_admm, do_exck, do_soc, explicit
REAL(kind=dp) :: conv
TYPE(admm_type), POINTER :: admm_env
TYPE(cp_blacs_env_type), POINTER :: blacs_env
Expand Down Expand Up @@ -971,9 +970,9 @@ SUBROUTINE tddfpt_energies(qs_env, nstates, work_matrices, &
tddfpt_print_section)
END IF

!! Too many states cal lead to Problems
!! You should be warned if there are mor states
!! then occ-virt Combinations!!
!! Too many states can lead to problems
!! You should be warned if there are more states
!! then occ-virt combinations!!
CALL cp_fm_get_info(gs_mos(1)%mos_occ, ncol_global=nocc)
CALL cp_fm_get_info(gs_mos(1)%mos_virt, ncol_global=nvirt)
nstate_max = nocc*nvirt
Expand Down Expand Up @@ -1003,8 +1002,6 @@ SUBROUTINE tddfpt_energies(qs_env, nstates, work_matrices, &
nstates_read = 0
END IF

is_restarted = nstates_read >= nstates

! build the list of missed singly excited states and sort them in ascending order
! according to their excitation energies
log_unit = cp_print_key_unit_nr(logger, tddfpt_print_section, &
Expand Down Expand Up @@ -1062,15 +1059,14 @@ SUBROUTINE tddfpt_energies(qs_env, nstates, work_matrices, &
! at this point at least one of the following conditions are met:
! a) convergence criteria has been achieved;
! b) maximum number of iterations has been reached;
! c) Davidson iterations must be restarted due to lack of Krylov vectors or numerical instability
! c) Davidson iterations must be restarted due to lack of Krylov vectors

CALL cp_iterate(logger%iter_info, increment=0, iter_nr_out=iter)
! terminate the loop if either (a) or (b) is true ...
IF ((conv <= tddfpt_control%conv &
.AND. is_restarted) .OR. iter >= niters) EXIT
IF ((conv <= tddfpt_control%conv) .OR. iter >= niters) EXIT

! ... otherwise restart Davidson iterations
is_restarted = .TRUE.
evals = 0.0_dp
IF (log_unit > 0) THEN
WRITE (log_unit, '(1X,25("-"),1X,A,1X,25("-"))') "Restart Davidson iterations"
CALL m_flush(log_unit)
Expand Down
2 changes: 1 addition & 1 deletion tests/QS/regtest-tddfpt/NO_tddfpt-s-1.inp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
&TDDFPT
CONVERGENCE 1.0e-5
MAX_ITER 10
MAX_KV 10
MAX_KV 30
NSTATES 3
&XC
&XC_FUNCTIONAL PBE
Expand Down
2 changes: 1 addition & 1 deletion tests/QS/regtest-tddfpt/NO_tddfpt-s-3.inp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
&TDDFPT
CONVERGENCE 1.0e-5
MAX_ITER 10
MAX_KV 10
MAX_KV 30
NSTATES 3
OE_CORR SAOP
RKS_TRIPLETS T
Expand Down
2 changes: 1 addition & 1 deletion tests/QS/regtest-tddfpt/NO_tddfpt-t-1.inp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
&TDDFPT
CONVERGENCE 1.0e-5
MAX_ITER 10
MAX_KV 10
MAX_KV 30
NSTATES 3
&XC
&XC_FUNCTIONAL BLYP
Expand Down
2 changes: 1 addition & 1 deletion tests/QS/regtest-tddfpt/NO_tddfpt-t-2.inp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
&TDDFPT
CONVERGENCE 1.0e-5
MAX_ITER 10
MAX_KV 10
MAX_KV 30
NSTATES 3
OE_CORR SAOP
RKS_TRIPLETS T
Expand Down
2 changes: 1 addition & 1 deletion tests/QS/regtest-tddfpt/NO_tddfpt-t-3.inp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
&TDDFPT
CONVERGENCE 1.0e-5
MAX_ITER 10
MAX_KV 10
MAX_KV 30
NSTATES 3
OE_CORR SAOP
&XC
Expand Down
10 changes: 5 additions & 5 deletions tests/QS/regtest-tddfpt/TEST_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
# for details see cp2k/tools/do_regtest
H2O_tddfpt-s-1.inp 37 4.0E-06 0.600232E+00
H2O_tddfpt-t-1.inp 37 4.0E-06 0.289055E+00
NO_tddfpt-s-1.inp 37 4.0E-06 0.335486E+00
NO_tddfpt-t-1.inp 37 2.0E-04 0.342419E+00
NO_tddfpt-s-1.inp 37 4.0E-06 0.319837E+00
NO_tddfpt-t-1.inp 37 2.0E-04 0.324319E+00
H2O_tddfpt-s-2.inp 37 4.0E-06 0.543390E+00
H2O_tddfpt-t-2.inp 37 4.0E-06 0.548605E+00
NO_tddfpt-t-2.inp 37 4.0E-06 0.358683E+00
NO_tddfpt-t-2.inp 37 4.0E-06 0.340342E+00
H2O_tddfpt-s-3.inp 37 4.0E-06 0.543390E+00
H2O_tddfpt-t-3.inp 37 4.0E-06 0.579030E+00
NO_tddfpt-s-3.inp 37 4.0E-06 0.350929E+00
NO_tddfpt-t-3.inp 37 4.0E-06 0.358683E+00
NO_tddfpt-s-3.inp 37 4.0E-06 0.326331E+00
NO_tddfpt-t-3.inp 37 4.0E-06 0.340342E+00
H2O_tddfpt_NTO.inp 37 4.0E-06 0.542432E+00
H2O_tddfpt_NTO_slist.inp 37 4.0E-06 0.542432E+00
H2O_tddfpt_NTO_restart.inp 37 4.0E-06 0.542432E+00
Expand Down

0 comments on commit 973f3dd

Please sign in to comment.