(git:50ddb19)
Loading...
Searching...
No Matches
kg_correction.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
8! **************************************************************************************************
9!> \brief Routines for a Kim-Gordon-like partitioning into molecular subunits
10!> \par History
11!> 2012.06 created [Martin Haeufel]
12!> \author Martin Haeufel and Florian Schiffmann
13! **************************************************************************************************
17 USE cp_dbcsr_api, ONLY: dbcsr_add,&
23 USE ec_methods, ONLY: create_kernel
32 USE kinds, ONLY: dp
41 USE pw_env_types, ONLY: pw_env_get,&
43 USE pw_methods, ONLY: pw_integral_ab,&
46 USE pw_types, ONLY: pw_c1d_gs_type,&
50 USE qs_integrate_potential, ONLY: integrate_v_rspace,&
51 integrate_v_rspace_one_center
55 USE qs_rho_types, ONLY: qs_rho_create,&
61 USE qs_vxc, ONLY: qs_vxc_create
62 USE virial_types, ONLY: virial_type
64#include "./base/base_uses.f90"
65
66 IMPLICIT NONE
67
68 PRIVATE
69
70 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'kg_correction'
71
72 PUBLIC :: kg_ekin_subset
73
74CONTAINS
75
76! **************************************************************************************************
77!> \brief Calculates the subsystem Hohenberg-Kohn kinetic energy and the forces
78!> \param qs_env ...
79!> \param ks_matrix ...
80!> \param ekin_mol ...
81!> \param calc_force ...
82!> \param do_kernel Contribution of kinetic energy functional to kernel in response calculation
83!> \param pmat_ext Response density used to fold 2nd deriv or to integrate kinetic energy functional
84!> \par History
85!> 2012.06 created [Martin Haeufel]
86!> 2014.01 added atomic potential option [JGH]
87!> 2020.01 Added KG contribution to linear response [fbelle]
88!> \author Martin Haeufel and Florian Schiffmann
89! **************************************************************************************************
90 SUBROUTINE kg_ekin_subset(qs_env, ks_matrix, ekin_mol, calc_force, do_kernel, pmat_ext)
91 TYPE(qs_environment_type), POINTER :: qs_env
92 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_matrix
93 REAL(kind=dp), INTENT(out) :: ekin_mol
94 LOGICAL, INTENT(IN) :: calc_force, do_kernel
95 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
96 POINTER :: pmat_ext
97
98 LOGICAL :: lrigpw
99 TYPE(dft_control_type), POINTER :: dft_control
100 TYPE(kg_environment_type), POINTER :: kg_env
101
102 CALL get_qs_env(qs_env, kg_env=kg_env, dft_control=dft_control)
103 lrigpw = dft_control%qs_control%lrigpw
104 IF ((kg_env%tnadd_method == kg_tnadd_embed_ri .OR. &
105 (kg_env%tnadd_method == kg_tnadd_embed .AND. lrigpw)) .AND. &
106 kg_uses_kinetic_energy_density(kg_env, dft_control%lsd)) THEN
107 cpabort("KG LRI/RI embedding with meta-kinetic energy functionals not implemented")
108 END IF
109 IF (kg_env%tnadd_method == kg_tnadd_embed) THEN
110 IF (lrigpw) THEN
111 CALL kg_ekin_embed_lri(qs_env, kg_env, ks_matrix, ekin_mol, calc_force)
112 ELSE
113 CALL kg_ekin_embed(qs_env, kg_env, ks_matrix, ekin_mol, calc_force, &
114 do_kernel, pmat_ext)
115 END IF
116 ELSE IF (kg_env%tnadd_method == kg_tnadd_embed_ri) THEN
117 CALL kg_ekin_ri_embed(qs_env, kg_env, ks_matrix, ekin_mol, calc_force, &
118 do_kernel, pmat_ext)
119 ELSE IF (kg_env%tnadd_method == kg_tnadd_atomic) THEN
120 CALL kg_ekin_atomic(qs_env, ks_matrix, ekin_mol)
121 ELSE IF (kg_env%tnadd_method == kg_tnadd_none) THEN
122 ekin_mol = 0.0_dp
123 ELSE
124 cpabort("Unknown KG embedding method")
125 END IF
126
127 END SUBROUTINE kg_ekin_subset
128
129! **************************************************************************************************
130!> \brief Returns whether the KG XC section needs the kinetic energy density.
131!> \param kg_env Kim-Gordon environment
132!> \param lsd spin-polarized calculation flag
133!> \return ...
134! **************************************************************************************************
135 FUNCTION kg_uses_kinetic_energy_density(kg_env, lsd) RESULT(res)
136 TYPE(kg_environment_type), POINTER :: kg_env
137 LOGICAL, INTENT(IN) :: lsd
138 LOGICAL :: res
139
140 LOGICAL :: explicit
141 TYPE(section_vals_type), POINTER :: xc_fun_section
142
143 res = .false.
144 IF (.NOT. ASSOCIATED(kg_env%xc_section_kg)) RETURN
145
146 xc_fun_section => section_vals_get_subs_vals(kg_env%xc_section_kg, "XC_FUNCTIONAL")
147 CALL section_vals_get(xc_fun_section, explicit=explicit)
148 IF (explicit) res = xc_uses_kinetic_energy_density(xc_fun_section, lsd)
149
150 END FUNCTION kg_uses_kinetic_energy_density
151
152! **************************************************************************************************
153!> \brief ...
154!> \param qs_env ...
155!> \param kg_env ...
156!> \param ks_matrix ...
157!> \param ekin_mol ...
158!> \param calc_force ...
159!> \param do_kernel Contribution of kinetic energy functional to kernel in response calculation
160!> \param pmat_ext Response density used to fold 2nd deriv or to integrate kinetic energy functional
161! **************************************************************************************************
162 SUBROUTINE kg_ekin_embed(qs_env, kg_env, ks_matrix, ekin_mol, calc_force, do_kernel, pmat_ext)
163 TYPE(qs_environment_type), POINTER :: qs_env
164 TYPE(kg_environment_type), POINTER :: kg_env
165 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_matrix
166 REAL(kind=dp), INTENT(out) :: ekin_mol
167 LOGICAL, INTENT(IN) :: calc_force, do_kernel
168 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
169 POINTER :: pmat_ext
170
171 CHARACTER(LEN=*), PARAMETER :: routinen = 'kg_ekin_embed'
172
173 CHARACTER(LEN=10) :: basis_type
174 INTEGER :: handle, iounit, ispin, isub, nspins
175 LOGICAL :: gapw, gapw_xc, use_gapw_soft, use_virial
176 REAL(kind=dp) :: alpha, ekin_imol
177 REAL(kind=dp), DIMENSION(3, 3) :: xcvirial
178 TYPE(cp_logger_type), POINTER :: logger
179 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: density_matrix
180 TYPE(dft_control_type), POINTER :: dft_control
181 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho1_g
182 TYPE(pw_env_type), POINTER :: pw_env
183 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
184 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho1_r, rho_r, tau1_r, vxc_rho, vxc_tau
185 TYPE(qs_ks_env_type), POINTER :: ks_env
186 TYPE(qs_rho_type), POINTER :: old_rho, rho1, rho1_use, rho1_xc, &
187 rho_struct, rho_use, rho_xc
188 TYPE(section_vals_type), POINTER :: xc_section
189 TYPE(virial_type), POINTER :: virial
190
191 CALL timeset(routinen, handle)
192
193 logger => cp_get_default_logger()
194 iounit = cp_logger_get_default_unit_nr(logger)
195
196 NULLIFY (ks_env, dft_control, old_rho, pw_env, rho1_use, rho1_xc, rho_struct, &
197 rho_use, rho_xc, virial, vxc_rho, vxc_tau)
198
199 CALL get_qs_env(qs_env, &
200 ks_env=ks_env, &
201 rho=old_rho, &
202 dft_control=dft_control, &
203 virial=virial, &
204 pw_env=pw_env)
205 nspins = dft_control%nspins
206 gapw = dft_control%qs_control%gapw
207 gapw_xc = dft_control%qs_control%gapw_xc
208 use_gapw_soft = gapw .OR. gapw_xc
209 IF (use_gapw_soft) THEN
210 basis_type = "ORB_SOFT"
211 ELSE
212 basis_type = "ORB"
213 END IF
214 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
215 use_virial = use_virial .AND. calc_force
216
217 ! Kernel potential in response calculation (no forces calculated at this point)
218 ! requires spin-factor
219 ! alpha = 2 closed-shell
220 ! alpha = 1 open-shell
221 alpha = 1.0_dp
222 IF (do_kernel .AND. .NOT. calc_force .AND. nspins == 1) alpha = 2.0_dp
223
224 NULLIFY (auxbas_pw_pool)
225 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
226
227 ! get the density matrix
228 CALL qs_rho_get(old_rho, rho_ao=density_matrix)
229 ! allocate and initialize the density
230 ALLOCATE (rho_struct)
231 CALL qs_rho_create(rho_struct)
232 ! set the density matrix to the blocked matrix
233 CALL qs_rho_set(rho_struct, rho_ao=density_matrix) ! blocked_matrix
234 CALL qs_rho_rebuild(rho_struct, qs_env, rebuild_ao=.false., rebuild_grids=.true.)
235 IF (gapw_xc) THEN
236 ALLOCATE (rho_xc)
237 CALL qs_rho_create(rho_xc)
238 CALL qs_rho_rebuild(rho_xc, qs_env, rebuild_ao=.true., rebuild_grids=.true.)
239 END IF
240 ! full density kinetic energy term
241 IF (gapw_xc) THEN
242 CALL qs_rho_update_rho(rho_struct, qs_env, rho_xc_external=rho_xc)
243 rho_use => rho_xc
244 ELSE
245 CALL qs_rho_update_rho(rho_struct, qs_env)
246 rho_use => rho_struct
247 END IF
248 ! get blocked density that has been put on grid
249 CALL qs_rho_get(rho_use, rho_r=rho_r)
250
251 ! If external density associated then it is needed either for
252 ! 1) folding of second derivative while partially integrating, or
253 ! 2) integration of response forces
254 NULLIFY (rho1)
255 IF (PRESENT(pmat_ext)) THEN
256 ALLOCATE (rho1)
257 CALL qs_rho_create(rho1)
258 CALL qs_rho_set(rho1, rho_ao=pmat_ext)
259 CALL qs_rho_rebuild(rho1, qs_env, rebuild_ao=.false., rebuild_grids=.true.)
260 IF (gapw_xc) THEN
261 ALLOCATE (rho1_xc)
262 CALL qs_rho_create(rho1_xc)
263 CALL qs_rho_rebuild(rho1_xc, qs_env, rebuild_ao=.true., rebuild_grids=.true.)
264 CALL qs_rho_update_rho(rho1, qs_env, rho_xc_external=rho1_xc)
265 rho1_use => rho1_xc
266 ELSE
267 CALL qs_rho_update_rho(rho1, qs_env)
268 rho1_use => rho1
269 END IF
270 END IF
271
272 ! XC-section pointing to kinetic energy functional in KG environment
273 NULLIFY (xc_section)
274 xc_section => kg_env%xc_section_kg
275
276 ekin_imol = 0.0_dp
277
278 ! calculate xc potential or kernel
279 IF (do_kernel) THEN
280 ! derivation wrt to rho_struct and evaluation at rho_struct
281 IF (use_virial) virial%pv_xc = 0.0_dp
282 CALL qs_rho_get(rho1_use, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
283 CALL create_kernel(qs_env, &
284 vxc=vxc_rho, &
285 vxc_tau=vxc_tau, &
286 rho=rho_use, &
287 rho1_r=rho1_r, &
288 rho1_g=rho1_g, &
289 tau1_r=tau1_r, &
290 xc_section=xc_section, &
291 compute_virial=use_virial, &
292 virial_xc=virial%pv_xc)
293 ELSE
294 CALL qs_vxc_create(ks_env=ks_env, &
295 rho_struct=rho_use, &
296 xc_section=xc_section, &
297 vxc_rho=vxc_rho, &
298 vxc_tau=vxc_tau, &
299 exc=ekin_imol)
300 END IF
301
302 ! Integrate xc-potential with external density for outer response forces
303 IF (PRESENT(pmat_ext) .AND. .NOT. do_kernel) THEN
304 CALL qs_rho_get(rho1, rho_ao=density_matrix)
305 CALL qs_rho_get(rho1_use, rho_r=rho1_r, tau_r=tau1_r)
306 ! Direct volume term of virial
307 ! xc-potential is unscaled
308 IF (use_virial) THEN
309 ekin_imol = 0.0_dp
310 DO ispin = 1, nspins
311 ekin_imol = ekin_imol + pw_integral_ab(rho1_r(ispin), vxc_rho(ispin))
312 IF (ASSOCIATED(vxc_tau)) THEN
313 ekin_imol = ekin_imol + pw_integral_ab(tau1_r(ispin), vxc_tau(ispin))
314 END IF
315 END DO
316 END IF
317 END IF
318
319 DO ispin = 1, nspins
320 CALL pw_scale(vxc_rho(ispin), alpha*vxc_rho(ispin)%pw_grid%dvol)
321 END DO
322
323 DO ispin = 1, nspins
324 CALL integrate_v_rspace(v_rspace=vxc_rho(ispin), &
325 pmat=density_matrix(ispin), hmat=ks_matrix(ispin), &
326 qs_env=qs_env, calculate_forces=calc_force, gapw=use_gapw_soft)
327 CALL auxbas_pw_pool%give_back_pw(vxc_rho(ispin))
328 IF (ASSOCIATED(vxc_tau)) THEN
329 CALL pw_scale(vxc_tau(ispin), alpha*vxc_tau(ispin)%pw_grid%dvol)
330 CALL integrate_v_rspace(v_rspace=vxc_tau(ispin), &
331 pmat=density_matrix(ispin), hmat=ks_matrix(ispin), &
332 qs_env=qs_env, compute_tau=.true., &
333 calculate_forces=calc_force, gapw=use_gapw_soft)
334 CALL auxbas_pw_pool%give_back_pw(vxc_tau(ispin))
335 END IF
336 END DO
337 DEALLOCATE (vxc_rho)
338 IF (ASSOCIATED(vxc_tau)) DEALLOCATE (vxc_tau)
339 ekin_mol = -ekin_imol
340 xcvirial(1:3, 1:3) = 0.0_dp
341 IF (use_virial) THEN
342 xcvirial(1:3, 1:3) = xcvirial(1:3, 1:3) - virial%pv_xc(1:3, 1:3)
343 END IF
344
345 ! loop over all subsets
346 DO isub = 1, kg_env%nsubsets
347 ! calculate the densities for the given blocked density matrix
348 ! pass the subset task_list
349 IF (gapw_xc) THEN
350 CALL qs_rho_update_rho(rho_struct, qs_env, rho_xc_external=rho_xc, &
351 task_list_external=kg_env%subset(isub)%task_list, &
352 task_list_external_soft=kg_env%subset(isub)%task_list)
353 rho_use => rho_xc
354 ELSE
355 CALL qs_rho_update_rho(rho_struct, qs_env, &
356 task_list_external=kg_env%subset(isub)%task_list)
357 rho_use => rho_struct
358 END IF
359 ! Same for external (response) density if present
360 IF (PRESENT(pmat_ext)) THEN
361 IF (gapw_xc) THEN
362 CALL qs_rho_update_rho(rho1, qs_env, rho_xc_external=rho1_xc, &
363 task_list_external=kg_env%subset(isub)%task_list, &
364 task_list_external_soft=kg_env%subset(isub)%task_list)
365 rho1_use => rho1_xc
366 ELSE
367 CALL qs_rho_update_rho(rho1, qs_env, &
368 task_list_external=kg_env%subset(isub)%task_list)
369 rho1_use => rho1
370 END IF
371 END IF
372
373 ekin_imol = 0.0_dp
374 NULLIFY (vxc_rho, vxc_tau)
375
376 ! calculate Hohenberg-Kohn kinetic energy of the density
377 ! corresponding to the remaining molecular block(s)
378 ! info per block in rho_struct now
379
380 ! calculate xc-potential or kernel
381 IF (do_kernel) THEN
382 IF (use_virial) virial%pv_xc = 0.0_dp
383 CALL qs_rho_get(rho1_use, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
384 CALL create_kernel(qs_env, &
385 vxc=vxc_rho, &
386 vxc_tau=vxc_tau, &
387 rho=rho_use, &
388 rho1_r=rho1_r, &
389 rho1_g=rho1_g, &
390 tau1_r=tau1_r, &
391 xc_section=xc_section, &
392 compute_virial=use_virial, &
393 virial_xc=virial%pv_xc)
394 ELSE
395 CALL qs_vxc_create(ks_env=ks_env, &
396 rho_struct=rho_use, &
397 xc_section=xc_section, &
398 vxc_rho=vxc_rho, &
399 vxc_tau=vxc_tau, &
400 exc=ekin_imol)
401 END IF
402
403 ! Integrate with response density for outer response forces
404 IF (PRESENT(pmat_ext) .AND. .NOT. do_kernel) THEN
405 CALL qs_rho_get(rho1, rho_ao=density_matrix)
406 CALL qs_rho_get(rho1_use, rho_r=rho1_r, tau_r=tau1_r)
407 ! Direct volume term of virial
408 ! xc-potential is unscaled
409 IF (use_virial) THEN
410 ekin_imol = 0.0_dp
411 DO ispin = 1, nspins
412 ekin_imol = ekin_imol + pw_integral_ab(rho1_r(ispin), vxc_rho(ispin))
413 IF (ASSOCIATED(vxc_tau)) THEN
414 ekin_imol = ekin_imol + pw_integral_ab(tau1_r(ispin), vxc_tau(ispin))
415 END IF
416 END DO
417 END IF
418 END IF
419
420 DO ispin = 1, nspins
421 CALL pw_scale(vxc_rho(ispin), -alpha*vxc_rho(ispin)%pw_grid%dvol)
422
423 CALL integrate_v_rspace(v_rspace=vxc_rho(ispin), &
424 pmat=density_matrix(ispin), &
425 hmat=ks_matrix(ispin), &
426 qs_env=qs_env, &
427 calculate_forces=calc_force, &
428 basis_type=basis_type, &
429 task_list_external=kg_env%subset(isub)%task_list)
430 ! clean up vxc_rho
431 CALL auxbas_pw_pool%give_back_pw(vxc_rho(ispin))
432 IF (ASSOCIATED(vxc_tau)) THEN
433 CALL pw_scale(vxc_tau(ispin), -alpha*vxc_tau(ispin)%pw_grid%dvol)
434 CALL integrate_v_rspace(v_rspace=vxc_tau(ispin), &
435 pmat=density_matrix(ispin), &
436 hmat=ks_matrix(ispin), &
437 qs_env=qs_env, &
438 compute_tau=.true., &
439 calculate_forces=calc_force, &
440 basis_type=basis_type, &
441 task_list_external=kg_env%subset(isub)%task_list)
442 ! clean up vxc_rho
443 CALL auxbas_pw_pool%give_back_pw(vxc_tau(ispin))
444 END IF
445 END DO
446 DEALLOCATE (vxc_rho)
447 IF (ASSOCIATED(vxc_tau)) DEALLOCATE (vxc_tau)
448
449 ekin_mol = ekin_mol + ekin_imol
450
451 IF (use_virial) THEN
452 xcvirial(1:3, 1:3) = xcvirial(1:3, 1:3) + virial%pv_xc(1:3, 1:3)
453 END IF
454
455 END DO
456
457 IF (use_virial) THEN
458 virial%pv_xc(1:3, 1:3) = xcvirial(1:3, 1:3)
459 END IF
460
461 ! clean up rho_struct
462 CALL qs_rho_unset_rho_ao(rho_struct)
463 CALL qs_rho_release(rho_struct)
464 DEALLOCATE (rho_struct)
465 IF (ASSOCIATED(rho_xc)) THEN
466 CALL qs_rho_release(rho_xc)
467 DEALLOCATE (rho_xc)
468 END IF
469 IF (PRESENT(pmat_ext)) THEN
470 CALL qs_rho_unset_rho_ao(rho1)
471 CALL qs_rho_release(rho1)
472 DEALLOCATE (rho1)
473 IF (ASSOCIATED(rho1_xc)) THEN
474 CALL qs_rho_release(rho1_xc)
475 DEALLOCATE (rho1_xc)
476 END IF
477 END IF
478
479 CALL timestop(handle)
480
481 END SUBROUTINE kg_ekin_embed
482
483! **************************************************************************************************
484!> \brief ...
485!> \param qs_env ...
486!> \param kg_env ...
487!> \param ks_matrix ...
488!> \param ekin_mol ...
489!> \param calc_force ...
490! **************************************************************************************************
491 SUBROUTINE kg_ekin_embed_lri(qs_env, kg_env, ks_matrix, ekin_mol, calc_force)
492 TYPE(qs_environment_type), POINTER :: qs_env
493 TYPE(kg_environment_type), POINTER :: kg_env
494 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_matrix
495 REAL(kind=dp), INTENT(out) :: ekin_mol
496 LOGICAL :: calc_force
497
498 CHARACTER(LEN=*), PARAMETER :: routinen = 'kg_ekin_embed_lri'
499
500 INTEGER :: color, handle, iatom, ikind, imol, &
501 ispin, isub, natom, nkind, nspins
502 INTEGER, ALLOCATABLE, DIMENSION(:) :: atomlist
503 LOGICAL :: use_virial
504 REAL(kind=dp) :: ekin_imol
505 REAL(kind=dp), DIMENSION(3, 3) :: xcvirial
506 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
507 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: density_matrix, ksmat
508 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: pmat
509 TYPE(dft_control_type), POINTER :: dft_control
510 TYPE(lri_density_type), POINTER :: lri_density
511 TYPE(lri_environment_type), POINTER :: lri_env
512 TYPE(lri_kind_type), DIMENSION(:), POINTER :: lri_v_int
513 TYPE(mp_para_env_type), POINTER :: para_env
514 TYPE(pw_env_type), POINTER :: pw_env
515 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
516 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vxc_rho, vxc_tau
517 TYPE(qs_ks_env_type), POINTER :: ks_env
518 TYPE(qs_rho_type), POINTER :: old_rho, rho_struct
519 TYPE(virial_type), POINTER :: virial
520
521 CALL timeset(routinen, handle)
522
523 NULLIFY (vxc_rho, vxc_tau, old_rho, rho_struct, ks_env)
524
525 CALL get_qs_env(qs_env, dft_control=dft_control)
526
527 ! get set of molecules, natom, dft_control, pw_env
528 CALL get_qs_env(qs_env, &
529 ks_env=ks_env, &
530 rho=old_rho, &
531 natom=natom, &
532 dft_control=dft_control, &
533 virial=virial, &
534 para_env=para_env, &
535 pw_env=pw_env)
536
537 nspins = dft_control%nspins
538 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
539 use_virial = use_virial .AND. calc_force
540
541 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
542
543 ! get the density matrix
544 CALL qs_rho_get(old_rho, rho_ao=density_matrix)
545 ! allocate and initialize the density
546 ALLOCATE (rho_struct)
547 CALL qs_rho_create(rho_struct)
548 ! set the density matrix to the blocked matrix
549 CALL qs_rho_set(rho_struct, rho_ao=density_matrix) ! blocked_matrix
550 CALL qs_rho_rebuild(rho_struct, qs_env, rebuild_ao=.false., rebuild_grids=.true.)
551
552 CALL get_qs_env(qs_env, lri_env=lri_env, lri_density=lri_density, nkind=nkind)
553 IF (lri_env%exact_1c_terms) THEN
554 cpabort(" KG with LRI and exact one-center terms not implemented")
555 END IF
556 ALLOCATE (atomlist(natom))
557 DO ispin = 1, nspins
558 lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
559 DO ikind = 1, nkind
560 lri_v_int(ikind)%v_int = 0.0_dp
561 IF (calc_force) THEN
562 lri_v_int(ikind)%v_dadr = 0.0_dp
563 lri_v_int(ikind)%v_dfdr = 0.0_dp
564 END IF
565 END DO
566 END DO
567
568 ! full density kinetic energy term
569 atomlist = 1
570 CALL lri_kg_rho_update(rho_struct, qs_env, lri_env, lri_density, atomlist)
571 ekin_imol = 0.0_dp
572 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho_struct, xc_section=kg_env%xc_section_kg, &
573 vxc_rho=vxc_rho, vxc_tau=vxc_tau, exc=ekin_imol)
574 IF (ASSOCIATED(vxc_tau)) THEN
575 cpabort(" KG with meta-kinetic energy functionals not implemented")
576 END IF
577 DO ispin = 1, nspins
578 CALL pw_scale(vxc_rho(ispin), vxc_rho(ispin)%pw_grid%dvol)
579 lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
580 CALL integrate_v_rspace_one_center(vxc_rho(ispin), qs_env, lri_v_int, calc_force, "LRI_AUX")
581 CALL auxbas_pw_pool%give_back_pw(vxc_rho(ispin))
582 END DO
583 DEALLOCATE (vxc_rho)
584 ekin_mol = -ekin_imol
585 xcvirial(1:3, 1:3) = 0.0_dp
586 IF (use_virial) xcvirial(1:3, 1:3) = xcvirial(1:3, 1:3) - virial%pv_xc(1:3, 1:3)
587
588 ! loop over all subsets
589 DO isub = 1, kg_env%nsubsets
590 atomlist = 0
591 DO iatom = 1, natom
592 imol = kg_env%atom_to_molecule(iatom)
593 color = kg_env%subset_of_mol(imol)
594 IF (color == isub) atomlist(iatom) = 1
595 END DO
596 CALL lri_kg_rho_update(rho_struct, qs_env, lri_env, lri_density, atomlist)
597
598 ekin_imol = 0.0_dp
599 ! calc Hohenberg-Kohn kin. energy of the density corresp. to the remaining molecular block(s)
600 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho_struct, xc_section=kg_env%xc_section_kg, &
601 vxc_rho=vxc_rho, vxc_tau=vxc_tau, exc=ekin_imol)
602 ekin_mol = ekin_mol + ekin_imol
603
604 DO ispin = 1, nspins
605 CALL pw_scale(vxc_rho(ispin), -vxc_rho(ispin)%pw_grid%dvol)
606 lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
607 CALL integrate_v_rspace_one_center(vxc_rho(ispin), qs_env, &
608 lri_v_int, calc_force, &
609 "LRI_AUX", atomlist=atomlist)
610 ! clean up vxc_rho
611 CALL auxbas_pw_pool%give_back_pw(vxc_rho(ispin))
612 END DO
613 DEALLOCATE (vxc_rho)
614
615 IF (use_virial) THEN
616 xcvirial(1:3, 1:3) = xcvirial(1:3, 1:3) + virial%pv_xc(1:3, 1:3)
617 END IF
618
619 END DO
620
621 IF (use_virial) THEN
622 virial%pv_xc(1:3, 1:3) = xcvirial(1:3, 1:3)
623 END IF
624
625 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
626 ALLOCATE (ksmat(1))
627 DO ispin = 1, nspins
628 lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
629 DO ikind = 1, nkind
630 CALL para_env%sum(lri_v_int(ikind)%v_int)
631 END DO
632 ksmat(1)%matrix => ks_matrix(ispin)%matrix
633 CALL calculate_lri_ks_matrix(lri_env, lri_v_int, ksmat, atomic_kind_set)
634 END DO
635 IF (calc_force) THEN
636 pmat(1:nspins, 1:1) => density_matrix(1:nspins)
637 CALL calculate_lri_forces(lri_env, lri_density, qs_env, pmat, atomic_kind_set)
638 END IF
639 DEALLOCATE (atomlist, ksmat)
640
641 ! clean up rho_struct
642 CALL qs_rho_unset_rho_ao(rho_struct)
643 CALL qs_rho_release(rho_struct)
644 DEALLOCATE (rho_struct)
645
646 CALL timestop(handle)
647
648 END SUBROUTINE kg_ekin_embed_lri
649
650! **************************************************************************************************
651!> \brief ...
652!> \param qs_env ...
653!> \param kg_env ...
654!> \param ks_matrix ...
655!> \param ekin_mol ...
656!> \param calc_force ...
657!> \param do_kernel Contribution of kinetic energy functional to kernel in response calculation
658!> \param pmat_ext Response density used to fold 2nd deriv or to integrate kinetic energy functional
659! **************************************************************************************************
660 SUBROUTINE kg_ekin_ri_embed(qs_env, kg_env, ks_matrix, ekin_mol, calc_force, &
661 do_kernel, pmat_ext)
662 TYPE(qs_environment_type), POINTER :: qs_env
663 TYPE(kg_environment_type), POINTER :: kg_env
664 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_matrix
665 REAL(kind=dp), INTENT(out) :: ekin_mol
666 LOGICAL :: calc_force, do_kernel
667 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
668 POINTER :: pmat_ext
669
670 CHARACTER(LEN=*), PARAMETER :: routinen = 'kg_ekin_ri_embed'
671
672 INTEGER :: color, handle, iatom, ikind, imol, &
673 iounit, ispin, isub, natom, nkind, &
674 nspins
675 INTEGER, ALLOCATABLE, DIMENSION(:) :: atomlist
676 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index
677 LOGICAL :: use_virial
678 REAL(kind=dp) :: alpha, ekin_imol
679 REAL(kind=dp), DIMENSION(3, 3) :: xcvirial
680 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
681 TYPE(cp_logger_type), POINTER :: logger
682 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: density_matrix, ksmat
683 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: pmat
684 TYPE(dft_control_type), POINTER :: dft_control
685 TYPE(lri_density_type), POINTER :: lri_density, lri_rho1
686 TYPE(lri_environment_type), POINTER :: lri_env, lri_env1
687 TYPE(lri_kind_type), DIMENSION(:), POINTER :: lri_v_int
688 TYPE(mp_para_env_type), POINTER :: para_env
689 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho1_g
690 TYPE(pw_env_type), POINTER :: pw_env
691 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
692 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho1_r, tau1_r, vxc_rho, vxc_tau
693 TYPE(qs_ks_env_type), POINTER :: ks_env
694 TYPE(qs_rho_type), POINTER :: rho, rho1, rho_struct
695 TYPE(section_vals_type), POINTER :: xc_section
696 TYPE(virial_type), POINTER :: virial
697
698 CALL timeset(routinen, handle)
699
700 logger => cp_get_default_logger()
701 iounit = cp_logger_get_default_unit_nr(logger)
702
703 CALL get_qs_env(qs_env, &
704 ks_env=ks_env, &
705 rho=rho, &
706 natom=natom, &
707 nkind=nkind, &
708 dft_control=dft_control, &
709 virial=virial, &
710 para_env=para_env, &
711 pw_env=pw_env)
712
713 nspins = dft_control%nspins
714 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
715 use_virial = use_virial .AND. calc_force
716
717 ! Kernel potential in response calculation (no forces calculated at this point)
718 ! requires spin-factor
719 ! alpha = 2 closed-shell
720 ! alpha = 1 open-shell
721 alpha = 1.0_dp
722 IF (do_kernel .AND. .NOT. calc_force .AND. nspins == 1) alpha = 2.0_dp
723
724 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
725
726 ! get the density matrix
727 CALL qs_rho_get(rho, rho_ao=density_matrix)
728 ! allocate and initialize the density
729 NULLIFY (rho_struct)
730 ALLOCATE (rho_struct)
731 CALL qs_rho_create(rho_struct)
732 ! set the density matrix to the blocked matrix
733 CALL qs_rho_set(rho_struct, rho_ao=density_matrix)
734 CALL qs_rho_rebuild(rho_struct, qs_env, rebuild_ao=.false., rebuild_grids=.true.)
735
736 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
737 ALLOCATE (cell_to_index(1, 1, 1))
738 cell_to_index(1, 1, 1) = 1
739 lri_env => kg_env%lri_env
740 lri_density => kg_env%lri_density
741
742 NULLIFY (pmat)
743 ALLOCATE (pmat(nspins, 1))
744 DO ispin = 1, nspins
745 pmat(ispin, 1)%matrix => density_matrix(ispin)%matrix
746 END DO
747 CALL calculate_lri_densities(lri_env, lri_density, qs_env, pmat, cell_to_index, &
748 rho_struct, atomic_kind_set, para_env, response_density=.false.)
749 kg_env%lri_density => lri_density
750
751 DEALLOCATE (pmat)
752
753 IF (PRESENT(pmat_ext)) THEN
754 ! If external density associated then it is needed either for
755 ! 1) folding of second derivative while partially integrating, or
756 ! 2) integration of response forces
757 NULLIFY (rho1)
758 ALLOCATE (rho1)
759 CALL qs_rho_create(rho1)
760 CALL qs_rho_set(rho1, rho_ao=pmat_ext)
761 CALL qs_rho_rebuild(rho1, qs_env, rebuild_ao=.false., rebuild_grids=.true.)
762
763 lri_env1 => kg_env%lri_env1
764 lri_rho1 => kg_env%lri_rho1
765 ! calculate external density as LRI-densities
766 NULLIFY (pmat)
767 ALLOCATE (pmat(nspins, 1))
768 DO ispin = 1, nspins
769 pmat(ispin, 1)%matrix => pmat_ext(ispin)%matrix
770 END DO
771 CALL calculate_lri_densities(lri_env1, lri_rho1, qs_env, pmat, cell_to_index, &
772 rho1, atomic_kind_set, para_env, response_density=.false.)
773 kg_env%lri_rho1 => lri_rho1
774 DEALLOCATE (pmat)
775
776 END IF
777
778 ! XC-section pointing to kinetic energy functional in KG environment
779 NULLIFY (xc_section)
780 xc_section => kg_env%xc_section_kg
781
782 ! full density kinetic energy term
783 ekin_imol = 0.0_dp
784 NULLIFY (vxc_rho, vxc_tau)
785
786 ! calculate xc potential or kernel
787 IF (do_kernel) THEN
788 ! kernel total
789 ! derivation wrt to rho_struct and evaluation at rho_struct
790 CALL qs_rho_get(rho1, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
791 CALL create_kernel(qs_env, &
792 vxc=vxc_rho, &
793 vxc_tau=vxc_tau, &
794 rho=rho_struct, &
795 rho1_r=rho1_r, &
796 rho1_g=rho1_g, &
797 tau1_r=tau1_r, &
798 xc_section=xc_section)
799 ELSE
800 ! vxc total
801 CALL qs_vxc_create(ks_env=ks_env, &
802 rho_struct=rho_struct, &
803 xc_section=xc_section, &
804 vxc_rho=vxc_rho, &
805 vxc_tau=vxc_tau, &
806 exc=ekin_imol)
807
808 END IF
809
810 IF (ASSOCIATED(vxc_tau)) THEN
811 cpabort(" KG with meta-kinetic energy functionals not implemented")
812 END IF
813
814 DO ispin = 1, nspins
815 CALL pw_scale(vxc_rho(ispin), alpha*vxc_rho(ispin)%pw_grid%dvol)
816
817 IF (PRESENT(pmat_ext) .AND. .NOT. do_kernel) THEN
818 ! int w/ pmat_ext
819 lri_v_int => lri_rho1%lri_coefs(ispin)%lri_kinds
820 ELSE
821 ! int w/ rho_ao
822 lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
823 END IF
824 CALL integrate_v_rspace_one_center(vxc_rho(ispin), qs_env, lri_v_int, calc_force, "LRI_AUX")
825 CALL auxbas_pw_pool%give_back_pw(vxc_rho(ispin))
826 END DO
827
828 DEALLOCATE (vxc_rho)
829 ekin_mol = -ekin_imol
830 xcvirial(1:3, 1:3) = 0.0_dp
831 IF (use_virial) xcvirial(1:3, 1:3) = xcvirial(1:3, 1:3) - virial%pv_xc(1:3, 1:3)
832
833 ! loop over all subsets
834 ALLOCATE (atomlist(natom))
835 DO isub = 1, kg_env%nsubsets
836 atomlist = 0
837 DO iatom = 1, natom
838 imol = kg_env%atom_to_molecule(iatom)
839 color = kg_env%subset_of_mol(imol)
840 IF (color == isub) atomlist(iatom) = 1
841 END DO
842 ! update ground-state density
843 CALL lri_kg_rho_update(rho_struct, qs_env, lri_env, lri_density, atomlist)
844
845 ! Same for external (response) density if present
846 IF (PRESENT(pmat_ext)) THEN
847 ! update response density
848 CALL lri_kg_rho_update(rho1, qs_env, lri_env1, lri_rho1, atomlist)
849 END IF
850
851 ekin_imol = 0.0_dp
852 ! calc Hohenberg-Kohn kin. energy of the density corresp. to the remaining molecular block(s)
853 NULLIFY (vxc_rho, vxc_tau)
854
855 ! calculate xc potential or kernel
856 IF (do_kernel) THEN
857 ! subsys kernel
858 CALL qs_rho_get(rho1, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
859 CALL create_kernel(qs_env, &
860 vxc=vxc_rho, &
861 vxc_tau=vxc_tau, &
862 rho=rho_struct, &
863 rho1_r=rho1_r, &
864 rho1_g=rho1_g, &
865 tau1_r=tau1_r, &
866 xc_section=xc_section)
867 ELSE
868
869 ! subsys xc-potential
870 CALL qs_vxc_create(ks_env=ks_env, &
871 rho_struct=rho_struct, &
872 xc_section=xc_section, &
873 vxc_rho=vxc_rho, &
874 vxc_tau=vxc_tau, &
875 exc=ekin_imol)
876 END IF
877 ekin_mol = ekin_mol + ekin_imol
878
879 DO ispin = 1, nspins
880 CALL pw_scale(vxc_rho(ispin), -alpha*vxc_rho(ispin)%pw_grid%dvol)
881
882 IF (PRESENT(pmat_ext) .AND. .NOT. do_kernel) THEN
883 ! int w/ pmat_ext
884 lri_v_int => lri_rho1%lri_coefs(ispin)%lri_kinds
885 ELSE
886 ! int w/ rho_ao
887 lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
888 END IF
889
890 CALL integrate_v_rspace_one_center(vxc_rho(ispin), qs_env, &
891 lri_v_int, calc_force, &
892 "LRI_AUX", atomlist=atomlist)
893 ! clean up vxc_rho
894 CALL auxbas_pw_pool%give_back_pw(vxc_rho(ispin))
895 END DO
896 DEALLOCATE (vxc_rho)
897
898 IF (use_virial) THEN
899 xcvirial(1:3, 1:3) = xcvirial(1:3, 1:3) + virial%pv_xc(1:3, 1:3)
900 END IF
901
902 END DO
903
904 IF (use_virial) THEN
905 virial%pv_xc(1:3, 1:3) = xcvirial(1:3, 1:3)
906 END IF
907
908 ALLOCATE (ksmat(1))
909 DO ispin = 1, nspins
910 ksmat(1)%matrix => ks_matrix(ispin)%matrix
911 IF (PRESENT(pmat_ext) .AND. .NOT. do_kernel) THEN
912 ! KS int with rho_ext"
913 lri_v_int => lri_rho1%lri_coefs(ispin)%lri_kinds
914 DO ikind = 1, nkind
915 CALL para_env%sum(lri_v_int(ikind)%v_int)
916 END DO
917 CALL calculate_lri_ks_matrix(lri_env1, lri_v_int, ksmat, atomic_kind_set)
918 ELSE
919 ! KS int with rho_ao"
920 lri_v_int => lri_density%lri_coefs(ispin)%lri_kinds
921 DO ikind = 1, nkind
922 CALL para_env%sum(lri_v_int(ikind)%v_int)
923 END DO
924 CALL calculate_lri_ks_matrix(lri_env, lri_v_int, ksmat, atomic_kind_set)
925 END IF
926
927 END DO
928 IF (calc_force) THEN
929
930 NULLIFY (pmat)
931 ALLOCATE (pmat(nspins, 1))
932
933 IF (PRESENT(pmat_ext) .AND. .NOT. do_kernel) THEN
934 ! Forces with rho_ext
935 DO ispin = 1, nspins
936 pmat(ispin, 1)%matrix => pmat_ext(ispin)%matrix
937 END DO
938 CALL calculate_lri_forces(lri_env1, lri_rho1, qs_env, pmat, atomic_kind_set)
939 ELSE
940 ! Forces with rho_ao
941 DO ispin = 1, nspins
942 pmat(ispin, 1)%matrix => density_matrix(ispin)%matrix
943 END DO
944 CALL calculate_lri_forces(lri_env, lri_density, qs_env, pmat, atomic_kind_set)
945 END IF
946
947 DEALLOCATE (pmat)
948
949 END IF
950 DEALLOCATE (atomlist, ksmat)
951
952 ! clean up rho_struct
953 CALL qs_rho_unset_rho_ao(rho_struct)
954 CALL qs_rho_release(rho_struct)
955 DEALLOCATE (rho_struct)
956 IF (PRESENT(pmat_ext)) THEN
957 CALL qs_rho_unset_rho_ao(rho1)
958 CALL qs_rho_release(rho1)
959 DEALLOCATE (rho1)
960 END IF
961 DEALLOCATE (cell_to_index)
962
963 CALL timestop(handle)
964
965 END SUBROUTINE kg_ekin_ri_embed
966
967! **************************************************************************************************
968!> \brief ...
969!> \param qs_env ...
970!> \param ks_matrix ...
971!> \param ekin_mol ...
972! **************************************************************************************************
973 SUBROUTINE kg_ekin_atomic(qs_env, ks_matrix, ekin_mol)
974 TYPE(qs_environment_type), POINTER :: qs_env
975 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_matrix
976 REAL(kind=dp), INTENT(out) :: ekin_mol
977
978 CHARACTER(LEN=*), PARAMETER :: routinen = 'kg_ekin_atomic'
979
980 INTEGER :: handle, ispin, nspins
981 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: density_matrix, tnadd_matrix
982 TYPE(kg_environment_type), POINTER :: kg_env
983 TYPE(qs_rho_type), POINTER :: rho
984
985 NULLIFY (rho, kg_env, density_matrix, tnadd_matrix)
986
987 CALL timeset(routinen, handle)
988 CALL get_qs_env(qs_env, kg_env=kg_env, rho=rho)
989
990 nspins = SIZE(ks_matrix)
991 ! get the density matrix
992 CALL qs_rho_get(rho, rho_ao=density_matrix)
993 ! get the tnadd matrix
994 tnadd_matrix => kg_env%tnadd_mat
995
996 ekin_mol = 0.0_dp
997 DO ispin = 1, nspins
998 CALL dbcsr_dot(tnadd_matrix(1)%matrix, density_matrix(ispin)%matrix, ekin_mol)
999 CALL dbcsr_add(ks_matrix(ispin)%matrix, tnadd_matrix(1)%matrix, &
1000 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
1001 END DO
1002 ! definition is inverted (see qs_ks_methods)
1003 ekin_mol = -ekin_mol
1004
1005 CALL timestop(handle)
1006
1007 END SUBROUTINE kg_ekin_atomic
1008
1009END MODULE kg_correction
Define the atomic kind types and their sub types.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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.
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
Routines used for Harris functional Kohn-Sham calculation.
Definition ec_methods.F:15
subroutine, public create_kernel(qs_env, vxc, vxc_tau, rho, rho1_r, rho1_g, tau1_r, xc_section, compute_virial, virial_xc)
Creation of second derivative xc-potential.
Definition ec_methods.F:89
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public kg_tnadd_none
integer, parameter, public kg_tnadd_embed_ri
integer, parameter, public kg_tnadd_embed
integer, parameter, public kg_tnadd_atomic
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
Routines for a Kim-Gordon-like partitioning into molecular subunits.
subroutine, public kg_ekin_subset(qs_env, ks_matrix, ekin_mol, calc_force, do_kernel, pmat_ext)
Calculates the subsystem Hohenberg-Kohn kinetic energy and the forces.
Types needed for a Kim-Gordon-like partitioning into molecular subunits.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Calculates integral matrices for LRIGPW method lri : local resolution of the identity.
subroutine, public lri_kg_rho_update(rho_struct, qs_env, lri_env, lri_density, atomlist)
...
subroutine, public calculate_lri_densities(lri_env, lri_density, qs_env, pmatrix, cell_to_index, lri_rho_struct, atomic_kind_set, para_env, response_density)
performs the fitting of the density and distributes the fitted density on the grid
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
Calculates forces for LRIGPW method lri : local resolution of the identity.
Definition lri_forces.F:16
subroutine, public calculate_lri_forces(lri_env, lri_density, qs_env, pmatrix, atomic_kind_set)
calculates the lri forces
Definition lri_forces.F:81
routines that build the Kohn-Sham matrix for the LRIGPW and xc parts
subroutine, public calculate_lri_ks_matrix(lri_env, lri_v_int, h_matrix, atomic_kind_set, cell_to_index)
update of LRIGPW KS matrix
Interface to the message passing library MPI.
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, 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.
Integrate single or product functions over a potential on a RS grid.
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
subroutine, public qs_rho_rebuild(rho, qs_env, rebuild_ao, rebuild_grids, admm, pw_env_external)
rebuilds rho (if necessary allocating and initializing it)
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_unset_rho_ao(rho_struct)
Unsets the rho_ao / rho_ao_kp field without calling kpoint_transitional_release().
subroutine, public qs_rho_create(rho)
Allocates a new instance of rho.
subroutine, public qs_rho_release(rho_struct)
releases a rho_struct by decreasing the reference count by one and deallocating if it reaches 0 (to b...
subroutine, public qs_vxc_create(ks_env, rho_struct, xc_section, vxc_rho, vxc_tau, exc, just_energy, edisp, dispersion_env, adiabatic_rescale_factor, pw_env_external, native_skala_atom_force)
calculates and allocates the xc potential, already reducing it to the dependence on rho and the one o...
Definition qs_vxc.F:102
Exchange and Correlation functional calculations.
Definition xc.F:17
logical function, public xc_uses_kinetic_energy_density(xc_fun_section, lsd)
...
Definition xc.F:95
Provides all information about an atomic kind.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains all the info needed for KG runs...
stores all the informations relevant to an mpi environment
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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.