Skip to content

Commit

Permalink
Uncontracted basis option for HFXSR (#3276)
Browse files Browse the repository at this point in the history
  • Loading branch information
juerghutter committed Feb 21, 2024
1 parent d3f223a commit 47690d8
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/cp_control_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ MODULE cp_control_types
!> for full kernel, do we have short-range/long-range HFX and/or Kxc potential
LOGICAL :: do_hfxsr = .FALSE.
LOGICAL :: hfxsr_re_int = .TRUE.
LOGICAL :: hfxsr_primbas = .FALSE.
LOGICAL :: do_hfxlr = .FALSE.
REAL(KIND=dp) :: hfxlr_rcut = 0.0_dp, hfxlr_scale = 0.0_dp
LOGICAL :: do_exck = .FALSE.
Expand Down
7 changes: 7 additions & 0 deletions src/input_cp2k_xc.F
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,13 @@ SUBROUTINE create_hfx_kernel_section(section)
lone_keyword_l_val=.TRUE.)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
NULLIFY (subsection, keyword)
CALL keyword_create(keyword, __LOCATION__, name="HFXSR_PRIMBAS", &
description="Default ADMM basis in HFXSR is primitive", &
usage="HFXSR_PRIMBAS T/F", default_l_val=.FALSE., &
lone_keyword_l_val=.TRUE.)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL create_hfx_section(subsection)
CALL section_add_subsection(section, subsection)
Expand Down
31 changes: 23 additions & 8 deletions src/min_basis_set.F
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
MODULE min_basis_set
USE basis_set_container_types, ONLY: add_basis_set_to_container
USE basis_set_types, ONLY: &
allocate_sto_basis_set, create_gto_from_sto_basis, deallocate_sto_basis_set, &
get_gto_basis_set, gto_basis_set_type, init_orb_basis_set, set_sto_basis_set, srules, &
sto_basis_set_type
allocate_sto_basis_set, create_gto_from_sto_basis, create_primitive_basis_set, &
deallocate_gto_basis_set, deallocate_sto_basis_set, get_gto_basis_set, gto_basis_set_type, &
init_orb_basis_set, set_sto_basis_set, srules, sto_basis_set_type
USE cp_control_types, ONLY: dft_control_type
USE kinds, ONLY: default_string_length,&
dp
Expand Down Expand Up @@ -45,21 +45,24 @@ MODULE min_basis_set
!> \param qs_env ...
!> \param unit_nr ...
!> \param basis_type ...
!> \param primitive ...
! **************************************************************************************************
SUBROUTINE create_minbas_set(qs_env, unit_nr, basis_type)
SUBROUTINE create_minbas_set(qs_env, unit_nr, basis_type, primitive)
TYPE(qs_environment_type), POINTER :: qs_env
INTEGER, INTENT(IN) :: unit_nr
CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: basis_type
LOGICAL, INTENT(IN), OPTIONAL :: primitive

CHARACTER(LEN=2) :: element_symbol
CHARACTER(LEN=default_string_length) :: bname, btype
INTEGER :: ikind, lb, mao, ne, ngau, nkind, nsgf, &
ub, z
INTEGER, DIMENSION(0:3) :: elcon
INTEGER, DIMENSION(:), POINTER :: econf
LOGICAL :: do_primitive
REAL(KIND=dp) :: zval
TYPE(dft_control_type), POINTER :: dft_control
TYPE(gto_basis_set_type), POINTER :: refbasis
TYPE(gto_basis_set_type), POINTER :: pbasis, refbasis
TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
TYPE(qs_kind_type), POINTER :: qs_kind

Expand All @@ -68,6 +71,11 @@ SUBROUTINE create_minbas_set(qs_env, unit_nr, basis_type)
ELSE
btype = "MIN"
END IF
IF (PRESENT(primitive)) THEN
do_primitive = primitive
ELSE
do_primitive = .FALSE.
END IF

