(git:5e7fe52)
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(nspins), gxc_rho(nspins))
236 DO ispin = 1, nspins
237 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
238 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
239 block
240 TYPE(pw_c1d_gs_type) :: xc_g, xc_g_uf
241 CALL auxbas_pw_pool%create_pw(xc_g)
242 CALL xc_pw_pool%create_pw(xc_g_uf)
243 CALL pw_transfer(fxc_rho_uf(ispin), xc_g_uf)
244 CALL pw_transfer(xc_g_uf, xc_g)
245 CALL pw_transfer(xc_g, fxc_rho(ispin))
246 CALL pw_transfer(gxc_rho_uf(ispin), xc_g_uf)
247 CALL pw_transfer(xc_g_uf, xc_g)
248 CALL pw_transfer(xc_g, gxc_rho(ispin))
249 CALL xc_pw_pool%give_back_pw(xc_g_uf)
250 CALL auxbas_pw_pool%give_back_pw(xc_g)
251 END block
252 CALL xc_pw_pool%give_back_pw(fxc_rho_uf(ispin))
253 CALL xc_pw_pool%give_back_pw(gxc_rho_uf(ispin))
254 END DO
255 DEALLOCATE (fxc_rho_uf, gxc_rho_uf)
256 ELSE
257 NULLIFY (fxc_rho, gxc_rho)
258 END IF
259 ! tau
260 IF (has_tau) THEN
261 ALLOCATE (fxc_tau(nspins), gxc_tau(nspins))
262 DO ispin = 1, nspins
263 CALL auxbas_pw_pool%create_pw(fxc_tau(ispin))
264 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
265 block
266 TYPE(pw_c1d_gs_type) :: xc_g, xc_g_uf
267 CALL auxbas_pw_pool%create_pw(xc_g)
268 CALL xc_pw_pool%create_pw(xc_g_uf)
269 CALL pw_transfer(fxc_tau_uf(ispin), xc_g_uf)
270 CALL pw_transfer(xc_g_uf, xc_g)
271 CALL pw_transfer(xc_g, fxc_tau(ispin))
272 CALL pw_transfer(gxc_tau_uf(ispin), xc_g_uf)
273 CALL pw_transfer(xc_g_uf, xc_g)
274 CALL pw_transfer(xc_g, gxc_tau(ispin))
275 CALL xc_pw_pool%give_back_pw(xc_g_uf)
276 CALL auxbas_pw_pool%give_back_pw(xc_g)
277 END block
278 CALL xc_pw_pool%give_back_pw(fxc_tau_uf(ispin))
279 CALL xc_pw_pool%give_back_pw(gxc_tau_uf(ispin))
280 END DO
281 DEALLOCATE (fxc_tau_uf, gxc_tau_uf)
282 ELSE
283 NULLIFY (fxc_tau, gxc_tau)
284 END IF
285 ELSE
286 fxc_rho => fxc_rho_uf
287 fxc_tau => fxc_tau_uf
288 gxc_rho => gxc_rho_uf
289 gxc_tau => gxc_tau_uf
290 END IF
291
292 ! de-apply NLCC density
293 IF (ASSOCIATED(rho_nlcc)) THEN
294 factor = -1.0_dp
295 DO ispin = 1, nspins
296 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
297 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
298 END DO
299 END IF
300
301 ELSE IF (analytic_2nd_deriv .AND. .NOT. analytic_3rd_deriv) THEN
302
303 NULLIFY (weights)
304 CALL get_qs_env(qs_env, xcint_weights=weights)
305 CALL qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
306 order, eps_delta, is_triplet, spinflip, &
307 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
308
309 ELSE IF (.NOT. (analytic_2nd_deriv .OR. analytic_3rd_deriv)) THEN
310
311 CALL qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
312 order, is_triplet, spinflip, &
313 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
314
315 ELSE
316 cpabort("EXC derivative option not available")
317 END IF
318
319 IF (do_onecenter) THEN
320 IF (analytic_2nd_deriv .AND. analytic_3rd_deriv) THEN
321 cpabort("Analytic 3rd EXC derivatives not available")
322 ELSE IF (analytic_2nd_deriv) THEN
323 CALL fgxc_atom_diff(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
324 qs_kind_set, xc_section, is_triplet, order, eps_delta)
325 ELSE IF (analytic_3rd_deriv) THEN
326 CALL cp_warn(__location__, "XC Analytic 3rd derivatives cannot be combined with "// &
327 "numeric 2nd derivatives.")
328 cpabort("XC derivative options")
329 ELSE
330 CALL fgxc_atom_calc(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
331 qs_kind_set, xc_section, is_triplet, order)
332 END IF
333 END IF
334
335 CALL timestop(handle)
336
337 END SUBROUTINE qs_fgxc_create
338
339! **************************************************************************************************
340!> \brief Calculates the values at the grid points in real space (r_i), of the second and third
341!> functional derivatives of the exchange-correlation energy functional.
342!> fxc_rho(r_i) = fxc[n](r_i)*n^(1)(r_i) ! Second functional derivative
343!> gxc_rho(r_i) = n^(1)(r_i)*gxc[n](r_i)*n^(1)(r_i) ! Third functional derivative
344!> \param rho0_struct Ground state density, n(r).
345!> \param rho1_struct Density used to fold the functional derivatives, n^(1)(r).
346!> \param xc_section ...
347!> \param pw_pool ...
348!> \param weights ...
349!> \param is_triplet Flag used to activate triplet kernel (not available)
350!> \param spinflip Flag used to activate the spin-flip noncollinear kernel and kernel derivatives.
351!> \param fxc_rho Second functional derivative with respect to the density, n(r).
352!> \param fxc_tau mGGA contribution to the second functional derivative with respect to the density.
353!> \param gxc_rho Third functional derivative with respect to the density, n(r).
354!> \param gxc_tau mGGA contribution to the third functional derivative with respect to the density.
355!> \par History
356!> * 07.2024 Created [LHS]
357! **************************************************************************************************
358 SUBROUTINE qs_fgxc_analytic(rho0_struct, rho1_struct, xc_section, pw_pool, weights, &
359 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
360
361 TYPE(qs_rho_type), POINTER :: rho0_struct, rho1_struct
362 TYPE(section_vals_type), POINTER :: xc_section
363 TYPE(pw_pool_type), POINTER :: pw_pool
364 TYPE(pw_r3d_rs_type), POINTER :: weights
365 LOGICAL, INTENT(IN) :: is_triplet, spinflip
366 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
367
368 CHARACTER(len=*), PARAMETER :: routinen = 'qs_fgxc_analytic'
369
370 INTEGER :: handle, ispin, nspins, spindim
371 INTEGER, DIMENSION(2, 3) :: bo
372 LOGICAL :: do_sf, lsd
373 REAL(kind=dp) :: fac
374 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho0_g, rho1_g
375 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho0_r, rho1_r, tau0_r, tau1_r
376 TYPE(section_vals_type), POINTER :: xc_fun_section
377 TYPE(xc_derivative_set_type) :: deriv_set
378 TYPE(xc_rho_cflags_type) :: needs
379 TYPE(xc_rho_set_type) :: rho0_set, rho1_set
380
381 CALL timeset(routinen, handle)
382
383 ! Only rho0 and rho1 should be associated
384 cpassert(.NOT. ASSOCIATED(fxc_rho))
385 cpassert(.NOT. ASSOCIATED(fxc_tau))
386 cpassert(.NOT. ASSOCIATED(gxc_rho))
387 cpassert(.NOT. ASSOCIATED(gxc_tau))
388 cpassert(ASSOCIATED(rho0_struct))
389 cpassert(ASSOCIATED(rho1_struct))
390
391 cpassert(.NOT. is_triplet)
392
393 ! Initialize parameters
394 do_sf = spinflip
395 !
396 ! Get the values on the gridpoints of the rho0 density
397 CALL qs_rho_get(rho0_struct, rho_r=rho0_r, rho_g=rho0_g, tau_r=tau0_r)
398 nspins = SIZE(rho0_r)
399 ! The perturbed fields have to be fetched here too: the meta-GGA branch
400 ! below tests ASSOCIATED(tau1_r) before rho1_set is built, and tau1_r is a
401 ! local pointer until this call defines it.
402 CALL qs_rho_get(rho1_struct, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
403
404 ! Analytic third derivatives cover the spin-flip case and, in the
405 ! reduced-gradient (gamma) formulation, the spin-restricted singlet one.
406 IF (.NOT. (do_sf .OR. nspins == 1 .OR. nspins == 2)) THEN
407 cpabort("Analytic 3rd XC derivatives: unsupported spin case")
408 END IF
409 lsd = (nspins == 2)
410 !
411 IF (do_sf) THEN
412 spindim = 1
413 ELSE
414 spindim = nspins
415 END IF
416 !
417 fac = 0._dp
418 IF (nspins == 1) THEN
419 fac = 1.0_dp
420 END IF
421
422 ! Read xc functional section and find out what the functional actually needs
423 xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
424 needs = xc_functionals_get_needs(xc_fun_section, lsd, .true.)
425
426 ! Create fields for the kernel and kernel derivative
427 ALLOCATE (fxc_rho(spindim), gxc_rho(nspins))
428 DO ispin = 1, spindim
429 CALL pw_pool%create_pw(fxc_rho(ispin))
430 CALL pw_zero(fxc_rho(ispin))
431 END DO
432 DO ispin = 1, nspins
433 CALL pw_pool%create_pw(gxc_rho(ispin))
434 CALL pw_zero(gxc_rho(ispin))
435 END DO
436 ! Create fields for mGGA functionals. This implementation is not ready yet!
437 IF (needs%tau .OR. needs%tau_spin) THEN
438 IF (.NOT. ASSOCIATED(tau1_r)) THEN
439 cpabort("Tau-dependent functionals requires allocated kinetic energy density grid")
440 END IF
441 ALLOCATE (fxc_tau(spindim), gxc_tau(nspins))
442 DO ispin = 1, spindim
443 CALL pw_pool%create_pw(fxc_tau(ispin))
444 CALL pw_zero(fxc_tau(ispin))
445 END DO
446 DO ispin = 1, nspins
447 CALL pw_pool%create_pw(gxc_tau(ispin))
448 CALL pw_zero(gxc_tau(ispin))
449 END DO
450 END IF
451
452 ! Build rho0_set
453 ! calculate the arguments needed by the functionals
454 ! Needs
455 ! deriv_set xc_derivative_set_type just declared
456 ! rho0_set xc_rho_set_type just declared
457 ! rho0_r pw_type calculated by qs_rho_get
458 ! pw_pool given by the calling subroutine
459 ! xc_section given by the calling subroutine
460 ! tau0_r pw_type calculated by qs_rho_get
461 CALL xc_prep_3rd_deriv(deriv_set, rho0_set, rho0_r, pw_pool, weights, &
462 xc_section, tau_r=tau0_r, do_sf=do_sf)
463
464 ! Build rho1_set
465 bo = rho1_r(1)%pw_grid%bounds_local
466 ! create the place where to store the argument for the functionals
467 ! Needs
468 ! rho1_set xc_rho_set_type just declared
469 ! bo 2x3 integer matrix should have bounds_local or rho1_r
470 CALL xc_rho_set_create(rho1_set, bo, &
471 rho_cutoff=section_get_rval(xc_section, "DENSITY_CUTOFF"), &
472 drho_cutoff=section_get_rval(xc_section, "GRADIENT_CUTOFF"), &
473 tau_cutoff=section_get_rval(xc_section, "TAU_CUTOFF"))
474 ! calculate the arguments needed by the functionals
475 ! Needs
476 ! rho1_set object created by xc_rho_set_create
477 ! rho1_r,rho1_g,tau1_r pw_type values of rho1 in real space grid
478 ! needs xc_rho_cflags_type defined through xc_functionals_get_needs
479 ! pw_pool Given by the calling subroutine
480 CALL xc_rho_set_update(rho1_set, rho1_r, rho1_g, tau1_r, needs, &
481 section_get_ival(xc_section, "XC_GRID%XC_DERIV"), &
482 section_get_ival(xc_section, "XC_GRID%XC_SMOOTH_RHO"), &
483 pw_pool, spinflip=do_sf)
484
485 ! Calculate exchange correlation kernel
486 ! Needs
487 ! fxc_rho, fxc_tau pw_type not associated
488 ! deriv_set created and defined by xc_prep_3rd_deriv
489 ! rho0_set xc_rho_set_type build by xc_prep_3rd_deriv
490 ! rho1_set xc_rho_set_type build by xc_rho_set_create/update
491 ! pw_pool needs to be given by the calling subroutine
492 ! xc_section needs to be given by the calling subroutine
493 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
494 xc_section, .false., spinflip=do_sf, tddfpt_fac=fac)
495 ! Calculate exchange correlation kernel derivative
496 CALL xc_calc_3rd_deriv_analytical(gxc_rho, gxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
497 xc_section, spinflip=do_sf)
498
499 CALL xc_dset_release(deriv_set)
500 CALL xc_rho_set_release(rho0_set)
501 CALL xc_rho_set_release(rho1_set)
502
503 CALL timestop(handle)
504
505 END SUBROUTINE qs_fgxc_analytic
506
507! **************************************************************************************************
508!> \brief ...
509!> \param qs_env ...
510!> \param rho0_struct ...
511!> \param rho1_struct ...
512!> \param xc_section ...
513!> \param accuracy ...
514!> \param epsrho ...
515!> \param is_triplet ...
516!> \param spinflip ...
517!> \param fxc_rho ...
518!> \param fxc_tau ...
519!> \param gxc_rho ...
520!> \param gxc_tau ...
521! **************************************************************************************************
522 SUBROUTINE qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, epsrho, &
523 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
524
525 TYPE(qs_environment_type), POINTER :: qs_env
526 TYPE(qs_rho_type), POINTER :: rho0_struct, rho1_struct
527 TYPE(section_vals_type), POINTER :: xc_section
528 INTEGER, INTENT(IN) :: accuracy
529 REAL(kind=dp), INTENT(IN) :: epsrho
530 LOGICAL, INTENT(IN) :: is_triplet, spinflip
531 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
532
533 CHARACTER(len=*), PARAMETER :: routinen = 'qs_fgxc_gdiff'
534
535 INTEGER :: handle, ispin, istep, nspins, nstep
536 LOGICAL :: do_sf
537 REAL(kind=dp) :: alpha, beta, exc, oeps1
538 REAL(kind=dp), DIMENSION(-4:4) :: ak
539 TYPE(dft_control_type), POINTER :: dft_control
540 TYPE(pw_env_type), POINTER :: pw_env
541 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
542 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: v_tau_rspace, vxc00, vxc00b
543 TYPE(qs_rho_type), POINTER :: rhoin
544 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set, rho1_atom_set
545
546 CALL timeset(routinen, handle)
547
548 cpassert(.NOT. ASSOCIATED(fxc_rho))
549 cpassert(.NOT. ASSOCIATED(fxc_tau))
550 cpassert(.NOT. ASSOCIATED(gxc_rho))
551 cpassert(.NOT. ASSOCIATED(gxc_tau))
552 cpassert(ASSOCIATED(rho0_struct))
553 cpassert(ASSOCIATED(rho1_struct))
554
555 do_sf = spinflip
556
557 ak = 0.0_dp
558 SELECT CASE (accuracy)
559 CASE (:4)
560 nstep = 2
561 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
562 CASE (5:7)
563 nstep = 3
564 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
565 CASE (8:)
566 nstep = 4
567 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
568 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
569 END SELECT
570
571 CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env)
572 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
573
574 nspins = dft_control%nspins
575 exc = 0.0_dp
576
577 IF (do_sf) THEN
578 CALL qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, &
579 .false., fxc_rho, fxc_tau, rho1_atom_set, &
580 is_triplet=is_triplet, spinflip=do_sf)
581 ELSE
582 CALL qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
583 accuracy, fxc_rho, fxc_tau, is_triplet)
584 END IF
585
586 DO istep = -nstep, nstep
587
588 IF (ak(istep) /= 0.0_dp) THEN
589 alpha = 1.0_dp
590 beta = real(istep, kind=dp)*epsrho
591 NULLIFY (rhoin)
592 ALLOCATE (rhoin)
593 CALL qs_rho_create(rhoin)
594 NULLIFY (vxc00, vxc00b, v_tau_rspace)
595 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
596 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
597 IF (do_sf) THEN
598 ! variation in alpha density
599 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
600 .false., vxc00, v_tau_rspace, rho1_atom_set, &
601 is_triplet=is_triplet, spinflip=do_sf)
602 ! variation in beta density
603 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
604 CALL qs_rho_scale_and_add_b(rhoin, rho1_struct, alpha, beta)
605 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
606 .false., vxc00b, v_tau_rspace, rho1_atom_set, &
607 is_triplet=is_triplet, spinflip=do_sf)
608 ELSE
609 CALL qs_fxc_fdiff(qs_env, rhoin, rho1_struct, xc_section, accuracy, &
610 fxc_rho=vxc00, fxc_tau=v_tau_rspace, is_triplet=is_triplet)
611 END IF
612 CALL qs_rho_release(rhoin)
613 DEALLOCATE (rhoin)
614 IF (.NOT. ASSOCIATED(gxc_rho)) THEN
615 ALLOCATE (gxc_rho(nspins))
616 DO ispin = 1, nspins
617 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
618 CALL pw_zero(gxc_rho(ispin))
619 END DO
620 END IF
621 IF (do_sf) THEN
622 CALL pw_axpy(vxc00(1), gxc_rho(1), ak(istep))
623 CALL pw_axpy(vxc00b(1), gxc_rho(2), ak(istep))
624 ELSE
625 DO ispin = 1, nspins
626 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), ak(istep))
627 END DO
628 END IF
629 DO ispin = 1, SIZE(vxc00)
630 CALL auxbas_pw_pool%give_back_pw(vxc00(ispin))
631 END DO
632 DEALLOCATE (vxc00)
633 IF (ASSOCIATED(vxc00b)) THEN
634 CALL auxbas_pw_pool%give_back_pw(vxc00b(1))
635 DEALLOCATE (vxc00b)
636 END IF
637 IF (ASSOCIATED(v_tau_rspace)) THEN
638 IF (.NOT. ASSOCIATED(gxc_tau)) THEN
639 ALLOCATE (gxc_tau(nspins))
640 DO ispin = 1, nspins
641 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
642 CALL pw_zero(gxc_tau(ispin))
643 END DO
644 END IF
645 DO ispin = 1, nspins
646 CALL pw_axpy(v_tau_rspace(ispin), gxc_tau(ispin), ak(istep))
647 END DO
648 DO ispin = 1, SIZE(v_tau_rspace)
649 CALL auxbas_pw_pool%give_back_pw(v_tau_rspace(ispin))
650 END DO
651 DEALLOCATE (v_tau_rspace)
652 END IF
653 END IF
654
655 END DO
656
657 oeps1 = 1.0_dp/epsrho
658 DO ispin = 1, nspins
659 CALL pw_scale(gxc_rho(ispin), oeps1)
660 END DO
661 IF (ASSOCIATED(gxc_tau)) THEN
662 DO ispin = 1, nspins
663 CALL pw_scale(gxc_tau(ispin), oeps1)
664 END DO
665 END IF
666
667 CALL timestop(handle)
668
669 END SUBROUTINE qs_fgxc_gdiff
670
671! **************************************************************************************************
672!> \brief ...
673!> \param qs_env ...
674!> \param rho0_struct ...
675!> \param rho1_struct ...
676!> \param xc_section ...
677!> \param accuracy ...
678!> \param is_triplet ...
679!> \param spinflip ...
680!> \param fxc_rho ...
681!> \param fxc_tau ...
682!> \param gxc_rho ...
683!> \param gxc_tau ...
684! **************************************************************************************************
685 SUBROUTINE qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
686 accuracy, is_triplet, spinflip, &
687 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
688
689 TYPE(qs_environment_type), POINTER :: qs_env
690 TYPE(qs_rho_type), POINTER :: rho0_struct, rho1_struct
691 TYPE(section_vals_type), POINTER :: xc_section
692 INTEGER, INTENT(IN) :: accuracy
693 LOGICAL, INTENT(IN) :: is_triplet, spinflip
694 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
695
696 CHARACTER(len=*), PARAMETER :: routinen = 'qs_fgxc_fgdiff'
697 REAL(kind=dp), PARAMETER :: epsrho = 5.e-4_dp
698
699 INTEGER :: handle, ispin, istep, nspins, nstep
700 REAL(kind=dp) :: alpha, beta, exc, oeps1, oeps2
701 REAL(kind=dp), DIMENSION(-4:4) :: ak, bl
702 TYPE(dft_control_type), POINTER :: dft_control
703 TYPE(pw_env_type), POINTER :: pw_env
704 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
705 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: v_tau_rspace, vxc00
706 TYPE(qs_ks_env_type), POINTER :: ks_env
707 TYPE(qs_rho_type), POINTER :: rhoin
708
709 CALL timeset(routinen, handle)
710
711 cpassert(.NOT. ASSOCIATED(fxc_rho))
712 cpassert(.NOT. ASSOCIATED(fxc_tau))
713 cpassert(.NOT. ASSOCIATED(gxc_rho))
714 cpassert(.NOT. ASSOCIATED(gxc_tau))
715 cpassert(ASSOCIATED(rho0_struct))
716 cpassert(ASSOCIATED(rho1_struct))
717
718 ! no spinflip tested
719 cpassert(.NOT. spinflip)
720
721 ak = 0.0_dp
722 bl = 0.0_dp
723 SELECT CASE (accuracy)
724 CASE (:4)
725 nstep = 2
726 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
727 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
728 CASE (5:7)
729 nstep = 3
730 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
731 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
732 CASE (8:)
733 nstep = 4
734 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
735 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
736 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
737 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
738 END SELECT
739
740 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=pw_env)
741 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
742
743 nspins = dft_control%nspins
744 exc = 0.0_dp
745
746 DO istep = -nstep, nstep
747
748 alpha = 1.0_dp
749 beta = real(istep, kind=dp)*epsrho
750 NULLIFY (rhoin)
751 ALLOCATE (rhoin)
752 CALL qs_rho_create(rhoin)
753 NULLIFY (vxc00, v_tau_rspace)
754 IF (is_triplet) THEN
755 cpassert(nspins == 1)
756 ! rhoin = (0.5 rho0, 0.5 rho0)
757 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, 2)
758 ! rhoin = (0.5 rho0 + 0.5 rho1, 0.5 rho0)
759 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, 0.5_dp*beta)
760 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
761 CALL pw_axpy(vxc00(2), vxc00(1), -1.0_dp)
762 ELSE
763 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
764 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
765 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
766 END IF
767 CALL qs_rho_release(rhoin)
768 DEALLOCATE (rhoin)
769 IF (.NOT. ASSOCIATED(fxc_rho)) THEN
770 ALLOCATE (fxc_rho(nspins))
771 DO ispin = 1, nspins
772 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
773 CALL pw_zero(fxc_rho(ispin))
774 END DO
775 END IF
776 IF (.NOT. ASSOCIATED(gxc_rho)) THEN
777 ALLOCATE (gxc_rho(nspins))
778 DO ispin = 1, nspins
779 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
780 CALL pw_zero(gxc_rho(ispin))
781 END DO
782 END IF
783 cpassert(.NOT. ASSOCIATED(v_tau_rspace))
784 DO ispin = 1, nspins
785 IF (ak(istep) /= 0.0_dp) THEN
786 CALL pw_axpy(vxc00(ispin), fxc_rho(ispin), ak(istep))
787 END IF
788 IF (bl(istep) /= 0.0_dp) THEN
789 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), bl(istep))
790 END IF
791 END DO
792 DO ispin = 1, SIZE(vxc00)
793 CALL auxbas_pw_pool%give_back_pw(vxc00(ispin))
794 END DO
795 DEALLOCATE (vxc00)
796
797 END DO
798
799 oeps1 = 1.0_dp/epsrho
800 oeps2 = 1.0_dp/(epsrho**2)
801 DO ispin = 1, nspins
802 CALL pw_scale(fxc_rho(ispin), oeps1)
803 CALL pw_scale(gxc_rho(ispin), oeps2)
804 END DO
805
806 CALL timestop(handle)
807
808 END SUBROUTINE qs_fgxc_fgdiff
809
810! **************************************************************************************************
811!> \brief ...
812!> \param fxc_rho ...
813!> \param fxc_tau ...
814!> \param gxc_rho ...
815!> \param gxc_tau ...
816!> \param pw_pool ...
817! **************************************************************************************************
818 SUBROUTINE qs_fgxc_release(fxc_rho, fxc_tau, gxc_rho, gxc_tau, pw_pool)
819
820 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
821 TYPE(pw_pool_type), POINTER :: pw_pool
822
823 INTEGER :: ispin
824
825 IF (ASSOCIATED(fxc_rho)) THEN
826 DO ispin = 1, SIZE(fxc_rho)
827 CALL pw_pool%give_back_pw(fxc_rho(ispin))
828 END DO
829 DEALLOCATE (fxc_rho)
830 END IF
831 IF (ASSOCIATED(fxc_tau)) THEN
832 DO ispin = 1, SIZE(fxc_tau)
833 CALL pw_pool%give_back_pw(fxc_tau(ispin))
834 END DO
835 DEALLOCATE (fxc_tau)
836 END IF
837 IF (ASSOCIATED(gxc_rho)) THEN
838 DO ispin = 1, SIZE(gxc_rho)
839 CALL pw_pool%give_back_pw(gxc_rho(ispin))
840 END DO
841 DEALLOCATE (gxc_rho)
842 END IF
843 IF (ASSOCIATED(gxc_tau)) THEN
844 DO ispin = 1, SIZE(gxc_tau)
845 CALL pw_pool%give_back_pw(gxc_tau(ispin))
846 END DO
847 DEALLOCATE (gxc_tau)
848 END IF
849
850 END SUBROUTINE qs_fgxc_release
851
852END MODULE qs_fgxc
static GRID_HOST_DEVICE double fac(const int i)
Factorial function, e.g. fac(5) = 5! = 120.
Definition grid_common.h:56
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:819
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:29
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:1027
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, compute_virial, virial_xc)
...
Definition qs_fxc.F:118
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:118
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:2057
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:4736
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:9923
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