(git:e966546)
Loading...
Searching...
No Matches
qs_tddfpt2_operators.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 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
10 USE cell_types, ONLY: cell_type,&
11 pbc
13 USE cp_dbcsr_api, ONLY: &
16 dbcsr_release, dbcsr_set, dbcsr_type, dbcsr_type_no_symmetry
23 USE cp_fm_types, ONLY: cp_fm_create,&
31 USE hfx_types, ONLY: hfx_type
32 USE input_constants, ONLY: no_sf_tddfpt,&
37 USE kinds, ONLY: dp
41 USE pw_env_types, ONLY: pw_env_get,&
43 USE pw_methods, ONLY: pw_axpy,&
45 pw_scale,&
50 USE pw_pool_types, ONLY: pw_pool_p_type,&
52 USE pw_types, ONLY: pw_c1d_gs_type,&
59 USE qs_rho_types, ONLY: qs_rho_get,&
71#include "./base/base_uses.f90"
72
73 IMPLICIT NONE
74
75 PRIVATE
76
77 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_tddfpt2_operators'
78
79 LOGICAL, PARAMETER, PRIVATE :: debug_this_module = .false.
80 ! number of first derivative components (3: d/dx, d/dy, d/dz)
81 INTEGER, PARAMETER, PRIVATE :: nderivs = 3
82 INTEGER, PARAMETER, PRIVATE :: maxspins = 2
83
86
87! **************************************************************************************************
88
89CONTAINS
90
91! **************************************************************************************************
92!> \brief Apply orbital energy difference term:
93!> Aop_evects(spin,state) += KS(spin) * evects(spin,state) -
94!> S * evects(spin,state) * diag(evals_occ(spin))
95!> \param Aop_evects action of TDDFPT operator on trial vectors (modified on exit)
96!> \param evects trial vectors C_{1,i}
97!> \param S_evects S * C_{1,i}
98!> \param gs_mos molecular orbitals optimised for the ground state (only occupied orbital
99!> energies [component %evals_occ] are needed)
100!> \param matrix_ks Kohn-Sham matrix
101!> \param tddfpt_control ...
102!> \par History
103!> * 05.2016 initialise all matrix elements in one go [Sergey Chulkov]
104!> * 03.2017 renamed from tddfpt_init_energy_diff(), altered prototype [Sergey Chulkov]
105!> \note Based on the subroutine p_op_l1() which was originally created by
106!> Thomas Chassaing on 08.2002.
107! **************************************************************************************************
108 SUBROUTINE tddfpt_apply_energy_diff(Aop_evects, evects, S_evects, gs_mos, matrix_ks, tddfpt_control)
109 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(INOUT) :: aop_evects
110 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(IN) :: evects, s_evects
111 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
112 INTENT(in) :: gs_mos
113 TYPE(dbcsr_p_type), DIMENSION(:), INTENT(in) :: matrix_ks
114 TYPE(tddfpt2_control_type), INTENT(in), POINTER :: tddfpt_control
115
116 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_apply_energy_diff'
117
118 INTEGER :: handle, ispin, ivect, nactive, nao, &
119 nspins, nvects, spin2
120 TYPE(cp_fm_struct_type), POINTER :: matrix_struct
121 TYPE(cp_fm_type) :: hevec
122
123 CALL timeset(routinen, handle)
124
125 nspins = SIZE(evects, 1)
126 nvects = SIZE(evects, 2)
127
128 DO ispin = 1, SIZE(evects, 1)
129 CALL cp_fm_get_info(matrix=evects(ispin, 1), matrix_struct=matrix_struct, &
130 nrow_global=nao, ncol_global=nactive)
131 CALL cp_fm_create(hevec, matrix_struct)
132
133 IF (tddfpt_control%spinflip == no_sf_tddfpt) THEN
134 spin2 = ispin
135 ELSE
136 spin2 = 2
137 END IF
138
139 DO ivect = 1, nvects
140 CALL cp_dbcsr_sm_fm_multiply(matrix_ks(spin2)%matrix, evects(ispin, ivect), &
141 aop_evects(ispin, ivect), ncol=nactive, &
142 alpha=1.0_dp, beta=1.0_dp)
143
144 IF (ASSOCIATED(gs_mos(ispin)%evals_occ_matrix)) THEN
145 ! orbital energy correction: evals_occ_matrix is not a diagonal matrix
146 CALL parallel_gemm('N', 'N', nao, nactive, nactive, 1.0_dp, &
147 s_evects(ispin, ivect), gs_mos(ispin)%evals_occ_matrix, &
148 0.0_dp, hevec)
149 ELSE
150 CALL cp_fm_to_fm(s_evects(ispin, ivect), hevec)
151 CALL cp_fm_column_scale(hevec, gs_mos(ispin)%evals_occ)
152 END IF
153
154 ! KS * C1 - S * C1 * occupied_orbital_energies
155 CALL cp_fm_scale_and_add(1.0_dp, aop_evects(ispin, ivect), -1.0_dp, hevec)
156 END DO
157 CALL cp_fm_release(hevec)
158 END DO
159
160 CALL timestop(handle)
161
162 END SUBROUTINE tddfpt_apply_energy_diff
163
164! **************************************************************************************************
165!> \brief Update v_rspace by adding coulomb term.
166!> \param A_ia_rspace action of TDDFPT operator on the trial vector expressed in a plane wave
167!> representation (modified on exit)
168!> \param rho_ia_g response density in reciprocal space for the given trial vector
169!> \param local_rho_set ...
170!> \param hartree_local ...
171!> \param qs_env ...
172!> \param sub_env the full sub_environment needed for calculation
173!> \param gapw Flag indicating GAPW cacluation
174!> \param work_v_gspace work reciprocal-space grid to store Coulomb potential (modified on exit)
175!> \param work_v_rspace work real-space grid to store Coulomb potential (modified on exit)
176!> \param tddfpt_mgrid ...
177!> \par History
178!> * 05.2016 compute all coulomb terms in one go [Sergey Chulkov]
179!> * 03.2017 proceed excited states sequentially; minimise the number of conversions between
180!> DBCSR and FM matrices [Sergey Chulkov]
181!> * 06.2018 return the action expressed in the plane wave representation instead of the one
182!> in the atomic basis set representation
183!> \note Based on the subroutine kpp1_calc_k_p_p1() which was originally created by
184!> Mohamed Fawzi on 10.2002.
185! **************************************************************************************************
186 SUBROUTINE tddfpt_apply_coulomb(A_ia_rspace, rho_ia_g, local_rho_set, hartree_local, &
187 qs_env, sub_env, gapw, work_v_gspace, work_v_rspace, tddfpt_mgrid)
188 TYPE(pw_r3d_rs_type), DIMENSION(:), INTENT(INOUT) :: a_ia_rspace
189 TYPE(pw_c1d_gs_type), INTENT(INOUT) :: rho_ia_g
190 TYPE(local_rho_type), POINTER :: local_rho_set
191 TYPE(hartree_local_type), POINTER :: hartree_local
192 TYPE(qs_environment_type), POINTER :: qs_env
193 TYPE(tddfpt_subgroup_env_type), INTENT(in) :: sub_env
194 LOGICAL, INTENT(IN) :: gapw
195 TYPE(pw_c1d_gs_type), INTENT(INOUT) :: work_v_gspace
196 TYPE(pw_r3d_rs_type), INTENT(INOUT) :: work_v_rspace
197 LOGICAL, INTENT(IN) :: tddfpt_mgrid
198
199 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_apply_coulomb'
200
201 INTEGER :: handle, ispin, nspins
202 REAL(kind=dp) :: alpha, pair_energy
203 TYPE(pw_env_type), POINTER :: pw_env
204 TYPE(pw_poisson_type), POINTER :: poisson_env
205 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: my_pools
206 TYPE(realspace_grid_desc_p_type), DIMENSION(:), &
207 POINTER :: my_rs_descs
208 TYPE(realspace_grid_type), DIMENSION(:), POINTER :: my_rs_grids
209
210 CALL timeset(routinen, handle)
211
212 nspins = SIZE(a_ia_rspace)
213 pw_env => sub_env%pw_env
214 IF (tddfpt_mgrid) THEN
215 CALL pw_env_get(pw_env, poisson_env=poisson_env, rs_grids=my_rs_grids, &
216 rs_descs=my_rs_descs, pw_pools=my_pools)
217 ELSE
218 CALL pw_env_get(pw_env, poisson_env=poisson_env)
219 END IF
220
221 IF (nspins > 1) THEN
222 alpha = 1.0_dp
223 ELSE
224 ! spin-restricted case: alpha == 2 due to singlet state.
225 ! In case of triplet states alpha == 0, so we should not call this subroutine at all.
226 alpha = 2.0_dp
227 END IF
228
229 IF (gapw) THEN
230 cpassert(ASSOCIATED(local_rho_set))
231 CALL pw_axpy(local_rho_set%rho0_mpole%rho0_s_gs, rho_ia_g)
232 IF (ASSOCIATED(local_rho_set%rho0_mpole%rhoz_cneo_s_gs)) THEN
233 CALL pw_axpy(local_rho_set%rho0_mpole%rhoz_cneo_s_gs, rho_ia_g)
234 END IF
235 END IF
236
237 CALL pw_poisson_solve(poisson_env, rho_ia_g, pair_energy, work_v_gspace)
238 CALL pw_transfer(work_v_gspace, work_v_rspace)
239
240 ! (i a || j b) = ( i_alpha a_alpha + i_beta a_beta || j_alpha b_alpha + j_beta b_beta) =
241 ! tr (Cj_alpha^T * [J_i{alpha}a{alpha}_munu + J_i{beta}a{beta}_munu] * Cb_alpha) +
242 ! tr (Cj_beta^T * [J_i{alpha}a{alpha}_munu + J_i{beta}a{beta}_munu] * Cb_beta)
243 DO ispin = 1, nspins
244 CALL pw_axpy(work_v_rspace, a_ia_rspace(ispin), alpha)
245 END DO
246
247 IF (gapw) THEN
248 CALL vh_1c_gg_integrals(qs_env, pair_energy, &
249 hartree_local%ecoul_1c, &
250 local_rho_set, &
251 sub_env%para_env, tddft=.true., core_2nd=.true.)
252 CALL pw_scale(work_v_rspace, work_v_rspace%pw_grid%dvol)
253 IF (tddfpt_mgrid) THEN
254 CALL integrate_vhg0_rspace(qs_env, work_v_rspace, sub_env%para_env, &
255 calculate_forces=.false., &
256 local_rho_set=local_rho_set, my_pools=my_pools, &
257 my_rs_descs=my_rs_descs)
258 ELSE
259 CALL integrate_vhg0_rspace(qs_env, work_v_rspace, sub_env%para_env, &
260 calculate_forces=.false., &
261 local_rho_set=local_rho_set)
262 END IF
263 END IF
264
265 CALL timestop(handle)
266
267 END SUBROUTINE tddfpt_apply_coulomb
268
269! **************************************************************************************************
270!> \brief Driver routine for applying fxc (analyic vs. finite difference for testing
271!> \param A_ia_rspace action of TDDFPT operator on trial vectors expressed in a plane wave
272!> representation (modified on exit)
273!> \param kernel_env kernel environment
274!> \param rho_ia_struct response density for the given trial vector
275!> \param is_rks_triplets indicates that the triplet excited states calculation using
276!> spin-unpolarised molecular orbitals has been requested
277!> \param pw_env plain wave environment
278!> \param work_v_xc work real-space grid to store the gradient of the exchange-correlation
279!> potential with respect to the response density (modified on exit)
280!> \param work_v_xc_tau ...
281!> \param spinflip ...
282! **************************************************************************************************
283 SUBROUTINE tddfpt_apply_xc(A_ia_rspace, kernel_env, rho_ia_struct, is_rks_triplets, &
284 pw_env, work_v_xc, work_v_xc_tau, spinflip)
285
286 TYPE(pw_r3d_rs_type), DIMENSION(:), INTENT(INOUT) :: a_ia_rspace
287 TYPE(full_kernel_env_type), INTENT(IN) :: kernel_env
288 TYPE(qs_rho_type), POINTER :: rho_ia_struct
289 LOGICAL, INTENT(in) :: is_rks_triplets
290 TYPE(pw_env_type), POINTER :: pw_env
291 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: work_v_xc, work_v_xc_tau
292 INTEGER, INTENT(in), OPTIONAL :: spinflip
293
294 INTEGER :: ispin, my_spinflip, nspins
295
296 nspins = SIZE(a_ia_rspace)
297 my_spinflip = 0
298 IF (PRESENT(spinflip)) my_spinflip = spinflip
299
300 IF (kernel_env%deriv2_analytic) THEN
301 CALL tddfpt_apply_xc_analytic(kernel_env, rho_ia_struct, is_rks_triplets, my_spinflip, &
302 nspins, pw_env, work_v_xc, work_v_xc_tau)
303 ELSE
304 CALL tddfpt_apply_xc_fd(kernel_env, rho_ia_struct, is_rks_triplets, nspins, &
305 pw_env, work_v_xc, work_v_xc_tau)
306 END IF
307
308 DO ispin = 1, nspins
309 ! pw2 = pw2 + alpha * pw1
310 CALL pw_axpy(work_v_xc(ispin), a_ia_rspace(ispin), kernel_env%alpha)
311 END DO
312
313 END SUBROUTINE tddfpt_apply_xc
314
315! **************************************************************************************************
316!> \brief Routine for applying fxc potential
317!> \param A_ia_rspace action of TDDFPT operator on trial vectors expressed in a plane wave
318!> representation (modified on exit)
319!> \param fxc_rspace ...
320!> \param rho_ia_struct response density for the given trial vector
321!> \param is_rks_triplets ...
322! **************************************************************************************************
323 SUBROUTINE tddfpt_apply_xc_potential(A_ia_rspace, fxc_rspace, rho_ia_struct, is_rks_triplets)
324
325 TYPE(pw_r3d_rs_type), DIMENSION(:), INTENT(INOUT) :: a_ia_rspace
326 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rspace
327 TYPE(qs_rho_type), POINTER :: rho_ia_struct
328 LOGICAL, INTENT(in) :: is_rks_triplets
329
330 INTEGER :: nspins
331 REAL(kind=dp) :: alpha
332 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho1_r
333
334 nspins = SIZE(a_ia_rspace)
335
336 alpha = 1.0_dp
337
338 CALL qs_rho_get(rho_ia_struct, rho_r=rho1_r)
339
340 IF (nspins == 2) THEN
341 CALL pw_multiply(a_ia_rspace(1), fxc_rspace(1), rho1_r(1), alpha)
342 CALL pw_multiply(a_ia_rspace(1), fxc_rspace(2), rho1_r(2), alpha)
343 CALL pw_multiply(a_ia_rspace(2), fxc_rspace(3), rho1_r(2), alpha)
344 CALL pw_multiply(a_ia_rspace(2), fxc_rspace(2), rho1_r(1), alpha)
345 ELSE IF (is_rks_triplets) THEN
346 CALL pw_multiply(a_ia_rspace(1), fxc_rspace(1), rho1_r(1), alpha)
347 CALL pw_multiply(a_ia_rspace(1), fxc_rspace(2), rho1_r(1), -alpha)
348 ELSE
349 CALL pw_multiply(a_ia_rspace(1), fxc_rspace(1), rho1_r(1), alpha)
350 CALL pw_multiply(a_ia_rspace(1), fxc_rspace(2), rho1_r(1), alpha)
351 END IF
352
353 END SUBROUTINE tddfpt_apply_xc_potential
354
355! **************************************************************************************************
356!> \brief Update A_ia_munu by adding exchange-correlation term.
357!> \param kernel_env kernel environment
358!> \param rho_ia_struct response density for the given trial vector
359!> \param is_rks_triplets indicates that the triplet excited states calculation using
360!> spin-unpolarised molecular orbitals has been requested
361!> \param spinflip ...
362!> \param nspins ...
363!> \param pw_env plain wave environment
364!> \param work_v_xc work real-space grid to store the gradient of the exchange-correlation
365!> potential with respect to the response density (modified on exit)
366!> \param work_v_xc_tau ...
367!> \par History
368!> * 05.2016 compute all kernel terms in one go [Sergey Chulkov]
369!> * 03.2017 proceed excited states sequentially; minimise the number of conversions between
370!> DBCSR and FM matrices [Sergey Chulkov]
371!> * 06.2018 return the action expressed in the plane wave representation instead of the one
372!> in the atomic basis set representation
373!> \note Based on the subroutine kpp1_calc_k_p_p1() which was originally created by
374!> Mohamed Fawzi on 10.2002.
375! **************************************************************************************************
376 SUBROUTINE tddfpt_apply_xc_analytic(kernel_env, rho_ia_struct, is_rks_triplets, spinflip, &
377 nspins, pw_env, work_v_xc, work_v_xc_tau)
378 TYPE(full_kernel_env_type), INTENT(in) :: kernel_env
379 TYPE(qs_rho_type), POINTER :: rho_ia_struct
380 LOGICAL, INTENT(in) :: is_rks_triplets
381 INTEGER, INTENT(in) :: spinflip, nspins
382 TYPE(pw_env_type), POINTER :: pw_env
383 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: work_v_xc, work_v_xc_tau
384
385 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_apply_xc_analytic'
386
387 INTEGER :: handle, ispin
388 LOGICAL :: do_spinflip
389 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_ia_g, rho_ia_g2
390 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
391 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_ia_r, rho_ia_r2, tau_ia_r, tau_ia_r2
392
393 CALL timeset(routinen, handle)
394
395 CALL qs_rho_get(rho_ia_struct, rho_g=rho_ia_g, rho_r=rho_ia_r, tau_r=tau_ia_r)
396 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
397
398 IF (debug_this_module) THEN
399 cpassert(SIZE(rho_ia_g) == nspins)
400 cpassert(SIZE(rho_ia_r) == nspins)
401 cpassert((.NOT. ASSOCIATED(tau_ia_r)) .OR. SIZE(tau_ia_r) == nspins)
402 cpassert((.NOT. is_rks_triplets) .OR. nspins == 1)
403 cpassert((spinflip .NE. no_sf_tddfpt) .EQV. (nspins == 2))
404 END IF
405
406 IF (spinflip == tddfpt_sf_noncol) THEN
407 do_spinflip = .true.
408 ELSE
409 do_spinflip = .false.
410 END IF
411
412 NULLIFY (tau_ia_r2)
413 IF (is_rks_triplets) THEN
414 ALLOCATE (rho_ia_r2(2))
415 ALLOCATE (rho_ia_g2(2))
416 rho_ia_r2(1) = rho_ia_r(1)
417 rho_ia_r2(2) = rho_ia_r(1)
418 rho_ia_g2(1) = rho_ia_g(1)
419 rho_ia_g2(2) = rho_ia_g(1)
420
421 IF (ASSOCIATED(tau_ia_r)) THEN
422 ALLOCATE (tau_ia_r2(2))
423 tau_ia_r2(1) = tau_ia_r(1)
424 tau_ia_r2(2) = tau_ia_r(1)
425 END IF
426 ELSE
427 rho_ia_r2 => rho_ia_r
428 rho_ia_g2 => rho_ia_g
429
430 tau_ia_r2 => tau_ia_r
431 END IF
432
433 DO ispin = 1, nspins
434 CALL pw_zero(work_v_xc(ispin))
435 IF (ASSOCIATED(work_v_xc_tau)) CALL pw_zero(work_v_xc_tau(ispin))
436 END DO
437
438 CALL xc_rho_set_update(rho_set=kernel_env%xc_rho1_set, rho_r=rho_ia_r2, rho_g=rho_ia_g2, tau=tau_ia_r2, &
439 needs=kernel_env%xc_rho1_cflags, xc_deriv_method_id=kernel_env%deriv_method_id, &
440 xc_rho_smooth_id=kernel_env%rho_smooth_id, pw_pool=auxbas_pw_pool)
441
442 CALL xc_calc_2nd_deriv_analytical(v_xc=work_v_xc, v_xc_tau=work_v_xc_tau, deriv_set=kernel_env%xc_deriv_set, &
443 rho_set=kernel_env%xc_rho_set, &
444 rho1_set=kernel_env%xc_rho1_set, pw_pool=auxbas_pw_pool, &
445 xc_section=kernel_env%xc_section, gapw=.false., tddfpt_fac=kernel_env%beta, &
446 spinflip=do_spinflip)
447
448 IF (is_rks_triplets) THEN
449 DEALLOCATE (rho_ia_r2)
450 DEALLOCATE (rho_ia_g2)
451 IF (ASSOCIATED(tau_ia_r2)) DEALLOCATE (tau_ia_r2)
452 END IF
453
454 CALL timestop(handle)
455
456 END SUBROUTINE tddfpt_apply_xc_analytic
457
458! **************************************************************************************************
459!> \brief Update A_ia_munu by adding exchange-correlation term using finite difference methods.
460!> \param kernel_env kernel environment
461!> \param rho_ia_struct response density for the given trial vector
462!> \param is_rks_triplets indicates that the triplet excited states calculation using
463!> spin-unpolarised molecular orbitals has been requested
464!> \param nspins ...
465!> \param pw_env plain wave environment
466!> \param work_v_xc work real-space grid to store the gradient of the exchange-correlation
467!> potential with respect to the response density (modified on exit)
468!> \param work_v_xc_tau ...
469! **************************************************************************************************
470 SUBROUTINE tddfpt_apply_xc_fd(kernel_env, rho_ia_struct, is_rks_triplets, nspins, &
471 pw_env, work_v_xc, work_v_xc_tau)
472 TYPE(full_kernel_env_type), INTENT(in) :: kernel_env
473 TYPE(qs_rho_type), POINTER :: rho_ia_struct
474 LOGICAL, INTENT(in) :: is_rks_triplets
475 INTEGER, INTENT(in) :: nspins
476 TYPE(pw_env_type), POINTER :: pw_env
477 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: work_v_xc, work_v_xc_tau
478
479 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_apply_xc_fd'
480
481 INTEGER :: handle, ispin
482 LOGICAL :: lsd, singlet, triplet
483 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho1_g
484 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
485 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho1_r, tau1_r
486 TYPE(xc_rho_set_type), POINTER :: rho_set
487
488 CALL timeset(routinen, handle)
489
490 CALL qs_rho_get(rho_ia_struct, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
491 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
492 DO ispin = 1, nspins
493 CALL pw_zero(work_v_xc(ispin))
494 END DO
495 rho_set => kernel_env%xc_rho_set
496
497 singlet = .false.
498 triplet = .false.
499 lsd = .false.
500 IF (nspins == 1 .AND. .NOT. is_rks_triplets) THEN
501 singlet = .true.
502 ELSE IF (nspins == 1 .AND. is_rks_triplets) THEN
503 triplet = .true.
504 ELSE IF (nspins == 2) THEN
505 lsd = .true.
506 ELSE
507 cpabort("illegal options")
508 END IF
509
510 IF (ASSOCIATED(tau1_r)) THEN
511 DO ispin = 1, nspins
512 CALL pw_zero(work_v_xc_tau(ispin))
513 END DO
514 END IF
515
516 CALL xc_calc_2nd_deriv_numerical(work_v_xc, work_v_xc_tau, rho_set, rho1_r, rho1_g, tau1_r, &
517 auxbas_pw_pool, kernel_env%xc_section, &
518 is_rks_triplets)
519
520 CALL timestop(handle)
521
522 END SUBROUTINE tddfpt_apply_xc_fd
523
524! **************************************************************************************************
525!> \brief Update action of TDDFPT operator on trial vectors by adding exact-exchange term.
526!> \param Aop_evects action of TDDFPT operator on trial vectors (modified on exit)
527!> \param evects trial vectors
528!> \param gs_mos molecular orbitals optimised for the ground state (only occupied
529!> molecular orbitals [component %mos_occ] are needed)
530!> \param do_admm perform auxiliary density matrix method calculations
531!> \param qs_env Quickstep environment
532!> \param work_rho_ia_ao_symm ...
533!> \param work_hmat_symm ...
534!> \param work_rho_ia_ao_asymm ...
535!> \param work_hmat_asymm ...
536!> \param wfm_rho_orb ...
537!> \par History
538!> * 05.2016 compute all exact-exchange terms in one go [Sergey Chulkov]
539!> * 03.2017 code related to ADMM correction is now moved to tddfpt_apply_admm_correction()
540!> in order to compute this correction within parallel groups [Sergey Chulkov]
541!> \note Based on the subroutine kpp1_calc_k_p_p1() which was originally created by
542!> Mohamed Fawzi on 10.2002.
543! **************************************************************************************************
544 SUBROUTINE tddfpt_apply_hfx(Aop_evects, evects, gs_mos, do_admm, qs_env, &
545 work_rho_ia_ao_symm, work_hmat_symm, work_rho_ia_ao_asymm, &
546 work_hmat_asymm, wfm_rho_orb)
547 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(INOUT) :: aop_evects
548 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(IN) :: evects
549 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
550 INTENT(in) :: gs_mos
551 LOGICAL, INTENT(in) :: do_admm
552 TYPE(qs_environment_type), POINTER :: qs_env
553 TYPE(dbcsr_p_type), DIMENSION(:), INTENT(INOUT) :: work_rho_ia_ao_symm
554 TYPE(dbcsr_p_type), DIMENSION(:), INTENT(INOUT), &
555 TARGET :: work_hmat_symm
556 TYPE(dbcsr_p_type), DIMENSION(:), INTENT(INOUT) :: work_rho_ia_ao_asymm
557 TYPE(dbcsr_p_type), DIMENSION(:), INTENT(INOUT), &
558 TARGET :: work_hmat_asymm
559 TYPE(cp_fm_type), INTENT(IN) :: wfm_rho_orb
560
561 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_apply_hfx'
562
563 INTEGER :: handle, ispin, ivect, nao, nao_aux, &
564 nspins, nvects
565 INTEGER, DIMENSION(maxspins) :: nactive
566 LOGICAL :: do_hfx
567 REAL(kind=dp) :: alpha
568 TYPE(admm_type), POINTER :: admm_env
569 TYPE(section_vals_type), POINTER :: hfx_section, input
570
571 CALL timeset(routinen, handle)
572
573 ! Check for hfx section
574 CALL get_qs_env(qs_env, input=input)
575 hfx_section => section_vals_get_subs_vals(input, "DFT%XC%HF")
576 CALL section_vals_get(hfx_section, explicit=do_hfx)
577
578 IF (do_hfx) THEN
579 nspins = SIZE(evects, 1)
580 nvects = SIZE(evects, 2)
581
582 IF (SIZE(gs_mos) > 1) THEN
583 alpha = 1.0_dp
584 ELSE
585 alpha = 2.0_dp
586 END IF
587
588 CALL cp_fm_get_info(gs_mos(1)%mos_occ, nrow_global=nao)
589 DO ispin = 1, nspins
590 CALL cp_fm_get_info(evects(ispin, 1), ncol_global=nactive(ispin))
591 END DO
592
593 IF (do_admm) THEN
594 CALL get_qs_env(qs_env, admm_env=admm_env)
595 CALL cp_fm_get_info(admm_env%A, nrow_global=nao_aux)
596 END IF
597
598 !Note: the symmetrized transition density matrix is P = 0.5*(C*evect^T + evect*C^T)
599 ! in the end, we only want evect*C^T for consistency with the MO formulation of TDDFT
600 ! therefore, we go in 2 steps: with the symmetric 0.5*(C*evect^T + evect*C^T) and
601 ! the antisymemtric 0.5*(C*evect^T - evect*C^T)
602
603 ! some stuff from qs_ks_build_kohn_sham_matrix
604 ! TO DO: add SIC support
605 DO ivect = 1, nvects
606 DO ispin = 1, nspins
607
608 !The symmetric density matrix
609 CALL parallel_gemm('N', 'T', nao, nao, nactive(ispin), 0.5_dp, evects(ispin, ivect), &
610 gs_mos(ispin)%mos_occ, 0.0_dp, wfm_rho_orb)
611 CALL parallel_gemm('N', 'T', nao, nao, nactive(ispin), 0.5_dp, gs_mos(ispin)%mos_occ, &
612 evects(ispin, ivect), 1.0_dp, wfm_rho_orb)
613
614 CALL dbcsr_set(work_hmat_symm(ispin)%matrix, 0.0_dp)
615 IF (do_admm) THEN
616 CALL parallel_gemm('N', 'N', nao_aux, nao, nao, 1.0_dp, admm_env%A, &
617 wfm_rho_orb, 0.0_dp, admm_env%work_aux_orb)
618 CALL parallel_gemm('N', 'T', nao_aux, nao_aux, nao, 1.0_dp, admm_env%work_aux_orb, admm_env%A, &
619 0.0_dp, admm_env%work_aux_aux)
620 CALL copy_fm_to_dbcsr(admm_env%work_aux_aux, work_rho_ia_ao_symm(ispin)%matrix, keep_sparsity=.true.)
621 ELSE
622 CALL copy_fm_to_dbcsr(wfm_rho_orb, work_rho_ia_ao_symm(ispin)%matrix, keep_sparsity=.true.)
623 END IF
624 END DO
625
626 CALL tddft_hfx_matrix(work_hmat_symm, work_rho_ia_ao_symm, qs_env)
627
628 IF (do_admm) THEN
629 DO ispin = 1, nspins
630 CALL cp_dbcsr_sm_fm_multiply(work_hmat_symm(ispin)%matrix, admm_env%A, admm_env%work_aux_orb, &
631 ncol=nao, alpha=1.0_dp, beta=0.0_dp)
632
633 CALL parallel_gemm('T', 'N', nao, nao, nao_aux, 1.0_dp, admm_env%A, &
634 admm_env%work_aux_orb, 0.0_dp, wfm_rho_orb)
635
636 CALL parallel_gemm('N', 'N', nao, nactive(ispin), nao, alpha, wfm_rho_orb, &
637 gs_mos(ispin)%mos_occ, 1.0_dp, aop_evects(ispin, ivect))
638 END DO
639 ELSE
640 DO ispin = 1, nspins
641 CALL cp_dbcsr_sm_fm_multiply(work_hmat_symm(ispin)%matrix, gs_mos(ispin)%mos_occ, &
642 aop_evects(ispin, ivect), ncol=nactive(ispin), &
643 alpha=alpha, beta=1.0_dp)
644 END DO
645 END IF
646
647 !The anti-symmetric density matrix
648 DO ispin = 1, nspins
649
650 !The symmetric density matrix
651 CALL parallel_gemm('N', 'T', nao, nao, nactive(ispin), 0.5_dp, evects(ispin, ivect), &
652 gs_mos(ispin)%mos_occ, 0.0_dp, wfm_rho_orb)
653 CALL parallel_gemm('N', 'T', nao, nao, nactive(ispin), -0.5_dp, gs_mos(ispin)%mos_occ, &
654 evects(ispin, ivect), 1.0_dp, wfm_rho_orb)
655
656 CALL dbcsr_set(work_hmat_asymm(ispin)%matrix, 0.0_dp)
657 IF (do_admm) THEN
658 CALL parallel_gemm('N', 'N', nao_aux, nao, nao, 1.0_dp, admm_env%A, &
659 wfm_rho_orb, 0.0_dp, admm_env%work_aux_orb)
660 CALL parallel_gemm('N', 'T', nao_aux, nao_aux, nao, 1.0_dp, admm_env%work_aux_orb, admm_env%A, &
661 0.0_dp, admm_env%work_aux_aux)
662 CALL copy_fm_to_dbcsr(admm_env%work_aux_aux, work_rho_ia_ao_asymm(ispin)%matrix, keep_sparsity=.true.)
663 ELSE
664 CALL copy_fm_to_dbcsr(wfm_rho_orb, work_rho_ia_ao_asymm(ispin)%matrix, keep_sparsity=.true.)
665 END IF
666 END DO
667
668 CALL tddft_hfx_matrix(work_hmat_asymm, work_rho_ia_ao_asymm, qs_env)
669
670 IF (do_admm) THEN
671 DO ispin = 1, nspins
672 CALL cp_dbcsr_sm_fm_multiply(work_hmat_asymm(ispin)%matrix, admm_env%A, admm_env%work_aux_orb, &
673 ncol=nao, alpha=1.0_dp, beta=0.0_dp)
674
675 CALL parallel_gemm('T', 'N', nao, nao, nao_aux, 1.0_dp, admm_env%A, &
676 admm_env%work_aux_orb, 0.0_dp, wfm_rho_orb)
677
678 CALL parallel_gemm('N', 'N', nao, nactive(ispin), nao, alpha, wfm_rho_orb, &
679 gs_mos(ispin)%mos_occ, 1.0_dp, aop_evects(ispin, ivect))
680 END DO
681 ELSE
682 DO ispin = 1, nspins
683 CALL cp_dbcsr_sm_fm_multiply(work_hmat_asymm(ispin)%matrix, gs_mos(ispin)%mos_occ, &
684 aop_evects(ispin, ivect), ncol=nactive(ispin), &
685 alpha=alpha, beta=1.0_dp)
686 END DO
687 END IF
688 END DO
689 END IF
690
691 CALL timestop(handle)
692
693 END SUBROUTINE tddfpt_apply_hfx
694
695! **************************************************************************************************
696!> \brief Update action of TDDFPT operator on trial vectors by adding exact-exchange term.
697!> \param Aop_evects action of TDDFPT operator on trial vectors (modified on exit)
698!> \param evects trial vectors
699!> \param gs_mos molecular orbitals optimised for the ground state (only occupied
700!> molecular orbitals [component %mos_occ] are needed)
701!> \param qs_env Quickstep environment
702!> \param admm_env ...
703!> \param hfx_section ...
704!> \param x_data ...
705!> \param symmetry ...
706!> \param recalc_integrals ...
707!> \param work_rho_ia_ao ...
708!> \param work_hmat ...
709!> \param wfm_rho_orb ...
710! **************************************************************************************************
711 SUBROUTINE tddfpt_apply_hfxsr_kernel(Aop_evects, evects, gs_mos, qs_env, admm_env, &
712 hfx_section, x_data, symmetry, recalc_integrals, &
713 work_rho_ia_ao, work_hmat, wfm_rho_orb)
714 TYPE(cp_fm_type), DIMENSION(:, :), INTENT(in) :: aop_evects, evects
715 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
716 INTENT(in) :: gs_mos
717 TYPE(qs_environment_type), POINTER :: qs_env
718 TYPE(admm_type), POINTER :: admm_env
719 TYPE(section_vals_type), POINTER :: hfx_section
720 TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
721 INTEGER, INTENT(IN) :: symmetry
722 LOGICAL, INTENT(IN) :: recalc_integrals
723 TYPE(dbcsr_p_type), DIMENSION(:), INTENT(INOUT) :: work_rho_ia_ao
724 TYPE(dbcsr_p_type), DIMENSION(:), INTENT(INOUT), &
725 TARGET :: work_hmat
726 TYPE(cp_fm_type), INTENT(IN) :: wfm_rho_orb
727
728 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_apply_hfxsr_kernel'
729
730 INTEGER :: handle, ispin, ivect, nao, nao_aux, &
731 nspins, nvects
732 INTEGER, DIMENSION(maxspins) :: nactive
733 LOGICAL :: reint
734 REAL(kind=dp) :: alpha
735
736 CALL timeset(routinen, handle)
737
738 nspins = SIZE(evects, 1)
739 nvects = SIZE(evects, 2)
740
741 alpha = 2.0_dp
742 IF (nspins > 1) alpha = 1.0_dp
743
744 CALL cp_fm_get_info(gs_mos(1)%mos_occ, nrow_global=nao)
745 CALL cp_fm_get_info(admm_env%A, nrow_global=nao_aux)
746 DO ispin = 1, nspins
747 CALL cp_fm_get_info(evects(ispin, 1), ncol_global=nactive(ispin))
748 END DO
749
750 reint = recalc_integrals
751
752 DO ivect = 1, nvects
753 DO ispin = 1, nspins
754 CALL parallel_gemm('N', 'T', nao, nao, nactive(ispin), 0.5_dp, evects(ispin, ivect), &
755 gs_mos(ispin)%mos_occ, 0.0_dp, wfm_rho_orb)
756 CALL parallel_gemm('N', 'T', nao, nao, nactive(ispin), 0.5_dp*symmetry, gs_mos(ispin)%mos_occ, &
757 evects(ispin, ivect), 1.0_dp, wfm_rho_orb)
758 CALL dbcsr_set(work_hmat(ispin)%matrix, 0.0_dp)
759 CALL parallel_gemm('N', 'N', nao_aux, nao, nao, 1.0_dp, admm_env%A, &
760 wfm_rho_orb, 0.0_dp, admm_env%work_aux_orb)
761 CALL parallel_gemm('N', 'T', nao_aux, nao_aux, nao, 1.0_dp, admm_env%work_aux_orb, admm_env%A, &
762 0.0_dp, admm_env%work_aux_aux)
763 CALL copy_fm_to_dbcsr(admm_env%work_aux_aux, work_rho_ia_ao(ispin)%matrix, keep_sparsity=.true.)
764 END DO
765
766 CALL tddft_hfx_matrix(work_hmat, work_rho_ia_ao, qs_env, .false., reint, hfx_section, x_data)
767 reint = .false.
768
769 DO ispin = 1, nspins
770 CALL cp_dbcsr_sm_fm_multiply(work_hmat(ispin)%matrix, admm_env%A, admm_env%work_aux_orb, &
771 ncol=nao, alpha=1.0_dp, beta=0.0_dp)
772 CALL parallel_gemm('T', 'N', nao, nao, nao_aux, 1.0_dp, admm_env%A, &
773 admm_env%work_aux_orb, 0.0_dp, wfm_rho_orb)
774 CALL parallel_gemm('N', 'N', nao, nactive(ispin), nao, alpha, wfm_rho_orb, &
775 gs_mos(ispin)%mos_occ, 1.0_dp, aop_evects(ispin, ivect))
776 END DO
777 END DO
778
779 CALL timestop(handle)
780
781 END SUBROUTINE tddfpt_apply_hfxsr_kernel
782
783! **************************************************************************************************
784!> \brief ...Calculate the HFXLR kernel contribution by contracting the Lowdin MO coefficients --
785!> transition charges with the exchange-type integrals using the sTDA approximation
786!> \param qs_env ...
787!> \param sub_env ...
788!> \param rcut ...
789!> \param hfx_scale ...
790!> \param work ...
791!> \param X ...
792!> \param res ... vector AX with A being the sTDA matrix and X the Davidson trial vector of the
793!> eigenvalue problem A*X = omega*X
794! **************************************************************************************************
795 SUBROUTINE tddfpt_apply_hfxlr_kernel(qs_env, sub_env, rcut, hfx_scale, work, X, res)
796
797 TYPE(qs_environment_type), POINTER :: qs_env
798 TYPE(tddfpt_subgroup_env_type) :: sub_env
799 REAL(kind=dp), INTENT(IN) :: rcut, hfx_scale
800 TYPE(tddfpt_work_matrices) :: work
801 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: x
802 TYPE(cp_fm_type), DIMENSION(:), INTENT(INOUT) :: res
803
804 CHARACTER(len=*), PARAMETER :: routinen = 'tddfpt_apply_hfxlr_kernel'
805
806 INTEGER :: handle, iatom, ispin, jatom, natom, &
807 nsgf, nspins
808 INTEGER, DIMENSION(2) :: nactive
809 REAL(kind=dp) :: dr, eps_filter, fcut, gabr
810 REAL(kind=dp), DIMENSION(3) :: rij
811 REAL(kind=dp), DIMENSION(:, :), POINTER :: pblock
812 TYPE(cell_type), POINTER :: cell
813 TYPE(cp_fm_struct_type), POINTER :: fmstruct
814 TYPE(cp_fm_type) :: cvec
815 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: xtransformed
816 TYPE(cp_fm_type), POINTER :: ct
817 TYPE(dbcsr_iterator_type) :: iter
818 TYPE(dbcsr_type) :: pdens
819 TYPE(dbcsr_type), POINTER :: tempmat
820 TYPE(mp_para_env_type), POINTER :: para_env
821 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
822
823 CALL timeset(routinen, handle)
824
825 ! parameters
826 eps_filter = 1.e-08_dp
827
828 nspins = SIZE(x)
829 DO ispin = 1, nspins
830 CALL cp_fm_get_info(x(ispin), ncol_global=nactive(ispin))
831 END DO
832
833 para_env => sub_env%para_env
834
835 CALL get_qs_env(qs_env, natom=natom, cell=cell, particle_set=particle_set)
836
837 ! calculate Loewdin transformed Davidson trial vector tilde(X)=S^1/2*X
838 ! and tilde(tilde(X))=S^1/2_A*tilde(X)_A
839 ALLOCATE (xtransformed(nspins))
840 DO ispin = 1, nspins
841 NULLIFY (fmstruct)
842 ct => work%ctransformed(ispin)
843 CALL cp_fm_get_info(ct, matrix_struct=fmstruct)
844 CALL cp_fm_create(matrix=xtransformed(ispin), matrix_struct=fmstruct, name="XTRANSFORMED")
845 END DO
846 CALL get_lowdin_x(work%shalf, x, xtransformed)
847
848 DO ispin = 1, nspins
849 ct => work%ctransformed(ispin)
850 CALL cp_fm_get_info(ct, matrix_struct=fmstruct, nrow_global=nsgf)
851 CALL cp_fm_create(cvec, fmstruct)
852 !
853 tempmat => work%shalf
854 CALL dbcsr_create(pdens, template=tempmat, matrix_type=dbcsr_type_no_symmetry)
855 ! P(nu,mu) = SUM_j XT(nu,j)*CT(mu,j)
856 ct => work%ctransformed(ispin)
857 CALL dbcsr_set(pdens, 0.0_dp)
858 CALL cp_dbcsr_plus_fm_fm_t(pdens, xtransformed(ispin), ct, nactive(ispin), &
859 1.0_dp, keep_sparsity=.false.)
860 CALL dbcsr_filter(pdens, eps_filter)
861 ! Apply PP*gab -> PP; gab = gamma_coulomb
862 ! P(nu,mu) = P(nu,mu)*g(a of nu,b of mu)
863 CALL dbcsr_iterator_start(iter, pdens)
864 DO WHILE (dbcsr_iterator_blocks_left(iter))
865 CALL dbcsr_iterator_next_block(iter, iatom, jatom, pblock)
866 rij = particle_set(iatom)%r - particle_set(jatom)%r
867 rij = pbc(rij, cell)
868 dr = sqrt(sum(rij(:)**2))
869 gabr = 1._dp/rcut
870 IF (dr < 1.e-6) THEN
871 gabr = 2._dp*gabr/sqrt(3.1415926_dp)
872 ELSE
873 gabr = erf(gabr*dr)/dr
874 fcut = exp(dr - 4._dp*rcut)
875 fcut = fcut/(fcut + 1._dp)
876 END IF
877 pblock = hfx_scale*gabr*pblock
878 END DO
879 CALL dbcsr_iterator_stop(iter)
880 ! CV(mu,i) = P(nu,mu)*CT(mu,i)
881 CALL cp_dbcsr_sm_fm_multiply(pdens, ct, cvec, nactive(ispin), 1.0_dp, 0.0_dp)
882 ! rho(nu,i) = rho(nu,i) + ShalfP(nu,mu)*CV(mu,i)
883 CALL cp_dbcsr_sm_fm_multiply(work%shalf, cvec, res(ispin), nactive(ispin), &
884 -1.0_dp, 1.0_dp)
885 !
886 CALL dbcsr_release(pdens)
887 !
888 CALL cp_fm_release(cvec)
889 END DO
890
891 CALL cp_fm_release(xtransformed)
892
893 CALL timestop(handle)
894
895 END SUBROUTINE tddfpt_apply_hfxlr_kernel
896
897! **************************************************************************************************
898
899END MODULE qs_tddfpt2_operators
Types and set/get functions for auxiliary density matrix methods.
Definition admm_types.F:15
Handles all functions related to the CELL.
Definition cell_types.F:15
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
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.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
represent the structure of a full 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)
creates a new full matrix with the given structure
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...
Utilities for hfx and admm methods.
subroutine, public tddft_hfx_matrix(matrix_ks, rho_ao, qs_env, update_energy, recalc_integrals, external_hfx_sections, external_x_data, external_para_env)
Add the hfx contributions to the Hamiltonian.
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 tddfpt_sf_noncol
integer, parameter, public no_sf_tddfpt
objects that represent the structure of input sections and the data contained in an input section
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
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
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
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 ...
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_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, 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 integrate_vhg0_rspace(qs_env, v_rspace, para_env, calculate_forces, local_rho_set, local_rho_set_2nd, atener, kforce, my_pools, my_rs_descs)
...
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_apply_hfx(aop_evects, evects, gs_mos, do_admm, qs_env, work_rho_ia_ao_symm, work_hmat_symm, work_rho_ia_ao_asymm, work_hmat_asymm, wfm_rho_orb)
Update action of TDDFPT operator on trial vectors by adding exact-exchange term.
subroutine, public tddfpt_apply_xc(a_ia_rspace, kernel_env, rho_ia_struct, is_rks_triplets, pw_env, work_v_xc, work_v_xc_tau, spinflip)
Driver routine for applying fxc (analyic vs. finite difference for testing.
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_energy_diff(aop_evects, evects, s_evects, gs_mos, matrix_ks, tddfpt_control)
Apply orbital energy difference term: Aop_evects(spin,state) += KS(spin) * evects(spin,...
subroutine, public tddfpt_apply_hfxlr_kernel(qs_env, sub_env, rcut, hfx_scale, work, x, res)
...Calculate the HFXLR kernel contribution by contracting the Lowdin MO coefficients – transition cha...
subroutine, public tddfpt_apply_hfxsr_kernel(aop_evects, evects, gs_mos, qs_env, admm_env, hfx_section, x_data, symmetry, recalc_integrals, work_rho_ia_ao, work_hmat, wfm_rho_orb)
Update action of TDDFPT operator on trial vectors by adding exact-exchange term.
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).
subroutine, public get_lowdin_x(shalf, xvec, xt)
Calculate Lowdin transformed Davidson trial vector X shalf (dbcsr), xvec, xt (fm) are defined in the ...
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, spinflip)
updates the given rho set with the density given by rho_r (and rho_g). The rho set will contain the c...
Exchange and Correlation functional calculations.
Definition xc.F:17
subroutine, public xc_calc_2nd_deriv_analytical(v_xc, v_xc_tau, deriv_set, rho_set, rho1_set, pw_pool, xc_section, gapw, vxg, tddfpt_fac, compute_virial, virial_xc, spinflip)
Calculates the second derivative of E_xc at rho in the direction rho1 (if you see the second derivati...
Definition xc.F:2650
subroutine, public xc_calc_2nd_deriv_numerical(v_xc, v_tau, rho_set, rho1_r, rho1_g, tau1_r, pw_pool, xc_section, do_triplet, calc_virial, virial_xc, deriv_set)
calculates 2nd derivative numerically
Definition xc.F:1663
stores some data used in wavefunction fitting
Definition admm_types.F:120
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
keeps the information about the structure of a full matrix
represent a full matrix
stores some data used in construction of Kohn-Sham matrix
Definition hfx_types.F:510
stores all the informations relevant to an mpi environment
contained for different pw related things
environment for the poisson solver
to create arrays of pools
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.
keeps the density in various representations, keeping track of which ones are valid.
Ground state molecular orbitals.
Set of temporary ("work") matrices.
represent a density, with all the representation and data needed to perform a functional evaluation