(git:b17b328)
Loading...
Searching...
No Matches
qs_tddfpt2_forces.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,&
14 USE bibliography, ONLY: sertcan2024,&
15 cite_reference
18 USE cp_dbcsr_api, ONLY: &
20 dbcsr_release, dbcsr_scale, dbcsr_set, dbcsr_type, dbcsr_type_antisymmetric
49 USE hfx_ri, ONLY: hfx_ri_update_ks
50 USE hfx_types, ONLY: hfx_type
52 oe_shift,&
61 USE kinds, ONLY: default_string_length,&
62 dp
64 USE mulliken, ONLY: ao_charges
67 USE pw_env_types, ONLY: pw_env_get,&
69 USE pw_methods, ONLY: pw_axpy,&
70 pw_scale,&
76 USE pw_types, ONLY: pw_c1d_gs_type,&
90 USE qs_fxc, ONLY: qs_fxc_analytic,&
93 USE qs_integrate_potential, ONLY: integrate_v_rspace
95 USE qs_kind_types, ONLY: get_qs_kind,&
98 USE qs_ks_atom, ONLY: update_ks_atom
101 USE qs_ks_types, ONLY: qs_ks_env_type
105 USE qs_mo_types, ONLY: get_mo_set,&
112 USE qs_rho0_methods, ONLY: init_rho0
117 USE qs_rho_types, ONLY: qs_rho_create,&
118 qs_rho_get,&
119 qs_rho_set,&
129 USE xtb_types, ONLY: get_xtb_atom_param,&
131#include "./base/base_uses.f90"
132
133 IMPLICIT NONE
134
135 PRIVATE
136
137 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_tddfpt2_forces'
138
139 PUBLIC :: tddfpt_forces_main
140
141! **************************************************************************************************
142
143CONTAINS
144
145! **************************************************************************************************
146!> \brief Perform TDDFPT gradient calculation.
147!> \param qs_env Quickstep environment
148!> \param gs_mos ...
149!> \param ex_env ...
150!> \param kernel_env ...
151!> \param sub_env ...
152!> \param work_matrices ...
153!> \par History
154!> * 10.2022 created JHU
155! **************************************************************************************************
156 SUBROUTINE tddfpt_forces_main(qs_env, gs_mos, ex_env, kernel_env, sub_env, work_matrices)
157 TYPE(qs_environment_type), POINTER :: qs_env
158 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
159 POINTER :: gs_mos
160 TYPE(excited_energy_type), POINTER :: ex_env
161 TYPE(kernel_env_type) :: kernel_env
162 TYPE(tddfpt_subgroup_env_type) :: sub_env
163 TYPE(tddfpt_work_matrices) :: work_matrices
164
165 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_forces_main'
166
167 INTEGER :: handle, ispin, nspins
168 TYPE(admm_type), POINTER :: admm_env
169 TYPE(cp_fm_struct_type), POINTER :: matrix_struct
170 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_pe_asymm, matrix_pe_symm, &
171 matrix_s, matrix_s_aux_fit
172 TYPE(dft_control_type), POINTER :: dft_control
173 TYPE(tddfpt2_control_type), POINTER :: tddfpt_control
174
175 CALL timeset(routinen, handle)
176
177 CALL get_qs_env(qs_env, dft_control=dft_control)
178
179 IF (dft_control%qs_control%gapw .OR. dft_control%qs_control%gapw_xc) CALL cite_reference(sertcan2024)
180
181 nspins = dft_control%nspins
182 tddfpt_control => dft_control%tddfpt2_control
183 ! rhs of linres equation
184 IF (ASSOCIATED(ex_env%cpmos)) THEN
185 DO ispin = 1, SIZE(ex_env%cpmos)
186 CALL cp_fm_release(ex_env%cpmos(ispin))
187 END DO
188 DEALLOCATE (ex_env%cpmos)
189 END IF
190 ALLOCATE (ex_env%cpmos(nspins))
191 DO ispin = 1, nspins
192 CALL cp_fm_get_info(matrix=ex_env%evect(ispin), matrix_struct=matrix_struct)
193 CALL cp_fm_create(ex_env%cpmos(ispin), matrix_struct)
194 CALL cp_fm_set_all(ex_env%cpmos(ispin), 0.0_dp)
195 END DO
196 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s)
197 NULLIFY (matrix_pe_asymm, matrix_pe_symm)
198 CALL dbcsr_allocate_matrix_set(ex_env%matrix_pe, nspins)
199 CALL dbcsr_allocate_matrix_set(matrix_pe_symm, nspins)
200 CALL dbcsr_allocate_matrix_set(matrix_pe_asymm, nspins)
201 DO ispin = 1, nspins
202 ALLOCATE (ex_env%matrix_pe(ispin)%matrix)
203 CALL dbcsr_create(ex_env%matrix_pe(ispin)%matrix, template=matrix_s(1)%matrix)
204 CALL dbcsr_copy(ex_env%matrix_pe(ispin)%matrix, matrix_s(1)%matrix)
205 CALL dbcsr_set(ex_env%matrix_pe(ispin)%matrix, 0.0_dp)
206
207 ALLOCATE (matrix_pe_symm(ispin)%matrix)
208 CALL dbcsr_create(matrix_pe_symm(ispin)%matrix, template=matrix_s(1)%matrix)
209 CALL dbcsr_copy(matrix_pe_symm(ispin)%matrix, ex_env%matrix_pe(ispin)%matrix)
210
211 ALLOCATE (matrix_pe_asymm(ispin)%matrix)
212 CALL dbcsr_create(matrix_pe_asymm(ispin)%matrix, template=matrix_s(1)%matrix, &
213 matrix_type=dbcsr_type_antisymmetric)
214 CALL dbcsr_complete_redistribute(ex_env%matrix_pe(ispin)%matrix, matrix_pe_asymm(ispin)%matrix)
215
216 CALL tddfpt_resvec1(ex_env%evect(ispin), gs_mos(ispin)%mos_occ, &
217 matrix_s(1)%matrix, ex_env%matrix_pe(ispin)%matrix)
218 END DO
219 !
220 ! ground state ADMM!
221 IF (dft_control%do_admm) THEN
222 CALL get_qs_env(qs_env, admm_env=admm_env)
223 CALL get_admm_env(admm_env, matrix_s_aux_fit=matrix_s_aux_fit)
224 CALL dbcsr_allocate_matrix_set(ex_env%matrix_pe_admm, nspins)
225 DO ispin = 1, nspins
226 ALLOCATE (ex_env%matrix_pe_admm(ispin)%matrix)
227 CALL dbcsr_create(ex_env%matrix_pe_admm(ispin)%matrix, template=matrix_s_aux_fit(1)%matrix)
228 CALL dbcsr_copy(ex_env%matrix_pe_admm(ispin)%matrix, matrix_s_aux_fit(1)%matrix)
229 CALL dbcsr_set(ex_env%matrix_pe_admm(ispin)%matrix, 0.0_dp)
230 CALL tddfpt_resvec1_admm(ex_env%matrix_pe(ispin)%matrix, &
231 admm_env, ex_env%matrix_pe_admm(ispin)%matrix)
232 END DO
233 END IF
234 !
235 CALL dbcsr_allocate_matrix_set(ex_env%matrix_hz, nspins)
236 DO ispin = 1, nspins
237 ALLOCATE (ex_env%matrix_hz(ispin)%matrix)
238 CALL dbcsr_create(ex_env%matrix_hz(ispin)%matrix, template=matrix_s(1)%matrix)
239 CALL dbcsr_copy(ex_env%matrix_hz(ispin)%matrix, matrix_s(1)%matrix)
240 CALL dbcsr_set(ex_env%matrix_hz(ispin)%matrix, 0.0_dp)
241 END DO
242 IF (dft_control%qs_control%xtb) THEN
243 CALL tddfpt_resvec2_xtb(qs_env, ex_env%matrix_pe, gs_mos, ex_env%matrix_hz, ex_env%cpmos)
244 ELSE
245 CALL tddfpt_resvec2(qs_env, ex_env%matrix_pe, ex_env%matrix_pe_admm, &
246 gs_mos, ex_env%matrix_hz, ex_env%cpmos)
247 END IF
248 !
249 CALL dbcsr_allocate_matrix_set(ex_env%matrix_px1, nspins)
250 CALL dbcsr_allocate_matrix_set(ex_env%matrix_px1_asymm, nspins)
251 DO ispin = 1, nspins
252 ALLOCATE (ex_env%matrix_px1(ispin)%matrix)
253 CALL dbcsr_create(ex_env%matrix_px1(ispin)%matrix, template=matrix_s(1)%matrix)
254 CALL dbcsr_copy(ex_env%matrix_px1(ispin)%matrix, matrix_s(1)%matrix)
255 CALL dbcsr_set(ex_env%matrix_px1(ispin)%matrix, 0.0_dp)
256
257 ALLOCATE (ex_env%matrix_px1_asymm(ispin)%matrix)
258 CALL dbcsr_create(ex_env%matrix_px1_asymm(ispin)%matrix, template=matrix_s(1)%matrix, &
259 matrix_type=dbcsr_type_antisymmetric)
260 CALL dbcsr_complete_redistribute(ex_env%matrix_px1(ispin)%matrix, ex_env%matrix_px1_asymm(ispin)%matrix)
261 END DO
262 ! Kernel ADMM
263 IF (tddfpt_control%do_admm) THEN
264 CALL get_qs_env(qs_env, admm_env=admm_env)
265 CALL get_admm_env(admm_env, matrix_s_aux_fit=matrix_s_aux_fit)
266 CALL dbcsr_allocate_matrix_set(ex_env%matrix_px1_admm, nspins)
267 CALL dbcsr_allocate_matrix_set(ex_env%matrix_px1_admm_asymm, nspins)
268 DO ispin = 1, nspins
269 ALLOCATE (ex_env%matrix_px1_admm(ispin)%matrix)
270 CALL dbcsr_create(ex_env%matrix_px1_admm(ispin)%matrix, template=matrix_s_aux_fit(1)%matrix)
271 CALL dbcsr_copy(ex_env%matrix_px1_admm(ispin)%matrix, matrix_s_aux_fit(1)%matrix)
272 CALL dbcsr_set(ex_env%matrix_px1_admm(ispin)%matrix, 0.0_dp)
273
274 ALLOCATE (ex_env%matrix_px1_admm_asymm(ispin)%matrix)
275 CALL dbcsr_create(ex_env%matrix_px1_admm_asymm(ispin)%matrix, template=matrix_s_aux_fit(1)%matrix, &
276 matrix_type=dbcsr_type_antisymmetric)
277 CALL dbcsr_complete_redistribute(ex_env%matrix_px1_admm(ispin)%matrix, &
278 ex_env%matrix_px1_admm_asymm(ispin)%matrix)
279 END DO
280 END IF
281 ! TDA forces
282 CALL tddfpt_forces(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices)
283 ! Rotate res vector cpmos into original frame of occupied orbitals
284 CALL tddfpt_resvec3(qs_env, ex_env%cpmos, work_matrices)
285
286 CALL dbcsr_deallocate_matrix_set(matrix_pe_symm)
287 CALL dbcsr_deallocate_matrix_set(matrix_pe_asymm)
288
289 CALL timestop(handle)
290
291 END SUBROUTINE tddfpt_forces_main
292
293! **************************************************************************************************
294!> \brief Calculate direct tddft forces
295!> \param qs_env ...
296!> \param ex_env ...
297!> \param gs_mos ...
298!> \param kernel_env ...
299!> \param sub_env ...
300!> \param work_matrices ...
301!> \par History
302!> * 01.2020 screated [JGH]
303! **************************************************************************************************
304 SUBROUTINE tddfpt_forces(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices)
305
306 TYPE(qs_environment_type), POINTER :: qs_env
307 TYPE(excited_energy_type), POINTER :: ex_env
308 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
309 POINTER :: gs_mos
310 TYPE(kernel_env_type), INTENT(IN) :: kernel_env
311 TYPE(tddfpt_subgroup_env_type) :: sub_env
312 TYPE(tddfpt_work_matrices) :: work_matrices
313
314 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_forces'
315
316 INTEGER :: handle
317 INTEGER, ALLOCATABLE, DIMENSION(:) :: natom_of_kind
318 LOGICAL :: debug_forces
319 REAL(kind=dp) :: ehartree, exc
320 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
321 TYPE(dft_control_type), POINTER :: dft_control
322 TYPE(qs_force_type), DIMENSION(:), POINTER :: ks_force, td_force
323
324 CALL timeset(routinen, handle)
325
326 ! for extended debug output
327 debug_forces = ex_env%debug_forces
328 ! prepare force array
329 CALL get_qs_env(qs_env, dft_control=dft_control, force=ks_force, &
330 atomic_kind_set=atomic_kind_set)
331 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, natom_of_kind=natom_of_kind)
332 NULLIFY (td_force)
333 CALL allocate_qs_force(td_force, natom_of_kind)
334 DEALLOCATE (natom_of_kind)
335 CALL zero_qs_force(td_force)
336 CALL set_qs_env(qs_env, force=td_force)
337 !
338 IF (dft_control%qs_control%xtb) THEN
339 CALL tddfpt_force_direct(qs_env, ex_env, gs_mos, kernel_env, sub_env, &
340 work_matrices, debug_forces)
341 ELSE
342 !
343 CALL exstate_potential_release(ex_env)
344 CALL ks_ref_potential(qs_env, ex_env%vh_rspace, ex_env%vxc_rspace, &
345 ex_env%vtau_rspace, ex_env%vadmm_rspace, ehartree, exc)
346 CALL ks_ref_potential_atom(qs_env, ex_env%local_rho_set, ex_env%local_rho_set_admm, &
347 ex_env%vh_rspace)
348 CALL tddfpt_force_direct(qs_env, ex_env, gs_mos, kernel_env, sub_env, &
349 work_matrices, debug_forces)
350 END IF
351 !
352 ! add TD and KS forces
353 CALL get_qs_env(qs_env, force=td_force)
354 CALL sum_qs_force(ks_force, td_force)
355 CALL set_qs_env(qs_env, force=ks_force)
356 CALL deallocate_qs_force(td_force)
357 !
358 CALL timestop(handle)
359
360 END SUBROUTINE tddfpt_forces
361
362! **************************************************************************************************
363!> \brief Calculate direct tddft forces
364!> \param qs_env ...
365!> \param ex_env ...
366!> \param gs_mos ...
367!> \param kernel_env ...
368!> \param sub_env ...
369!> \param work_matrices ...
370!> \param debug_forces ...
371!> \par History
372!> * 01.2020 screated [JGH]
373! **************************************************************************************************
374 SUBROUTINE tddfpt_force_direct(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices, &
375 debug_forces)
376
377 TYPE(qs_environment_type), POINTER :: qs_env
378 TYPE(excited_energy_type), POINTER :: ex_env
379 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
380 POINTER :: gs_mos
381 TYPE(kernel_env_type), INTENT(IN) :: kernel_env
382 TYPE(tddfpt_subgroup_env_type) :: sub_env
383 TYPE(tddfpt_work_matrices) :: work_matrices
384 LOGICAL :: debug_forces
385
386 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_force_direct'
387
388 INTEGER :: handle, iounit, ispin, natom, norb, &
389 nspins
390 REAL(kind=dp) :: evalue
391 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: ftot1, ftot2
392 REAL(kind=dp), DIMENSION(3) :: fodeb
393 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
394 TYPE(cp_fm_type), DIMENSION(:), POINTER :: evect
395 TYPE(cp_logger_type), POINTER :: logger
396 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_s, matrix_wx1, &
397 matrix_wz, scrm
398 TYPE(dft_control_type), POINTER :: dft_control
399 TYPE(mp_para_env_type), POINTER :: para_env
400 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
401 POINTER :: sab_orb
402 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
403 TYPE(qs_ks_env_type), POINTER :: ks_env
404 TYPE(tddfpt2_control_type), POINTER :: tddfpt_control
405
406 CALL timeset(routinen, handle)
407
408 logger => cp_get_default_logger()
409 IF (logger%para_env%is_source()) THEN
410 iounit = cp_logger_get_default_unit_nr(logger, local=.true.)
411 ELSE
412 iounit = -1
413 END IF
414
415 evect => ex_env%evect
416
417 CALL get_qs_env(qs_env=qs_env, ks_env=ks_env, para_env=para_env, &
418 sab_orb=sab_orb, dft_control=dft_control, force=force)
419 NULLIFY (tddfpt_control)
420 tddfpt_control => dft_control%tddfpt2_control
421 nspins = dft_control%nspins
422
423 IF (debug_forces) THEN
424 CALL get_qs_env(qs_env, natom=natom, atomic_kind_set=atomic_kind_set)
425 ALLOCATE (ftot1(3, natom))
426 CALL total_qs_force(ftot1, force, atomic_kind_set)
427 END IF
428
429 CALL tddfpt_kernel_force(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices, debug_forces)
430
431 ! Overlap matrix
432 matrix_wx1 => ex_env%matrix_wx1
433 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s, matrix_ks=matrix_ks)
434 NULLIFY (matrix_wz)
435 CALL dbcsr_allocate_matrix_set(matrix_wz, nspins)
436 DO ispin = 1, nspins
437 ALLOCATE (matrix_wz(ispin)%matrix)
438 CALL dbcsr_create(matrix=matrix_wz(ispin)%matrix, template=matrix_s(1)%matrix)
439 CALL cp_dbcsr_alloc_block_from_nbl(matrix_wz(ispin)%matrix, sab_orb)
440 CALL dbcsr_set(matrix_wz(ispin)%matrix, 0.0_dp)
441 CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, ncol_global=norb)
442 CALL cp_dbcsr_plus_fm_fm_t(matrix_wz(ispin)%matrix, matrix_v=evect(ispin), ncol=norb)
443 evalue = ex_env%evalue
444 IF (tddfpt_control%oe_corr == oe_shift) THEN
445 evalue = ex_env%evalue - tddfpt_control%ev_shift
446 END IF
447 CALL dbcsr_scale(matrix_wz(ispin)%matrix, evalue)
448 CALL calculate_wx_matrix(gs_mos(ispin)%mos_occ, evect(ispin), matrix_ks(ispin)%matrix, &
449 matrix_wz(ispin)%matrix)
450 END DO
451 IF (nspins == 2) THEN
452 CALL dbcsr_add(matrix_wz(1)%matrix, matrix_wz(2)%matrix, &
453 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
454 END IF
455 NULLIFY (scrm)
456 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
457 CALL build_overlap_matrix(ks_env, matrix_s=scrm, &
458 matrix_name="OVERLAP MATRIX", &
459 basis_type_a="ORB", basis_type_b="ORB", &
460 sab_nl=sab_orb, calculate_forces=.true., &
461 matrix_p=matrix_wz(1)%matrix)
463 CALL dbcsr_deallocate_matrix_set(matrix_wz)
464 IF (debug_forces) THEN
465 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
466 CALL para_env%sum(fodeb)
467 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Wx*dS ", fodeb
468 END IF
469
470 ! Overlap matrix
471 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s, matrix_ks=matrix_ks)
472 NULLIFY (matrix_wz)
473 CALL dbcsr_allocate_matrix_set(matrix_wz, nspins)
474 DO ispin = 1, nspins
475 ALLOCATE (matrix_wz(ispin)%matrix)
476 CALL dbcsr_create(matrix=matrix_wz(ispin)%matrix, template=matrix_s(1)%matrix)
477 CALL cp_dbcsr_alloc_block_from_nbl(matrix_wz(ispin)%matrix, sab_orb)
478 CALL dbcsr_set(matrix_wz(ispin)%matrix, 0.0_dp)
479 CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, ncol_global=norb)
480 evalue = ex_env%evalue
481 IF (tddfpt_control%oe_corr == oe_shift) THEN
482 evalue = ex_env%evalue - tddfpt_control%ev_shift
483 END IF
484 CALL calculate_xwx_matrix(gs_mos(ispin)%mos_occ, evect(ispin), matrix_s(1)%matrix, &
485 matrix_ks(ispin)%matrix, matrix_wz(ispin)%matrix, evalue)
486 END DO
487 IF (nspins == 2) THEN
488 CALL dbcsr_add(matrix_wz(1)%matrix, matrix_wz(2)%matrix, &
489 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
490 END IF
491 NULLIFY (scrm)
492 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
493 CALL build_overlap_matrix(ks_env, matrix_s=scrm, &
494 matrix_name="OVERLAP MATRIX", &
495 basis_type_a="ORB", basis_type_b="ORB", &
496 sab_nl=sab_orb, calculate_forces=.true., &
497 matrix_p=matrix_wz(1)%matrix)
499 CALL dbcsr_deallocate_matrix_set(matrix_wz)
500 IF (debug_forces) THEN
501 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
502 CALL para_env%sum(fodeb)
503 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: xWx*dS ", fodeb
504 END IF
505
506 ! Overlap matrix
507 IF (ASSOCIATED(matrix_wx1)) THEN
508 IF (nspins == 2) THEN
509 CALL dbcsr_add(matrix_wx1(1)%matrix, matrix_wx1(2)%matrix, &
510 alpha_scalar=0.5_dp, beta_scalar=0.5_dp)
511 END IF
512 NULLIFY (scrm)
513 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
514 CALL build_overlap_matrix(ks_env, matrix_s=scrm, &
515 matrix_name="OVERLAP MATRIX", &
516 basis_type_a="ORB", basis_type_b="ORB", &
517 sab_nl=sab_orb, calculate_forces=.true., &
518 matrix_p=matrix_wx1(1)%matrix)
520 IF (debug_forces) THEN
521 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
522 CALL para_env%sum(fodeb)
523 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: WK*dS ", fodeb
524 END IF
525 END IF
526
527 IF (debug_forces) THEN
528 ALLOCATE (ftot2(3, natom))
529 CALL total_qs_force(ftot2, force, atomic_kind_set)
530 fodeb(1:3) = ftot2(1:3, 1) - ftot1(1:3, 1)
531 CALL para_env%sum(fodeb)
532 IF (iounit > 0) WRITE (iounit, "(T3,A,T30,3F16.8)") "DEBUG:: Excitation Force", fodeb
533 DEALLOCATE (ftot1, ftot2)
534 END IF
535
536 CALL timestop(handle)
537
538 END SUBROUTINE tddfpt_force_direct
539
540! **************************************************************************************************
541!> \brief ...
542!> \param evect ...
543!> \param mos_occ ...
544!> \param matrix_s ...
545!> \param matrix_pe ...
546! **************************************************************************************************
547 SUBROUTINE tddfpt_resvec1(evect, mos_occ, matrix_s, matrix_pe)
548
549 TYPE(cp_fm_type), INTENT(IN) :: evect, mos_occ
550 TYPE(dbcsr_type), POINTER :: matrix_s, matrix_pe
551
552 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_resvec1'
553
554 INTEGER :: handle, iounit, nao, norb
555 REAL(kind=dp) :: tmp
556 TYPE(cp_fm_struct_type), POINTER :: fmstruct, fmstruct2
557 TYPE(cp_fm_type) :: cxmat, xxmat
558 TYPE(cp_logger_type), POINTER :: logger
559
560 CALL timeset(routinen, handle)
561 ! X*X^T
562 CALL cp_fm_get_info(mos_occ, nrow_global=nao, ncol_global=norb)
563 CALL cp_dbcsr_plus_fm_fm_t(matrix_pe, matrix_v=evect, ncol=norb)
564 ! X^T*S*X
565 CALL cp_fm_get_info(evect, matrix_struct=fmstruct)
566 NULLIFY (fmstruct2)
567 CALL cp_fm_struct_create(fmstruct=fmstruct2, template_fmstruct=fmstruct, &
568 nrow_global=norb, ncol_global=norb)
569 CALL cp_fm_create(xxmat, matrix_struct=fmstruct2)
570 CALL cp_fm_struct_release(fmstruct2)
571 CALL cp_fm_create(cxmat, matrix_struct=fmstruct)
572 CALL cp_dbcsr_sm_fm_multiply(matrix_s, evect, cxmat, norb, alpha=1.0_dp, beta=0.0_dp)
573 CALL parallel_gemm('T', 'N', norb, norb, nao, 1.0_dp, cxmat, evect, 0.0_dp, xxmat)
574 CALL parallel_gemm('N', 'N', nao, norb, norb, 1.0_dp, mos_occ, xxmat, 0.0_dp, cxmat)
575 CALL cp_fm_release(xxmat)
576 ! C*C^T*XX
577 CALL cp_dbcsr_plus_fm_fm_t(matrix_pe, matrix_v=mos_occ, matrix_g=cxmat, &
578 ncol=norb, alpha=-1.0_dp, symmetry_mode=1)
579 CALL cp_fm_release(cxmat)
580 !
581 ! Test for Tr(Pe*S)=0
582 CALL dbcsr_dot(matrix_pe, matrix_s, tmp)
583 IF (abs(tmp) > 1.e-08_dp) THEN
584 logger => cp_get_default_logger()
585 IF (logger%para_env%is_source()) THEN
586 iounit = cp_logger_get_default_unit_nr(logger, local=.true.)
587 ELSE
588 iounit = -1
589 END IF
590 cpwarn("Electron count of excitation density matrix is non-zero.")
591 IF (iounit > 0) THEN
592 WRITE (iounit, "(T2,A,T61,G20.10)") "Measured electron count is ", tmp
593 WRITE (iounit, "(T2,A,/)") repeat("*", 79)
594 END IF
595 END IF
596 !
597
598 CALL timestop(handle)
599
600 END SUBROUTINE tddfpt_resvec1
601
602! **************************************************************************************************
603!> \brief PA = A * P * A(T)
604!> \param matrix_pe ...
605!> \param admm_env ...
606!> \param matrix_pe_admm ...
607! **************************************************************************************************
608 SUBROUTINE tddfpt_resvec1_admm(matrix_pe, admm_env, matrix_pe_admm)
609
610 TYPE(dbcsr_type), POINTER :: matrix_pe
611 TYPE(admm_type), POINTER :: admm_env
612 TYPE(dbcsr_type), POINTER :: matrix_pe_admm
613
614 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_resvec1_admm'
615
616 INTEGER :: handle, nao, nao_aux
617
618 CALL timeset(routinen, handle)
619 !
620 nao_aux = admm_env%nao_aux_fit
621 nao = admm_env%nao_orb
622 !
623 CALL copy_dbcsr_to_fm(matrix_pe, admm_env%work_orb_orb)
624 CALL parallel_gemm('N', 'N', nao_aux, nao, nao, &
625 1.0_dp, admm_env%A, admm_env%work_orb_orb, 0.0_dp, &
626 admm_env%work_aux_orb)
627 CALL parallel_gemm('N', 'T', nao_aux, nao_aux, nao, &
628 1.0_dp, admm_env%work_aux_orb, admm_env%A, 0.0_dp, &
629 admm_env%work_aux_aux)
630 CALL copy_fm_to_dbcsr(admm_env%work_aux_aux, matrix_pe_admm, keep_sparsity=.true.)
631 !
632 CALL timestop(handle)
633
634 END SUBROUTINE tddfpt_resvec1_admm
635
636! **************************************************************************************************
637!> \brief ...
638!> \param qs_env ...
639!> \param matrix_pe ...
640!> \param matrix_pe_admm ...
641!> \param gs_mos ...
642!> \param matrix_hz ...
643!> \param cpmos ...
644! **************************************************************************************************
645 SUBROUTINE tddfpt_resvec2(qs_env, matrix_pe, matrix_pe_admm, gs_mos, matrix_hz, cpmos)
646
647 TYPE(qs_environment_type), POINTER :: qs_env
648 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_pe, matrix_pe_admm
649 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
650 POINTER :: gs_mos
651 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_hz
652 TYPE(cp_fm_type), DIMENSION(:), INTENT(INOUT) :: cpmos
653
654 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_resvec2'
655
656 CHARACTER(LEN=default_string_length) :: basis_type
657 INTEGER :: handle, iounit, ispin, mspin, n_rep_hf, &
658 nao, nao_aux, natom, norb, nspins
659 LOGICAL :: deriv2_analytic, distribute_fock_matrix, &
660 do_hfx, gapw, gapw_xc, &
661 hfx_treat_lsd_in_core, &
662 s_mstruct_changed
663 REAL(kind=dp) :: eh1, focc, rhotot, thartree
664 REAL(kind=dp), DIMENSION(2) :: total_rho
665 REAL(kind=dp), DIMENSION(:), POINTER :: qlm_tot
666 TYPE(admm_type), POINTER :: admm_env
667 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
668 TYPE(cp_fm_type), POINTER :: mos
669 TYPE(cp_logger_type), POINTER :: logger
670 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: msaux
671 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: mhz, mpe
672 TYPE(dbcsr_type), POINTER :: dbwork
673 TYPE(dft_control_type), POINTER :: dft_control
674 TYPE(hartree_local_type), POINTER :: hartree_local
675 TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
676 TYPE(local_rho_type), POINTER :: local_rho_set, local_rho_set_admm
677 TYPE(mp_para_env_type), POINTER :: para_env
678 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
679 POINTER :: sab, sab_aux_fit
680 TYPE(oce_matrix_type), POINTER :: oce
681 TYPE(pw_c1d_gs_type) :: rho_tot_gspace, v_hartree_gspace
682 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g, rho_g_aux, rhoz_g_aux, trho_g, &
683 trho_xc_g
684 TYPE(pw_env_type), POINTER :: pw_env
685 TYPE(pw_poisson_type), POINTER :: poisson_env
686 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
687 TYPE(pw_r3d_rs_type) :: v_hartree_rspace
688 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r, rho_r_aux, rhoz_r_aux, tau_r, &
689 trho_r, trho_xc_r, v_xc, v_xc_tau
690 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
691 TYPE(qs_ks_env_type), POINTER :: ks_env
692 TYPE(qs_rho_type), POINTER :: rho, rho_aux_fit, rho_xc, rhoz_aux, trho
693 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho1_atom_set, rho_atom_set
694 TYPE(section_vals_type), POINTER :: hfx_section, input, xc_section
695 TYPE(task_list_type), POINTER :: task_list
696
697 CALL timeset(routinen, handle)
698
699 NULLIFY (pw_env)
700 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, ks_env=ks_env, &
701 dft_control=dft_control, para_env=para_env)
702 cpassert(ASSOCIATED(pw_env))
703 nspins = dft_control%nspins
704 gapw = dft_control%qs_control%gapw
705 gapw_xc = dft_control%qs_control%gapw_xc
706
707 cpassert(.NOT. dft_control%tddfpt2_control%do_exck)
708 cpassert(.NOT. dft_control%tddfpt2_control%do_hfxsr)
709 cpassert(.NOT. dft_control%tddfpt2_control%do_hfxlr)
710
711 NULLIFY (auxbas_pw_pool, poisson_env)
712 ! gets the tmp grids
713 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
714 poisson_env=poisson_env)
715
716 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
717 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
718 CALL auxbas_pw_pool%create_pw(v_hartree_rspace)
719
720 ALLOCATE (trho_r(nspins), trho_g(nspins))
721 DO ispin = 1, nspins
722 CALL auxbas_pw_pool%create_pw(trho_r(ispin))
723 CALL auxbas_pw_pool%create_pw(trho_g(ispin))
724 END DO
725 IF (gapw_xc) THEN
726 ALLOCATE (trho_xc_r(nspins), trho_xc_g(nspins))
727 DO ispin = 1, nspins
728 CALL auxbas_pw_pool%create_pw(trho_xc_r(ispin))
729 CALL auxbas_pw_pool%create_pw(trho_xc_g(ispin))
730 END DO
731 END IF
732
733 ! GAPW/GAPW_XC initializations
734 NULLIFY (hartree_local, local_rho_set)
735 IF (gapw) THEN
736 CALL get_qs_env(qs_env, &
737 atomic_kind_set=atomic_kind_set, &
738 natom=natom, &
739 qs_kind_set=qs_kind_set)
740 CALL local_rho_set_create(local_rho_set)
741 CALL allocate_rho_atom_internals(local_rho_set%rho_atom_set, atomic_kind_set, &
742 qs_kind_set, dft_control, para_env)
743 CALL init_rho0(local_rho_set, qs_env, dft_control%qs_control%gapw_control, &
744 zcore=0.0_dp)
745 CALL rho0_s_grid_create(pw_env, local_rho_set%rho0_mpole)
746 CALL hartree_local_create(hartree_local)
747 CALL init_coulomb_local(hartree_local, natom)
748 ELSEIF (gapw_xc) THEN
749 CALL get_qs_env(qs_env, &
750 atomic_kind_set=atomic_kind_set, &
751 qs_kind_set=qs_kind_set)
752 CALL local_rho_set_create(local_rho_set)
753 CALL allocate_rho_atom_internals(local_rho_set%rho_atom_set, atomic_kind_set, &
754 qs_kind_set, dft_control, para_env)
755 END IF
756
757 total_rho = 0.0_dp
758 CALL pw_zero(rho_tot_gspace)
759 DO ispin = 1, nspins
760 CALL calculate_rho_elec(ks_env=ks_env, matrix_p=matrix_pe(ispin)%matrix, &
761 rho=trho_r(ispin), &
762 rho_gspace=trho_g(ispin), &
763 soft_valid=gapw, &
764 total_rho=total_rho(ispin))
765 CALL pw_axpy(trho_g(ispin), rho_tot_gspace)
766 IF (gapw_xc) THEN
767 CALL calculate_rho_elec(ks_env=ks_env, matrix_p=matrix_pe(ispin)%matrix, &
768 rho=trho_xc_r(ispin), &
769 rho_gspace=trho_xc_g(ispin), &
770 soft_valid=gapw_xc, &
771 total_rho=rhotot)
772 END IF
773 END DO
774
775 ! GAPW o GAPW_XC require the calculation of hard and soft local densities
776 IF (gapw .OR. gapw_xc) THEN
777 CALL get_qs_env(qs_env=qs_env, oce=oce, sab_orb=sab)
778 CALL calculate_rho_atom_coeff(qs_env, matrix_pe, local_rho_set%rho_atom_set, &
779 qs_kind_set, oce, sab, para_env)
780 CALL prepare_gapw_den(qs_env, local_rho_set, do_rho0=gapw)
781 END IF
782 rhotot = sum(total_rho)
783 IF (gapw) THEN
784 CALL get_rho0_mpole(local_rho_set%rho0_mpole, qlm_tot=qlm_tot)
785 rhotot = rhotot + local_rho_set%rho0_mpole%total_rho0_h
786 CALL pw_axpy(local_rho_set%rho0_mpole%rho0_s_gs, rho_tot_gspace)
787 IF (ASSOCIATED(local_rho_set%rho0_mpole%rhoz_cneo_s_gs)) THEN
788 CALL pw_axpy(local_rho_set%rho0_mpole%rhoz_cneo_s_gs, rho_tot_gspace)
789 END IF
790 END IF
791
792 IF (abs(rhotot) > 1.e-05_dp) THEN
793 logger => cp_get_default_logger()
794 IF (logger%para_env%is_source()) THEN
795 iounit = cp_logger_get_default_unit_nr(logger, local=.true.)
796 ELSE
797 iounit = -1
798 END IF
799 cpwarn("Real space electron count of excitation density is non-zero.")
800 IF (iounit > 0) THEN
801 WRITE (iounit, "(T2,A,T61,G20.10)") "Measured electron count is ", rhotot
802 WRITE (iounit, "(T2,A,/)") repeat("*", 79)
803 END IF
804 END IF
805
806 ! calculate associated hartree potential
807 CALL pw_poisson_solve(poisson_env, rho_tot_gspace, thartree, &
808 v_hartree_gspace)
809 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
810 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
811 IF (gapw) THEN
812 CALL vh_1c_gg_integrals(qs_env, thartree, hartree_local%ecoul_1c, &
813 local_rho_set, para_env, tddft=.true.)
814 CALL integrate_vhg0_rspace(qs_env, v_hartree_rspace, para_env, &
815 calculate_forces=.false., &
816 local_rho_set=local_rho_set)
817 END IF
818
819 ! Fxc*drho term
820 CALL get_qs_env(qs_env, rho=rho)
821 CALL qs_rho_get(rho, rho_r=rho_r, rho_g=rho_g)
822 !
823 CALL get_qs_env(qs_env, input=input)
824 IF (dft_control%do_admm) THEN
825 CALL get_qs_env(qs_env, admm_env=admm_env)
826 xc_section => admm_env%xc_section_primary
827 ELSE
828 xc_section => section_vals_get_subs_vals(input, "DFT%XC")
829 END IF
830 !
831 deriv2_analytic = section_get_lval(xc_section, "2ND_DERIV_ANALYTICAL")
832 IF (deriv2_analytic) THEN
833 NULLIFY (v_xc, v_xc_tau, tau_r)
834 IF (gapw_xc) THEN
835 CALL get_qs_env(qs_env=qs_env, rho_xc=rho_xc)
836 CALL qs_fxc_analytic(rho_xc, trho_xc_r, tau_r, xc_section, auxbas_pw_pool, .false., v_xc, v_xc_tau)
837 ELSE
838 CALL qs_fxc_analytic(rho, trho_r, tau_r, xc_section, auxbas_pw_pool, .false., v_xc, v_xc_tau)
839 END IF
840 IF (gapw .OR. gapw_xc) THEN
841 CALL get_qs_env(qs_env, rho_atom_set=rho_atom_set)
842 rho1_atom_set => local_rho_set%rho_atom_set
843 CALL calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, xc_section, para_env, &
844 do_triplet=.false.)
845 END IF
846 ELSE
847 cpabort("NYA 00006")
848 NULLIFY (v_xc, trho)
849 ALLOCATE (trho)
850 CALL qs_rho_create(trho)
851 CALL qs_rho_set(trho, rho_r=trho_r, rho_g=trho_g)
852 CALL qs_fxc_fdiff(ks_env, rho, trho, xc_section, 6, .false., v_xc, v_xc_tau)
853 DEALLOCATE (trho)
854 END IF
855
856 DO ispin = 1, nspins
857 CALL dbcsr_set(matrix_hz(ispin)%matrix, 0.0_dp)
858 CALL pw_scale(v_xc(ispin), v_xc(ispin)%pw_grid%dvol)
859 END DO
860 IF (gapw_xc) THEN
861 DO ispin = 1, nspins
862 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_hartree_rspace, &
863 hmat=matrix_hz(ispin), &
864 calculate_forces=.false.)
865 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_xc(ispin), &
866 hmat=matrix_hz(ispin), &
867 gapw=gapw_xc, calculate_forces=.false.)
868 END DO
869 ELSE
870 ! vtot = v_xc(ispin) + v_hartree
871 DO ispin = 1, nspins
872 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_xc(ispin), &
873 hmat=matrix_hz(ispin), &
874 gapw=gapw, calculate_forces=.false.)
875 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_hartree_rspace, &
876 hmat=matrix_hz(ispin), &
877 gapw=gapw, calculate_forces=.false.)
878 END DO
879 END IF
880 IF (gapw .OR. gapw_xc) THEN
881 mhz(1:nspins, 1:1) => matrix_hz(1:nspins)
882 mpe(1:nspins, 1:1) => matrix_pe(1:nspins)
883 CALL update_ks_atom(qs_env, mhz, mpe, forces=.false., &
884 rho_atom_external=local_rho_set%rho_atom_set)
885 END IF
886
887 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
888 CALL auxbas_pw_pool%give_back_pw(v_hartree_rspace)
889 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
890 DO ispin = 1, nspins
891 CALL auxbas_pw_pool%give_back_pw(trho_r(ispin))
892 CALL auxbas_pw_pool%give_back_pw(trho_g(ispin))
893 CALL auxbas_pw_pool%give_back_pw(v_xc(ispin))
894 END DO
895 DEALLOCATE (trho_r, trho_g, v_xc)
896 IF (gapw_xc) THEN
897 DO ispin = 1, nspins
898 CALL auxbas_pw_pool%give_back_pw(trho_xc_r(ispin))
899 CALL auxbas_pw_pool%give_back_pw(trho_xc_g(ispin))
900 END DO
901 DEALLOCATE (trho_xc_r, trho_xc_g)
902 END IF
903 IF (ASSOCIATED(v_xc_tau)) THEN
904 DO ispin = 1, nspins
905 CALL auxbas_pw_pool%give_back_pw(v_xc_tau(ispin))
906 END DO
907 DEALLOCATE (v_xc_tau)
908 END IF
909 IF (dft_control%do_admm) THEN
910 IF (qs_env%admm_env%aux_exch_func == do_admm_aux_exch_func_none) THEN
911 ! nothing to do
912 ELSE
913 ! add ADMM xc_section_aux terms: f_x[rhoz_ADMM]
914 CALL get_qs_env(qs_env, admm_env=admm_env)
915 CALL get_admm_env(admm_env, rho_aux_fit=rho_aux_fit, matrix_s_aux_fit=msaux, &
916 task_list_aux_fit=task_list)
917 basis_type = "AUX_FIT"
918 !
919 NULLIFY (mpe, mhz)
920 ALLOCATE (mpe(nspins, 1))
921 CALL dbcsr_allocate_matrix_set(mhz, nspins, 1)
922 DO ispin = 1, nspins
923 ALLOCATE (mhz(ispin, 1)%matrix)
924 CALL dbcsr_create(mhz(ispin, 1)%matrix, template=msaux(1)%matrix)
925 CALL dbcsr_copy(mhz(ispin, 1)%matrix, msaux(1)%matrix)
926 CALL dbcsr_set(mhz(ispin, 1)%matrix, 0.0_dp)
927 mpe(ispin, 1)%matrix => matrix_pe_admm(ispin)%matrix
928 END DO
929 !
930 ! GAPW/GAPW_XC initializations
931 NULLIFY (local_rho_set_admm)
932 IF (admm_env%do_gapw) THEN
933 basis_type = "AUX_FIT_SOFT"
934 task_list => admm_env%admm_gapw_env%task_list
935 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
936 CALL get_admm_env(admm_env, sab_aux_fit=sab_aux_fit)
937 CALL local_rho_set_create(local_rho_set_admm)
938 CALL allocate_rho_atom_internals(local_rho_set_admm%rho_atom_set, atomic_kind_set, &
939 admm_env%admm_gapw_env%admm_kind_set, dft_control, para_env)
940 CALL calculate_rho_atom_coeff(qs_env, matrix_pe_admm, &
941 rho_atom_set=local_rho_set_admm%rho_atom_set, &
942 qs_kind_set=admm_env%admm_gapw_env%admm_kind_set, &
943 oce=admm_env%admm_gapw_env%oce, sab=sab_aux_fit, para_env=para_env)
944 CALL prepare_gapw_den(qs_env, local_rho_set=local_rho_set_admm, &
945 do_rho0=.false., kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
946 END IF
947 !
948 xc_section => admm_env%xc_section_aux
949 !
950 NULLIFY (rho_g_aux, rho_r_aux, rhoz_g_aux, rhoz_r_aux)
951 CALL qs_rho_get(rho_aux_fit, rho_r=rho_r_aux, rho_g=rho_g_aux)
952 ! rhoz_aux
953 ALLOCATE (rhoz_r_aux(nspins), rhoz_g_aux(nspins))
954 DO ispin = 1, nspins
955 CALL auxbas_pw_pool%create_pw(rhoz_r_aux(ispin))
956 CALL auxbas_pw_pool%create_pw(rhoz_g_aux(ispin))
957 END DO
958 DO ispin = 1, nspins
959 CALL calculate_rho_elec(ks_env=ks_env, matrix_p=mpe(ispin, 1)%matrix, &
960 rho=rhoz_r_aux(ispin), rho_gspace=rhoz_g_aux(ispin), &
961 basis_type=basis_type, &
962 task_list_external=task_list)
963 END DO
964 !
965 NULLIFY (v_xc)
966 deriv2_analytic = section_get_lval(xc_section, "2ND_DERIV_ANALYTICAL")
967 IF (deriv2_analytic) THEN
968 NULLIFY (tau_r)
969 CALL qs_fxc_analytic(rho_aux_fit, rhoz_r_aux, tau_r, xc_section, auxbas_pw_pool, .false., v_xc, v_xc_tau)
970 ELSE
971 cpabort("NYA 00007")
972 NULLIFY (rhoz_aux)
973 ALLOCATE (rhoz_aux)
974 CALL qs_rho_create(rhoz_aux)
975 CALL qs_rho_set(rhoz_aux, rho_r=rhoz_r_aux, rho_g=rhoz_g_aux)
976 CALL qs_fxc_fdiff(ks_env, rho_aux_fit, rhoz_aux, xc_section, 6, .false., v_xc, v_xc_tau)
977 DEALLOCATE (rhoz_aux)
978 END IF
979 !
980 DO ispin = 1, nspins
981 CALL pw_scale(v_xc(ispin), v_xc(ispin)%pw_grid%dvol)
982 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_xc(ispin), &
983 hmat=mhz(ispin, 1), basis_type=basis_type, &
984 calculate_forces=.false., &
985 task_list_external=task_list)
986 END DO
987 DO ispin = 1, nspins
988 CALL auxbas_pw_pool%give_back_pw(v_xc(ispin))
989 CALL auxbas_pw_pool%give_back_pw(rhoz_r_aux(ispin))
990 CALL auxbas_pw_pool%give_back_pw(rhoz_g_aux(ispin))
991 END DO
992 DEALLOCATE (v_xc, rhoz_r_aux, rhoz_g_aux)
993 !
994 IF (admm_env%do_gapw) THEN
995 rho_atom_set => admm_env%admm_gapw_env%local_rho_set%rho_atom_set
996 rho1_atom_set => local_rho_set_admm%rho_atom_set
997 CALL calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, xc_section, &
998 para_env, kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
999 CALL update_ks_atom(qs_env, mhz(:, 1), matrix_pe_admm, forces=.false., tddft=.false., &
1000 rho_atom_external=rho1_atom_set, &
1001 kind_set_external=admm_env%admm_gapw_env%admm_kind_set, &
1002 oce_external=admm_env%admm_gapw_env%oce, &
1003 sab_external=sab_aux_fit)
1004 END IF
1005 !
1006 nao = admm_env%nao_orb
1007 nao_aux = admm_env%nao_aux_fit
1008 ALLOCATE (dbwork)
1009 CALL dbcsr_create(dbwork, template=matrix_hz(1)%matrix)
1010 DO ispin = 1, nspins
1011 CALL cp_dbcsr_sm_fm_multiply(mhz(ispin, 1)%matrix, admm_env%A, &
1012 admm_env%work_aux_orb, nao)
1013 CALL parallel_gemm('T', 'N', nao, nao, nao_aux, &
1014 1.0_dp, admm_env%A, admm_env%work_aux_orb, 0.0_dp, &
1015 admm_env%work_orb_orb)
1016 CALL dbcsr_copy(dbwork, matrix_hz(1)%matrix)
1017 CALL dbcsr_set(dbwork, 0.0_dp)
1018 CALL copy_fm_to_dbcsr(admm_env%work_orb_orb, dbwork, keep_sparsity=.true.)
1019 CALL dbcsr_add(matrix_hz(ispin)%matrix, dbwork, 1.0_dp, 1.0_dp)
1020 END DO
1021 CALL dbcsr_release(dbwork)
1022 DEALLOCATE (dbwork)
1024 DEALLOCATE (mpe)
1025 IF (admm_env%do_gapw) THEN
1026 IF (ASSOCIATED(local_rho_set_admm)) CALL local_rho_set_release(local_rho_set_admm)
1027 END IF
1028 END IF
1029 END IF
1030 IF (gapw .OR. gapw_xc) THEN
1031 IF (ASSOCIATED(local_rho_set)) CALL local_rho_set_release(local_rho_set)
1032 IF (ASSOCIATED(hartree_local)) CALL hartree_local_release(hartree_local)
1033 END IF
1034
1035 ! HFX
1036 hfx_section => section_vals_get_subs_vals(xc_section, "HF")
1037 CALL section_vals_get(hfx_section, explicit=do_hfx)
1038 IF (do_hfx) THEN
1039 CALL section_vals_get(hfx_section, n_repetition=n_rep_hf)
1040 cpassert(n_rep_hf == 1)
1041 CALL section_vals_val_get(hfx_section, "TREAT_LSD_IN_CORE", l_val=hfx_treat_lsd_in_core, &
1042 i_rep_section=1)
1043 mspin = 1
1044 IF (hfx_treat_lsd_in_core) mspin = nspins
1045 !
1046 CALL get_qs_env(qs_env=qs_env, rho=rho, x_data=x_data, para_env=para_env, &
1047 s_mstruct_changed=s_mstruct_changed)
1048 distribute_fock_matrix = .true.
1049 IF (dft_control%do_admm) THEN
1050 CALL get_qs_env(qs_env, admm_env=admm_env)
1051 CALL get_admm_env(admm_env, matrix_s_aux_fit=msaux)
1052 NULLIFY (mpe, mhz)
1053 ALLOCATE (mpe(nspins, 1))
1054 CALL dbcsr_allocate_matrix_set(mhz, nspins, 1)
1055 DO ispin = 1, nspins
1056 ALLOCATE (mhz(ispin, 1)%matrix)
1057 CALL dbcsr_create(mhz(ispin, 1)%matrix, template=msaux(1)%matrix)
1058 CALL dbcsr_copy(mhz(ispin, 1)%matrix, msaux(1)%matrix)
1059 CALL dbcsr_set(mhz(ispin, 1)%matrix, 0.0_dp)
1060 mpe(ispin, 1)%matrix => matrix_pe_admm(ispin)%matrix
1061 END DO
1062 IF (x_data(1, 1)%do_hfx_ri) THEN
1063 eh1 = 0.0_dp
1064 CALL hfx_ri_update_ks(qs_env, x_data(1, 1)%ri_data, mhz, eh1, rho_ao=mpe, &
1065 geometry_did_change=s_mstruct_changed, nspins=nspins, &
1066 hf_fraction=x_data(1, 1)%general_parameter%fraction)
1067 ELSE
1068 DO ispin = 1, mspin
1069 eh1 = 0.0
1070 CALL integrate_four_center(qs_env, x_data, mhz, eh1, mpe, hfx_section, &
1071 para_env, s_mstruct_changed, 1, distribute_fock_matrix, &
1072 ispin=ispin)
1073 END DO
1074 END IF
1075 !
1076 cpassert(ASSOCIATED(admm_env%work_aux_orb))
1077 cpassert(ASSOCIATED(admm_env%work_orb_orb))
1078 nao = admm_env%nao_orb
1079 nao_aux = admm_env%nao_aux_fit
1080 ALLOCATE (dbwork)
1081 CALL dbcsr_create(dbwork, template=matrix_hz(1)%matrix)
1082 DO ispin = 1, nspins
1083 CALL cp_dbcsr_sm_fm_multiply(mhz(ispin, 1)%matrix, admm_env%A, &
1084 admm_env%work_aux_orb, nao)
1085 CALL parallel_gemm('T', 'N', nao, nao, nao_aux, &
1086 1.0_dp, admm_env%A, admm_env%work_aux_orb, 0.0_dp, &
1087 admm_env%work_orb_orb)
1088 CALL dbcsr_copy(dbwork, matrix_hz(ispin)%matrix)
1089 CALL dbcsr_set(dbwork, 0.0_dp)
1090 CALL copy_fm_to_dbcsr(admm_env%work_orb_orb, dbwork, keep_sparsity=.true.)
1091 CALL dbcsr_add(matrix_hz(ispin)%matrix, dbwork, 1.0_dp, 1.0_dp)
1092 END DO
1093 CALL dbcsr_release(dbwork)
1094 DEALLOCATE (dbwork)
1096 DEALLOCATE (mpe)
1097 ELSE
1098 NULLIFY (mpe, mhz)
1099 ALLOCATE (mpe(nspins, 1), mhz(nspins, 1))
1100 DO ispin = 1, nspins
1101 mhz(ispin, 1)%matrix => matrix_hz(ispin)%matrix
1102 mpe(ispin, 1)%matrix => matrix_pe(ispin)%matrix
1103 END DO
1104 IF (x_data(1, 1)%do_hfx_ri) THEN
1105 eh1 = 0.0_dp
1106 CALL hfx_ri_update_ks(qs_env, x_data(1, 1)%ri_data, mhz, eh1, rho_ao=mpe, &
1107 geometry_did_change=s_mstruct_changed, nspins=nspins, &
1108 hf_fraction=x_data(1, 1)%general_parameter%fraction)
1109 ELSE
1110 DO ispin = 1, mspin
1111 eh1 = 0.0
1112 CALL integrate_four_center(qs_env, x_data, mhz, eh1, mpe, hfx_section, &
1113 para_env, s_mstruct_changed, 1, distribute_fock_matrix, &
1114 ispin=ispin)
1115 END DO
1116 END IF
1117 DEALLOCATE (mpe, mhz)
1118 END IF
1119 END IF
1120
1121 focc = 4.0_dp
1122 IF (nspins == 2) focc = 2.0_dp
1123 DO ispin = 1, nspins
1124 mos => gs_mos(ispin)%mos_occ
1125 CALL cp_fm_get_info(mos, ncol_global=norb)
1126 CALL cp_dbcsr_sm_fm_multiply(matrix_hz(ispin)%matrix, mos, cpmos(ispin), &
1127 norb, alpha=focc, beta=0.0_dp)
1128 END DO
1129
1130 CALL timestop(handle)
1131
1132 END SUBROUTINE tddfpt_resvec2
1133
1134! **************************************************************************************************
1135!> \brief ...
1136!> \param qs_env ...
1137!> \param matrix_pe ...
1138!> \param gs_mos ...
1139!> \param matrix_hz ...
1140!> \param cpmos ...
1141! **************************************************************************************************
1142 SUBROUTINE tddfpt_resvec2_xtb(qs_env, matrix_pe, gs_mos, matrix_hz, cpmos)
1143
1144 TYPE(qs_environment_type), POINTER :: qs_env
1145 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_pe
1146 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
1147 POINTER :: gs_mos
1148 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_hz
1149 TYPE(cp_fm_type), DIMENSION(:), INTENT(INOUT) :: cpmos
1150
1151 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_resvec2_xtb'
1152
1153 INTEGER :: atom_a, handle, iatom, ikind, is, ispin, &
1154 na, natom, natorb, nkind, norb, ns, &
1155 nsgf, nspins
1156 INTEGER, DIMENSION(25) :: lao
1157 INTEGER, DIMENSION(5) :: occ
1158 REAL(dp), ALLOCATABLE, DIMENSION(:) :: mcharge, mcharge1
1159 REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: aocg, aocg1, charges, charges1
1160 REAL(kind=dp) :: focc
1161 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1162 TYPE(cp_fm_type), POINTER :: mos
1163 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: p_matrix
1164 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_p, matrix_s
1165 TYPE(dbcsr_type), POINTER :: s_matrix
1166 TYPE(dft_control_type), POINTER :: dft_control
1167 TYPE(mp_para_env_type), POINTER :: para_env
1168 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1169 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1170 TYPE(qs_rho_type), POINTER :: rho
1171 TYPE(xtb_atom_type), POINTER :: xtb_kind
1172
1173 CALL timeset(routinen, handle)
1174
1175 cpassert(ASSOCIATED(matrix_pe))
1176
1177 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
1178 nspins = dft_control%nspins
1179
1180 DO ispin = 1, nspins
1181 CALL dbcsr_set(matrix_hz(ispin)%matrix, 0.0_dp)
1182 END DO
1183
1184 IF (dft_control%qs_control%xtb_control%coulomb_interaction) THEN
1185 ! Mulliken charges
1186 CALL get_qs_env(qs_env, rho=rho, particle_set=particle_set, &
1187 matrix_s_kp=matrix_s, para_env=para_env)
1188 natom = SIZE(particle_set)
1189 CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
1190 ALLOCATE (mcharge(natom), charges(natom, 5))
1191 ALLOCATE (mcharge1(natom), charges1(natom, 5))
1192 charges = 0.0_dp
1193 charges1 = 0.0_dp
1194 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
1195 nkind = SIZE(atomic_kind_set)
1196 CALL get_qs_kind_set(qs_kind_set, maxsgf=nsgf)
1197 ALLOCATE (aocg(nsgf, natom))
1198 aocg = 0.0_dp
1199 ALLOCATE (aocg1(nsgf, natom))
1200 aocg1 = 0.0_dp
1201 p_matrix => matrix_p(:, 1)
1202 s_matrix => matrix_s(1, 1)%matrix
1203 CALL ao_charges(p_matrix, s_matrix, aocg, para_env)
1204 CALL ao_charges(matrix_pe, s_matrix, aocg1, para_env)
1205 DO ikind = 1, nkind
1206 CALL get_atomic_kind(atomic_kind_set(ikind), natom=na)
1207 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
1208 CALL get_xtb_atom_param(xtb_kind, natorb=natorb, lao=lao, occupation=occ)
1209 DO iatom = 1, na
1210 atom_a = atomic_kind_set(ikind)%atom_list(iatom)
1211 charges(atom_a, :) = real(occ(:), kind=dp)
1212 DO is = 1, natorb
1213 ns = lao(is) + 1
1214 charges(atom_a, ns) = charges(atom_a, ns) - aocg(is, atom_a)
1215 charges1(atom_a, ns) = charges1(atom_a, ns) - aocg1(is, atom_a)
1216 END DO
1217 END DO
1218 END DO
1219 DEALLOCATE (aocg, aocg1)
1220 DO iatom = 1, natom
1221 mcharge(iatom) = sum(charges(iatom, :))
1222 mcharge1(iatom) = sum(charges1(iatom, :))
1223 END DO
1224 ! Coulomb Kernel
1225 CALL xtb_coulomb_hessian(qs_env, matrix_hz, charges1, mcharge1, mcharge)
1226 !
1227 DEALLOCATE (charges, mcharge, charges1, mcharge1)
1228 END IF
1229
1230 focc = 2.0_dp
1231 IF (nspins == 2) focc = 1.0_dp
1232 DO ispin = 1, nspins
1233 mos => gs_mos(ispin)%mos_occ
1234 CALL cp_fm_get_info(mos, ncol_global=norb)
1235 CALL cp_dbcsr_sm_fm_multiply(matrix_hz(ispin)%matrix, mos, cpmos(ispin), &
1236 norb, alpha=focc, beta=0.0_dp)
1237 END DO
1238
1239 CALL timestop(handle)
1240
1241 END SUBROUTINE tddfpt_resvec2_xtb
1242
1243! **************************************************************************************************
1244!> \brief ...
1245!> \param qs_env ...
1246!> \param cpmos ...
1247!> \param work ...
1248! **************************************************************************************************
1249 SUBROUTINE tddfpt_resvec3(qs_env, cpmos, work)
1250
1251 TYPE(qs_environment_type), POINTER :: qs_env
1252 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: cpmos
1253 TYPE(tddfpt_work_matrices) :: work
1254
1255 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_resvec3'
1256
1257 INTEGER :: handle, ispin, nao, norb, nspins
1258 TYPE(cp_fm_struct_type), POINTER :: fmstruct
1259 TYPE(cp_fm_type) :: cvec, umat
1260 TYPE(cp_fm_type), POINTER :: omos
1261 TYPE(dft_control_type), POINTER :: dft_control
1262 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
1263
1264 CALL timeset(routinen, handle)
1265
1266 CALL get_qs_env(qs_env, mos=mos, dft_control=dft_control)
1267 nspins = dft_control%nspins
1268
1269 DO ispin = 1, nspins
1270 CALL get_mo_set(mos(ispin), mo_coeff=omos)
1271 associate(rvecs => cpmos(ispin))
1272 CALL cp_fm_get_info(rvecs, nrow_global=nao, ncol_global=norb)
1273 CALL cp_fm_create(cvec, rvecs%matrix_struct, "cvec")
1274 CALL cp_fm_struct_create(fmstruct, context=rvecs%matrix_struct%context, nrow_global=norb, &
1275 ncol_global=norb, para_env=rvecs%matrix_struct%para_env)
1276 CALL cp_fm_create(umat, fmstruct, "umat")
1277 CALL cp_fm_struct_release(fmstruct)
1278 !
1279 CALL parallel_gemm("T", "N", norb, norb, nao, 1.0_dp, omos, work%S_C0(ispin), 0.0_dp, umat)
1280 CALL cp_fm_copy_general(rvecs, cvec, rvecs%matrix_struct%para_env)
1281 CALL parallel_gemm("N", "T", nao, norb, norb, 1.0_dp, cvec, umat, 0.0_dp, rvecs)
1282 END associate
1283 CALL cp_fm_release(cvec)
1284 CALL cp_fm_release(umat)
1285 END DO
1286
1287 CALL timestop(handle)
1288
1289 END SUBROUTINE tddfpt_resvec3
1290
1291! **************************************************************************************************
1292!> \brief Calculate direct tddft forces
1293!> \param qs_env ...
1294!> \param ex_env ...
1295!> \param gs_mos ...
1296!> \param kernel_env ...
1297!> \param sub_env ...
1298!> \param work_matrices ...
1299!> \param debug_forces ...
1300!> \par History
1301!> * 01.2020 screated [JGH]
1302! **************************************************************************************************
1303 SUBROUTINE tddfpt_kernel_force(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices, debug_forces)
1304
1305 TYPE(qs_environment_type), POINTER :: qs_env
1306 TYPE(excited_energy_type), POINTER :: ex_env
1307 TYPE(tddfpt_ground_state_mos), DIMENSION(:), &
1308 POINTER :: gs_mos
1309 TYPE(kernel_env_type), INTENT(IN) :: kernel_env
1310 TYPE(tddfpt_subgroup_env_type) :: sub_env
1311 TYPE(tddfpt_work_matrices) :: work_matrices
1312 LOGICAL, INTENT(IN) :: debug_forces
1313
1314 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_kernel_force'
1315
1316 INTEGER :: handle
1317 TYPE(dft_control_type), POINTER :: dft_control
1318 TYPE(tddfpt2_control_type), POINTER :: tddfpt_control
1319
1320 mark_used(work_matrices)
1321
1322 CALL timeset(routinen, handle)
1323
1324 CALL get_qs_env(qs_env, dft_control=dft_control)
1325 tddfpt_control => dft_control%tddfpt2_control
1326
1327 IF (tddfpt_control%kernel == tddfpt_kernel_full) THEN
1328 ! full Kernel
1329 CALL fhxc_force(qs_env, ex_env, gs_mos, kernel_env%full_kernel, debug_forces)
1330 ELSE IF (tddfpt_control%kernel == tddfpt_kernel_stda) THEN
1331 ! sTDA Kernel
1332 CALL stda_force(qs_env, ex_env, gs_mos, kernel_env%stda_kernel, sub_env, work_matrices, debug_forces)
1333 ELSE IF (tddfpt_control%kernel == tddfpt_kernel_none) THEN
1334 ! nothing to be done here
1335 ex_env%matrix_wx1 => null()
1336 ELSE
1337 cpabort('Unknown kernel type')
1338 END IF
1339
1340 CALL timestop(handle)
1341
1342 END SUBROUTINE tddfpt_kernel_force
1343
1344END MODULE qs_tddfpt2_forces
Types and set/get functions for auxiliary density matrix methods.
Definition admm_types.F:15
subroutine, public get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, rho_aux_fit_buffer, admm_dm)
Get routine for the ADMM env.
Definition admm_types.F:593
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public sertcan2024
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_complete_redistribute(matrix, redist)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
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 copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS 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 the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_copy_general(source, destination, para_env)
General copy of a fm matrix to another fm matrix. Uses non-blocking MPI rather than ScaLAPACK.
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_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Types for excited states potential energies.
subroutine, public exstate_potential_release(ex_env)
...
subroutine, public init_coulomb_local(hartree_local, natom)
...
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...
subroutine, public hartree_local_release(hartree_local)
...
subroutine, public hartree_local_create(hartree_local)
...
Routines to calculate HFX energy and potential.
subroutine, public integrate_four_center(qs_env, x_data, ks_matrix, ehfx, rho_ao, hfx_section, para_env, geometry_did_change, irep, distribute_fock_matrix, ispin)
computes four center integrals for a full basis set and updates the Kohn-Sham-Matrix and energy....
RI-methods for HFX.
Definition hfx_ri.F:12
subroutine, public hfx_ri_update_ks(qs_env, ri_data, ks_matrix, ehfx, mos, rho_ao, geometry_did_change, nspins, hf_fraction)
...
Definition hfx_ri.F:1041
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_kernel_none
integer, parameter, public oe_shift
integer, parameter, public do_admm_aux_exch_func_none
integer, parameter, public tddfpt_kernel_full
integer, parameter, public tddfpt_kernel_stda
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
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
logical function, public section_get_lval(section_vals, keyword_name)
...
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
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Definition mulliken.F:13
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 ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
collects routines that calculate density matrices
subroutine, public calculate_wx_matrix(mos_occ, xvec, ks_matrix, w_matrix)
Calculate the excited state W matrix from the MO eigenvectors, KS matrix.
subroutine, public calculate_xwx_matrix(mos_occ, xvec, s_matrix, ks_matrix, w_matrix, eval)
Calculate the excited state W matrix from the MO eigenvectors, KS matrix.
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 set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
subroutine, public sum_qs_force(qs_force_out, qs_force_in)
Sum up two qs_force entities qs_force_out = qs_force_out + qs_force_in.
subroutine, public deallocate_qs_force(qs_force)
Deallocate a Quickstep force data structure.
subroutine, public zero_qs_force(qs_force)
Initialize a Quickstep force data structure.
subroutine, public allocate_qs_force(qs_force, natom_of_kind)
Allocate a Quickstep force data structure.
subroutine, public total_qs_force(force, qs_force, atomic_kind_set)
Get current total force.
https://en.wikipedia.org/wiki/Finite_difference_coefficient
Definition qs_fxc.F:27
subroutine, public qs_fxc_analytic(rho0, rho1_r, tau1_r, xc_section, auxbas_pw_pool, is_triplet, v_xc, v_xc_tau)
...
Definition qs_fxc.F:85
subroutine, public qs_fxc_fdiff(ks_env, rho0_struct, rho1_struct, xc_section, accuracy, is_triplet, fxc_rho, fxc_tau)
...
Definition qs_fxc.F:146
subroutine, public prepare_gapw_den(qs_env, local_rho_set, do_rho0, kind_set_external, pw_env_sub)
...
Integrate single or product functions over a potential on a RS grid.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
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
Calculate the KS reference potentials.
subroutine, public ks_ref_potential(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, ehartree, exc, h_stress)
calculate the Kohn-Sham reference potential
subroutine, public ks_ref_potential_atom(qs_env, local_rho_set, local_rho_set_admm, v_hartree_rspace)
calculate the Kohn-Sham GAPW reference potentials
subroutine, public local_rho_set_create(local_rho_set)
...
subroutine, public local_rho_set_release(local_rho_set)
...
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
Calculation of overlap matrix, its derivatives and forces.
Definition qs_overlap.F:19
subroutine, public build_overlap_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p)
Calculation of the overlap matrix over Cartesian Gaussian functions.
Definition qs_overlap.F:120
subroutine, public rho0_s_grid_create(pw_env, rho0_mpole)
...
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)
...
subroutine, public init_rho0(local_rho_set, qs_env, gapw_control, zcore)
...
subroutine, public get_rho0_mpole(rho0_mpole, g0_h, vg0_h, iat, ikind, lmax_0, l0_ikind, mp_gau_ikind, mp_rho, norm_g0l_h, qlm_gg, qlm_car, qlm_tot, zet0_h, igrid_zet0_s, rpgf0_h, rpgf0_s, max_rpgf0_s, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs)
...
subroutine, public allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
subroutine, public calculate_rho_atom_coeff(qs_env, rho_ao, rho_atom_set, qs_kind_set, oce, sab, para_env)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(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)
...
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 qs_rho_create(rho)
Allocates a new instance of rho.
subroutine, public stda_force(qs_env, ex_env, gs_mos, stda_env, sub_env, work, debug_forces)
Simplified Tamm Dancoff approach (sTDA). Kernel contribution to forces.
subroutine, public fhxc_force(qs_env, ex_env, gs_mos, full_kernel, debug_forces)
Calculate direct tddft forces.
subroutine, public tddfpt_forces_main(qs_env, gs_mos, ex_env, kernel_env, sub_env, work_matrices)
Perform TDDFPT gradient calculation.
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, kind_set_external)
...
types for task lists
Calculation of Coulomb Hessian contributions in xTB.
Definition xtb_ehess.F:12
subroutine, public xtb_coulomb_hessian(qs_env, ks_matrix, charges1, mcharge1, mcharge)
...
Definition xtb_ehess.F:77
Definition of the xTB parameter types.
Definition xtb_types.F:20
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, xi, kappa0, alpg, occupation, electronegativity, chmax, en, kqat2, kcn, kq)
...
Definition xtb_types.F:199
stores some data used in wavefunction fitting
Definition admm_types.F:120
Provides all information about an atomic kind.
keeps the information about the structure of a full matrix
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information on the excited states energy.
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
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Type to hold environments for the different kernels.
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.
Ground state molecular orbitals.
Set of temporary ("work") matrices.