(git:6a2e663)
hfx_exx.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
8 ! **************************************************************************************************
9 !> \brief Routines to calculate EXX in RPA and energy correction methods
10 !> \par History
11 !> 07.2020 separated from mp2.F [F. Stein, code by Jan Wilhelm]
12 !> 06.2022 EXX contribution to the forces [A. Bussy]
13 !> 03.2023 Generalized for energy correction methods
14 !> \author Jan Wilhelm, Frederick Stein, Augustin Bussy, Fabian Belleflamme
15 ! **************************************************************************************************
16 MODULE hfx_exx
18  USE admm_types, ONLY: admm_env_create,&
20  admm_type,&
22  USE cp_control_types, ONLY: dft_control_type
29  cp_logger_type
30  USE dbcsr_api, ONLY: dbcsr_add,&
31  dbcsr_copy,&
32  dbcsr_create,&
33  dbcsr_p_type,&
34  dbcsr_release,&
35  dbcsr_scale,&
36  dbcsr_set,&
37  dbcsr_type
42  USE hfx_ri, ONLY: hfx_ri_update_forces,&
44  USE hfx_types, ONLY: hfx_type
52  section_vals_type,&
54  USE kinds, ONLY: dp
55  USE machine, ONLY: m_walltime
56  USE message_passing, ONLY: mp_para_env_type
57  USE parallel_gemm_api, ONLY: parallel_gemm
58  USE pw_env_types, ONLY: pw_env_get,&
59  pw_env_type
60  USE pw_methods, ONLY: pw_scale
61  USE pw_pool_types, ONLY: pw_pool_type
62  USE pw_types, ONLY: pw_r3d_rs_type
63  USE qs_energy_types, ONLY: qs_energy_type
64  USE qs_environment_types, ONLY: get_qs_env,&
65  qs_environment_type
66  USE qs_integrate_potential, ONLY: integrate_v_rspace
68  USE qs_rho_types, ONLY: qs_rho_get,&
69  qs_rho_type
70  USE qs_vxc, ONLY: qs_vxc_create
71  USE task_list_types, ONLY: task_list_type
72  USE virial_types, ONLY: virial_type
73 
74 !$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_get_thread_num, omp_get_num_threads
75 
76 #include "./base/base_uses.f90"
77 
78  IMPLICIT NONE
79 
80  PRIVATE
81 
82  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'hfx_exx'
83 
85 
86 CONTAINS
87 
88 ! **************************************************************************************************
89 !> \brief ...
90 !> \param qs_env ...
91 !> \param unit_nr ...
92 !> \param hfx_sections ...
93 !> \param x_data ...
94 !> \param do_gw ...
95 !> \param do_admm ...
96 !> \param calc_forces ...
97 !> \param reuse_hfx ...
98 !> \param do_im_time ...
99 !> \param E_ex_from_GW ...
100 !> \param E_admm_from_GW ...
101 !> \param t3 ...
102 ! **************************************************************************************************
103  SUBROUTINE calculate_exx(qs_env, unit_nr, hfx_sections, x_data, &
104  do_gw, do_admm, calc_forces, reuse_hfx, do_im_time, &
105  E_ex_from_GW, E_admm_from_GW, t3)
106  TYPE(qs_environment_type), POINTER :: qs_env
107  INTEGER, INTENT(IN) :: unit_nr
108  TYPE(section_vals_type), POINTER :: hfx_sections
109  TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
110  LOGICAL, INTENT(IN) :: do_gw, do_admm, calc_forces, reuse_hfx, &
111  do_im_time
112  REAL(kind=dp), INTENT(IN) :: e_ex_from_gw, e_admm_from_gw(2), t3
113 
114  CHARACTER(len=*), PARAMETER :: routinen = 'calculate_exx'
115 
116  INTEGER :: handle, i, irep, ispin, mspin, n_rep_hf, &
117  nspins
118  LOGICAL :: calc_ints, hfx_treat_lsd_in_core, &
119  use_virial
120  REAL(kind=dp) :: eh1, ehfx, t1, t2, tf1, tf2
121  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_ks_aux_fit, rho_ao, &
122  rho_ao_aux_fit, rho_ao_resp
123  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_ks_2d, rho_ao_2d
124  TYPE(dft_control_type), POINTER :: dft_control
125  TYPE(mp_para_env_type), POINTER :: para_env
126  TYPE(qs_energy_type), POINTER :: energy
127  TYPE(qs_rho_type), POINTER :: rho, rho_aux_fit
128  TYPE(section_vals_type), POINTER :: input
129  TYPE(virial_type), POINTER :: virial
130 
131  CALL timeset(routinen, handle)
132 
133  t1 = m_walltime()
134 
135  NULLIFY (input, para_env, matrix_ks, matrix_ks_aux_fit, rho, rho_ao, virial, &
136  dft_control, rho_aux_fit, rho_ao_aux_fit)
137 
138  CALL exx_pre_hfx(hfx_sections, x_data, reuse_hfx)
139 
140  CALL get_qs_env(qs_env=qs_env, &
141  input=input, &
142  para_env=para_env, &
143  energy=energy, &
144  rho=rho, &
145  matrix_ks=matrix_ks, &
146  virial=virial, &
147  dft_control=dft_control)
148  CALL qs_rho_get(rho, rho_ao=rho_ao)
149 
150  IF (do_admm) THEN
151  CALL get_admm_env(qs_env%admm_env, &
152  matrix_ks_aux_fit=matrix_ks_aux_fit, &
153  rho_aux_fit=rho_aux_fit)
154  CALL qs_rho_get(rho_aux_fit, rho_ao=rho_ao_aux_fit)
155 
156  IF (qs_env%admm_env%do_gapw) THEN
157  cpabort("ADMM EXX only implmented with GPW")
158  END IF
159  END IF
160 
161  CALL section_vals_get(hfx_sections, n_repetition=n_rep_hf)
162  CALL section_vals_val_get(hfx_sections, "TREAT_LSD_IN_CORE", l_val=hfx_treat_lsd_in_core, &
163  i_rep_section=1)
164 
165  ! put matrix_ks to zero
166  DO i = 1, SIZE(matrix_ks)
167  CALL dbcsr_set(matrix_ks(i)%matrix, 0.0_dp)
168  IF (do_admm) THEN
169  CALL dbcsr_set(matrix_ks_aux_fit(i)%matrix, 0.0_dp)
170  END IF
171  END DO
172 
173  ! take the exact exchange energy from GW or calculate it
174  IF (do_gw) THEN
175 
176  IF (calc_forces) cpabort("Not implemented")
177 
178  IF (qs_env%mp2_env%ri_g0w0%update_xc_energy) THEN
179  CALL remove_exc_energy(energy)
180  energy%total = energy%total + e_ex_from_gw
181  energy%ex = e_ex_from_gw
182  IF (do_admm) THEN
183  energy%total = energy%total + e_admm_from_gw(1) + e_admm_from_gw(2)
184  energy%exc = e_admm_from_gw(1)
185  energy%exc_aux_fit = e_admm_from_gw(2)
186  END IF
187  t2 = m_walltime()
188 
189  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total EXX Time=', t2 - t1 + t3
190  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'EXX energy = ', energy%ex
191  IF (do_admm .AND. unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') &
192  'EXX ADMM XC correction = ', e_admm_from_gw(1) + e_admm_from_gw(2)
193  END IF
194 
195  ELSE
196 
197  CALL remove_exc_energy(energy)
198 
199  nspins = dft_control%nspins
200  mspin = 1
201  IF (hfx_treat_lsd_in_core) mspin = nspins
202 
203  calc_ints = .true.
204  IF (reuse_hfx) calc_ints = .false.
205  IF (calc_forces .AND. do_im_time) calc_ints = .false.
206 
207  ehfx = 0.0_dp
208  IF (do_admm) THEN
209  matrix_ks_2d(1:nspins, 1:1) => matrix_ks_aux_fit(1:nspins)
210  rho_ao_2d(1:nspins, 1:1) => rho_ao_aux_fit(1:nspins)
211  ELSE
212  matrix_ks_2d(1:nspins, 1:1) => matrix_ks(1:nspins)
213  rho_ao_2d(1:nspins, 1:1) => rho_ao(1:nspins)
214  END IF
215 
216  DO irep = 1, n_rep_hf
217 
218  IF (x_data(irep, 1)%do_hfx_ri) THEN
219  CALL hfx_ri_update_ks(qs_env, x_data(irep, 1)%ri_data, matrix_ks_2d, ehfx, &
220  rho_ao=rho_ao_2d, geometry_did_change=calc_ints, nspins=nspins, &
221  hf_fraction=x_data(irep, 1)%general_parameter%fraction)
222  ELSE
223 
224  DO ispin = 1, mspin
225 
226  CALL integrate_four_center(qs_env, x_data, matrix_ks_2d, eh1, &
227  rho_ao_2d, hfx_sections, para_env, &
228  calc_ints, irep, .true., ispin=ispin)
229  ehfx = ehfx + eh1
230  END DO
231  END IF
232  END DO
233 
234  ! include the EXX contribution to the total energy
235  energy%ex = ehfx
236  energy%total = energy%total + energy%ex
237 
238  use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
239  IF (use_virial) THEN
240  virial%pv_calculate = .true.
241  virial%pv_fock_4c = 0.0_dp
242  END IF
243 
244  IF (calc_forces) THEN
245  tf1 = m_walltime()
246 
247  !Note: no need to remove xc forces: they are not even calculated in the first place
248  NULLIFY (rho_ao_resp)
249 
250  DO irep = 1, n_rep_hf
251 
252  IF (x_data(irep, 1)%do_hfx_ri) THEN
253 
254  CALL hfx_ri_update_forces(qs_env, x_data(irep, 1)%ri_data, nspins, &
255  x_data(irep, 1)%general_parameter%fraction, &
256  rho_ao=rho_ao_2d, rho_ao_resp=rho_ao_resp, &
257  use_virial=use_virial)
258  ELSE
259 
260  CALL derivatives_four_center(qs_env, rho_ao_2d, rho_ao_resp, &
261  hfx_sections, para_env, irep, &
262  use_virial, external_x_data=x_data)
263 
264  END IF
265 
266  END DO !irep
267 
268  tf2 = m_walltime()
269  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total EXX Force Time=', tf2 - tf1
270  END IF
271 
272  IF (use_virial) THEN
273  virial%pv_exx = virial%pv_exx - virial%pv_fock_4c
274  virial%pv_virial = virial%pv_virial - virial%pv_fock_4c
275  END IF
276 
277  ! ADMM XC correction
278  IF (do_admm) THEN
279 
280  CALL calc_exx_admm_xc_contributions(qs_env, matrix_ks, matrix_ks_aux_fit, x_data, &
281  energy%exc, energy%exc_aux_fit, calc_forces, &
282  use_virial)
283 
284  ! ADMM overlap forces
285  IF (calc_forces) CALL admm_projection_derivative(qs_env, matrix_ks_aux_fit, rho_ao)
286 
287  energy%total = energy%total + energy%exc_aux_fit
288  energy%total = energy%total + energy%exc
289 
290  END IF
291 
292  IF (use_virial) THEN
293  virial%pv_calculate = .false.
294  END IF
295 
296  t2 = m_walltime()
297 
298  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total EXX Time=', t2 - t1 + t3
299  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'EXX energy = ', energy%ex
300  IF (do_admm .AND. unit_nr > 0) THEN
301  WRITE (unit_nr, '(T3,A,T56,F25.14)') 'EXX ADMM XC correction = ', energy%exc + energy%exc_aux_fit
302  END IF
303  END IF
304 
305  CALL exx_post_hfx(qs_env, x_data, reuse_hfx)
306 
307  CALL timestop(handle)
308 
309  END SUBROUTINE calculate_exx
310 
311 ! **************************************************************************************************
312 !> \brief Add the EXX contribution to the RHS of the Z-vector equation, namely the HF Hamiltonian
313 !> \param rhs ...
314 !> \param qs_env ...
315 !> \param ext_hfx_section ...
316 !> \param x_data ...
317 !> \param recalc_integrals ...
318 !> \param do_admm ...
319 !> \param do_ec ...
320 !> \param do_exx ...
321 !> \param reuse_hfx ...
322 ! **************************************************************************************************
323  SUBROUTINE add_exx_to_rhs(rhs, qs_env, ext_hfx_section, x_data, &
324  recalc_integrals, do_admm, do_ec, do_exx, reuse_hfx)
325 
326  TYPE(dbcsr_p_type), DIMENSION(:), INTENT(IN) :: rhs
327  TYPE(qs_environment_type), POINTER :: qs_env
328  TYPE(section_vals_type), POINTER :: ext_hfx_section
329  TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
330  LOGICAL, INTENT(IN), OPTIONAL :: recalc_integrals, do_admm, do_ec, &
331  do_exx, reuse_hfx
332 
333  CHARACTER(LEN=*), PARAMETER :: routinen = 'add_exx_to_rhs'
334 
335  INTEGER :: handle, ispin, nao, nao_aux, nspins, &
336  unit_nr
337  LOGICAL :: calc_ints, do_hfx, my_do_ec, my_do_exx, &
338  my_recalc_integrals
339  REAL(dp) :: dummy_real1, dummy_real2
340  TYPE(admm_type), POINTER :: admm_env
341  TYPE(cp_logger_type), POINTER :: logger
342  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: dbcsr_work, matrix_ks, matrix_s_aux, &
343  rho_ao, rho_ao_aux, work_admm
344  TYPE(dbcsr_type) :: dbcsr_tmp
345  TYPE(dft_control_type), POINTER :: dft_control
346  TYPE(pw_env_type), POINTER :: pw_env
347  TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
348  TYPE(pw_r3d_rs_type) :: vh_rspace
349  TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vadmm_rspace, vtau_rspace, vxc_rspace
350  TYPE(qs_rho_type), POINTER :: rho, rho_aux_fit
351  TYPE(section_vals_type), POINTER :: hfx_section
352  TYPE(task_list_type), POINTER :: task_list_aux_fit
353 
354  NULLIFY (dbcsr_work, matrix_ks, rho, hfx_section, pw_env, vadmm_rspace, vtau_rspace, vxc_rspace, &
355  auxbas_pw_pool, dft_control, rho_ao, rho_aux_fit, rho_ao_aux, work_admm, &
356  matrix_s_aux, admm_env, task_list_aux_fit)
357 
358  logger => cp_get_default_logger()
359  IF (logger%para_env%is_source()) THEN
360  unit_nr = cp_logger_get_default_unit_nr(logger, local=.true.)
361  ELSE
362  unit_nr = -1
363  END IF
364 
365  CALL timeset(routinen, handle)
366 
367  my_recalc_integrals = .false.
368  IF (PRESENT(recalc_integrals)) my_recalc_integrals = recalc_integrals
369  my_do_ec = .false.
370  IF (PRESENT(do_ec)) my_do_ec = do_ec
371  my_do_exx = .true.
372  IF (PRESENT(do_exx)) my_do_exx = do_exx
373 
374  ! Strategy: we take the ks_matrix, remove the current xc contribution, and then add the RPA HF one
375  CALL get_qs_env(qs_env, matrix_ks=matrix_ks, rho=rho, pw_env=pw_env, dft_control=dft_control)
376  nspins = dft_control%nspins
377 
378  ! do_exx ; subtract XC and EX
379  ! do_dcdft: subtract EX
380 
381  CALL dbcsr_allocate_matrix_set(dbcsr_work, nspins)
382  DO ispin = 1, nspins
383  ALLOCATE (dbcsr_work(ispin)%matrix)
384  CALL dbcsr_copy(dbcsr_work(ispin)%matrix, matrix_ks(ispin)%matrix)
385  CALL dbcsr_set(dbcsr_work(ispin)%matrix, 0.0_dp)
386  END DO
387 
388  IF (dft_control%do_admm) THEN
389  CALL get_qs_env(qs_env, admm_env=admm_env)
390  CALL get_admm_env(admm_env, matrix_s_aux_fit=matrix_s_aux, task_list_aux_fit=task_list_aux_fit, &
391  rho_aux_fit=rho_aux_fit)
392  CALL dbcsr_allocate_matrix_set(work_admm, nspins)
393  DO ispin = 1, nspins
394  ALLOCATE (work_admm(ispin)%matrix)
395  CALL dbcsr_create(work_admm(ispin)%matrix, template=matrix_s_aux(1)%matrix)
396  CALL dbcsr_copy(work_admm(ispin)%matrix, matrix_s_aux(1)%matrix)
397  CALL dbcsr_set(work_admm(ispin)%matrix, 0.0_dp)
398  END DO
399  CALL dbcsr_create(dbcsr_tmp, template=matrix_ks(1)%matrix)
400  CALL dbcsr_copy(dbcsr_tmp, matrix_ks(1)%matrix)
401 
402  nao = admm_env%nao_orb
403  nao_aux = admm_env%nao_aux_fit
404  CALL qs_rho_get(rho_aux_fit, rho_ao=rho_ao_aux)
405  END IF
406 
407  CALL qs_rho_get(rho, rho_ao=rho_ao)
408 
409  ! Remove the standard XC + HFX contribution
410  CALL ks_ref_potential(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, dummy_real1, dummy_real2)
411 
412  ! Only remove standard XC and/or HFX
413  ! (due to different requirements for RHS)
414  IF (my_do_exx) THEN
415 
416  DO ispin = 1, nspins
417  CALL dbcsr_copy(dbcsr_work(ispin)%matrix, matrix_ks(ispin)%matrix)
418  END DO
419 
420  DO ispin = 1, nspins
421  CALL pw_scale(vxc_rspace(ispin), -1.0_dp)
422  CALL integrate_v_rspace(v_rspace=vxc_rspace(ispin), hmat=dbcsr_work(ispin), qs_env=qs_env, &
423  calculate_forces=.false.)
424  IF (ASSOCIATED(vtau_rspace)) THEN
425  CALL pw_scale(vtau_rspace(ispin), -1.0_dp)
426  CALL integrate_v_rspace(v_rspace=vtau_rspace(ispin), hmat=dbcsr_work(ispin), qs_env=qs_env, &
427  calculate_forces=.false., compute_tau=.true.)
428  END IF
429  END DO
430 
431  END IF ! do_exx
432 
433  ! Remove standard HFX
434  IF (my_do_exx .OR. my_do_ec) THEN
435 
436  hfx_section => section_vals_get_subs_vals(qs_env%input, "DFT%XC%HF")
437  CALL section_vals_get(hfx_section, explicit=do_hfx)
438  IF (do_hfx) THEN
439  IF (dft_control%do_admm) THEN
440 
441  !note: factor -1.0 taken care of later, after HFX ADMM contribution is taken
442  IF (.NOT. qs_env%admm_env%aux_exch_func == do_admm_aux_exch_func_none) THEN
443  DO ispin = 1, nspins
444  CALL integrate_v_rspace(v_rspace=vadmm_rspace(ispin), hmat=work_admm(ispin), &
445  qs_env=qs_env, calculate_forces=.false., basis_type="AUX_FIT", &
446  task_list_external=task_list_aux_fit)
447  END DO
448  END IF
449 
450  CALL tddft_hfx_matrix(work_admm, rho_ao_aux, qs_env, .false., my_recalc_integrals)
451 
452  DO ispin = 1, nspins
453  CALL copy_dbcsr_to_fm(work_admm(ispin)%matrix, admm_env%work_aux_aux)
454  CALL parallel_gemm('N', 'N', nao_aux, nao, nao_aux, 1.0_dp, admm_env%work_aux_aux, admm_env%A, &
455  0.0_dp, admm_env%work_aux_orb)
456  CALL parallel_gemm('T', 'N', nao, nao, nao_aux, 1.0_dp, admm_env%A, admm_env%work_aux_orb, &
457  0.0_dp, admm_env%work_orb_orb)
458  CALL copy_fm_to_dbcsr(admm_env%work_orb_orb, dbcsr_tmp, keep_sparsity=.true.)
459  CALL dbcsr_add(dbcsr_work(ispin)%matrix, dbcsr_tmp, 1.0_dp, -1.0_dp)
460  END DO
461  ELSE
462  DO ispin = 1, nspins
463  CALL dbcsr_scale(rho_ao(ispin)%matrix, -1.0_dp)
464  END DO
465  CALL tddft_hfx_matrix(dbcsr_work, rho_ao, qs_env, .false., my_recalc_integrals)
466  DO ispin = 1, nspins
467  CALL dbcsr_scale(rho_ao(ispin)%matrix, -1.0_dp)
468  END DO
469  END IF
470  END IF !do_hfx
471 
472  END IF ! do_exx
473 
474  ! Clean
475  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
476  CALL auxbas_pw_pool%give_back_pw(vh_rspace)
477  DO ispin = 1, nspins
478  CALL auxbas_pw_pool%give_back_pw(vxc_rspace(ispin))
479  IF (ASSOCIATED(vtau_rspace)) THEN
480  CALL auxbas_pw_pool%give_back_pw(vtau_rspace(ispin))
481  END IF
482  END DO
483  DEALLOCATE (vxc_rspace)
484  IF (ASSOCIATED(vtau_rspace)) DEALLOCATE (vtau_rspace)
485 
486  IF (dft_control%do_admm) THEN
487  DO ispin = 1, nspins
488  IF (ASSOCIATED(vadmm_rspace)) THEN
489  CALL auxbas_pw_pool%give_back_pw(vadmm_rspace(ispin))
490  END IF
491  END DO
492  IF (ASSOCIATED(vadmm_rspace)) DEALLOCATE (vadmm_rspace)
493  END IF
494 
495  !Add the HF contribution from RI_RPA/EC_ENV to the ks matrix
496  CALL exx_pre_hfx(ext_hfx_section, x_data, reuse_hfx)
497 
498  calc_ints = .true.
499  IF (reuse_hfx) calc_ints = .false.
500  IF (do_admm) THEN
501  DO ispin = 1, nspins
502  CALL dbcsr_set(work_admm(ispin)%matrix, 0.0_dp)
503  END DO
504 
505  CALL tddft_hfx_matrix(work_admm, rho_ao_aux, qs_env, .false., calc_ints, ext_hfx_section, &
506  x_data)
507 
508  !ADMM XC correction
509  CALL calc_exx_admm_xc_contributions(qs_env, dbcsr_work, work_admm, x_data, dummy_real1, &
510  dummy_real2, .false., .false.)
511 
512  DO ispin = 1, nspins
513  CALL copy_dbcsr_to_fm(work_admm(ispin)%matrix, admm_env%work_aux_aux)
514  CALL parallel_gemm('N', 'N', nao_aux, nao, nao_aux, 1.0_dp, admm_env%work_aux_aux, admm_env%A, &
515  0.0_dp, admm_env%work_aux_orb)
516  CALL parallel_gemm('T', 'N', nao, nao, nao_aux, 1.0_dp, admm_env%A, admm_env%work_aux_orb, &
517  0.0_dp, admm_env%work_orb_orb)
518  CALL copy_fm_to_dbcsr(admm_env%work_orb_orb, dbcsr_tmp, keep_sparsity=.true.)
519  CALL dbcsr_add(dbcsr_work(ispin)%matrix, dbcsr_tmp, 1.0_dp, 1.0_dp)
520  END DO
521 
522  ELSE
523  CALL tddft_hfx_matrix(dbcsr_work, rho_ao, qs_env, .false., calc_ints, ext_hfx_section, x_data)
524  END IF
525  CALL exx_post_hfx(qs_env, x_data, reuse_hfx)
526 
527  !Update the RHS
528  DO ispin = 1, nspins
529  CALL dbcsr_add(rhs(ispin)%matrix, dbcsr_work(ispin)%matrix, 1.0_dp, 1.0_dp)
530  END DO
531 
532  CALL dbcsr_deallocate_matrix_set(dbcsr_work)
533  IF (dft_control%do_admm) THEN
534  CALL dbcsr_deallocate_matrix_set(work_admm)
535  CALL dbcsr_release(dbcsr_tmp)
536  END IF
537 
538  CALL timestop(handle)
539 
540  END SUBROUTINE add_exx_to_rhs
541 
542 ! **************************************************************************************************
543 !> \brief get the ADMM XC section from the ri_rpa/ec_env type if available, create and store them otherwise
544 !> \param qs_env ...
545 !> \param x_data ...
546 !> \param xc_section_aux ...
547 !> \param xc_section_primary ...
548 ! **************************************************************************************************
549  SUBROUTINE get_exx_admm_xc_sections(qs_env, x_data, xc_section_aux, xc_section_primary)
550  TYPE(qs_environment_type), POINTER :: qs_env
551  TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
552  TYPE(section_vals_type), POINTER :: xc_section_aux, xc_section_primary
553 
554  INTEGER :: natom
555  TYPE(admm_type), POINTER :: qs_admm_env, tmp_admm_env
556  TYPE(dft_control_type), POINTER :: dft_control
557  TYPE(mp_para_env_type), POINTER :: para_env
558  TYPE(section_vals_type), POINTER :: xc_fun, xc_fun_empty, xc_section, &
559  xc_section_empty
560 
561  NULLIFY (qs_admm_env, tmp_admm_env, para_env, xc_section, xc_section_empty, xc_fun_empty, &
562  xc_fun, dft_control)
563 
564  IF (ASSOCIATED(qs_env%mp2_env)) THEN
565  IF (ASSOCIATED(qs_env%mp2_env%ri_rpa%xc_section_aux) .AND. &
566  ASSOCIATED(qs_env%mp2_env%ri_rpa%xc_section_primary)) THEN
567  xc_section_aux => qs_env%mp2_env%ri_rpa%xc_section_aux
568  xc_section_primary => qs_env%mp2_env%ri_rpa%xc_section_primary
569  END IF
570  ELSEIF (qs_env%energy_correction) THEN
571  IF (ASSOCIATED(qs_env%ec_env%xc_section_aux) .AND. &
572  ASSOCIATED(qs_env%ec_env%xc_section_primary)) THEN
573  xc_section_aux => qs_env%ec_env%xc_section_aux
574  xc_section_primary => qs_env%ec_env%xc_section_primary
575  END IF
576  END IF
577 
578  IF (.NOT. ASSOCIATED(xc_section_aux) .OR. .NOT. ASSOCIATED(xc_section_primary)) THEN
579 
580  CALL get_qs_env(qs_env, admm_env=qs_admm_env, natom=natom, para_env=para_env, dft_control=dft_control)
581  cpassert(ASSOCIATED(qs_admm_env))
582 
583  !create XC section with XC_FUNCITONAL NONE (aka empty XC_FUNCTIONAL section)
584  xc_section => section_vals_get_subs_vals(qs_env%input, "DFT%XC")
585  xc_fun => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
586  CALL section_vals_duplicate(xc_section, xc_section_empty)
587  CALL section_vals_create(xc_fun_empty, xc_fun%section)
588  CALL section_vals_set_subs_vals(xc_section_empty, "XC_FUNCTIONAL", xc_fun_empty)
589 
590  CALL admm_env_create(tmp_admm_env, dft_control%admm_control, qs_admm_env%mos_aux_fit, &
591  para_env, natom, qs_admm_env%nao_aux_fit)
592 
593  CALL create_admm_xc_section(x_data=x_data, xc_section=xc_section_empty, &
594  admm_env=tmp_admm_env)
595 
596  CALL section_vals_duplicate(tmp_admm_env%xc_section_aux, xc_section_aux)
597  CALL section_vals_duplicate(tmp_admm_env%xc_section_primary, xc_section_primary)
598 
599  IF (ASSOCIATED(qs_env%mp2_env)) THEN
600  qs_env%mp2_env%ri_rpa%xc_section_aux => xc_section_aux
601  qs_env%mp2_env%ri_rpa%xc_section_primary => xc_section_primary
602  END IF
603  IF (qs_env%energy_correction) THEN
604  qs_env%ec_env%xc_section_aux => xc_section_aux
605  qs_env%ec_env%xc_section_primary => xc_section_primary
606  END IF
607 
608  CALL section_vals_release(xc_section_empty)
609  CALL section_vals_release(xc_fun_empty)
610  CALL admm_env_release(tmp_admm_env)
611 
612  END IF
613 
614  END SUBROUTINE get_exx_admm_xc_sections
615 
616 ! **************************************************************************************************
617 !> \brief Calculate the RI_RPA%HF / EC_ENV%HF ADMM XC contributions to the KS matrices and the respective energies
618 !> \param qs_env ...
619 !> \param matrix_prim ...
620 !> \param matrix_aux ...
621 !> \param x_data ...
622 !> \param exc ...
623 !> \param exc_aux_fit ...
624 !> \param calc_forces ...
625 !> \param use_virial ...
626 ! **************************************************************************************************
627  SUBROUTINE calc_exx_admm_xc_contributions(qs_env, matrix_prim, matrix_aux, x_data, exc, exc_aux_fit, &
628  calc_forces, use_virial)
629  TYPE(qs_environment_type), POINTER :: qs_env
630  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_prim, matrix_aux
631  TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
632  REAL(dp), INTENT(INOUT) :: exc, exc_aux_fit
633  LOGICAL, INTENT(IN) :: calc_forces, use_virial
634 
635  INTEGER :: ispin, nspins
636  REAL(dp), DIMENSION(3, 3) :: pv_loc
637  TYPE(admm_type), POINTER :: admm_env
638  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao, rho_ao_aux_fit
639  TYPE(dft_control_type), POINTER :: dft_control
640  TYPE(pw_env_type), POINTER :: pw_env
641  TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
642  TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: v_dummy, v_rspace, v_rspace_aux_fit
643  TYPE(qs_rho_type), POINTER :: rho, rho_aux_fit
644  TYPE(section_vals_type), POINTER :: xc_section_aux, xc_section_primary
645  TYPE(virial_type), POINTER :: virial
646 
647  NULLIFY (xc_section_aux, xc_section_primary, rho, rho_aux_fit, v_dummy, v_rspace, v_rspace_aux_fit, &
648  auxbas_pw_pool, pw_env, rho_ao, rho_ao_aux_fit, dft_control, admm_env)
649 
650  CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env, rho=rho, admm_env=admm_env, virial=virial)
651  CALL get_admm_env(admm_env, rho_aux_fit=rho_aux_fit)
652 
653  nspins = dft_control%nspins
654  CALL qs_rho_get(rho, rho_ao=rho_ao)
655  CALL qs_rho_get(rho_aux_fit, rho_ao=rho_ao_aux_fit)
656  CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
657 
658  CALL get_exx_admm_xc_sections(qs_env, x_data, xc_section_aux, xc_section_primary)
659 
660  IF (use_virial) virial%pv_xc = 0.0_dp
661  CALL qs_vxc_create(qs_env%ks_env, rho_struct=rho_aux_fit, xc_section=xc_section_aux, &
662  vxc_rho=v_rspace_aux_fit, vxc_tau=v_dummy, exc=exc_aux_fit)
663  IF (use_virial) THEN
664  virial%pv_exc = virial%pv_exc - virial%pv_xc
665  virial%pv_virial = virial%pv_virial - virial%pv_xc
666  END IF
667 
668  IF (.NOT. dft_control%admm_control%aux_exch_func == do_admm_aux_exch_func_none) THEN
669  IF (use_virial) pv_loc = virial%pv_virial
670  DO ispin = 1, nspins
671  CALL pw_scale(v_rspace_aux_fit(ispin), v_rspace_aux_fit(ispin)%pw_grid%dvol)
672  CALL integrate_v_rspace(v_rspace=v_rspace_aux_fit(ispin), hmat=matrix_aux(ispin), &
673  pmat=rho_ao_aux_fit(ispin), qs_env=qs_env, &
674  basis_type="AUX_FIT", calculate_forces=calc_forces, &
675  task_list_external=qs_env%admm_env%task_list_aux_fit)
676  END DO
677  IF (use_virial) virial%pv_ehartree = virial%pv_ehartree + (virial%pv_virial - pv_loc)
678  END IF
679 
680  IF (ASSOCIATED(v_rspace_aux_fit)) THEN
681  DO ispin = 1, nspins
682  CALL auxbas_pw_pool%give_back_pw(v_rspace_aux_fit(ispin))
683  END DO
684  DEALLOCATE (v_rspace_aux_fit)
685  END IF
686  IF (ASSOCIATED(v_dummy)) THEN
687  DO ispin = 1, nspins
688  CALL auxbas_pw_pool%give_back_pw(v_dummy(ispin))
689  END DO
690  DEALLOCATE (v_dummy)
691  END IF
692 
693  IF (use_virial) virial%pv_xc = 0.0_dp
694  CALL qs_vxc_create(qs_env%ks_env, rho_struct=rho, xc_section=xc_section_primary, &
695  vxc_rho=v_rspace, vxc_tau=v_dummy, exc=exc)
696  IF (use_virial) THEN
697  virial%pv_exc = virial%pv_exc - virial%pv_xc
698  virial%pv_virial = virial%pv_virial - virial%pv_xc
699  END IF
700 
701  IF (.NOT. dft_control%admm_control%aux_exch_func == do_admm_aux_exch_func_none) THEN
702  IF (use_virial) pv_loc = virial%pv_virial
703  DO ispin = 1, nspins
704  CALL pw_scale(v_rspace(ispin), v_rspace(ispin)%pw_grid%dvol)
705  CALL integrate_v_rspace(v_rspace=v_rspace(ispin), hmat=matrix_prim(ispin), &
706  pmat=rho_ao(ispin), qs_env=qs_env, &
707  calculate_forces=calc_forces)
708  END DO
709  IF (use_virial) virial%pv_ehartree = virial%pv_ehartree + (virial%pv_virial - pv_loc)
710  END IF
711 
712  IF (ASSOCIATED(v_rspace)) THEN
713  DO ispin = 1, nspins
714  CALL auxbas_pw_pool%give_back_pw(v_rspace(ispin))
715  END DO
716  DEALLOCATE (v_rspace)
717  END IF
718  IF (ASSOCIATED(v_dummy)) THEN
719  DO ispin = 1, nspins
720  CALL auxbas_pw_pool%give_back_pw(v_dummy(ispin))
721  END DO
722  DEALLOCATE (v_dummy)
723  END IF
724 
725  END SUBROUTINE calc_exx_admm_xc_contributions
726 
727 ! **************************************************************************************************
728 !> \brief Prepare the external x_data for integration. Simply change the HFX fraction in case the
729 !> qs_env%x_data is reused
730 !> \param ext_hfx_section ...
731 !> \param x_data ...
732 !> \param reuse_hfx ...
733 ! **************************************************************************************************
734  SUBROUTINE exx_pre_hfx(ext_hfx_section, x_data, reuse_hfx)
735  TYPE(section_vals_type), POINTER :: ext_hfx_section
736  TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
737  LOGICAL :: reuse_hfx
738 
739  INTEGER :: irep, n_rep_hf
740  REAL(dp) :: frac
741 
742  IF (.NOT. reuse_hfx) RETURN
743 
744  CALL section_vals_get(ext_hfx_section, n_repetition=n_rep_hf)
745 
746  DO irep = 1, n_rep_hf
747  CALL section_vals_val_get(ext_hfx_section, "FRACTION", r_val=frac, i_rep_section=irep)
748  x_data(irep, :)%general_parameter%fraction = frac
749  END DO
750 
751  END SUBROUTINE exx_pre_hfx
752 
753 ! **************************************************************************************************
754 !> \brief Revert back to the proper HFX fraction in case qs_env%x_data is reused
755 !> \param qs_env ...
756 !> \param x_data ...
757 !> \param reuse_hfx ...
758 ! **************************************************************************************************
759  SUBROUTINE exx_post_hfx(qs_env, x_data, reuse_hfx)
760  TYPE(qs_environment_type), POINTER :: qs_env
761  TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data
762  LOGICAL :: reuse_hfx
763 
764  INTEGER :: irep, n_rep_hf
765  REAL(dp) :: frac
766  TYPE(section_vals_type), POINTER :: input, qs_hfx_section
767 
768  IF (.NOT. reuse_hfx) RETURN
769 
770  CALL get_qs_env(qs_env, input=input)
771  qs_hfx_section => section_vals_get_subs_vals(input, "DFT%XC%HF")
772  CALL section_vals_get(qs_hfx_section, n_repetition=n_rep_hf)
773 
774  DO irep = 1, n_rep_hf
775  CALL section_vals_val_get(qs_hfx_section, "FRACTION", r_val=frac, i_rep_section=irep)
776  x_data(irep, :)%general_parameter%fraction = frac
777  END DO
778 
779  END SUBROUTINE exx_post_hfx
780 
781 ! **************************************************************************************************
782 !> \brief ...
783 !> \param energy ...
784 ! **************************************************************************************************
785  ELEMENTAL SUBROUTINE remove_exc_energy(energy)
786  TYPE(qs_energy_type), INTENT(INOUT) :: energy
787 
788  ! Remove the Exchange-correlation energy contributions from the total energy
789  energy%total = energy%total - (energy%exc + energy%exc1 + energy%ex + &
790  energy%exc_aux_fit + energy%exc1_aux_fit)
791 
792  energy%exc = 0.0_dp
793  energy%exc1 = 0.0_dp
794  energy%exc_aux_fit = 0.0_dp
795  energy%exc1_aux_fit = 0.0_dp
796  energy%ex = 0.0_dp
797 
798  END SUBROUTINE
799 
800 END MODULE hfx_exx
801 
Contains ADMM methods which require molecular orbitals.
Definition: admm_methods.F:15
subroutine, public admm_projection_derivative(qs_env, matrix_hz, matrix_pz, fval)
Calculate derivatives terms from overlap matrices.
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
subroutine, public admm_env_release(admm_env)
releases the ADMM environment, cleans up all types
Definition: admm_types.F:426
subroutine, public admm_env_create(admm_env, admm_control, mos, para_env, natoms, nao_aux_fit, blacs_env_ext)
creates ADMM environment, initializes the basic types
Definition: admm_types.F:220
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
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
Utilities for hfx and admm methods.
subroutine, public create_admm_xc_section(x_data, xc_section, admm_env)
This routine modifies the xc section depending on the potential type used for the HF exchange and the...
subroutine, public tddft_hfx_matrix(matrix_ks, rho_ao, qs_env, update_energy, recalc_integrals, external_hfx_sections, external_x_data)
Add the hfx contributions to the Hamiltonian.
Routines to calculate derivatives with respect to basis function origin.
subroutine, public derivatives_four_center(qs_env, rho_ao, rho_ao_resp, hfx_section, para_env, irep, use_virial, adiabatic_rescale_factor, resp_only, external_x_data)
computes four center derivatives for a full basis set and updates the forcesfock_4c arrays....
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....
Routines to calculate EXX in RPA and energy correction methods.
Definition: hfx_exx.F:16
subroutine, public calc_exx_admm_xc_contributions(qs_env, matrix_prim, matrix_aux, x_data, exc, exc_aux_fit, calc_forces, use_virial)
Calculate the RI_RPAHF / EC_ENVHF ADMM XC contributions to the KS matrices and the respective energie...
Definition: hfx_exx.F:629
subroutine, public exx_pre_hfx(ext_hfx_section, x_data, reuse_hfx)
Prepare the external x_data for integration. Simply change the HFX fraction in case the qs_envx_data ...
Definition: hfx_exx.F:735
subroutine, public exx_post_hfx(qs_env, x_data, reuse_hfx)
Revert back to the proper HFX fraction in case qs_envx_data is reused.
Definition: hfx_exx.F:760
subroutine, public calculate_exx(qs_env, unit_nr, hfx_sections, x_data, do_gw, do_admm, calc_forces, reuse_hfx, do_im_time, E_ex_from_GW, E_admm_from_GW, t3)
...
Definition: hfx_exx.F:106
subroutine, public add_exx_to_rhs(rhs, qs_env, ext_hfx_section, x_data, recalc_integrals, do_admm, do_ec, do_exx, reuse_hfx)
Add the EXX contribution to the RHS of the Z-vector equation, namely the HF Hamiltonian.
Definition: hfx_exx.F:325
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:1033
subroutine, public hfx_ri_update_forces(qs_env, ri_data, nspins, hf_fraction, rho_ao, rho_ao_resp, mos, use_virial, resp_only, rescale_factor)
the general routine that calls the relevant force code
Definition: hfx_ri.F:3036
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 do_admm_aux_exch_func_none
objects that represent the structure of input sections and the data contained in an input section
recursive subroutine, public section_vals_create(section_vals, section)
creates a object where to store the values of a 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_set_subs_vals(section_vals, subsection_name, new_section_vals, i_rep_section)
replaces of the requested subsection with the one given
subroutine, public section_vals_duplicate(section_vals_in, section_vals_out, i_rep_start, i_rep_end)
creates a deep copy from section_vals_in to section_vals_out
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
recursive subroutine, public section_vals_release(section_vals)
releases the given object
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
Machine interface based on Fortran 2003 and POSIX.
Definition: machine.F:17
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition: machine.F:123
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
container for various plainwaves related things
Definition: pw_env_types.F:14
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
Definition: pw_env_types.F:113
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Definition: pw_pool_types.F:24
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_nonbond, sab_almo, sab_kp, sab_kp_nosym, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
Get the QUICKSTEP environment.
Integrate single or product functions over a potential on a RS grid.
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
superstucture that hold various representations of the density and keeps track of which ones are vali...
Definition: qs_rho_types.F:18
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...
Definition: qs_rho_types.F:229
Definition: qs_vxc.F:16
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)
calculates and allocates the xc potential, already reducing it to the dependence on rho and the one o...
Definition: qs_vxc.F:98
types for task lists