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