! check for or generate reference basis
CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set)
Expand All @@ -77,7 +85,7 @@ SUBROUTINE create_minbas_set(qs_env, unit_nr, basis_type)
qs_kind => qs_kind_set(ikind)
CALL get_qs_kind(qs_kind, zeff=zval, elec_conf=econf, element_symbol=element_symbol)
CALL get_ptable_info(element_symbol, ielement=z)
NULLIFY (refbasis)
NULLIFY (refbasis, pbasis)
CALL get_qs_kind(qs_kind=qs_kind, basis_set=refbasis, basis_type=btype)
IF (.NOT. ASSOCIATED(refbasis)) THEN
CALL get_qs_kind(qs_kind=qs_kind, mao=mao)
Expand All @@ -90,8 +98,15 @@ SUBROUTINE create_minbas_set(qs_env, unit_nr, basis_type)
! STO-3G
ngau = 3
CALL create_min_basis(refbasis, z, elcon, mao, ngau)
CALL init_interaction_radii_orb_basis(refbasis, dft_control%qs_control%eps_pgf_orb)
CALL add_basis_set_to_container(qs_kind%basis_sets, refbasis, btype)
IF (do_primitive) THEN
CALL create_primitive_basis_set(refbasis, pbasis)
CALL init_interaction_radii_orb_basis(pbasis, dft_control%qs_control%eps_pgf_orb)
CALL add_basis_set_to_container(qs_kind%basis_sets, pbasis, btype)
CALL deallocate_gto_basis_set(refbasis)
ELSE
CALL init_interaction_radii_orb_basis(refbasis, dft_control%qs_control%eps_pgf_orb)
CALL add_basis_set_to_container(qs_kind%basis_sets, refbasis, btype)
END IF
END IF
IF (unit_nr > 0) THEN
CALL get_gto_basis_set(refbasis, name=bname, nsgf=nsgf)
Expand Down
7 changes: 6 additions & 1 deletion src/qs_tddfpt2_methods.F
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ SUBROUTINE tddfpt(qs_env, calc_forces)
tddfpt_control%do_hfx = do_hfx
tddfpt_control%do_admm = do_admm
tddfpt_control%do_hfxsr = do_hfxsr
tddfpt_control%hfxsr_primbas = .FALSE.
tddfpt_control%hfxsr_re_int = .TRUE.
tddfpt_control%do_hfxlr = do_hfxlr
tddfpt_control%do_exck = do_exck
Expand Down Expand Up @@ -292,8 +293,12 @@ SUBROUTINE tddfpt(qs_env, calc_forces)
END IF

IF (tddfpt_control%do_hfxsr) THEN
kernel_section => section_vals_get_subs_vals(tddfpt_section, "XC%HFX_KERNEL")
CALL section_vals_val_get(kernel_section, "HFXSR_PRIMBAS", &
l_val=tddfpt_control%hfxsr_primbas)
! basis set
CALL create_minbas_set(qs_env, log_unit, basis_type="TDA_HFX")
CALL create_minbas_set(qs_env, log_unit, basis_type="TDA_HFX", &
primitive=tddfpt_control%hfxsr_primbas)
! admm control
ALLOCATE (full_kernel_env%admm_control)
full_kernel_env%admm_control%purification_method = do_admm_purify_none
Expand Down
1 change: 1 addition & 0 deletions tests/QS/regtest-tddfpt-lri/TEST_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ h2o_lri01_only_es.inp 37 1.0E-05
h2o_lri02_es_and_gs.inp 37 2.0E-05 0.942152E+00
h2o_hfxlr.inp 37 2.0E-05 0.473039E+00
h2o_t01.inp 37 2.0E-05 0.505312E+00
h2o_t02.inp 37 2.0E-05 0.508663E+00
#EOF
93 changes: 93 additions & 0 deletions tests/QS/regtest-tddfpt-lri/h2o_t02.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
&GLOBAL
PRINT_LEVEL LOW
PROJECT test
RUN_TYPE ENERGY
&END GLOBAL

&FORCE_EVAL
METHOD Quickstep
&DFT
BASIS_SET_FILE_NAME BASIS_ccGRB_UZH
&EXCITED_STATES T
STATE 1
&END EXCITED_STATES
&MGRID
CUTOFF 200
&END MGRID
&POISSON
PERIODIC NONE
POISSON_SOLVER MT
&END POISSON
&QS
EPS_DEFAULT 1.e-10
METHOD GPW
&END QS
&SCF
EPS_SCF 1.0E-6
MAX_SCF 10
SCF_GUESS ATOMIC
&OT
MINIMIZER DIIS
PRECONDITIONER FULL_SINGLE_INVERSE
&END OT
&OUTER_SCF
EPS_SCF 1.0E-6
MAX_SCF 10
&END OUTER_SCF
&END SCF
&XC
&HF
&HF_INFO ON
&END HF_INFO
&END HF
&XC_FUNCTIONAL PBE0
&END XC_FUNCTIONAL
&END XC
&END DFT
&PROPERTIES
&TDDFPT
CONVERGENCE [eV] 1.0e-7
DO_LRIGPW T
KERNEL FULL
MAX_ITER 100
NSTATES 2
&LRIGPW
RI_STATISTIC T
&END LRIGPW
&XC
&HFX_KERNEL
DO_HFXSR T
HFXSR_PRIMBAS
&HF
FRACTION 0.20
&HF_INFO ON
&END HF_INFO
&END HF
&HFXLR
&END HFXLR
&END HFX_KERNEL
&XC_KERNEL LDAFXC
&END XC_KERNEL
&END XC
&END TDDFPT
&END PROPERTIES
&SUBSYS
&CELL
ABC [angstrom] 5.0 5.0 5.0
PERIODIC NONE
&END CELL
&COORD
O 0.000000 0.000000 -0.065587
H 0.000000 -0.757136 0.520545
H 0.000000 0.757136 0.520545
&END COORD
&KIND H
BASIS_SET ccGRB-D-q1
POTENTIAL GTH-PADE-q1
&END KIND
&KIND O
BASIS_SET ccGRB-D-q6
POTENTIAL GTH-PADE-q6
&END KIND
&END SUBSYS
&END FORCE_EVAL

0 comments on commit 47690d8

Please sign in to comment.