(git:03cdb6f)
Loading...
Searching...
No Matches
qs_tddfpt2_fhxc.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
9 USE admm_types, ONLY: admm_type
12 USE cp_dbcsr_api, ONLY: &
14 dbcsr_p_type, dbcsr_release, dbcsr_set, dbcsr_type, dbcsr_type_symmetric
19 USE cp_fm_types, ONLY: cp_fm_create,&
27 USE kinds, ONLY: default_string_length,&
28 dp
32 USE pw_env_types, ONLY: pw_env_get
33 USE pw_methods, ONLY: pw_axpy,&
34 pw_scale,&
37 USE pw_types, ONLY: pw_c1d_gs_type,&
42 USE qs_integrate_potential, ONLY: integrate_v_rspace,&
43 integrate_v_rspace_one_center
45 USE qs_ks_atom, ONLY: update_ks_atom
49 USE qs_rho_types, ONLY: qs_rho_get
61#include "./base/base_uses.f90"
62
63 IMPLICIT NONE
64
65 PRIVATE
66
67 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_tddfpt2_fhxc'
68
69 INTEGER, PARAMETER, PRIVATE :: maxspins = 2
70
71 PUBLIC :: fhxc_kernel, stda_kernel
72
73! **************************************************************************************************
74
75CONTAINS
76
77! **************************************************************************************************
78!> \brief Compute action matrix-vector products with the FHxc Kernel
79!> \param Aop_evects action of TDDFPT operator on trial vectors (modified on exit)
80!> \param evects TDDFPT trial vectors
81!> \param is_rks_triplets indicates that a triplet excited states calculation using
82!> spin-unpolarised molecular orbitals has been requested
83!> \param do_hfx flag that activates computation of exact-exchange terms
84!> \param do_admm ...
85!> \param qs_env Quickstep environment
86!> \param kernel_env kernel environment
87!> \param kernel_env_admm_aux kernel environment for ADMM correction
88!> \param sub_env parallel (sub)group environment
89!> \param work_matrices collection of work matrices (modified on exit)
90!> \param admm_symm use symmetric definition of ADMM kernel correction
91!> \param admm_xc_correction use ADMM XC kernel correction
92!> \param do_lrigpw ...
93!> \param tddfpt_mgrid ...
94!> \par History
95!> * 06.2016 created [Sergey Chulkov]
96!> * 03.2017 refactored [Sergey Chulkov]
97!> * 04.2019 refactored [JHU]
98! **************************************************************************************************
99 SUBROUTINE fhxc_kernel(Aop_evects, evects, is_rks_triplets, &
100 do_hfx, do_admm, qs_env, kernel_env, kernel_env_admm_aux, &
101 sub_env, work_matrices, admm_symm, admm_xc_correction, do_lrigpw, &
102 tddfpt_mgrid)
103 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(INOUT) :: aop_evects
104 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(IN) :: evects
105 LOGICAL, INTENT(in) :: is_rks_triplets, do_hfx, do_admm
106 TYPE(qs_environment_type), POINTER :: qs_env
107 TYPE(full_kernel_env_type), POINTER :: kernel_env, kernel_env_admm_aux
108 TYPE(tddfpt_subgroup_env_type), INTENT(in) :: sub_env
109 TYPE(tddfpt_work_matrices), INTENT(inout) :: work_matrices
110 LOGICAL, INTENT(in) :: admm_symm, admm_xc_correction, &
111 do_lrigpw, tddfpt_mgrid
112
113 CHARACTER(LEN=*), PARAMETER :: routinen = 'fhxc_kernel'
114
115 CHARACTER(LEN=default_string_length) :: basis_type
116 INTEGER :: handle, ikind, ispin, ivect, nao, &
117 nao_aux, nkind, nspins, nvects, &
118 spinflip
119 INTEGER, DIMENSION(:), POINTER :: blk_sizes
120 INTEGER, DIMENSION(maxspins) :: nactive
121 LOGICAL :: do_noncol, gapw, gapw_xc
122 TYPE(admm_type), POINTER :: admm_env
123 TYPE(cp_fm_type) :: work_aux_orb, work_orb_orb
124 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: a_xc_munu_sub, rho_ia_ao, &
125 rho_ia_ao_aux_fit
126 TYPE(dbcsr_type), POINTER :: dbwork
127 TYPE(dft_control_type), POINTER :: dft_control
128 TYPE(lri_kind_type), DIMENSION(:), POINTER :: lri_v_int
129 TYPE(mp_para_env_type), POINTER :: para_env
130 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_ia_g, rho_ia_g_aux_fit
131 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
132 TYPE(pw_r3d_rs_type), ALLOCATABLE, DIMENSION(:) :: v_rspace_sub
133 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_ia_r, rho_ia_r_aux_fit
134 TYPE(pw_r3d_rs_type), POINTER :: weights
135 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho1_atom_set, rho_atom_set
136 TYPE(task_list_type), POINTER :: task_list
137
138 CALL timeset(routinen, handle)
139
140 nspins = SIZE(evects, 1)
141 nvects = SIZE(evects, 2)
142 IF (do_admm) THEN
143 cpassert(do_hfx)
144 cpassert(ASSOCIATED(sub_env%admm_A))
145 END IF
146 CALL get_qs_env(qs_env, dft_control=dft_control)
147
148 gapw = dft_control%qs_control%gapw
149 gapw_xc = dft_control%qs_control%gapw_xc
150 spinflip = dft_control%tddfpt2_control%spinflip
151
152 do_noncol = spinflip == tddfpt_sf_noncol
153
154 CALL cp_fm_get_info(evects(1, 1), nrow_global=nao)
155 DO ispin = 1, nspins
156 CALL cp_fm_get_info(evects(ispin, 1), ncol_global=nactive(ispin))
157 END DO
158
159 CALL qs_rho_get(work_matrices%rho_orb_struct_sub, rho_ao=rho_ia_ao, &
160 rho_g=rho_ia_g, rho_r=rho_ia_r)
161 IF (do_hfx .AND. do_admm) THEN
162 CALL get_qs_env(qs_env, admm_env=admm_env)
163 CALL qs_rho_get(work_matrices%rho_aux_fit_struct_sub, &
164 rho_ao=rho_ia_ao_aux_fit, rho_g=rho_ia_g_aux_fit, &
165 rho_r=rho_ia_r_aux_fit)
166 END IF
167
168 NULLIFY (weights)
169 CALL get_qs_env(qs_env, xcint_weights=weights)
170
171 DO ivect = 1, nvects
172
173 ! Transform TDDFT vectors to AO space and store them into rho_ia_ao
174 IF (ALLOCATED(work_matrices%evects_sub)) THEN
175 IF (ASSOCIATED(work_matrices%evects_sub(1, ivect)%matrix_struct)) THEN
176 DO ispin = 1, nspins
177 CALL dbcsr_set(rho_ia_ao(ispin)%matrix, 0.0_dp)
178 CALL cp_dbcsr_plus_fm_fm_t(rho_ia_ao(ispin)%matrix, &
179 matrix_v=sub_env%mos_active(ispin), &
180 matrix_g=work_matrices%evects_sub(ispin, ivect), &
181 ncol=nactive(ispin), symmetry_mode=1)
182 END DO
183 ELSE
184 ! skip trial vectors which are assigned to different parallel groups
185 cycle
186 END IF
187 ELSE
188 DO ispin = 1, nspins
189 CALL dbcsr_set(rho_ia_ao(ispin)%matrix, 0.0_dp)
190 CALL cp_dbcsr_plus_fm_fm_t(rho_ia_ao(ispin)%matrix, &
191 matrix_v=sub_env%mos_active(ispin), &
192 matrix_g=evects(ispin, ivect), &
193 ncol=nactive(ispin), symmetry_mode=1)
194 END DO
195 END IF
196
197 IF (do_lrigpw) THEN
198 CALL qs_rho_update_tddfpt(work_matrices%rho_orb_struct_sub, qs_env, &
199 pw_env_external=sub_env%pw_env, &
200 task_list_external=sub_env%task_list_orb, &
201 para_env_external=sub_env%para_env, &
202 tddfpt_lri_env=kernel_env%lri_env, &
203 tddfpt_lri_density=kernel_env%lri_density)
204 ELSEIF (dft_control%qs_control%lrigpw .OR. &
205 dft_control%qs_control%rigpw) THEN
206 CALL qs_rho_update_tddfpt(work_matrices%rho_orb_struct_sub, qs_env, &
207 pw_env_external=sub_env%pw_env, &
208 task_list_external=sub_env%task_list_orb, &
209 para_env_external=sub_env%para_env)
210 ELSE
211 IF (gapw) THEN
212 CALL qs_rho_update_rho(work_matrices%rho_orb_struct_sub, qs_env, &
213 local_rho_set=work_matrices%local_rho_set, &
214 pw_env_external=sub_env%pw_env, &
215 task_list_external=sub_env%task_list_orb_soft, &
216 para_env_external=sub_env%para_env)
217 CALL prepare_gapw_den(qs_env, work_matrices%local_rho_set, &
218 do_rho0=(.NOT. is_rks_triplets), pw_env_sub=sub_env%pw_env)
219 ELSEIF (gapw_xc) THEN
220 CALL qs_rho_update_rho(work_matrices%rho_orb_struct_sub, qs_env, &
221 rho_xc_external=work_matrices%rho_xc_struct_sub, &
222 local_rho_set=work_matrices%local_rho_set, &
223 pw_env_external=sub_env%pw_env, &
224 task_list_external=sub_env%task_list_orb, &
225 task_list_external_soft=sub_env%task_list_orb_soft, &
226 para_env_external=sub_env%para_env)
227 CALL prepare_gapw_den(qs_env, work_matrices%local_rho_set, do_rho0=.false., &
228 pw_env_sub=sub_env%pw_env)
229 ELSE
230 CALL qs_rho_update_rho(work_matrices%rho_orb_struct_sub, qs_env, &
231 pw_env_external=sub_env%pw_env, &
232 task_list_external=sub_env%task_list_orb, &
233 para_env_external=sub_env%para_env)
234 END IF
235 END IF
236
237 DO ispin = 1, nspins
238 CALL dbcsr_set(work_matrices%A_ia_munu_sub(ispin)%matrix, 0.0_dp)
239 END DO
240
241 ! electron-hole exchange-correlation interaction
242 DO ispin = 1, nspins
243 CALL pw_zero(work_matrices%A_ia_rspace_sub(ispin))
244 END DO
245
246 ! Skip kernel if collinear xc-kernel for spin-flip is requested
247 IF (spinflip /= tddfpt_sf_col) THEN
248 IF ((.NOT. dft_control%tddfpt2_control%do_bse) .AND. (.NOT. dft_control%tddfpt2_control%do_bse_w_only)) THEN
249 IF ((.NOT. dft_control%tddfpt2_control%do_bse_gw_only)) THEN
250 ! C_x d^{2}E_{x}^{DFT}[\rho] / d\rho^2
251 ! + C_{HF} d^{2}E_{x, ADMM}^{DFT}[\rho] / d\rho^2 in case of ADMM calculation
252 IF (gapw_xc) THEN
253 IF (kernel_env%do_exck) THEN
254 cpabort("NYA")
255 ELSE
256 CALL tddfpt_apply_xc(a_ia_rspace=work_matrices%A_ia_rspace_sub, kernel_env=kernel_env, &
257 rho_ia_struct=work_matrices%rho_xc_struct_sub, &
258 is_rks_triplets=is_rks_triplets, pw_env=sub_env%pw_env, &
259 weights=weights, &
260 work_v_xc=work_matrices%wpw_rspace_sub, &
261 work_v_xc_tau=work_matrices%wpw_tau_rspace_sub, &
262 spinflip=spinflip)
263 END IF
264 DO ispin = 1, nspins
265 CALL pw_scale(work_matrices%A_ia_rspace_sub(ispin), &
266 work_matrices%A_ia_rspace_sub(ispin)%pw_grid%dvol)
267 CALL integrate_v_rspace(v_rspace=work_matrices%A_ia_rspace_sub(ispin), &
268 hmat=work_matrices%A_ia_munu_sub(ispin), &
269 qs_env=qs_env, calculate_forces=.false., gapw=gapw_xc, &
270 pw_env_external=sub_env%pw_env, &
271 task_list_external=sub_env%task_list_orb_soft)
272 CALL pw_zero(work_matrices%A_ia_rspace_sub(ispin))
273 END DO
274 ELSE
275 IF (kernel_env%do_exck) THEN
276 CALL tddfpt_apply_xc_potential(work_matrices%A_ia_rspace_sub, work_matrices%fxc_rspace_sub, &
277 work_matrices%rho_orb_struct_sub, is_rks_triplets)
278 ELSE
279 CALL tddfpt_apply_xc(a_ia_rspace=work_matrices%A_ia_rspace_sub, kernel_env=kernel_env, &
280 rho_ia_struct=work_matrices%rho_orb_struct_sub, &
281 is_rks_triplets=is_rks_triplets, pw_env=sub_env%pw_env, &
282 weights=weights, &
283 work_v_xc=work_matrices%wpw_rspace_sub, &
284 work_v_xc_tau=work_matrices%wpw_tau_rspace_sub, &
285 spinflip=spinflip)
286 END IF
287 END IF
288 IF (gapw .OR. gapw_xc) THEN
289 rho_atom_set => sub_env%local_rho_set%rho_atom_set
290 rho1_atom_set => work_matrices%local_rho_set%rho_atom_set
291 CALL calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, kernel_env%xc_section, &
292 sub_env%para_env, do_tddfpt2=.true., do_triplet=is_rks_triplets, &
293 do_sf=do_noncol)
294 END IF
295
296 END IF ! do_bse
297 END IF ! do_bse
298 END IF ! spin-flip
299
300 ! ADMM correction
301 IF ((.NOT. dft_control%tddfpt2_control%do_bse) .AND. (.NOT. dft_control%tddfpt2_control%do_bse_w_only) &
302 .AND. (.NOT. dft_control%tddfpt2_control%do_bse_gw_only)) THEN
303 IF (do_admm .AND. admm_xc_correction) THEN
304 IF (dft_control%admm_control%aux_exch_func /= do_admm_aux_exch_func_none) THEN
305 CALL tddfpt_construct_aux_fit_density(rho_orb_struct=work_matrices%rho_orb_struct_sub, &
306 rho_aux_fit_struct=work_matrices%rho_aux_fit_struct_sub, &
307 local_rho_set=work_matrices%local_rho_set_admm, &
308 qs_env=qs_env, sub_env=sub_env, &
309 wfm_rho_orb=work_matrices%rho_ao_orb_fm_sub, &
310 wfm_rho_aux_fit=work_matrices%rho_ao_aux_fit_fm_sub, &
311 wfm_aux_orb=work_matrices%wfm_aux_orb_sub)
312 ! - C_{HF} d^{2}E_{x, ADMM}^{DFT}[\hat{\rho}] / d\hat{\rho}^2
313 IF (admm_symm) THEN
314 CALL dbcsr_get_info(rho_ia_ao_aux_fit(1)%matrix, row_blk_size=blk_sizes)
315 ALLOCATE (a_xc_munu_sub(nspins))
316 DO ispin = 1, nspins
317 ALLOCATE (a_xc_munu_sub(ispin)%matrix)
318 CALL dbcsr_create(matrix=a_xc_munu_sub(ispin)%matrix, name="ADMM_XC", &
319 dist=sub_env%dbcsr_dist, matrix_type=dbcsr_type_symmetric, &
320 row_blk_size=blk_sizes, col_blk_size=blk_sizes)
321 CALL cp_dbcsr_alloc_block_from_nbl(a_xc_munu_sub(ispin)%matrix, sub_env%sab_aux_fit)
322 CALL dbcsr_set(a_xc_munu_sub(ispin)%matrix, 0.0_dp)
323 END DO
324
325 CALL pw_env_get(sub_env%pw_env, auxbas_pw_pool=auxbas_pw_pool)
326 ALLOCATE (v_rspace_sub(nspins))
327 DO ispin = 1, nspins
328 CALL auxbas_pw_pool%create_pw(v_rspace_sub(ispin))
329 CALL pw_zero(v_rspace_sub(ispin))
330 END DO
331
332 IF (admm_env%do_gapw) THEN
333 basis_type = "AUX_FIT_SOFT"
334 task_list => sub_env%task_list_aux_fit_soft
335 ELSE
336 basis_type = "AUX_FIT"
337 task_list => sub_env%task_list_aux_fit
338 END IF
339
340 CALL tddfpt_apply_xc(a_ia_rspace=v_rspace_sub, &
341 kernel_env=kernel_env_admm_aux, &
342 rho_ia_struct=work_matrices%rho_aux_fit_struct_sub, &
343 is_rks_triplets=is_rks_triplets, pw_env=sub_env%pw_env, &
344 weights=weights, &
345 work_v_xc=work_matrices%wpw_rspace_sub, &
346 work_v_xc_tau=work_matrices%wpw_tau_rspace_sub, &
347 spinflip=spinflip)
348 DO ispin = 1, nspins
349 CALL pw_scale(v_rspace_sub(ispin), v_rspace_sub(ispin)%pw_grid%dvol)
350 CALL integrate_v_rspace(v_rspace=v_rspace_sub(ispin), &
351 hmat=a_xc_munu_sub(ispin), &
352 qs_env=qs_env, calculate_forces=.false., &
353 pw_env_external=sub_env%pw_env, &
354 basis_type=basis_type, &
355 task_list_external=task_list)
356 END DO
357 IF (admm_env%do_gapw) THEN
358 rho_atom_set => sub_env%local_rho_set_admm%rho_atom_set
359 rho1_atom_set => work_matrices%local_rho_set_admm%rho_atom_set
360 CALL calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, &
361 kernel_env_admm_aux%xc_section, &
362 sub_env%para_env, do_tddfpt2=.true., &
363 do_triplet=is_rks_triplets, do_sf=do_noncol, &
364 kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
365 CALL update_ks_atom(qs_env, a_xc_munu_sub, rho_ia_ao_aux_fit, forces=.false., tddft=.true., &
366 rho_atom_external=rho1_atom_set, &
367 kind_set_external=admm_env%admm_gapw_env%admm_kind_set, &
368 oce_external=admm_env%admm_gapw_env%oce, &
369 sab_external=sub_env%sab_aux_fit)
370 END IF
371 ALLOCATE (dbwork)
372 CALL dbcsr_create(dbwork, template=work_matrices%A_ia_munu_sub(1)%matrix)
373 CALL cp_fm_create(work_aux_orb, &
374 matrix_struct=work_matrices%wfm_aux_orb_sub%matrix_struct)
375 CALL cp_fm_create(work_orb_orb, &
376 matrix_struct=work_matrices%rho_ao_orb_fm_sub%matrix_struct)
377 CALL cp_fm_get_info(work_aux_orb, nrow_global=nao_aux, ncol_global=nao)
378 DO ispin = 1, nspins
379 CALL cp_dbcsr_sm_fm_multiply(a_xc_munu_sub(ispin)%matrix, sub_env%admm_A, &
380 work_aux_orb, nao)
381 CALL parallel_gemm('T', 'N', nao, nao, nao_aux, 1.0_dp, sub_env%admm_A, &
382 work_aux_orb, 0.0_dp, work_orb_orb)
383 CALL dbcsr_copy(dbwork, work_matrices%A_ia_munu_sub(1)%matrix)
384 CALL dbcsr_set(dbwork, 0.0_dp)
385 CALL copy_fm_to_dbcsr(work_orb_orb, dbwork, keep_sparsity=.true.)
386 CALL dbcsr_add(work_matrices%A_ia_munu_sub(ispin)%matrix, dbwork, 1.0_dp, 1.0_dp)
387 END DO
388 CALL dbcsr_release(dbwork)
389 DEALLOCATE (dbwork)
390 DO ispin = 1, nspins
391 CALL auxbas_pw_pool%give_back_pw(v_rspace_sub(ispin))
392 END DO
393 DEALLOCATE (v_rspace_sub)
394 CALL cp_fm_release(work_aux_orb)
395 CALL cp_fm_release(work_orb_orb)
396 DO ispin = 1, nspins
397 CALL dbcsr_deallocate_matrix(a_xc_munu_sub(ispin)%matrix)
398 END DO
399 DEALLOCATE (a_xc_munu_sub)
400 ELSE
401 CALL tddfpt_apply_xc(a_ia_rspace=work_matrices%A_ia_rspace_sub, &
402 kernel_env=kernel_env_admm_aux, &
403 rho_ia_struct=work_matrices%rho_aux_fit_struct_sub, &
404 is_rks_triplets=is_rks_triplets, pw_env=sub_env%pw_env, &
405 weights=weights, &
406 work_v_xc=work_matrices%wpw_rspace_sub, &
407 work_v_xc_tau=work_matrices%wpw_tau_rspace_sub, &
408 spinflip=spinflip)
409 IF (admm_env%do_gapw) THEN
410 cpwarn("GAPW/ADMM needs symmetric ADMM kernel")
411 cpabort("GAPW/ADMM@TDDFT")
412 END IF
413 END IF
414 END IF
415 END IF
416 END IF
417
418 ! electron-hole Coulomb interaction
419 IF (.NOT. dft_control%tddfpt2_control%do_bse_w_only) THEN
420 IF (.NOT. dft_control%tddfpt2_control%do_bse_gw_only) THEN
421 IF ((.NOT. is_rks_triplets) .AND. (spinflip == no_sf_tddfpt)) THEN
422 ! a sum J_i{alpha}a{alpha}_munu + J_i{beta}a{beta}_munu can be computed by solving
423 ! the Poisson equation for combined density (rho_{ia,alpha} + rho_{ia,beta}) .
424 ! The following action will destroy reciprocal-space grid in spin-unrestricted case.
425 DO ispin = 2, nspins
426 CALL pw_axpy(rho_ia_g(ispin), rho_ia_g(1))
427 END DO
428 CALL tddfpt_apply_coulomb(a_ia_rspace=work_matrices%A_ia_rspace_sub, &
429 rho_ia_g=rho_ia_g(1), &
430 local_rho_set=work_matrices%local_rho_set, &
431 hartree_local=work_matrices%hartree_local, &
432 qs_env=qs_env, sub_env=sub_env, gapw=gapw, &
433 work_v_gspace=work_matrices%wpw_gspace_sub(1), &
434 work_v_rspace=work_matrices%wpw_rspace_sub(1), &
435 tddfpt_mgrid=tddfpt_mgrid)
436 END IF
437
438 ! convert from the plane-wave representation into the Gaussian basis set representation
439 DO ispin = 1, nspins
440 IF (.NOT. do_lrigpw) THEN
441 CALL pw_scale(work_matrices%A_ia_rspace_sub(ispin), &
442 work_matrices%A_ia_rspace_sub(ispin)%pw_grid%dvol)
443
444 IF (gapw) THEN
445 CALL integrate_v_rspace(v_rspace=work_matrices%A_ia_rspace_sub(ispin), &
446 hmat=work_matrices%A_ia_munu_sub(ispin), &
447 qs_env=qs_env, calculate_forces=.false., gapw=gapw, &
448 pw_env_external=sub_env%pw_env, &
449 task_list_external=sub_env%task_list_orb_soft)
450 ELSEIF (gapw_xc) THEN
451 IF (.NOT. is_rks_triplets) THEN
452 CALL integrate_v_rspace(v_rspace=work_matrices%A_ia_rspace_sub(ispin), &
453 hmat=work_matrices%A_ia_munu_sub(ispin), &
454 qs_env=qs_env, calculate_forces=.false., gapw=.false., &
455 pw_env_external=sub_env%pw_env, task_list_external=sub_env%task_list_orb)
456 END IF
457 ELSE
458 CALL integrate_v_rspace(v_rspace=work_matrices%A_ia_rspace_sub(ispin), &
459 hmat=work_matrices%A_ia_munu_sub(ispin), &
460 qs_env=qs_env, calculate_forces=.false., gapw=.false., &
461 pw_env_external=sub_env%pw_env, task_list_external=sub_env%task_list_orb)
462 END IF
463 ELSE ! for full kernel using lri
464 CALL pw_scale(work_matrices%A_ia_rspace_sub(ispin), &
465 work_matrices%A_ia_rspace_sub(ispin)%pw_grid%dvol)
466 lri_v_int => kernel_env%lri_density%lri_coefs(ispin)%lri_kinds
467 CALL get_qs_env(qs_env, nkind=nkind, para_env=para_env)
468 DO ikind = 1, nkind
469 lri_v_int(ikind)%v_int = 0.0_dp
470 END DO
471 CALL integrate_v_rspace_one_center(work_matrices%A_ia_rspace_sub(ispin), &
472 qs_env, lri_v_int, .false., "P_LRI_AUX")
473 DO ikind = 1, nkind
474 CALL para_env%sum(lri_v_int(ikind)%v_int)
475 END DO
476 END IF ! for full kernel using lri
477 END DO
478
479 ! local atom contributions
480 IF (.NOT. do_lrigpw) THEN
481 IF (gapw .OR. gapw_xc) THEN
482 ! rho_ia_ao will not be touched
483 CALL update_ks_atom(qs_env, work_matrices%A_ia_munu_sub, rho_ia_ao, forces=.false., &
484 rho_atom_external=work_matrices%local_rho_set%rho_atom_set, &
485 tddft=.true.)
486 END IF
487 END IF
488
489 ! calculate Coulomb contribution to response vector for lrigpw !
490 ! this is restricting lri to Coulomb only at the moment !
491 IF (do_lrigpw .AND. (.NOT. is_rks_triplets)) THEN !
492 CALL tddfpt2_lri_amat(qs_env, sub_env, kernel_env%lri_env, lri_v_int, work_matrices%A_ia_munu_sub)
493 END IF
494
495 DO ispin = 1, nspins
496 IF (ALLOCATED(work_matrices%evects_sub)) THEN
497 CALL cp_dbcsr_sm_fm_multiply(work_matrices%A_ia_munu_sub(ispin)%matrix, &
498 sub_env%mos_active(ispin), &
499 work_matrices%Aop_evects_sub(ispin, ivect), &
500 ncol=nactive(ispin), alpha=1.0_dp, beta=0.0_dp)
501 ELSE
502 CALL cp_dbcsr_sm_fm_multiply(work_matrices%A_ia_munu_sub(ispin)%matrix, &
503 sub_env%mos_active(ispin), &
504 aop_evects(ispin, ivect), &
505 ncol=nactive(ispin), alpha=1.0_dp, beta=0.0_dp)
506 END IF
507 END DO
508 END IF
509 END IF
510 END DO
511
512 CALL timestop(handle)
513
514 END SUBROUTINE fhxc_kernel
515
516! **************************************************************************************************
517!> \brief Compute action matrix-vector products with the sTDA Kernel
518!> \param Aop_evects action of TDDFPT operator on trial vectors (modified on exit)
519!> \param evects TDDFPT trial vectors
520!> \param is_rks_triplets indicates that a triplet excited states calculation using
521!> spin-unpolarised molecular orbitals has been requested
522!> \param qs_env Quickstep environment
523!> \param stda_control control parameters for sTDA kernel
524!> \param stda_env ...
525!> \param sub_env parallel (sub)group environment
526!> \param work_matrices collection of work matrices (modified on exit)
527!> \par History
528!> * 04.2019 initial version [JHU]
529! **************************************************************************************************
530 SUBROUTINE stda_kernel(Aop_evects, evects, is_rks_triplets, &
531 qs_env, stda_control, stda_env, &
532 sub_env, work_matrices)
533
534 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(INOUT) :: aop_evects
535 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(IN) :: evects
536 LOGICAL, INTENT(in) :: is_rks_triplets
537 TYPE(qs_environment_type), POINTER :: qs_env
538 TYPE(stda_control_type) :: stda_control
539 TYPE(stda_env_type) :: stda_env
540 TYPE(tddfpt_subgroup_env_type) :: sub_env
541 TYPE(tddfpt_work_matrices), INTENT(inout) :: work_matrices
542
543 CHARACTER(LEN=*), PARAMETER :: routinen = 'stda_kernel'
544
545 INTEGER :: handle, ivect, nvects
546
547 CALL timeset(routinen, handle)
548
549 nvects = SIZE(evects, 2)
550
551 DO ivect = 1, nvects
552 IF (ALLOCATED(work_matrices%evects_sub)) THEN
553 IF (ASSOCIATED(work_matrices%evects_sub(1, ivect)%matrix_struct)) THEN
554 CALL stda_calculate_kernel(qs_env, stda_control, stda_env, sub_env, work_matrices, &
555 is_rks_triplets, work_matrices%evects_sub(:, ivect), &
556 work_matrices%Aop_evects_sub(:, ivect))
557 ELSE
558 ! skip trial vectors which are assigned to different parallel groups
559 cycle
560 END IF
561 ELSE
562 CALL stda_calculate_kernel(qs_env, stda_control, stda_env, sub_env, work_matrices, &
563 is_rks_triplets, evects(:, ivect), aop_evects(:, ivect))
564 END IF
565 END DO
566
567 CALL timestop(handle)
568
569 END SUBROUTINE stda_kernel
570
571! **************************************************************************************************
572
573END MODULE qs_tddfpt2_fhxc
Types and set/get functions for auxiliary density matrix methods.
Definition admm_types.F:15
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
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
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr 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
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp, nrow, ncol, set_zero)
creates a new full matrix with the given structure
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public tddfpt_sf_col
integer, parameter, public do_admm_aux_exch_func_none
integer, parameter, public tddfpt_sf_noncol
integer, parameter, public no_sf_tddfpt
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...
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
container for various plainwaves related things
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
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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, mimic, 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_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, 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, xcint_weights, 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, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_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, harris_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, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public prepare_gapw_den(qs_env, local_rho_set, do_rho0, kind_set_external, pw_env_sub)
...
Integrate single or product functions over a potential on a RS grid.
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
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_tddfpt(rho_struct, qs_env, pw_env_external, task_list_external, para_env_external, tddfpt_lri_env, tddfpt_lri_density)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
superstucture that hold various representations of the density and keeps track of which ones are vali...
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...
subroutine, public tddfpt_construct_aux_fit_density(rho_orb_struct, rho_aux_fit_struct, local_rho_set, qs_env, sub_env, wfm_rho_orb, wfm_rho_aux_fit, wfm_aux_orb)
Project a charge density expressed in primary basis set into the auxiliary basis set.
subroutine, public fhxc_kernel(aop_evects, evects, is_rks_triplets, do_hfx, do_admm, qs_env, kernel_env, kernel_env_admm_aux, sub_env, work_matrices, admm_symm, admm_xc_correction, do_lrigpw, tddfpt_mgrid)
Compute action matrix-vector products with the FHxc Kernel.
subroutine, public stda_kernel(aop_evects, evects, is_rks_triplets, qs_env, stda_control, stda_env, sub_env, work_matrices)
Compute action matrix-vector products with the sTDA Kernel.
subroutine, public tddfpt2_lri_amat(qs_env, sub_env, lri_env, lri_v_int, a_ia_munu_sub)
Calculate contribution to response vector for LRI.
subroutine, public tddfpt_apply_coulomb(a_ia_rspace, rho_ia_g, local_rho_set, hartree_local, qs_env, sub_env, gapw, work_v_gspace, work_v_rspace, tddfpt_mgrid)
Update v_rspace by adding coulomb term.
subroutine, public tddfpt_apply_xc(a_ia_rspace, kernel_env, rho_ia_struct, is_rks_triplets, pw_env, weights, work_v_xc, work_v_xc_tau, spinflip)
Driver routine for applying fxc (analyic vs. finite difference for testing.
subroutine, public tddfpt_apply_xc_potential(a_ia_rspace, fxc_rspace, rho_ia_struct, is_rks_triplets)
Routine for applying fxc potential.
Simplified Tamm Dancoff approach (sTDA).
Simplified Tamm Dancoff approach (sTDA).
subroutine, public stda_calculate_kernel(qs_env, stda_control, stda_env, sub_env, work, is_rks_triplets, x, res)
...Calculate the sTDA kernel contribution by contracting the Lowdin MO coefficients – transition char...
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_tddfpt2, do_triplet, do_sf, kind_set_external)
...
types for task lists
stores some data used in wavefunction fitting
Definition admm_types.F:120
represent a full matrix
stores all the informations relevant to an mpi environment
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Collection of variables required to evaluate adiabatic TDDFPT kernel.
Set of temporary ("work") matrices.