(git:6344619)
Loading...
Searching...
No Matches
qs_fgxc.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 https://en.wikipedia.org/wiki/Finite_difference_coefficient
10!---------------------------------------------------------------------------------------------------
11!Derivative Accuracy 4 3 2 1 0 1 2 3 4
12!---------------------------------------------------------------------------------------------------
13! 1 2 -1/2 0 1/2
14! 4 1/12 -2/3 0 2/3 -1/12
15! 6 -1/60 3/20 -3/4 0 3/4 -3/20 1/60
16! 8 1/280 -4/105 1/5 -4/5 0 4/5 -1/5 4/105 -1/280
17!---------------------------------------------------------------------------------------------------
18! 2 2 1 -2 1
19! 4 -1/12 4/3 -5/2 4/3 -1/12
20! 6 1/90 -3/20 3/2 -49/18 3/2 -3/20 1/90
21! 8 -1/560 8/315 -1/5 8/5 -205/72 8/5 -1/5 8/315 -1/560
22!---------------------------------------------------------------------------------------------------
23!> \par History
24!> init 17.03.2020
25!> complete refactoring 08.2026
26!> \author JGH
27! **************************************************************************************************
28MODULE qs_fgxc
29
36 USE kinds, ONLY: dp
37 USE pw_env_types, ONLY: pw_env_get,&
39 USE pw_grids, ONLY: pw_grid_compare
40 USE pw_methods, ONLY: pw_axpy,&
41 pw_scale,&
45 USE pw_types, ONLY: pw_c1d_gs_type,&
49 USE qs_fgxc_atom, ONLY: fgxc_atom_calc,&
51 USE qs_fxc, ONLY: qs_fxc_create,&
56 USE qs_rho_methods, ONLY: qs_rho_copy,&
60 USE qs_rho_types, ONLY: qs_rho_create,&
64 USE qs_vxc, ONLY: qs_vxc_create
76#include "./base/base_uses.f90"
77
78 IMPLICIT NONE
79
80 PRIVATE
81
82 ! *** Public subroutines ***
84
85 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_fgxc'
86
87! **************************************************************************************************
88
89CONTAINS
90
91! **************************************************************************************************
92!> \brief ...
93!> \param qs_env ...
94!> \param rho0_struct ...
95!> \param rho1_struct ...
96!> \param rho0_atom_set ...
97!> \param xc_section ...
98!> \param do_onecenter ...
99!> \param is_triplet ...
100!> \param spinflip ...
101!> \param fxc_rho ...
102!> \param fxc_tau ...
103!> \param gxc_rho ...
104!> \param gxc_tau ...
105!> \param rhof_atom_set ...
106!> \param rhog_atom_set ...
107!> \param qs_kind_set ...
108! **************************************************************************************************
109 SUBROUTINE qs_fgxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, &
110 xc_section, do_onecenter, is_triplet, spinflip, &
111 fxc_rho, fxc_tau, gxc_rho, gxc_tau, &
112 rhof_atom_set, rhog_atom_set, qs_kind_set)
113
114 TYPE(qs_environment_type), POINTER :: qs_env
115 TYPE(qs_rho_type), POINTER :: rho0_struct, rho1_struct
116 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set
117 TYPE(section_vals_type), POINTER :: xc_section
118 LOGICAL, INTENT(IN) :: do_onecenter, is_triplet, spinflip
119 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
120 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rhof_atom_set, rhog_atom_set
121 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
122
123 CHARACTER(len=*), PARAMETER :: routinen = 'qs_fgxc_create'
124
125 INTEGER :: handle, ispin, nspins, nsteps, order
126 LOGICAL :: analytic_2nd_deriv, analytic_3rd_deriv, &
127 has_rho, has_tau, uf_grid
128 REAL(kind=dp) :: eps_delta, factor
129 TYPE(dft_control_type), POINTER :: dft_control
130 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
131 TYPE(pw_c1d_gs_type), POINTER :: rho_nlcc_g
132 TYPE(pw_env_type), POINTER :: pw_env
133 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool, uf_pw_pool, xc_pw_pool
134 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho_uf, fxc_tau_uf, gxc_rho_uf, &
135 gxc_tau_uf, rho_r
136 TYPE(pw_r3d_rs_type), POINTER :: rho_nlcc, weights, weights_uf
137 TYPE(qs_rho_type), POINTER :: rho0_uf, rho1_uf
138
139 CALL timeset(routinen, handle)
140
141 ! Only rho0 and rho1 should be associated
142 cpassert(.NOT. ASSOCIATED(fxc_rho))
143 cpassert(.NOT. ASSOCIATED(fxc_tau))
144 cpassert(.NOT. ASSOCIATED(gxc_rho))
145 cpassert(.NOT. ASSOCIATED(gxc_tau))
146 cpassert(ASSOCIATED(rho0_struct))
147 cpassert(ASSOCIATED(rho1_struct))
148
149 nsteps = section_get_ival(xc_section, "NSTEPS")
150 order = 2*nsteps
151 eps_delta = section_get_rval(xc_section, "STEP_SIZE")
152 analytic_2nd_deriv = section_get_lval(xc_section, "2ND_DERIV_ANALYTICAL")
153 analytic_3rd_deriv = section_get_lval(xc_section, "3RD_DERIV_ANALYTICAL")
154 IF (analytic_3rd_deriv .AND. .NOT. analytic_2nd_deriv) THEN
155 CALL cp_warn(__location__, "XC Analytic 3rd derivatives cannot be combined with "// &
156 "numeric 2nd derivatives.")
157 cpabort("XC derivative options")
158 END IF
159
160 CALL get_qs_env(qs_env, dft_control=dft_control)
161 nspins = dft_control%nspins
162
163 CALL get_qs_env(qs_env, pw_env=pw_env)
164 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, xc_pw_pool=xc_pw_pool)
165 uf_grid = .NOT. pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
166
167 NULLIFY (fxc_rho_uf, fxc_tau_uf, gxc_rho_uf, gxc_tau_uf)
168 IF (analytic_2nd_deriv .AND. analytic_3rd_deriv) THEN
169
170 ! NLCC
171 NULLIFY (rho_nlcc, rho_nlcc_g)
172 CALL get_qs_env(qs_env, rho_nlcc=rho_nlcc, rho_nlcc_g=rho_nlcc_g)
173 IF (ASSOCIATED(rho_nlcc)) THEN
174 NULLIFY (rho_r, rho_g)
175 CALL qs_rho_get(rho0_struct, rho_r=rho_r, rho_g=rho_g)
176 factor = 1.0_dp
177 DO ispin = 1, nspins
178 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
179 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
180 END DO
181 END IF
182
183 ! Integration weights
184 NULLIFY (weights)
185 CALL get_qs_env(qs_env, xcint_weights=weights)
186
187 NULLIFY (weights_uf)
188 IF (uf_grid) THEN
189 IF (ASSOCIATED(weights)) THEN
190 ALLOCATE (weights_uf)
191 CALL xc_pw_pool%create_pw(weights_uf)
192 block
193 TYPE(pw_c1d_gs_type) :: weights_g, weights_g_uf
194 CALL auxbas_pw_pool%create_pw(weights_g)
195 CALL xc_pw_pool%create_pw(weights_g_uf)
196 CALL pw_transfer(weights, weights_g)
197 CALL pw_transfer(weights_g, weights_g_uf)
198 CALL pw_transfer(weights_g_uf, weights_uf)
199 CALL xc_pw_pool%give_back_pw(weights_g_uf)
200 CALL auxbas_pw_pool%give_back_pw(weights_g)
201 END block
202 END IF
203 !
204 ALLOCATE (rho0_uf, rho1_uf)
205 CALL qs_rho_create(rho0_uf)
206 CALL qs_rho_create(rho1_uf)
207 CALL qs_rho_transfer(rho0_struct, rho0_uf, auxbas_pw_pool, xc_pw_pool)
208 CALL qs_rho_transfer(rho1_struct, rho1_uf, auxbas_pw_pool, xc_pw_pool)
209 uf_pw_pool => xc_pw_pool
210 ELSE
211 weights_uf => weights
212 rho0_uf => rho0_struct
213 rho1_uf => rho1_struct
214 uf_pw_pool => auxbas_pw_pool
215 END IF
216
217 ! Analytic third derivatives cover the spin-flip case and, in the
218 ! reduced-gradient (gamma) formulation, the spin-restricted singlet one.
219 IF (.NOT. spinflip .AND. is_triplet) THEN
220 cpabort("Analytic 3rd XC derivatives: no restricted triplets yet")
221 END IF
222 CALL qs_fgxc_analytic(rho0_uf, rho1_uf, xc_section, uf_pw_pool, weights_uf, &
223 is_triplet, spinflip, &
224 fxc_rho_uf, fxc_tau_uf, gxc_rho_uf, gxc_tau_uf)
225
226 ! check for results
227 has_rho = .false.
228 IF (ASSOCIATED(fxc_rho_uf) .AND. ASSOCIATED(gxc_rho_uf)) has_rho = .true.
229 has_tau = .false.
230 IF (ASSOCIATED(fxc_tau_uf) .AND. ASSOCIATED(gxc_tau_uf)) has_tau = .true.
231 ! transfer to standard grid
232 IF (uf_grid) THEN
233 ! rho
234 IF (has_rho) THEN
235 ALLOCATE (fxc_rho(SIZE(fxc_rho_uf)), gxc_rho(SIZE(gxc_rho_uf)))
236 block
237 TYPE(pw_c1d_gs_type) :: xc_g, xc_g_uf
238 CALL auxbas_pw_pool%create_pw(xc_g)
239 CALL xc_pw_pool%create_pw(xc_g_uf)
240 DO ispin = 1, SIZE(fxc_rho)
241 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
242 CALL pw_transfer(fxc_rho_uf(ispin), xc_g_uf)
243 CALL pw_transfer(xc_g_uf, xc_g)
244 CALL pw_transfer(xc_g, fxc_rho(ispin))
245 CALL xc_pw_pool%give_back_pw(fxc_rho_uf(ispin))
246 END DO
247 DO ispin = 1, SIZE(gxc_rho)
248 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
249 CALL pw_transfer(gxc_rho_uf(ispin), xc_g_uf)
250 CALL pw_transfer(xc_g_uf, xc_g)
251 CALL pw_transfer(xc_g, gxc_rho(ispin))
252 CALL xc_pw_pool%give_back_pw(gxc_rho_uf(ispin))
253 END DO
254 CALL xc_pw_pool%give_back_pw(xc_g_uf)
255 CALL auxbas_pw_pool%give_back_pw(xc_g)
256 END block
257 DEALLOCATE (fxc_rho_uf, gxc_rho_uf)
258 ELSE
259 NULLIFY (fxc_rho, gxc_rho)
260 END IF
261 ! tau
262 IF (has_tau) THEN
263 ALLOCATE (fxc_tau(SIZE(fxc_tau_uf)), gxc_tau(SIZE(gxc_tau_uf)))
264 block
265 TYPE(pw_c1d_gs_type) :: xc_g, xc_g_uf
266 CALL auxbas_pw_pool%create_pw(xc_g)
267 CALL xc_pw_pool%create_pw(xc_g_uf)
268 DO ispin = 1, SIZE(fxc_tau)
269 CALL auxbas_pw_pool%create_pw(fxc_tau(ispin))
270 CALL pw_transfer(fxc_tau_uf(ispin), xc_g_uf)
271 CALL pw_transfer(xc_g_uf, xc_g)
272 CALL pw_transfer(xc_g, fxc_tau(ispin))
273 CALL xc_pw_pool%give_back_pw(fxc_tau_uf(ispin))
274 END DO
275 DO ispin = 1, SIZE(gxc_tau)
276 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
277 CALL pw_transfer(gxc_tau_uf(ispin), xc_g_uf)
278 CALL pw_transfer(xc_g_uf, xc_g)
279 CALL pw_transfer(xc_g, gxc_tau(ispin))
280 CALL xc_pw_pool%give_back_pw(gxc_tau_uf(ispin))
281 END DO
282 CALL xc_pw_pool%give_back_pw(xc_g_uf)
283 CALL auxbas_pw_pool%give_back_pw(xc_g)
284 END block
285 DEALLOCATE (fxc_tau_uf, gxc_tau_uf)
286 ELSE
287 NULLIFY (fxc_tau, gxc_tau)
288 END IF
289 ELSE
290 fxc_rho => fxc_rho_uf
291 fxc_tau => fxc_tau_uf
292 gxc_rho => gxc_rho_uf
293 gxc_tau => gxc_tau_uf
294 END IF
295
296 ! de-apply NLCC density
297 IF (ASSOCIATED(rho_nlcc)) THEN
298 factor = -1.0_dp
299 DO ispin = 1, nspins
300 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
301 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
302 END DO
303 END IF
304
305 ELSE IF (analytic_2nd_deriv .AND. .NOT. analytic_3rd_deriv) THEN
306
307 NULLIFY (weights)
308 CALL get_qs_env(qs_env, xcint_weights=weights)
309 CALL qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
310 order, eps_delta, is_triplet, spinflip, &
311 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
312
313 ELSE IF (.NOT. (analytic_2nd_deriv .OR. analytic_3rd_deriv)) THEN
314
315 CALL qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
316 order, is_triplet, spinflip, &
317 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
318
319 ELSE
320 cpabort("EXC derivative option not available")
321 END IF
322
323 IF (do_onecenter) THEN
324 IF (analytic_2nd_deriv .AND. analytic_3rd_deriv) THEN
325 cpabort("Analytic 3rd EXC derivatives not available")
326 ELSE IF (analytic_2nd_deriv) THEN
327 CALL fgxc_atom_diff(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
328 qs_kind_set, xc_section, is_triplet, order, eps_delta)
329 ELSE IF (analytic_3rd_deriv) THEN
330 CALL cp_warn(__location__, "XC Analytic 3rd derivatives cannot be combined with "// &
331 "numeric 2nd derivatives.")
332 cpabort("XC derivative options")
333 ELSE
334 CALL fgxc_atom_calc(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
335 qs_kind_set, xc_section, is_triplet, order)
336 END IF
337 END IF
338
339 CALL timestop(handle)
340
341 END SUBROUTINE qs_fgxc_create
342
343! **************************************************************************************************
344!> \brief Calculates the values at the grid points in real space (r_i), of the second and third
345!> functional derivatives of the exchange-correlation energy functional.
346!> fxc_rho(r_i) = fxc[n](r_i)*n^(1)(r_i) ! Second functional derivative
347!> gxc_rho(r_i) = n^(1)(r_i)*gxc[n](r_i)*n^(1)(r_i) ! Third functional derivative
348!> \param rho0_struct Ground state density, n(r).
349!> \param rho1_struct Density used to fold the functional derivatives, n^(1)(r).
350!> \param xc_section ...
351!> \param pw_pool ...
352!> \param weights ...
353!> \param is_triplet Flag used to activate triplet kernel (not available)
354!> \param spinflip Flag used to activate the spin-flip noncollinear kernel and kernel derivatives.
355!> \param fxc_rho Second functional derivative with respect to the density, n(r).
356!> \param fxc_tau mGGA contribution to the second functional derivative with respect to the density.
357!> \param gxc_rho Third functional derivative with respect to the density, n(r).
358!> \param gxc_tau mGGA contribution to the third functional derivative with respect to the density.
359!> \par History
360!> * 07.2024 Created [LHS]
361! **************************************************************************************************
362 SUBROUTINE qs_fgxc_analytic(rho0_struct, rho1_struct, xc_section, pw_pool, weights, &
363 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
364
365 TYPE(qs_rho_type), POINTER :: rho0_struct, rho1_struct
366 TYPE(section_vals_type), POINTER :: xc_section
367 TYPE(pw_pool_type), POINTER :: pw_pool
368 TYPE(pw_r3d_rs_type), POINTER :: weights
369 LOGICAL, INTENT(IN) :: is_triplet, spinflip
370 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
371
372 CHARACTER(len=*), PARAMETER :: routinen = 'qs_fgxc_analytic'
373
374 INTEGER :: handle, ispin, nspins, spindim
375 INTEGER, DIMENSION(2, 3) :: bo
376 LOGICAL :: do_sf, lsd
377 REAL(kind=dp) :: fac
378 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho0_g, rho1_g
379 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho0_r, rho1_r, tau0_r, tau1_r
380 TYPE(section_vals_type), POINTER :: xc_fun_section
381 TYPE(xc_derivative_set_type) :: deriv_set
382 TYPE(xc_rho_cflags_type) :: needs
383 TYPE(xc_rho_set_type) :: rho0_set, rho1_set
384
385 CALL timeset(routinen, handle)
386
387 ! Only rho0 and rho1 should be associated
388 cpassert(.NOT. ASSOCIATED(fxc_rho))
389 cpassert(.NOT. ASSOCIATED(fxc_tau))
390 cpassert(.NOT. ASSOCIATED(gxc_rho))
391 cpassert(.NOT. ASSOCIATED(gxc_tau))
392 cpassert(ASSOCIATED(rho0_struct))
393 cpassert(ASSOCIATED(rho1_struct))
394
395 cpassert(.NOT. is_triplet)
396
397 ! Initialize parameters
398 do_sf = spinflip
399 !
400 ! Get the values on the gridpoints of the rho0 density
401 CALL qs_rho_get(rho0_struct, rho_r=rho0_r, rho_g=rho0_g, tau_r=tau0_r)
402 nspins = SIZE(rho0_r)
403 ! The perturbed fields have to be fetched here too: the meta-GGA branch
404 ! below tests ASSOCIATED(tau1_r) before rho1_set is built, and tau1_r is a
405 ! local pointer until this call defines it.
406 CALL qs_rho_get(rho1_struct, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
407
408 ! Analytic third derivatives cover the spin-flip case and, in the
409 ! reduced-gradient (gamma) formulation, the spin-restricted singlet one.
410 IF (.NOT. (do_sf .OR. nspins == 1 .OR. nspins == 2)) THEN
411 cpabort("Analytic 3rd XC derivatives: unsupported spin case")
412 END IF
413 lsd = (nspins == 2)
414 !
415 IF (do_sf) THEN
416 spindim = 1
417 ELSE
418 spindim = nspins
419 END IF
420 !
421 fac = 0._dp
422 IF (nspins == 1) THEN
423 fac = 1.0_dp
424 END IF
425
426 ! Read xc functional section and find out what the functional actually needs
427 xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
428 needs = xc_functionals_get_needs(xc_fun_section, lsd, .true.)
429
430 ! Create fields for the kernel and kernel derivative
431 ALLOCATE (fxc_rho(spindim), gxc_rho(nspins))
432 DO ispin = 1, spindim
433 CALL pw_pool%create_pw(fxc_rho(ispin))
434 CALL pw_zero(fxc_rho(ispin))
435 END DO
436 DO ispin = 1, nspins
437 CALL pw_pool%create_pw(gxc_rho(ispin))
438 CALL pw_zero(gxc_rho(ispin))
439 END DO
440 ! Create fields for mGGA functionals. This implementation is not ready yet!
441 IF (needs%tau .OR. needs%tau_spin) THEN
442 IF (.NOT. ASSOCIATED(tau1_r)) THEN
443 cpabort("Tau-dependent functionals requires allocated kinetic energy density grid")
444 END IF
445 ALLOCATE (fxc_tau(spindim), gxc_tau(nspins))
446 DO ispin = 1, spindim
447 CALL pw_pool%create_pw(fxc_tau(ispin))
448 CALL pw_zero(fxc_tau(ispin))
449 END DO
450 DO ispin = 1, nspins
451 CALL pw_pool%create_pw(gxc_tau(ispin))
452 CALL pw_zero(gxc_tau(ispin))
453 END DO
454 END IF
455
456 ! Build rho0_set
457 ! calculate the arguments needed by the functionals
458 ! Needs
459 ! deriv_set xc_derivative_set_type just declared
460 ! rho0_set xc_rho_set_type just declared
461 ! rho0_r pw_type calculated by qs_rho_get
462 ! pw_pool given by the calling subroutine
463 ! xc_section given by the calling subroutine
464 ! tau0_r pw_type calculated by qs_rho_get
465 CALL xc_prep_3rd_deriv(deriv_set, rho0_set, rho0_r, pw_pool, weights, &
466 xc_section, tau_r=tau0_r, do_sf=do_sf)
467
468 ! Build rho1_set
469 bo = rho1_r(1)%pw_grid%bounds_local
470 ! create the place where to store the argument for the functionals
471 ! Needs
472 ! rho1_set xc_rho_set_type just declared
473 ! bo 2x3 integer matrix should have bounds_local or rho1_r
474 CALL xc_rho_set_create(rho1_set, bo, &
475 rho_cutoff=section_get_rval(xc_section, "DENSITY_CUTOFF"), &
476 drho_cutoff=section_get_rval(xc_section, "GRADIENT_CUTOFF"), &
477 tau_cutoff=section_get_rval(xc_section, "TAU_CUTOFF"))
478 ! calculate the arguments needed by the functionals
479 ! Needs
480 ! rho1_set object created by xc_rho_set_create
481 ! rho1_r,rho1_g,tau1_r pw_type values of rho1 in real space grid
482 ! needs xc_rho_cflags_type defined through xc_functionals_get_needs
483 ! pw_pool Given by the calling subroutine
484 CALL xc_rho_set_update(rho1_set, rho1_r, rho1_g, tau1_r, needs, &
485 section_get_ival(xc_section, "XC_GRID%XC_DERIV"), &
486 section_get_ival(xc_section, "XC_GRID%XC_SMOOTH_RHO"), &
487 pw_pool, spinflip=do_sf)
488
489 ! Calculate exchange correlation kernel
490 ! Needs
491 ! fxc_rho, fxc_tau pw_type not associated
492 ! deriv_set created and defined by xc_prep_3rd_deriv
493 ! rho0_set xc_rho_set_type build by xc_prep_3rd_deriv
494 ! rho1_set xc_rho_set_type build by xc_rho_set_create/update
495 ! pw_pool needs to be given by the calling subroutine
496 ! xc_section needs to be given by the calling subroutine
497 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
498 xc_section, .false., spinflip=do_sf, tddfpt_fac=fac)
499 ! Calculate exchange correlation kernel derivative
500 CALL xc_calc_3rd_deriv_analytical(gxc_rho, gxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
501 xc_section, spinflip=do_sf)
502
503 CALL xc_dset_release(deriv_set)
504 CALL xc_rho_set_release(rho0_set)
505 CALL xc_rho_set_release(rho1_set)
506
507 CALL timestop(handle)
508
509 END SUBROUTINE qs_fgxc_analytic
510
511! **************************************************************************************************
512!> \brief ...
513!> \param qs_env ...
514!> \param rho0_struct ...
515!> \param rho1_struct ...
516!> \param xc_section ...
517!> \param accuracy ...
518!> \param epsrho ...
519!> \param is_triplet ...
520!> \param spinflip ...
521!> \param fxc_rho ...
522!> \param fxc_tau ...
523!> \param gxc_rho ...
524!> \param gxc_tau ...
525! **************************************************************************************************
526 SUBROUTINE qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, epsrho, &
527 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
528
529 TYPE(qs_environment_type), POINTER :: qs_env
530 TYPE(qs_rho_type), POINTER :: rho0_struct, rho1_struct
531 TYPE(section_vals_type), POINTER :: xc_section
532 INTEGER, INTENT(IN) :: accuracy
533 REAL(kind=dp), INTENT(IN) :: epsrho
534 LOGICAL, INTENT(IN) :: is_triplet, spinflip
535 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
536
537 CHARACTER(len=*), PARAMETER :: routinen = 'qs_fgxc_gdiff'
538
539 INTEGER :: handle, ispin, istep, nspins, nstep
540 LOGICAL :: do_sf
541 REAL(kind=dp) :: alpha, beta, exc, oeps1
542 REAL(kind=dp), DIMENSION(-4:4) :: ak
543 TYPE(dft_control_type), POINTER :: dft_control
544 TYPE(pw_env_type), POINTER :: pw_env
545 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
546 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: v_tau_rspace, v_tau_rspaceb, vxc00, &
547 vxc00b
548 TYPE(qs_rho_type), POINTER :: rhoin
549 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set, rho1_atom_set
550
551 CALL timeset(routinen, handle)
552
553 cpassert(.NOT. ASSOCIATED(fxc_rho))
554 cpassert(.NOT. ASSOCIATED(fxc_tau))
555 cpassert(.NOT. ASSOCIATED(gxc_rho))
556 cpassert(.NOT. ASSOCIATED(gxc_tau))
557 cpassert(ASSOCIATED(rho0_struct))
558 cpassert(ASSOCIATED(rho1_struct))
559
560 do_sf = spinflip
561
562 ak = 0.0_dp
563 SELECT CASE (accuracy)
564 CASE (:4)
565 nstep = 2
566 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
567 CASE (5:7)
568 nstep = 3
569 ak(-3:3) = [-1.0_dp, 9.0_dp, -45.0_dp, 0.0_dp, 45.0_dp, -9.0_dp, 1.0_dp]/60.0_dp
570 CASE (8:)
571 nstep = 4
572 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
573 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
574 END SELECT
575
576 CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env)
577 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
578
579 nspins = dft_control%nspins
580 exc = 0.0_dp
581
582 IF (do_sf) THEN
583 CALL qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, &
584 .false., fxc_rho, fxc_tau, rho1_atom_set, &
585 is_triplet=is_triplet, spinflip=do_sf)
586 ELSE
587 CALL qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
588 accuracy, fxc_rho, fxc_tau, is_triplet)
589 END IF
590
591 DO istep = -nstep, nstep
592
593 IF (ak(istep) /= 0.0_dp) THEN
594 alpha = 1.0_dp
595 beta = real(istep, kind=dp)*epsrho
596 NULLIFY (rhoin)
597 ALLOCATE (rhoin)
598 CALL qs_rho_create(rhoin)
599 NULLIFY (vxc00, vxc00b, v_tau_rspace, v_tau_rspaceb)
600 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
601 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
602 IF (do_sf) THEN
603 ! variation in alpha density
604 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
605 .false., vxc00, v_tau_rspace, rho1_atom_set, &
606 is_triplet=is_triplet, spinflip=do_sf)
607 ! variation in beta density
608 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
609 CALL qs_rho_scale_and_add_b(rhoin, rho1_struct, alpha, beta)
610 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
611 .false., vxc00b, v_tau_rspaceb, rho1_atom_set, &
612 is_triplet=is_triplet, spinflip=do_sf)
613 ELSE
614 CALL qs_fxc_fdiff(qs_env, rhoin, rho1_struct, xc_section, accuracy, &
615 fxc_rho=vxc00, fxc_tau=v_tau_rspace, is_triplet=is_triplet)
616 END IF
617 CALL qs_rho_release(rhoin)
618 DEALLOCATE (rhoin)
619 IF (.NOT. ASSOCIATED(gxc_rho)) THEN
620 ALLOCATE (gxc_rho(nspins))
621 DO ispin = 1, nspins
622 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
623 CALL pw_zero(gxc_rho(ispin))
624 END DO
625 END IF
626 IF (do_sf) THEN
627 CALL pw_axpy(vxc00(1), gxc_rho(1), ak(istep))
628 CALL pw_axpy(vxc00b(1), gxc_rho(2), ak(istep))
629 ELSE
630 DO ispin = 1, nspins
631 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), ak(istep))
632 END DO
633 END IF
634 IF (ASSOCIATED(v_tau_rspace)) THEN
635 IF (.NOT. ASSOCIATED(gxc_tau)) THEN
636 ALLOCATE (gxc_tau(nspins))
637 DO ispin = 1, nspins
638 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
639 CALL pw_zero(gxc_tau(ispin))
640 END DO
641 END IF
642 IF (do_sf) THEN
643 CALL pw_axpy(v_tau_rspace(1), gxc_tau(1), ak(istep))
644 CALL pw_axpy(v_tau_rspaceb(1), gxc_tau(2), ak(istep))
645 ELSE
646 DO ispin = 1, nspins
647 CALL pw_axpy(v_tau_rspace(ispin), gxc_tau(ispin), ak(istep))
648 END DO
649 END IF
650 END IF
651 CALL qs_fgxc_release(vxc00, v_tau_rspace, vxc00b, v_tau_rspaceb, auxbas_pw_pool)
652 END IF
653
654 END DO
655
656 oeps1 = 1.0_dp/epsrho
657 DO ispin = 1, nspins
658 CALL pw_scale(gxc_rho(ispin), oeps1)
659 END DO
660 IF (ASSOCIATED(gxc_tau)) THEN
661 DO ispin = 1, nspins
662 CALL pw_scale(gxc_tau(ispin), oeps1)
663 END DO
664 END IF
665
666 CALL timestop(handle)
667
668 END SUBROUTINE qs_fgxc_gdiff
669
670! **************************************************************************************************
671!> \brief ...
672!> \param qs_env ...
673!> \param rho0_struct ...
674!> \param rho1_struct ...
675!> \param xc_section ...
676!> \param accuracy ...
677!> \param is_triplet ...
678!> \param spinflip ...
679!> \param fxc_rho ...
680!> \param fxc_tau ...
681!> \param gxc_rho ...
682!> \param gxc_tau ...
683! **************************************************************************************************
684 SUBROUTINE qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
685 accuracy, is_triplet, spinflip, &
686 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
687
688 TYPE(qs_environment_type), POINTER :: qs_env
689 TYPE(qs_rho_type), POINTER :: rho0_struct, rho1_struct
690 TYPE(section_vals_type), POINTER :: xc_section
691 INTEGER, INTENT(IN) :: accuracy
692 LOGICAL, INTENT(IN) :: is_triplet, spinflip
693 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
694
695 CHARACTER(len=*), PARAMETER :: routinen = 'qs_fgxc_fgdiff'
696 REAL(kind=dp), PARAMETER :: epsrho = 5.e-4_dp
697
698 INTEGER :: handle, ispin, istep, nspins, nstep
699 REAL(kind=dp) :: alpha, beta, exc, oeps1, oeps2
700 REAL(kind=dp), DIMENSION(-4:4) :: ak, bl
701 TYPE(dft_control_type), POINTER :: dft_control
702 TYPE(pw_env_type), POINTER :: pw_env
703 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
704 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: v_tau_rspace, vxc00
705 TYPE(qs_ks_env_type), POINTER :: ks_env
706 TYPE(qs_rho_type), POINTER :: rhoin
707
708 CALL timeset(routinen, handle)
709
710 cpassert(.NOT. ASSOCIATED(fxc_rho))
711 cpassert(.NOT. ASSOCIATED(fxc_tau))
712 cpassert(.NOT. ASSOCIATED(gxc_rho))
713 cpassert(.NOT. ASSOCIATED(gxc_tau))
714 cpassert(ASSOCIATED(rho0_struct))
715 cpassert(ASSOCIATED(rho1_struct))
716
717 ! no spinflip tested
718 cpassert(.NOT. spinflip)
719
720 ak = 0.0_dp
721 bl = 0.0_dp
722 SELECT CASE (accuracy)
723 CASE (:4)
724 nstep = 2
725 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
726 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
727 CASE (5:7)
728 nstep = 3
729 ak(-3:3) = [-1.0_dp, 9.0_dp, -45.0_dp, 0.0_dp, 45.0_dp, -9.0_dp, 1.0_dp]/60.0_dp
730 bl(-3:3) = [2.0_dp, -27.0_dp, 270.0_dp, -490.0_dp, 270.0_dp, -27.0_dp, 2.0_dp]/180.0_dp
731 CASE (8:)
732 nstep = 4
733 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
734 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
735 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
736 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
737 END SELECT
738
739 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=pw_env)
740 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
741
742 nspins = dft_control%nspins
743 exc = 0.0_dp
744
745 DO istep = -nstep, nstep
746
747 alpha = 1.0_dp
748 beta = real(istep, kind=dp)*epsrho
749 NULLIFY (rhoin)
750 ALLOCATE (rhoin)
751 CALL qs_rho_create(rhoin)
752 NULLIFY (vxc00, v_tau_rspace)
753 IF (is_triplet) THEN
754 cpassert(nspins == 1)
755 ! rhoin = (0.5 rho0, 0.5 rho0)
756 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, 2)
757 ! rhoin = (0.5 rho0 + 0.5 rho1, 0.5 rho0)
758 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, 0.5_dp*beta)
759 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
760 CALL pw_axpy(vxc00(2), vxc00(1), -1.0_dp)
761 ELSE
762 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
763 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
764 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
765 END IF
766 CALL qs_rho_release(rhoin)
767 DEALLOCATE (rhoin)
768 IF (.NOT. ASSOCIATED(fxc_rho)) THEN
769 ALLOCATE (fxc_rho(nspins))
770 DO ispin = 1, nspins
771 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
772 CALL pw_zero(fxc_rho(ispin))
773 END DO
774 END IF
775 IF (.NOT. ASSOCIATED(gxc_rho)) THEN
776 ALLOCATE (gxc_rho(nspins))
777 DO ispin = 1, nspins
778 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
779 CALL pw_zero(gxc_rho(ispin))
780 END DO
781 END IF
782 cpassert(.NOT. ASSOCIATED(v_tau_rspace))
783 DO ispin = 1, nspins
784 IF (ak(istep) /= 0.0_dp) THEN
785 CALL pw_axpy(vxc00(ispin), fxc_rho(ispin), ak(istep))
786 END IF
787 IF (bl(istep) /= 0.0_dp) THEN
788 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), bl(istep))
789 END IF
790 END DO
791 DO ispin = 1, SIZE(vxc00)
792 CALL auxbas_pw_pool%give_back_pw(vxc00(ispin))
793 END DO
794 DEALLOCATE (vxc00)
795
796 END DO
797
798 oeps1 = 1.0_dp/epsrho
799 oeps2 = 1.0_dp/(epsrho**2)
800 DO ispin = 1, nspins
801 CALL pw_scale(fxc_rho(ispin), oeps1)
802 CALL pw_scale(gxc_rho(ispin), oeps2)
803 END DO
804
805 CALL timestop(handle)
806
807 END SUBROUTINE qs_fgxc_fgdiff
808
809! **************************************************************************************************
810!> \brief ...
811!> \param fxc_rho ...
812!> \param fxc_tau ...
813!> \param gxc_rho ...
814!> \param gxc_tau ...
815!> \param pw_pool ...
816! **************************************************************************************************
817 SUBROUTINE qs_fgxc_release(fxc_rho, fxc_tau, gxc_rho, gxc_tau, pw_pool)
818
819 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
820 TYPE(pw_pool_type), POINTER :: pw_pool
821
822 INTEGER :: ispin
823
824 IF (ASSOCIATED(fxc_rho)) THEN
825 DO ispin = 1, SIZE(fxc_rho)
826 CALL pw_pool%give_back_pw(fxc_rho(ispin))
827 END DO
828 DEALLOCATE (fxc_rho)
829 END IF
830 IF (ASSOCIATED(fxc_tau)) THEN
831 DO ispin = 1, SIZE(fxc_tau)
832 CALL pw_pool%give_back_pw(fxc_tau(ispin))
833 END DO
834 DEALLOCATE (fxc_tau)
835 END IF
836 IF (ASSOCIATED(gxc_rho)) THEN
837 DO ispin = 1, SIZE(gxc_rho)
838 CALL pw_pool%give_back_pw(gxc_rho(ispin))
839 END DO
840 DEALLOCATE (gxc_rho)
841 END IF
842 IF (ASSOCIATED(gxc_tau)) THEN
843 DO ispin = 1, SIZE(gxc_tau)
844 CALL pw_pool%give_back_pw(gxc_tau(ispin))
845 END DO
846 DEALLOCATE (gxc_tau)
847 END IF
848
849 END SUBROUTINE qs_fgxc_release
850
851END MODULE qs_fgxc
static GRID_HOST_DEVICE double fac(const int i)
Factorial function, e.g. fac(5) = 5! = 120.
Definition grid_common.h:57
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
objects that represent the structure of input sections and the data contained in an input section
real(kind=dp) function, public section_get_rval(section_vals, keyword_name)
...
integer function, public section_get_ival(section_vals, keyword_name)
...
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
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
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
This module defines the grid data type and some basic operations on it.
Definition pw_grids.F:36
logical function, public pw_grid_compare(grida, gridb)
Check if two pw_grids are equal.
Definition pw_grids.F:148
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.
routines that build the integrals of the Fxc kernel calculated for the atomic density in the basis se...
subroutine, public fgxc_atom_diff(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, kind_set, xc_section, is_triplet, accuracy, epsrho)
...
subroutine, public fgxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, kind_set, xc_section, is_triplet, accuracy)
...
https://en.wikipedia.org/wiki/Finite_difference_coefficient
Definition qs_fgxc.F:28
subroutine, public qs_fgxc_release(fxc_rho, fxc_tau, gxc_rho, gxc_tau, pw_pool)
...
Definition qs_fgxc.F:818
subroutine, public qs_fgxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, do_onecenter, is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau, rhof_atom_set, rhog_atom_set, qs_kind_set)
...
Definition qs_fgxc.F:113
Setup Routine for Fxc Potentials.
Definition qs_fxc.F:15
subroutine, public qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, do_onecenter, fxc_rho, fxc_tau, rho1_atom_set, do_scale, is_triplet, spinflip, no_weights, uf_grid_results, pw_env_ext, kind_set_external, para_env_external, dispersion_env, compute_virial, virial_xc)
...
Definition qs_fxc.F:109
subroutine, public qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, fxc_rho, fxc_tau, is_triplet, spinflip)
...
Definition qs_fxc.F:1065
Define the quickstep kind type and their sub types.
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_copy(rho_input, rho_output, auxbas_pw_pool, mspin, factor)
Allocate a density structure and fill it with data from an input structure SIZE(rho_input) == mspin =...
subroutine, public qs_rho_scale_and_add_b(rhoa, rhob, alpha, beta)
rhoa(2) = alpha*rhoa(2)+beta*rhob(1)
subroutine, public qs_rho_scale_and_add(rhoa, rhob, alpha, beta)
rhoa = alpha*rhoa+beta*rhob
subroutine, public qs_rho_transfer(rho_input, rho_output, in_pw_pool, out_pw_pool)
Allocate a density structure and fill it with data from an input structure Transfer all data to input...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
subroutine, public 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, qs_env_external, native_gapw_composite_override, native_skala_defer_to_atom_composite)
calculates and allocates the xc potential, already reducing it to the dependence on rho and the one o...
Definition qs_vxc.F:120
represent a group ofunctional derivatives
subroutine, public xc_dset_release(derivative_set)
releases a derivative set
type(xc_rho_cflags_type) function, public xc_functionals_get_needs(functionals, lsd, calc_potential)
...
contains the structure
contains the structure
subroutine, public xc_rho_set_create(rho_set, local_bounds, rho_cutoff, drho_cutoff, tau_cutoff)
allocates and does (minimal) initialization of a rho_set
subroutine, public xc_rho_set_release(rho_set, pw_pool)
releases the given rho_set
subroutine, public xc_rho_set_update(rho_set, rho_r, rho_g, tau, needs, xc_deriv_method_id, xc_rho_smooth_id, pw_pool, spinflip)
updates the given rho set with the density given by rho_r (and rho_g). The rho set will contain the c...
Exchange and Correlation functional calculations.
Definition xc.F:17
subroutine, public xc_calc_2nd_deriv_analytical(v_xc, v_xc_tau, deriv_set, rho_set, rho1_set, pw_pool, xc_section, gapw, vxg, tddfpt_fac, compute_virial, virial_xc, spinflip)
Calculates the second derivative of E_xc at rho in the direction rho1 (if you see the second derivati...
Definition xc.F:2060
subroutine, public xc_calc_3rd_deriv_analytical(v_xc, v_xc_tau, deriv_set, rho_set, rho1_set, pw_pool, xc_section, spinflip, gapw, vxg)
Calculates the third functional derivative of the exchange-correlation functional,...
Definition xc.F:4739
subroutine, public xc_prep_3rd_deriv(deriv_set, rho_set, rho_r, pw_pool, weights, xc_section, tau_r, do_sf)
Prepare deriv_set for the calculation of the 3rd derivatives of the density functional....
Definition xc.F:9926
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 ...
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.
A derivative set contains the different derivatives of a xc-functional in form of a linked list.
contains a flag for each component of xc_rho_set, so that you can use it to tell which components you...
represent a density, with all the representation and data needed to perform a functional evaluation