(git:34ef472)
qs_linres_kernel.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
8 ! **************************************************************************************************
9 !> \brief linres kernel functions
10 !> \par History
11 !> created from qs_linres_methods
12 !> \author JGH
13 ! **************************************************************************************************
15  USE admm_types, ONLY: admm_type,&
17  USE atomic_kind_types, ONLY: atomic_kind_type,&
19  USE cp_control_types, ONLY: dft_control_type
23  USE cp_fm_types, ONLY: cp_fm_get_info,&
24  cp_fm_type
26  cp_logger_type,&
27  cp_to_string
28  USE dbcsr_api, ONLY: dbcsr_add,&
29  dbcsr_copy,&
30  dbcsr_create,&
31  dbcsr_deallocate_matrix,&
32  dbcsr_p_type,&
33  dbcsr_set
36  USE hfx_ri, ONLY: hfx_ri_update_ks
37  USE hfx_types, ONLY: hfx_type
48  section_vals_type,&
50  USE kg_correction, ONLY: kg_ekin_subset
51  USE kg_environment_types, ONLY: kg_environment_type
52  USE kinds, ONLY: default_string_length,&
53  dp
54  USE lri_environment_types, ONLY: lri_density_type,&
55  lri_environment_type,&
56  lri_kind_type
58  USE message_passing, ONLY: mp_para_env_type
59  USE mulliken, ONLY: ao_charges
60  USE particle_types, ONLY: particle_type
61  USE pw_env_types, ONLY: pw_env_get,&
62  pw_env_type
63  USE pw_methods, ONLY: pw_axpy,&
64  pw_copy,&
65  pw_scale,&
66  pw_transfer
67  USE pw_poisson_methods, ONLY: pw_poisson_solve
68  USE pw_poisson_types, ONLY: pw_poisson_type
69  USE pw_pool_types, ONLY: pw_pool_type
70  USE pw_types, ONLY: pw_c1d_gs_type,&
71  pw_r3d_rs_type
72  USE qs_environment_types, ONLY: get_qs_env,&
73  qs_environment_type
74  USE qs_fxc, ONLY: qs_fxc_analytic,&
77  USE qs_integrate_potential, ONLY: integrate_v_rspace,&
78  integrate_v_rspace_diagonal,&
79  integrate_v_rspace_one_center
80  USE qs_kind_types, ONLY: get_qs_kind,&
82  qs_kind_type
83  USE qs_kpp1_env_types, ONLY: qs_kpp1_env_type
84  USE qs_ks_atom, ONLY: update_ks_atom
85  USE qs_ks_types, ONLY: qs_ks_env_type
86  USE qs_linres_types, ONLY: linres_control_type
87  USE qs_neighbor_list_types, ONLY: neighbor_list_set_p_type
89  USE qs_p_env_types, ONLY: qs_p_env_type
91  USE qs_rho_atom_types, ONLY: rho_atom_type
92  USE qs_rho_types, ONLY: qs_rho_get,&
93  qs_rho_type
95  USE task_list_types, ONLY: task_list_type
96  USE xc, ONLY: xc_calc_2nd_deriv,&
99  USE xc_rho_cflags_types, ONLY: xc_rho_cflags_type
102  xc_rho_set_type,&
104  USE xtb_ehess, ONLY: xtb_coulomb_hessian
105  USE xtb_types, ONLY: get_xtb_atom_param,&
106  xtb_atom_type
107 #include "./base/base_uses.f90"
108 
109  IMPLICIT NONE
110 
111  PRIVATE
112 
113  ! *** Public subroutines ***
114  PUBLIC :: apply_xc_admm
115  PUBLIC :: apply_hfx
116  PUBLIC :: apply_op_2
117  PUBLIC :: hfx_matrix
118 
119  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_linres_kernel'
120 
121 ! **************************************************************************************************
122 
123 CONTAINS
124 
125 ! **************************************************************************************************
126 !> \brief ...
127 !> \param qs_env ...
128 !> \param p_env ...
129 !> \param c0 ...
130 !> \param Av ...
131 ! **************************************************************************************************
132  SUBROUTINE apply_op_2(qs_env, p_env, c0, Av)
133  !
134  TYPE(qs_environment_type), POINTER :: qs_env
135  TYPE(qs_p_env_type) :: p_env
136  TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: c0, av
137 
138  INTEGER :: ispin, ncol
139  TYPE(dft_control_type), POINTER :: dft_control
140 
141  CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
142  IF (dft_control%qs_control%semi_empirical) THEN
143  cpabort("Linear response not available with SE methods")
144  ELSEIF (dft_control%qs_control%dftb) THEN
145  cpabort("Linear response not available with DFTB")
146  ELSEIF (dft_control%qs_control%xtb) THEN
147  CALL apply_op_2_xtb(qs_env, p_env)
148  ELSE
149  CALL apply_op_2_dft(qs_env, p_env)
150  CALL apply_hfx(qs_env, p_env)
151  CALL apply_xc_admm(qs_env, p_env)
152  IF (dft_control%do_admm) CALL p_env_finish_kpp1(qs_env, p_env)
153  END IF
154 
155  DO ispin = 1, SIZE(c0)
156  CALL cp_fm_get_info(c0(ispin), ncol_global=ncol)
157  CALL cp_dbcsr_sm_fm_multiply(p_env%kpp1(ispin)%matrix, &
158  c0(ispin), &
159  av(ispin), &
160  ncol=ncol, alpha=1.0_dp, beta=1.0_dp)
161  END DO
162 
163  END SUBROUTINE apply_op_2
164 
165 ! **************************************************************************************************
166 !> \brief ...
167 !> \param qs_env ...
168 !> \param p_env ...
169 ! **************************************************************************************************
170  SUBROUTINE apply_op_2_dft(qs_env, p_env)
171  TYPE(qs_environment_type), POINTER :: qs_env
172  TYPE(qs_p_env_type) :: p_env
173 
174  CHARACTER(len=*), PARAMETER :: routinen = 'apply_op_2_dft'
175 
176  INTEGER :: handle, ikind, ispin, nkind, ns, nspins
177  LOGICAL :: deriv2_analytic, gapw, gapw_xc, &
178  lr_triplet, lrigpw
179  REAL(kind=dp) :: alpha, ekin_mol, energy_hartree, &
180  energy_hartree_1c
181  TYPE(admm_type), POINTER :: admm_env
182  TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
183  TYPE(cp_logger_type), POINTER :: logger
184  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: k1mat, matrix_s, rho1_ao, rho_ao
185  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: ksmat, psmat
186  TYPE(dft_control_type), POINTER :: dft_control
187  TYPE(kg_environment_type), POINTER :: kg_env
188  TYPE(linres_control_type), POINTER :: linres_control
189  TYPE(lri_density_type), POINTER :: lri_density
190  TYPE(lri_environment_type), POINTER :: lri_env
191  TYPE(lri_kind_type), DIMENSION(:), POINTER :: lri_v_int
192  TYPE(mp_para_env_type), POINTER :: para_env
193  TYPE(pw_c1d_gs_type) :: rho1_tot_gspace, v_hartree_gspace
194  TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho1_g
195  TYPE(pw_env_type), POINTER :: pw_env
196  TYPE(pw_poisson_type), POINTER :: poisson_env
197  TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
198  TYPE(pw_r3d_rs_type) :: v_hartree_rspace
199  TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho1_r, rho_r, tau1_r, v_rspace_new, &
200  v_xc, v_xc_tau
201  TYPE(qs_kpp1_env_type), POINTER :: kpp1_env
202  TYPE(qs_ks_env_type), POINTER :: ks_env
203  TYPE(qs_rho_type), POINTER :: rho, rho0, rho1, rho1_xc, rho1a, &
204  rho_aux, rho_xc
205  TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho1_atom_set, rho_atom_set
206  TYPE(section_vals_type), POINTER :: input, xc_section, xc_section_aux
207 
208  CALL timeset(routinen, handle)
209 
210  NULLIFY (auxbas_pw_pool, pw_env, v_rspace_new, para_env, rho1_r, &
211  v_xc, rho1_ao, rho_ao, poisson_env, input, rho, dft_control, &
212  logger, rho1_g, v_xc_tau)
213  logger => cp_get_default_logger()
214 
215  energy_hartree = 0.0_dp
216  energy_hartree_1c = 0.0_dp
217 
218  cpassert(ASSOCIATED(p_env%kpp1))
219  cpassert(ASSOCIATED(p_env%kpp1_env))
220  kpp1_env => p_env%kpp1_env
221 
222  CALL get_qs_env(qs_env=qs_env, &
223  ks_env=ks_env, &
224  pw_env=pw_env, &
225  input=input, &
226  admm_env=admm_env, &
227  para_env=para_env, &
228  rho=rho, &
229  rho_xc=rho_xc, &
230  linres_control=linres_control, &
231  dft_control=dft_control)
232 
233  gapw = dft_control%qs_control%gapw
234  gapw_xc = dft_control%qs_control%gapw_xc
235  lr_triplet = linres_control%lr_triplet
236 
237  rho1 => p_env%rho1
238  rho1_xc => p_env%rho1_xc
239  cpassert(ASSOCIATED(rho1))
240  IF (gapw_xc) THEN
241  cpassert(ASSOCIATED(rho1_xc))
242  END IF
243 
244  CALL qs_rho_get(rho, rho_ao=rho_ao, rho_r=rho_r)
245  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
246 
247  nspins = SIZE(p_env%kpp1)
248  lrigpw = dft_control%qs_control%lrigpw
249  IF (lrigpw) THEN
250  CALL get_qs_env(qs_env, &
251  lri_env=lri_env, &
252  lri_density=lri_density, &
253  atomic_kind_set=atomic_kind_set)
254  END IF
255 
256  IF (.NOT. ASSOCIATED(kpp1_env%v_ao)) THEN
257  CALL get_qs_env(qs_env, matrix_s=matrix_s)
258  CALL dbcsr_allocate_matrix_set(kpp1_env%v_ao, nspins)
259  DO ispin = 1, nspins
260  ALLOCATE (kpp1_env%v_ao(ispin)%matrix)
261  CALL dbcsr_copy(kpp1_env%v_ao(ispin)%matrix, matrix_s(1)%matrix, &
262  name="kpp1%v_ao-"//adjustl(cp_to_string(ispin)))
263  END DO
264  END IF
265 
266  IF (dft_control%do_admm) THEN
267  xc_section => admm_env%xc_section_primary
268  ELSE
269  xc_section => section_vals_get_subs_vals(input, "DFT%XC")
270  END IF
271 
272  ! gets the tmp grids
273  cpassert(ASSOCIATED(pw_env))
274  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
275  poisson_env=poisson_env)
276  CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
277  CALL auxbas_pw_pool%create_pw(v_hartree_rspace)
278 
279  IF (gapw .OR. gapw_xc) &
280  CALL prepare_gapw_den(qs_env, p_env%local_rho_set, do_rho0=(.NOT. gapw_xc))
281 
282  ! *** calculate the hartree potential on the total density ***
283  CALL auxbas_pw_pool%create_pw(rho1_tot_gspace)
284 
285  CALL qs_rho_get(rho1, rho_g=rho1_g)
286  CALL pw_copy(rho1_g(1), rho1_tot_gspace)
287  DO ispin = 2, nspins
288  CALL pw_axpy(rho1_g(ispin), rho1_tot_gspace)
289  END DO
290  IF (gapw) &
291  CALL pw_axpy(p_env%local_rho_set%rho0_mpole%rho0_s_gs, rho1_tot_gspace)
292 
293  IF (.NOT. (nspins == 1 .AND. lr_triplet)) THEN
294  CALL pw_poisson_solve(poisson_env, rho1_tot_gspace, &
295  energy_hartree, &
296  v_hartree_gspace)
297  CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
298  END IF
299 
300  CALL auxbas_pw_pool%give_back_pw(rho1_tot_gspace)
301 
302  ! *** calculate the xc potential ***
303  NULLIFY (rho1a)
304  IF (gapw_xc) THEN
305  rho0 => rho_xc
306  rho1a => rho1_xc
307  ELSE
308  rho0 => rho
309  rho1a => rho1
310  END IF
311 
312  deriv2_analytic = section_get_lval(xc_section, "2ND_DERIV_ANALYTICAL")
313  NULLIFY (v_xc_tau)
314  IF (deriv2_analytic) THEN
315  CALL qs_rho_get(rho1a, rho_r=rho1_r, tau_r=tau1_r)
316  CALL qs_fxc_analytic(rho0, rho1_r, tau1_r, xc_section, auxbas_pw_pool, lr_triplet, v_xc, v_xc_tau)
317  IF (gapw .OR. gapw_xc) THEN
318  CALL get_qs_env(qs_env, rho_atom_set=rho_atom_set)
319  rho1_atom_set => p_env%local_rho_set%rho_atom_set
320  CALL calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, xc_section, para_env, &
321  do_tddft=.false., do_triplet=lr_triplet)
322  END IF
323  ELSE
324  CALL qs_fxc_fdiff(ks_env, rho0, rho1a, xc_section, 6, lr_triplet, v_xc, v_xc_tau)
325  cpassert((.NOT. gapw) .AND. (.NOT. gapw_xc))
326  END IF
327 
328  v_rspace_new => v_xc
329  NULLIFY (v_xc)
330 
331  CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
332  DO ispin = 1, nspins
333  CALL pw_scale(v_rspace_new(ispin), v_rspace_new(ispin)%pw_grid%dvol)
334  IF (ASSOCIATED(v_xc_tau)) CALL pw_scale(v_xc_tau(ispin), v_xc_tau(ispin)%pw_grid%dvol)
335  END DO
336 
337  ! ADMM Correction
338  IF (dft_control%do_admm) THEN
339  IF (admm_env%aux_exch_func /= do_admm_aux_exch_func_none) THEN
340  IF (.NOT. ASSOCIATED(kpp1_env%deriv_set_admm)) THEN
341  cpassert(.NOT. lr_triplet)
342  xc_section_aux => admm_env%xc_section_aux
343  CALL get_admm_env(qs_env%admm_env, rho_aux_fit=rho_aux)
344  CALL qs_rho_get(rho_aux, rho_r=rho_r)
345  ALLOCATE (kpp1_env%deriv_set_admm, kpp1_env%rho_set_admm)
346  CALL xc_prep_2nd_deriv(kpp1_env%deriv_set_admm, kpp1_env%rho_set_admm, &
347  rho_r, auxbas_pw_pool, &
348  xc_section=xc_section_aux)
349  END IF
350  END IF
351  END IF
352 
353  !-------------------------------!
354  ! Add both hartree and xc terms !
355  !-------------------------------!
356  DO ispin = 1, nspins
357  CALL dbcsr_set(kpp1_env%v_ao(ispin)%matrix, 0.0_dp)
358 
359  IF (gapw_xc) THEN
360  ! XC and Hartree are integrated separatedly
361  ! XC uses the soft basis set only
362 
363  IF (nspins == 1) THEN
364 
365  IF (.NOT. (lr_triplet)) THEN
366  CALL pw_scale(v_rspace_new(1), 2.0_dp)
367  IF (ASSOCIATED(v_xc_tau)) CALL pw_scale(v_xc_tau(1), 2.0_dp)
368  END IF
369  CALL qs_rho_get(rho1, rho_ao=rho1_ao)
370  ! remove kpp1_env%v_ao and work directly on k_p_p1 ?
371  CALL integrate_v_rspace(v_rspace=v_rspace_new(ispin), &
372  pmat=rho1_ao(ispin), &
373  hmat=kpp1_env%v_ao(ispin), &
374  qs_env=qs_env, &
375  calculate_forces=.false., gapw=gapw_xc)
376 
377  IF (ASSOCIATED(v_xc_tau)) THEN
378  CALL integrate_v_rspace(v_rspace=v_xc_tau(ispin), &
379  pmat=rho1_ao(ispin), &
380  hmat=kpp1_env%v_ao(ispin), &
381  qs_env=qs_env, &
382  compute_tau=.true., &
383  calculate_forces=.false., gapw=gapw_xc)
384  END IF
385 
386  ! add hartree only for SINGLETS
387  IF (.NOT. lr_triplet) THEN
388  CALL pw_axpy(v_hartree_rspace, v_rspace_new(1), 2.0_dp, 0.0_dp)
389 
390  CALL integrate_v_rspace(v_rspace=v_rspace_new(ispin), &
391  pmat=rho_ao(ispin), &
392  hmat=kpp1_env%v_ao(ispin), &
393  qs_env=qs_env, &
394  calculate_forces=.false., gapw=gapw)
395  END IF
396  ELSE
397  ! remove kpp1_env%v_ao and work directly on k_p_p1 ?
398  CALL integrate_v_rspace(v_rspace=v_rspace_new(ispin), &
399  pmat=rho_ao(ispin), &
400  hmat=kpp1_env%v_ao(ispin), &
401  qs_env=qs_env, &
402  calculate_forces=.false., gapw=gapw_xc)
403 
404  IF (ASSOCIATED(v_xc_tau)) THEN
405  CALL integrate_v_rspace(v_rspace=v_xc_tau(ispin), &
406  pmat=rho_ao(ispin), &
407  hmat=kpp1_env%v_ao(ispin), &
408  qs_env=qs_env, &
409  compute_tau=.true., &
410  calculate_forces=.false., gapw=gapw_xc)
411  END IF
412 
413  CALL pw_copy(v_hartree_rspace, v_rspace_new(ispin))
414  CALL integrate_v_rspace(v_rspace=v_rspace_new(ispin), &
415  pmat=rho_ao(ispin), &
416  hmat=kpp1_env%v_ao(ispin), &
417  qs_env=qs_env, &
418  calculate_forces=.false., gapw=gapw)
419  END IF
420 
421  ELSE
422 
423  IF (nspins == 1) THEN
424  IF (.NOT. (lr_triplet)) THEN
425  CALL pw_scale(v_rspace_new(1), 2.0_dp)
426  IF (ASSOCIATED(v_xc_tau)) CALL pw_scale(v_xc_tau(1), 2.0_dp)
427  END IF
428  ! add hartree only for SINGLETS
429  !IF (res_etype == tddfpt_singlet) THEN
430  IF (.NOT. lr_triplet) THEN
431  CALL pw_axpy(v_hartree_rspace, v_rspace_new(1), 2.0_dp)
432  END IF
433  ELSE
434  CALL pw_axpy(v_hartree_rspace, v_rspace_new(ispin), 1.0_dp)
435  END IF
436 
437  IF (lrigpw) THEN
438  IF (ASSOCIATED(v_xc_tau)) &
439  cpabort("metaGGA-functionals not supported with LRI!")
440 
441  lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
442  CALL get_qs_env(qs_env, nkind=nkind)
443  DO ikind = 1, nkind
444  lri_v_int(ikind)%v_int = 0.0_dp
445  END DO
446  CALL integrate_v_rspace_one_center(v_rspace_new(ispin), qs_env, &
447  lri_v_int, .false., "LRI_AUX")
448  DO ikind = 1, nkind
449  CALL para_env%sum(lri_v_int(ikind)%v_int)
450  END DO
451  ALLOCATE (k1mat(1))
452  k1mat(1)%matrix => kpp1_env%v_ao(ispin)%matrix
453  IF (lri_env%exact_1c_terms) THEN
454  CALL integrate_v_rspace_diagonal(v_rspace_new(ispin), k1mat(1)%matrix, &
455  rho_ao(ispin)%matrix, qs_env, .false., "ORB")
456  END IF
457  CALL calculate_lri_ks_matrix(lri_env, lri_v_int, k1mat, atomic_kind_set)
458  DEALLOCATE (k1mat)
459  ELSE
460  CALL integrate_v_rspace(v_rspace=v_rspace_new(ispin), &
461  pmat=rho_ao(ispin), &
462  hmat=kpp1_env%v_ao(ispin), &
463  qs_env=qs_env, &
464  calculate_forces=.false., gapw=gapw)
465 
466  IF (ASSOCIATED(v_xc_tau)) THEN
467  CALL integrate_v_rspace(v_rspace=v_xc_tau(ispin), &
468  pmat=rho_ao(ispin), &
469  hmat=kpp1_env%v_ao(ispin), &
470  qs_env=qs_env, &
471  compute_tau=.true., &
472  calculate_forces=.false., gapw=gapw)
473  END IF
474  END IF
475 
476  END IF
477 
478  CALL dbcsr_copy(p_env%kpp1(ispin)%matrix, kpp1_env%v_ao(ispin)%matrix)
479  END DO
480 
481  IF (gapw) THEN
482  IF (.NOT. ((nspins == 1 .AND. lr_triplet))) THEN
483  CALL vh_1c_gg_integrals(qs_env, energy_hartree_1c, &
484  p_env%hartree_local%ecoul_1c, &
485  p_env%local_rho_set, &
486  para_env, tddft=.true., core_2nd=.true.)
487 
488  CALL integrate_vhg0_rspace(qs_env, v_hartree_rspace, para_env, &
489  calculate_forces=.false., &
490  local_rho_set=p_env%local_rho_set)
491  END IF
492  ! *** Add single atom contributions to the KS matrix ***
493  ! remap pointer
494  ns = SIZE(p_env%kpp1)
495  ksmat(1:ns, 1:1) => p_env%kpp1(1:ns)
496  ns = SIZE(rho_ao)
497  psmat(1:ns, 1:1) => rho_ao(1:ns)
498  CALL update_ks_atom(qs_env, ksmat, psmat, forces=.false., tddft=.true., &
499  rho_atom_external=p_env%local_rho_set%rho_atom_set)
500  ELSEIF (gapw_xc) THEN
501  ns = SIZE(p_env%kpp1)
502  ksmat(1:ns, 1:1) => p_env%kpp1(1:ns)
503  ns = SIZE(rho_ao)
504  psmat(1:ns, 1:1) => rho_ao(1:ns)
505  CALL update_ks_atom(qs_env, ksmat, psmat, forces=.false., tddft=.true., &
506  rho_atom_external=p_env%local_rho_set%rho_atom_set)
507  END IF
508 
509  ! KG embedding, contribution of kinetic energy functional to kernel
510  IF (dft_control%qs_control%do_kg .AND. .NOT. (lr_triplet .OR. gapw .OR. gapw_xc)) THEN
511  IF (qs_env%kg_env%tnadd_method == kg_tnadd_embed) THEN
512 
513  CALL qs_rho_get(rho1, rho_ao=rho1_ao)
514  alpha = 1.0_dp
515 
516  ekin_mol = 0.0_dp
517  CALL get_qs_env(qs_env, kg_env=kg_env)
518  CALL kg_ekin_subset(qs_env=qs_env, &
519  ks_matrix=p_env%kpp1, &
520  ekin_mol=ekin_mol, &
521  calc_force=.false., &
522  do_kernel=.true., &
523  pmat_ext=rho1_ao)
524  END IF
525  END IF
526 
527  CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
528  CALL auxbas_pw_pool%give_back_pw(v_hartree_rspace)
529  DO ispin = 1, nspins
530  CALL auxbas_pw_pool%give_back_pw(v_rspace_new(ispin))
531  END DO
532  DEALLOCATE (v_rspace_new)
533  IF (ASSOCIATED(v_xc_tau)) THEN
534  DO ispin = 1, nspins
535  CALL auxbas_pw_pool%give_back_pw(v_xc_tau(ispin))
536  END DO
537  DEALLOCATE (v_xc_tau)
538  END IF
539 
540  CALL timestop(handle)
541 
542  END SUBROUTINE apply_op_2_dft
543 
544 ! **************************************************************************************************
545 !> \brief ...
546 !> \param qs_env ...
547 !> \param p_env ...
548 ! **************************************************************************************************
549  SUBROUTINE apply_op_2_xtb(qs_env, p_env)
550  TYPE(qs_environment_type), POINTER :: qs_env
551  TYPE(qs_p_env_type) :: p_env
552 
553  CHARACTER(len=*), PARAMETER :: routinen = 'apply_op_2_xtb'
554 
555  INTEGER :: atom_a, handle, iatom, ikind, is, ispin, &
556  na, natom, natorb, nkind, ns, nsgf, &
557  nspins
558  INTEGER, DIMENSION(25) :: lao
559  INTEGER, DIMENSION(5) :: occ
560  LOGICAL :: lr_triplet
561  REAL(dp), ALLOCATABLE, DIMENSION(:) :: mcharge, mcharge1
562  REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: aocg, aocg1, charges, charges1
563  TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
564  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
565  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_p, matrix_p1, matrix_s
566  TYPE(dft_control_type), POINTER :: dft_control
567  TYPE(linres_control_type), POINTER :: linres_control
568  TYPE(mp_para_env_type), POINTER :: para_env
569  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
570  TYPE(pw_env_type), POINTER :: pw_env
571  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
572  TYPE(qs_kpp1_env_type), POINTER :: kpp1_env
573  TYPE(qs_rho_type), POINTER :: rho, rho1
574  TYPE(xtb_atom_type), POINTER :: xtb_kind
575 
576  CALL timeset(routinen, handle)
577 
578  cpassert(ASSOCIATED(p_env%kpp1_env))
579  cpassert(ASSOCIATED(p_env%kpp1))
580  kpp1_env => p_env%kpp1_env
581 
582  rho1 => p_env%rho1
583  cpassert(ASSOCIATED(rho1))
584 
585  CALL get_qs_env(qs_env=qs_env, &
586  pw_env=pw_env, &
587  para_env=para_env, &
588  rho=rho, &
589  linres_control=linres_control, &
590  dft_control=dft_control)
591 
592  CALL qs_rho_get(rho, rho_ao=rho_ao)
593 
594  lr_triplet = linres_control%lr_triplet
595  cpassert(.NOT. lr_triplet)
596 
597  nspins = SIZE(p_env%kpp1)
598 
599  DO ispin = 1, nspins
600  CALL dbcsr_set(p_env%kpp1(ispin)%matrix, 0.0_dp)
601  END DO
602 
603  IF (dft_control%qs_control%xtb_control%coulomb_interaction) THEN
604  ! Mulliken charges
605  CALL get_qs_env(qs_env, particle_set=particle_set, matrix_s_kp=matrix_s)
606  natom = SIZE(particle_set)
607  CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
608  CALL qs_rho_get(rho1, rho_ao_kp=matrix_p1)
609  ALLOCATE (mcharge(natom), charges(natom, 5))
610  ALLOCATE (mcharge1(natom), charges1(natom, 5))
611  charges = 0.0_dp
612  charges1 = 0.0_dp
613  CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
614  nkind = SIZE(atomic_kind_set)
615  CALL get_qs_kind_set(qs_kind_set, maxsgf=nsgf)
616  ALLOCATE (aocg(nsgf, natom))
617  aocg = 0.0_dp
618  ALLOCATE (aocg1(nsgf, natom))
619  aocg1 = 0.0_dp
620  CALL ao_charges(matrix_p, matrix_s, aocg, para_env)
621  CALL ao_charges(matrix_p1, matrix_s, aocg1, para_env)
622  DO ikind = 1, nkind
623  CALL get_atomic_kind(atomic_kind_set(ikind), natom=na)
624  CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
625  CALL get_xtb_atom_param(xtb_kind, natorb=natorb, lao=lao, occupation=occ)
626  DO iatom = 1, na
627  atom_a = atomic_kind_set(ikind)%atom_list(iatom)
628  charges(atom_a, :) = real(occ(:), kind=dp)
629  DO is = 1, natorb
630  ns = lao(is) + 1
631  charges(atom_a, ns) = charges(atom_a, ns) - aocg(is, atom_a)
632  charges1(atom_a, ns) = charges1(atom_a, ns) - aocg1(is, atom_a)
633  END DO
634  END DO
635  END DO
636  DEALLOCATE (aocg, aocg1)
637  DO iatom = 1, natom
638  mcharge(iatom) = sum(charges(iatom, :))
639  mcharge1(iatom) = sum(charges1(iatom, :))
640  END DO
641  ! Coulomb Kernel
642  CALL xtb_coulomb_hessian(qs_env, p_env%kpp1, charges1, mcharge1, mcharge)
643  !
644  DEALLOCATE (charges, mcharge, charges1, mcharge1)
645  END IF
646 
647  CALL timestop(handle)
648 
649  END SUBROUTINE apply_op_2_xtb
650 
651 ! **************************************************************************************************
652 !> \brief Update action of TDDFPT operator on trial vectors by adding exact-exchange term.
653 !> \param qs_env ...
654 !> \param p_env ...
655 !> \par History
656 !> * 11.2019 adapted from tddfpt_apply_hfx
657 ! **************************************************************************************************
658  SUBROUTINE apply_hfx(qs_env, p_env)
659  TYPE(qs_environment_type), POINTER :: qs_env
660  TYPE(qs_p_env_type) :: p_env
661 
662  CHARACTER(LEN=*), PARAMETER :: routinen = 'apply_hfx'
663 
664  INTEGER :: handle, ispin, nspins
665  LOGICAL :: do_hfx
666  REAL(kind=dp) :: alpha
667  TYPE(cp_logger_type), POINTER :: logger
668  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: h1_mat, matrix_s, rho1_ao, work
669  TYPE(dft_control_type), POINTER :: dft_control
670  TYPE(section_vals_type), POINTER :: hfx_section, input
671 
672  CALL timeset(routinen, handle)
673 
674  logger => cp_get_default_logger()
675 
676  CALL get_qs_env(qs_env=qs_env, &
677  input=input, &
678  matrix_s=matrix_s, &
679  dft_control=dft_control)
680  nspins = dft_control%nspins
681 
682  hfx_section => section_vals_get_subs_vals(input, "DFT%XC%HF")
683  CALL section_vals_get(hfx_section, explicit=do_hfx)
684 
685  IF (do_hfx) THEN
686 
687  IF (dft_control%do_admm) THEN
688  IF (dft_control%admm_control%purification_method /= do_admm_purify_none) THEN
689  cpabort("ADMM: Linear Response needs purification_method=none")
690  END IF
691  IF (dft_control%admm_control%scaling_model /= do_admm_exch_scaling_none) THEN
692  cpabort("ADMM: Linear Response needs scaling_model=none")
693  END IF
694  IF (dft_control%admm_control%method /= do_admm_basis_projection) THEN
695  cpabort("ADMM: Linear Response needs admm_method=basis_projection")
696  END IF
697  !
698  rho1_ao => p_env%p1_admm
699  h1_mat => p_env%kpp1_admm
700  ELSE
701  rho1_ao => p_env%p1
702  h1_mat => p_env%kpp1
703  END IF
704 
705  NULLIFY (work)
706  CALL dbcsr_allocate_matrix_set(work, nspins)
707  DO ispin = 1, nspins
708  ALLOCATE (work(ispin)%matrix)
709  CALL dbcsr_create(work(ispin)%matrix, template=h1_mat(ispin)%matrix)
710  CALL dbcsr_copy(work(ispin)%matrix, h1_mat(ispin)%matrix)
711  CALL dbcsr_set(work(ispin)%matrix, 0.0_dp)
712  END DO
713 
714  CALL hfx_matrix(work, rho1_ao, qs_env, hfx_section)
715 
716  alpha = 2.0_dp
717  IF (nspins == 2) alpha = 1.0_dp
718 
719  DO ispin = 1, nspins
720  CALL dbcsr_add(h1_mat(ispin)%matrix, work(ispin)%matrix, 1.0_dp, alpha)
721  END DO
722 
723  CALL dbcsr_deallocate_matrix_set(work)
724 
725  END IF
726 
727  CALL timestop(handle)
728 
729  END SUBROUTINE apply_hfx
730 
731 ! **************************************************************************************************
732 !> \brief Add the hfx contributions to the Hamiltonian
733 !>
734 !> \param matrix_ks ...
735 !> \param rho_ao ...
736 !> \param qs_env ...
737 !> \param hfx_sections ...
738 !> \param external_x_data ...
739 !> \param ex ...
740 !> \note
741 !> Simplified version of subroutine hfx_ks_matrix()
742 ! **************************************************************************************************
743  SUBROUTINE hfx_matrix(matrix_ks, rho_ao, qs_env, hfx_sections, external_x_data, ex)
744  TYPE(dbcsr_p_type), DIMENSION(:), TARGET :: matrix_ks, rho_ao
745  TYPE(qs_environment_type), POINTER :: qs_env
746  TYPE(section_vals_type), POINTER :: hfx_sections
747  TYPE(hfx_type), DIMENSION(:, :), OPTIONAL, TARGET :: external_x_data
748  REAL(kind=dp), OPTIONAL :: ex
749 
750  CHARACTER(LEN=*), PARAMETER :: routinen = 'hfx_matrix'
751 
752  INTEGER :: handle, irep, ispin, mspin, n_rep_hf, &
753  nspins
754  LOGICAL :: distribute_fock_matrix, &
755  hfx_treat_lsd_in_core, &
756  s_mstruct_changed
757  REAL(kind=dp) :: eh1, ehfx
758  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_ks_kp, rho_ao_kp
759  TYPE(dft_control_type), POINTER :: dft_control
760  TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
761  TYPE(mp_para_env_type), POINTER :: para_env
762 
763  CALL timeset(routinen, handle)
764 
765  NULLIFY (dft_control, para_env, matrix_ks_kp, rho_ao_kp, x_data)
766 
767  CALL get_qs_env(qs_env=qs_env, &
768  dft_control=dft_control, &
769  para_env=para_env, &
770  s_mstruct_changed=s_mstruct_changed, &
771  x_data=x_data)
772 
773  IF (PRESENT(external_x_data)) x_data => external_x_data
774 
775  cpassert(dft_control%nimages == 1)
776  nspins = dft_control%nspins
777 
778  CALL section_vals_get(hfx_sections, n_repetition=n_rep_hf)
779  CALL section_vals_val_get(hfx_sections, "TREAT_LSD_IN_CORE", l_val=hfx_treat_lsd_in_core, &
780  i_rep_section=1)
781 
782  CALL section_vals_get(hfx_sections, n_repetition=n_rep_hf)
783  distribute_fock_matrix = .true.
784 
785  mspin = 1
786  IF (hfx_treat_lsd_in_core) mspin = nspins
787 
788  matrix_ks_kp(1:nspins, 1:1) => matrix_ks(1:nspins)
789  rho_ao_kp(1:nspins, 1:1) => rho_ao(1:nspins)
790 
791  DO irep = 1, n_rep_hf
792  ehfx = 0.0_dp
793 
794  IF (x_data(irep, 1)%do_hfx_ri) THEN
795  CALL hfx_ri_update_ks(qs_env, x_data(irep, 1)%ri_data, matrix_ks_kp, ehfx, &
796  rho_ao=rho_ao_kp, geometry_did_change=s_mstruct_changed, &
797  nspins=nspins, hf_fraction=x_data(irep, 1)%general_parameter%fraction)
798 
799  ELSE
800 
801  DO ispin = 1, mspin
802  CALL integrate_four_center(qs_env, x_data, matrix_ks_kp, eh1, rho_ao_kp, hfx_sections, para_env, &
803  s_mstruct_changed, irep, distribute_fock_matrix, ispin=ispin)
804  ehfx = ehfx + eh1
805  END DO
806 
807  END IF
808  END DO
809 
810  ! Export energy
811  IF (PRESENT(ex)) ex = ehfx
812 
813  CALL timestop(handle)
814 
815  END SUBROUTINE hfx_matrix
816 
817 ! **************************************************************************************************
818 !> \brief ...
819 !> \param qs_env ...
820 !> \param p_env ...
821 ! **************************************************************************************************
822  SUBROUTINE apply_xc_admm(qs_env, p_env)
823  TYPE(qs_environment_type), POINTER :: qs_env
824  TYPE(qs_p_env_type) :: p_env
825 
826  CHARACTER(len=*), PARAMETER :: routinen = 'apply_xc_admm'
827 
828  CHARACTER(LEN=default_string_length) :: basis_type
829  INTEGER :: handle, ispin, ns, nspins
830  INTEGER, DIMENSION(2, 3) :: bo
831  LOGICAL :: gapw, lsd
832  REAL(kind=dp) :: alpha
833  TYPE(admm_type), POINTER :: admm_env
834  TYPE(dbcsr_p_type) :: xcmat
835  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
836  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: ksmat, psmat
837  TYPE(dft_control_type), POINTER :: dft_control
838  TYPE(linres_control_type), POINTER :: linres_control
839  TYPE(mp_para_env_type), POINTER :: para_env
840  TYPE(neighbor_list_set_p_type), DIMENSION(:), &
841  POINTER :: sab_aux_fit
842  TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho1_aux_g
843  TYPE(pw_env_type), POINTER :: pw_env
844  TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
845  TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho1_aux_r, tau_pw, v_xc, v_xc_tau
846  TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho1_atom_set, rho_atom_set
847  TYPE(section_vals_type), POINTER :: xc_fun_section, xc_section
848  TYPE(task_list_type), POINTER :: task_list
849  TYPE(xc_rho_cflags_type) :: needs
850  TYPE(xc_rho_set_type) :: rho1_set
851 
852  CALL timeset(routinen, handle)
853 
854  CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
855 
856  IF (dft_control%do_admm) THEN
857  IF (qs_env%admm_env%aux_exch_func == do_admm_aux_exch_func_none) THEN
858  ! nothing to do
859  ELSE
860  CALL get_qs_env(qs_env=qs_env, linres_control=linres_control)
861  cpassert(.NOT. dft_control%qs_control%lrigpw)
862  cpassert(.NOT. linres_control%lr_triplet)
863 
864  nspins = dft_control%nspins
865 
866  ! AUX basis contribution
867  CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
868  cpassert(ASSOCIATED(pw_env))
869  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
870  NULLIFY (tau_pw)
871  ! calculate the xc potential
872  lsd = (nspins == 2)
873  CALL get_admm_env(qs_env%admm_env, matrix_s_aux_fit=matrix_s)
874  ALLOCATE (xcmat%matrix)
875  CALL dbcsr_create(xcmat%matrix, template=matrix_s(1)%matrix)
876 
877  CALL get_qs_env(qs_env, admm_env=admm_env)
878  gapw = admm_env%do_gapw
879 
880  CALL qs_rho_get(p_env%rho1_admm, rho_r=rho1_aux_r, rho_g=rho1_aux_g)
881  xc_section => admm_env%xc_section_aux
882  bo = rho1_aux_r(1)%pw_grid%bounds_local
883  ! create the place where to store the argument for the functionals
884  CALL xc_rho_set_create(rho1_set, bo, &
885  rho_cutoff=section_get_rval(xc_section, "DENSITY_CUTOFF"), &
886  drho_cutoff=section_get_rval(xc_section, "GRADIENT_CUTOFF"), &
887  tau_cutoff=section_get_rval(xc_section, "TAU_CUTOFF"))
888 
889  xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
890  needs = xc_functionals_get_needs(xc_fun_section, lsd, .true.)
891 
892  ! calculate the arguments needed by the functionals
893  CALL xc_rho_set_update(rho1_set, rho1_aux_r, rho1_aux_g, tau_pw, needs, &
894  section_get_ival(xc_section, "XC_GRID%XC_DERIV"), &
895  section_get_ival(xc_section, "XC_GRID%XC_SMOOTH_RHO"), &
896  auxbas_pw_pool)
897  CALL xc_calc_2nd_deriv(v_xc, v_xc_tau, p_env%kpp1_env%deriv_set_admm, p_env%kpp1_env%rho_set_admm, &
898  rho1_aux_r, rho1_aux_g, tau_pw, auxbas_pw_pool, gapw=.false., &
899  xc_section=xc_section)
900  IF (ASSOCIATED(v_xc_tau)) THEN
901  cpabort("Meta-GGA ADMM functionals not yet supported!")
902  END IF
903  CALL xc_rho_set_release(rho1_set)
904 
905  basis_type = "AUX_FIT"
906  CALL get_qs_env(qs_env, para_env=para_env)
907  CALL get_admm_env(admm_env, task_list_aux_fit=task_list)
908  IF (admm_env%do_gapw) THEN
909  CALL prepare_gapw_den(qs_env, local_rho_set=p_env%local_rho_set_admm, &
910  do_rho0=.false., kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
911  rho_atom_set => admm_env%admm_gapw_env%local_rho_set%rho_atom_set
912  rho1_atom_set => p_env%local_rho_set_admm%rho_atom_set
913  CALL calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, xc_section, para_env, &
914  kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
915  basis_type = "AUX_FIT_SOFT"
916  task_list => admm_env%admm_gapw_env%task_list
917  END IF
918 
919  alpha = 1.0_dp
920  IF (nspins == 1) alpha = 2.0_dp
921 
922  DO ispin = 1, nspins
923  CALL pw_scale(v_xc(ispin), v_xc(ispin)%pw_grid%dvol)
924  CALL dbcsr_copy(xcmat%matrix, matrix_s(1)%matrix)
925  CALL dbcsr_set(xcmat%matrix, 0.0_dp)
926  CALL integrate_v_rspace(v_rspace=v_xc(ispin), hmat=xcmat, qs_env=qs_env, &
927  calculate_forces=.false., basis_type=basis_type, &
928  task_list_external=task_list)
929  CALL dbcsr_add(p_env%kpp1_admm(ispin)%matrix, xcmat%matrix, 1.0_dp, alpha)
930  END DO
931 
932  IF (admm_env%do_gapw) THEN
933  CALL get_admm_env(admm_env, sab_aux_fit=sab_aux_fit)
934  ns = SIZE(p_env%kpp1_admm)
935  ksmat(1:ns, 1:1) => p_env%kpp1_admm(1:ns)
936  psmat(1:ns, 1:1) => p_env%p1_admm(1:ns)
937  CALL update_ks_atom(qs_env, ksmat, psmat, forces=.false., tddft=.true., &
938  rho_atom_external=p_env%local_rho_set_admm%rho_atom_set, &
939  kind_set_external=admm_env%admm_gapw_env%admm_kind_set, &
940  oce_external=admm_env%admm_gapw_env%oce, &
941  sab_external=sab_aux_fit)
942  END IF
943 
944  DO ispin = 1, nspins
945  CALL auxbas_pw_pool%give_back_pw(v_xc(ispin))
946  END DO
947  DEALLOCATE (v_xc)
948  CALL dbcsr_deallocate_matrix(xcmat%matrix)
949 
950  END IF
951  END IF
952 
953  CALL timestop(handle)
954 
955  END SUBROUTINE apply_xc_admm
956 
957 END MODULE qs_linres_kernel
Types and set/get functions for auxiliary density matrix methods.
Definition: admm_types.F:15
subroutine, public get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, rho_aux_fit_buffer, admm_dm)
Get routine for the ADMM env.
Definition: admm_types.F:593
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
represent a full matrix distributed on many processors
Definition: cp_fm_types.F:15
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
Definition: cp_fm_types.F:1016
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
subroutine, public vh_1c_gg_integrals(qs_env, energy_hartree_1c, ecoul_1c, local_rho_set, para_env, tddft, local_rho_set_2nd, core_2nd)
Calculates one center GAPW Hartree energies and matrix elements Hartree potentials are input Takes po...
Routines to calculate HFX energy and potential.
subroutine, public integrate_four_center(qs_env, x_data, ks_matrix, ehfx, rho_ao, hfx_section, para_env, geometry_did_change, irep, distribute_fock_matrix, ispin)
computes four center integrals for a full basis set and updates the Kohn-Sham-Matrix and energy....
RI-methods for HFX.
Definition: hfx_ri.F:12
subroutine, public hfx_ri_update_ks(qs_env, ri_data, ks_matrix, ehfx, mos, rho_ao, geometry_did_change, nspins, hf_fraction)
...
Definition: hfx_ri.F:1033
Types and set/get functions for HFX.
Definition: hfx_types.F:15
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_admm_purify_none
integer, parameter, public kg_tnadd_embed
integer, parameter, public do_admm_basis_projection
integer, parameter, public do_admm_aux_exch_func_none
integer, parameter, public do_admm_exch_scaling_none
objects that represent the structure of input sections and the data contained in an input section
real(kind=dp) function, public section_get_rval(section_vals, keyword_name)
...
integer function, public section_get_ival(section_vals, keyword_name)
...
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
logical function, public section_get_lval(section_vals, keyword_name)
...
Routines for a Kim-Gordon-like partitioning into molecular subunits.
Definition: kg_correction.F:14
subroutine, public kg_ekin_subset(qs_env, ks_matrix, ekin_mol, calc_force, do_kernel, pmat_ext)
Calculates the subsystem Hohenberg-Kohn kinetic energy and the forces.
Definition: kg_correction.F:88
Types needed for a Kim-Gordon-like partitioning into molecular subunits.
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
integer, parameter, public default_string_length
Definition: kinds.F:57
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
routines that build the Kohn-Sham matrix for the LRIGPW and xc parts
subroutine, public calculate_lri_ks_matrix(lri_env, lri_v_int, h_matrix, atomic_kind_set, cell_to_index)
update of LRIGPW KS matrix
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Definition: mulliken.F:13
Define the data structure for the particle information.
container for various plainwaves related things
Definition: pw_env_types.F:14
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Definition: pw_env_types.F:113
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Definition: pw_pool_types.F:24
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, WannierCentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
https://en.wikipedia.org/wiki/Finite_difference_coefficient
Definition: qs_fxc.F:27
subroutine, public qs_fxc_analytic(rho0, rho1_r, tau1_r, xc_section, auxbas_pw_pool, is_triplet, v_xc, v_xc_tau)
...
Definition: qs_fxc.F:85
subroutine, public qs_fxc_fdiff(ks_env, rho0_struct, rho1_struct, xc_section, accuracy, is_triplet, fxc_rho, fxc_tau)
...
Definition: qs_fxc.F:146
subroutine, public prepare_gapw_den(qs_env, local_rho_set, do_rho0, kind_set_external)
...
Integrate single or product functions over a potential on a RS grid.
Define the quickstep kind type and their sub types.
Definition: qs_kind_types.F:23
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_r3d_rs_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, U_of_dft_plus_u, J_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr)
Get attributes of an atomic kind set.
basis types for the calculation of the perturbation of density theory.
routines that build the Kohn-Sham matrix contributions coming from local atomic densities
Definition: qs_ks_atom.F:12
subroutine, public update_ks_atom(qs_env, ksmat, pmat, forces, tddft, rho_atom_external, kind_set_external, oce_external, sab_external, kscale, kintegral, kforce, fscale)
The correction to the KS matrix due to the GAPW local terms to the hartree and XC contributions is he...
Definition: qs_ks_atom.F:110
linres kernel functions
subroutine, public apply_xc_admm(qs_env, p_env)
...
subroutine, public hfx_matrix(matrix_ks, rho_ao, qs_env, hfx_sections, external_x_data, ex)
Add the hfx contributions to the Hamiltonian.
subroutine, public apply_hfx(qs_env, p_env)
Update action of TDDFPT operator on trial vectors by adding exact-exchange term.
subroutine, public apply_op_2(qs_env, p_env, c0, Av)
...
Type definitiona for linear response calculations.
Define the neighbor list data types and the corresponding functionality.
Utility functions for the perturbation calculations.
subroutine, public p_env_finish_kpp1(qs_env, p_env)
...
basis types for the calculation of the perturbation of density theory.
subroutine, public integrate_vhg0_rspace(qs_env, v_rspace, para_env, calculate_forces, local_rho_set, local_rho_set_2nd, atener, kforce)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
Definition: qs_rho_types.F:18
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Definition: qs_rho_types.F:229
routines that build the integrals of the Vxc potential calculated for the atomic density in the basis...
Definition: qs_vxc_atom.F:12
subroutine, public calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, xc_section, para_env, do_tddft, do_tddfpt2, do_triplet, kind_set_external)
...
Definition: qs_vxc_atom.F:446
types for task lists
type(xc_rho_cflags_type) function, public xc_functionals_get_needs(functionals, lsd, calc_potential)
...
contains the structure
contains the structure
subroutine, public xc_rho_set_update(rho_set, rho_r, rho_g, tau, needs, xc_deriv_method_id, xc_rho_smooth_id, pw_pool)
updates the given rho set with the density given by rho_r (and rho_g). The rho set will contain the c...
subroutine, public xc_rho_set_create(rho_set, local_bounds, rho_cutoff, drho_cutoff, tau_cutoff)
allocates and does (minimal) initialization of a rho_set
subroutine, public xc_rho_set_release(rho_set, pw_pool)
releases the given rho_set
Exchange and Correlation functional calculations.
Definition: xc.F:17
subroutine, public xc_calc_2nd_deriv(v_xc, v_xc_tau, deriv_set, rho_set, rho1_r, rho1_g, tau1_r, pw_pool, xc_section, gapw, vxg, lsd_singlets, do_excitations, do_triplet, do_tddft, compute_virial, virial_xc)
Caller routine to calculate the second order potential in the direction of rho1_r.
Definition: xc.F:1523
subroutine, public xc_prep_2nd_deriv(deriv_set, rho_set, rho_r, pw_pool, xc_section, tau_r)
Prepare objects for the calculation of the 2nd derivatives of the density functional....
Definition: xc.F:5364
Calculation of Coulomb Hessian contributions in xTB.
Definition: xtb_ehess.F:12
subroutine, public xtb_coulomb_hessian(qs_env, ks_matrix, charges1, mcharge1, mcharge)
...
Definition: xtb_ehess.F:77
Definition of the xTB parameter types.
Definition: xtb_types.F:20
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, occupation, electronegativity, chmax)
...
Definition: xtb_types.F:175