Skip to content

Commit

Permalink
Remove KERNEL FLEX option (#1939)
Browse files Browse the repository at this point in the history
* Change units in output for Mode_selective IR intensities

* Update TEST_Files for regtests

* Remove KERNEL FLEX option, is included in FULL kernel option
  • Loading branch information
juerghutter committed Feb 10, 2022
1 parent 73726b2 commit b290291
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 77 deletions.
2 changes: 1 addition & 1 deletion src/cp_control_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ MODULE cp_control_types
LOGICAL :: rks_triplets
!> local resolution of identity for Coulomb contribution
LOGICAL :: do_lrigpw
!> logical to distinguish response and GS density during update, necessary for flex kernel
!> logical to distinguish response and GS density during update
! in contrast to logical enabled, this is only set to true when GS finished and TDDFPT2 starts
LOGICAL :: do_response_now
! automatic generation of auxiliary basis for LRI-TDDFT
Expand Down
2 changes: 1 addition & 1 deletion src/cp_control_utils.F
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ SUBROUTINE read_tddfpt2_control(t_control, t_section, qs_control)
CALL section_vals_val_get(t_section, "ADMM_KERNEL_CORRECTION_SYMMETRIC", l_val=t_control%admm_symm)
t_control%do_response_now = .FALSE. ! logical to control that update of response density is distinguished
! from update of GS density, necessary for flex kernel
! from update of GS density
! read automatically generated auxiliary basis for LRI
CALL section_vals_val_get(t_section, "AUTO_BASIS", n_rep_val=nrep)
Expand Down
3 changes: 1 addition & 2 deletions src/input_constants.F
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,7 @@ MODULE input_constants
tddfpt_davidson = 1
INTEGER, PARAMETER, PUBLIC :: tddfpt_kernel_none = 2, &
tddfpt_kernel_full = 1, &
tddfpt_kernel_stda = 0, &
tddfpt_kernel_flex = 3
tddfpt_kernel_stda = 0
INTEGER, PARAMETER, PUBLIC :: oe_none = 0, &
oe_lb = 1, &
oe_gllb = 2, &
Expand Down
9 changes: 4 additions & 5 deletions src/input_cp2k_properties_dft.F
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ MODULE input_cp2k_properties_dft
ot_precond_full_all, ot_precond_full_kinetic, ot_precond_full_single, &
ot_precond_full_single_inverse, ot_precond_none, ot_precond_s_inverse, scan_x, scan_xy, &
scan_xyz, scan_xz, scan_y, scan_yz, scan_z, tddfpt_dipole_berry, tddfpt_dipole_length, &
tddfpt_dipole_velocity, tddfpt_kernel_flex, tddfpt_kernel_full, tddfpt_kernel_none, &
tddfpt_kernel_stda, use_mom_ref_coac, use_mom_ref_com, use_mom_ref_user, use_mom_ref_zero
tddfpt_dipole_velocity, tddfpt_kernel_full, tddfpt_kernel_none, tddfpt_kernel_stda, &
use_mom_ref_coac, use_mom_ref_com, use_mom_ref_user, use_mom_ref_zero
USE input_cp2k_atprop, ONLY: create_atprop_section
USE input_cp2k_dft, ONLY: create_ddapc_restraint_section,&
create_interp_section,&
Expand Down Expand Up @@ -1306,9 +1306,8 @@ SUBROUTINE create_tddfpt2_section(section)
CALL keyword_create(keyword, __LOCATION__, name="KERNEL", &
description="Options to compute the kernel", &
usage="KERNEL FULL", &
enum_c_vals=s2a("FULL", "sTDA", "NONE", "FLEX"), &
enum_i_vals=(/tddfpt_kernel_full, tddfpt_kernel_stda, tddfpt_kernel_none, &
tddfpt_kernel_flex/), &
enum_c_vals=s2a("FULL", "sTDA", "NONE"), &
enum_i_vals=(/tddfpt_kernel_full, tddfpt_kernel_stda, tddfpt_kernel_none/), &
default_i_val=tddfpt_kernel_full)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
Expand Down
3 changes: 1 addition & 2 deletions src/qs_kernel_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ MODULE qs_kernel_types
!> flags for finite differences/analytic XC kernels
LOGICAL :: deriv2_analytic
LOGICAL :: deriv3_analytic
! Local resolution of the identity for Coulomb (at the moment only for flex kernel)
! Local resolution of the identity for Coulomb
TYPE(lri_environment_type), POINTER :: lri_env => Null()
TYPE(lri_density_type), POINTER :: lri_density => Null()
END TYPE full_kernel_env_type
Expand All @@ -71,7 +71,6 @@ MODULE qs_kernel_types
TYPE kernel_env_type
TYPE(full_kernel_env_type), POINTER :: full_kernel => Null()
TYPE(full_kernel_env_type), POINTER :: admm_kernel => Null()
TYPE(full_kernel_env_type), POINTER :: flex_kernel => Null()
TYPE(stda_env_type), POINTER :: stda_kernel => Null()
END TYPE kernel_env_type

Expand Down
18 changes: 3 additions & 15 deletions src/qs_tddfpt2_eigensolver.F
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ MODULE qs_tddfpt2_eigensolver
USE dbcsr_api, ONLY: dbcsr_get_info,&
dbcsr_p_type,&
dbcsr_type
USE input_constants, ONLY: tddfpt_kernel_flex,&
tddfpt_kernel_full,&
USE input_constants, ONLY: tddfpt_kernel_full,&
tddfpt_kernel_none,&
tddfpt_kernel_stda
USE input_section_types, ONLY: section_vals_type
Expand Down Expand Up @@ -321,16 +320,10 @@ SUBROUTINE tddfpt_compute_Aop_evects(Aop_evects, evects, S_evects, gs_mos, tddfp
LOGICAL :: do_admm, do_hfx, do_lri_response, &
is_rks_triplets
TYPE(cp_para_env_type), POINTER :: para_env
TYPE(full_kernel_env_type), POINTER :: full_kernel_env, kernel_env_admm_aux
TYPE(full_kernel_env_type), POINTER :: kernel_env_admm_aux

CALL timeset(routineN, handle)

IF (tddfpt_control%kernel == tddfpt_kernel_full) THEN
full_kernel_env => kernel_env%full_kernel
ELSE IF (tddfpt_control%kernel == tddfpt_kernel_flex) THEN
full_kernel_env => kernel_env%flex_kernel
END IF

nspins = SIZE(evects, 1)
nvects = SIZE(evects, 2)
do_hfx = tddfpt_control%do_hfx
Expand Down Expand Up @@ -370,7 +363,7 @@ SUBROUTINE tddfpt_compute_Aop_evects(Aop_evects, evects, S_evects, gs_mos, tddfp
IF (tddfpt_control%kernel == tddfpt_kernel_full) THEN
! full TDDFPT kernel
CALL fhxc_kernel(Aop_evects, evects, is_rks_triplets, do_hfx, do_admm, qs_env, &
full_kernel_env, kernel_env_admm_aux, sub_env, work_matrices, &
kernel_env%full_kernel, kernel_env_admm_aux, sub_env, work_matrices, &
tddfpt_control%admm_symm, do_lri_response)
ELSE IF (tddfpt_control%kernel == tddfpt_kernel_stda) THEN
! sTDA kernel
Expand All @@ -383,11 +376,6 @@ SUBROUTINE tddfpt_compute_Aop_evects(Aop_evects, evects, S_evects, gs_mos, tddfp
CALL cp_fm_set_all(Aop_evects(ispin, ivect)%matrix, 0.0_dp)
END DO
END DO
ELSE IF (tddfpt_control%kernel == tddfpt_kernel_flex) THEN
! flex kernel
CALL fhxc_kernel(Aop_evects, evects, is_rks_triplets, do_hfx, do_admm, qs_env, &
full_kernel_env, kernel_env_admm_aux, sub_env, work_matrices, &
tddfpt_control%admm_symm, do_lri_response)
ELSE
CPABORT("Kernel type not implemented")
END IF
Expand Down
4 changes: 2 additions & 2 deletions src/qs_tddfpt2_fhxc.F
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ SUBROUTINE fhxc_kernel(Aop_evects, evects, is_rks_triplets, &
hmat=work_matrices%A_ia_munu_sub(ispin), &
qs_env=qs_env, calculate_forces=.FALSE., gapw=.FALSE., &
pw_env_external=sub_env%pw_env, task_list_external=sub_env%task_list_orb)
ELSE ! for flex kernel using lri
ELSE ! for full kernel using lri
CALL pw_scale(work_matrices%A_ia_rspace_sub(ispin)%pw, &
work_matrices%A_ia_rspace_sub(ispin)%pw%pw_grid%dvol)
lri_v_int => kernel_env%lri_density%lri_coefs(ispin)%lri_kinds
Expand All @@ -333,7 +333,7 @@ SUBROUTINE fhxc_kernel(Aop_evects, evects, is_rks_triplets, &
! IF (lri_env%ppl_ri) THEN
! CALL v_int_ppl_update(qs_env, lri_v_int, calculate_forces)
! END IF
END IF ! for flex kernel using lri
END IF ! for full kernel using lri
END DO

! calculate Coulomb contribution to response vector for lrigpw !
Expand Down
30 changes: 12 additions & 18 deletions src/qs_tddfpt2_lri_utils.F
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,27 @@ SUBROUTINE tddfpt2_lri_init(qs_env, kernel_env, lri_section, tddfpt_print_sectio
CALL get_qs_env(qs_env, dft_control=dft_control)
tddfpt2_control => dft_control%tddfpt2_control

NULLIFY (kernel_env%flex_kernel%lri_env)
! initialize lri_env
CALL lri_env_init(kernel_env%flex_kernel%lri_env, lri_section)
NULLIFY (kernel_env%full_kernel%lri_env)
! initialize lri_env
CALL lri_env_init(kernel_env%full_kernel%lri_env, lri_section)
NULLIFY (lri_env)
lri_env => kernel_env%flex_kernel%lri_env
lri_env => kernel_env%full_kernel%lri_env
redefine_interaction_radii = .FALSE.

! exact_1c_terms not implemented
! exact_1c_terms not implemented
IF (lri_env%exact_1c_terms) THEN
CPABORT("TDDFT with LRI and exact one-center terms not implemented")
END IF

! ! check if LRI_AUX basis is available
! check if LRI_AUX basis is available
CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
nkind = SIZE(qs_kind_set)
DO ikind = 1, nkind
NULLIFY (p_lri_aux_basis)
qs_kind => qs_kind_set(ikind)
CALL get_qs_kind(qs_kind, basis_set=p_lri_aux_basis, basis_type="P_LRI_AUX")
IF (.NOT. (ASSOCIATED(p_lri_aux_basis))) THEN
! ! Generate a default basis
! Generate a default basis
redefine_interaction_radii = .TRUE.
CALL cp_warn(__LOCATION__, "Automatic Generation of P_LRI_AUX basis. "// &
"This is experimental code.")
Expand Down Expand Up @@ -219,8 +219,8 @@ SUBROUTINE tddfpt2_lri_init(qs_env, kernel_env, lri_section, tddfpt_print_sectio
CALL section_vals_val_get(qs_env%input, "DFT%SUBCELLS", r_val=subcells)
CALL build_neighbor_lists(soo_list, particle_set, atom2d, cell, pair_radius, &
mic=mic, molecular=molecule_only, subcells=subcells, nlname="soo_list")
!
!!! make this a TDDFT neighborlist

! make this a TDDFT neighborlist
neighbor_list_section => section_vals_get_subs_vals(qs_env%input, "DFT%PRINT%NEIGHBOR_LISTS")
CALL write_neighbor_lists(soo_list, particle_set, cell, para_env, neighbor_list_section, &
"/SOO_LIST", "soo_list", "ORBITAL ORBITAL (RI)")
Expand All @@ -229,12 +229,12 @@ SUBROUTINE tddfpt2_lri_init(qs_env, kernel_env, lri_section, tddfpt_print_sectio
CALL atom2d_cleanup(atom2d)
DEALLOCATE (orb_present, orb_radius, pair_radius)

! calculate LRI integrals
! calculate LRI integrals
lri_env%ppl_ri = .FALSE. ! make sure that option is not available for ES
CALL build_lri_matrices(lri_env, qs_env)
kernel_env%flex_kernel%lri_env => lri_env
kernel_env%full_kernel%lri_env => lri_env

! CALL get_condition_number_of_overlap(lri_env)
! CALL get_condition_number_of_overlap(lri_env)

CALL timestop(handle)

Expand All @@ -248,7 +248,6 @@ END SUBROUTINE tddfpt2_lri_init
!> \param A_ia_munu_sub ...
! **************************************************************************************************
SUBROUTINE tddfpt2_lri_Amat(qs_env, sub_env, lri_env, lri_v_int, A_ia_munu_sub)
!
TYPE(qs_environment_type), INTENT(IN), POINTER :: qs_env
TYPE(tddfpt_subgroup_env_type), INTENT(IN) :: sub_env
TYPE(lri_environment_type), INTENT(IN), POINTER :: lri_env
Expand All @@ -262,14 +261,10 @@ SUBROUTINE tddfpt2_lri_Amat(qs_env, sub_env, lri_env, lri_v_int, A_ia_munu_sub)
TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: dummymat, matrix_s

!

CALL timeset(routineN, handle)
!
NULLIFY (atomic_kind_set)
NULLIFY (matrix_s)
CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, matrix_s=matrix_s)
!
nspins = SIZE(A_ia_munu_sub)
DO ispin = 1, nspins!
!no kpoints for excited states => using dummy matrix with no cell index
Expand All @@ -287,7 +282,6 @@ SUBROUTINE tddfpt2_lri_Amat(qs_env, sub_env, lri_env, lri_v_int, A_ia_munu_sub)
CALL dbcsr_deallocate_matrix(dummymat(1)%matrix)
DEALLOCATE (dummymat)
END DO

CALL timestop(handle)

END SUBROUTINE tddfpt2_lri_Amat
Expand Down
35 changes: 9 additions & 26 deletions src/qs_tddfpt2_methods.F
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ MODULE qs_tddfpt2_methods
USE exstates_types, ONLY: excited_energy_type
USE header, ONLY: tddfpt_header
USE input_constants, ONLY: tddfpt_dipole_velocity,&
tddfpt_kernel_flex,&
tddfpt_kernel_full,&
tddfpt_kernel_none,&
tddfpt_kernel_stda
Expand Down Expand Up @@ -204,8 +203,8 @@ SUBROUTINE tddfpt(qs_env, calc_forces)
! obtain corrected KS-matrix
CALL tddfpt_oecorr(qs_env, gs_mos, matrix_ks_oep)

IF ((tddfpt_control%do_lrigpw) .AND. (tddfpt_control%kernel /= tddfpt_kernel_flex)) THEN
CALL cp_abort(__LOCATION__, "LRI only implemented for flex kernel")
IF ((tddfpt_control%do_lrigpw) .AND. (tddfpt_control%kernel /= tddfpt_kernel_full)) THEN
CALL cp_abort(__LOCATION__, "LRI only implemented for full kernel")
END IF

NULLIFY (admm_env)
Expand Down Expand Up @@ -238,7 +237,7 @@ SUBROUTINE tddfpt(qs_env, calc_forces)
CALL tddfpt_sub_env_init(sub_env, qs_env, mos_occ=evects(:, 1), kernel=tddfpt_control%kernel)
DEALLOCATE (evects)

IF ((tddfpt_control%kernel == tddfpt_kernel_full) .OR. (tddfpt_control%kernel == tddfpt_kernel_flex)) THEN
IF (tddfpt_control%kernel == tddfpt_kernel_full) THEN
! create environment for Full Kernel
IF (dft_control%qs_control%xtb) THEN
CPABORT("TDDFPT: xTB only works with sTDA Kernel")
Expand Down Expand Up @@ -312,20 +311,6 @@ SUBROUTINE tddfpt(qs_env, calc_forces)
NULLIFY (kernel_env%full_kernel)
NULLIFY (kernel_env%admm_kernel)
NULLIFY (kernel_env%stda_kernel)
ELSE IF (tddfpt_control%kernel == tddfpt_kernel_flex) THEN
nactive = 0
CALL cp_fm_get_info(gs_mos(1)%mos_occ, nrow_global=nao)
DO ispin = 1, SIZE(gs_mos)
CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, ncol_global=nactive(ispin))
END DO
CALL create_kernel_env(kernel_env=full_kernel_env, &
rho_struct_sub=work_matrices%rho_orb_struct_sub, &
xc_section=xc_section, &
is_rks_triplets=tddfpt_control%rks_triplets, sub_env=sub_env)
kernel_env%flex_kernel => full_kernel_env
NULLIFY (kernel_env%full_kernel)
NULLIFY (kernel_env%admm_kernel)
NULLIFY (kernel_env%stda_kernel)
ELSE
CPABORT('Unknown kernel type')
END IF
Expand Down Expand Up @@ -458,7 +443,7 @@ SUBROUTINE tddfpt(qs_env, calc_forces)
tddfpt_print_section)

IF (tddfpt_control%do_lrigpw) THEN
CALL lri_print_stat(qs_env, ltddfpt=.TRUE., tddfpt_lri_env=kernel_env%flex_kernel%lri_env)
CALL lri_print_stat(qs_env, ltddfpt=.TRUE., tddfpt_lri_env=kernel_env%full_kernel%lri_env)
END IF

! excited state potential energy surface
Expand Down Expand Up @@ -576,17 +561,15 @@ SUBROUTINE tddfpt(qs_env, calc_forces)

IF (tddfpt_control%kernel == tddfpt_kernel_full) THEN
IF (do_admm) CALL release_kernel_env(kernel_env%admm_kernel)
IF (tddfpt_control%do_lrigpw) THEN
CALL lri_env_release(kernel_env%full_kernel%lri_env)
CALL lri_density_release(kernel_env%full_kernel%lri_density)
END IF
CALL release_kernel_env(kernel_env%full_kernel)
ELSE IF (tddfpt_control%kernel == tddfpt_kernel_stda) THEN
CALL deallocate_stda_env(stda_kernel)
ELSE IF (tddfpt_control%kernel == tddfpt_kernel_none) THEN
!
ELSE IF (tddfpt_control%kernel == tddfpt_kernel_flex) THEN
IF (tddfpt_control%do_lrigpw) THEN
CALL lri_env_release(kernel_env%flex_kernel%lri_env)
CALL lri_density_release(kernel_env%flex_kernel%lri_density)
END IF
CALL release_kernel_env(kernel_env%flex_kernel)
ELSE
CPABORT('Unknown kernel type')
END IF
Expand Down Expand Up @@ -659,7 +642,7 @@ SUBROUTINE tddfpt_input(qs_env, do_hfx, do_admm, do_exck, do_hfxlr, &
tddfpt_section => section_vals_get_subs_vals(input, "PROPERTIES%TDDFPT")
tddfpt_print_section => section_vals_get_subs_vals(tddfpt_section, "PRINT")

IF ((tddfpt_control%kernel == tddfpt_kernel_full) .OR. (tddfpt_control%kernel == tddfpt_kernel_flex)) THEN
IF (tddfpt_control%kernel == tddfpt_kernel_full) THEN
NULLIFY (xc_root)
xc_root => section_vals_get_subs_vals(tddfpt_section, "XC")
CALL section_vals_get(xc_root, explicit=explicit_root)
Expand Down
5 changes: 2 additions & 3 deletions src/qs_tddfpt2_subgroups.F
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ MODULE qs_tddfpt2_subgroups
USE distribution_2d_types, ONLY: distribution_2d_release,&
distribution_2d_type
USE distribution_methods, ONLY: distribute_molecules_2d
USE input_constants, ONLY: tddfpt_kernel_flex,&
tddfpt_kernel_full,&
USE input_constants, ONLY: tddfpt_kernel_full,&
tddfpt_kernel_none,&
tddfpt_kernel_stda
USE input_section_types, ONLY: section_vals_type,&
Expand Down Expand Up @@ -263,7 +262,7 @@ SUBROUTINE tddfpt_sub_env_init(sub_env, qs_env, mos_occ, kernel)
END IF
END IF

IF ((kernel == tddfpt_kernel_full) .OR. (kernel == tddfpt_kernel_flex)) THEN
IF (kernel == tddfpt_kernel_full) THEN
! ++ allocate a new plane wave environment
sub_env%is_mgrid = sub_env%is_split .OR. tddfpt_control%mgrid_is_explicit

Expand Down
2 changes: 1 addition & 1 deletion tests/QS/regtest-tddfpt-lri/h2o_lri01_only_es.inp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
NSTATES 5
MAX_ITER 100
CONVERGENCE [eV] 1.0e-7
KERNEL FLEX
KERNEL FULL
DO_LRIGPW T
&LRIGPW
SHG_LRI_INTEGRALS F
Expand Down
2 changes: 1 addition & 1 deletion tests/QS/regtest-tddfpt-lri/h2o_lri02_es_and_gs.inp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
NSTATES 5
MAX_ITER 100
CONVERGENCE [eV] 1.0e-4
KERNEL FLEX
KERNEL FULL
DO_LRIGPW T
&LRIGPW
SHG_LRI_INTEGRALS F
Expand Down

0 comments on commit b290291

Please sign in to comment.