(git:5e7fe52)
Loading...
Searching...
No Matches
qs_fgxc_atom.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief routines that build the integrals of the Fxc kernel calculated
10!> for the atomic density in the basis set of spherical primitives
11! **************************************************************************************************
17 USE input_constants, ONLY: xc_none
21 USE kinds, ONLY: dp
25 USE qs_fxc_atom, ONLY: fxc_atom_calc
28 USE qs_kind_types, ONLY: get_qs_kind,&
29 has_nlcc,&
34 USE qs_vxc_atom_utils, ONLY: &
37 USE util, ONLY: get_limit
38 USE xc_atom, ONLY: fill_rho_set,&
51#include "./base/base_uses.f90"
52
53 IMPLICIT NONE
54
55 PRIVATE
56
57 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_fgxc_atom'
58
59 PUBLIC :: fgxc_atom_calc, &
61
62! **************************************************************************************************
63
64CONTAINS
65
66! **************************************************************************************************
67!> \brief ...
68!> \param qs_env ...
69!> \param rho0_atom_set ...
70!> \param rho1_atom_set ...
71!> \param rho2_atom_set ...
72!> \param kind_set ...
73!> \param xc_section ...
74!> \param is_triplet ...
75!> \param accuracy ...
76! **************************************************************************************************
77 SUBROUTINE fgxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, &
78 kind_set, xc_section, is_triplet, accuracy)
79
80 TYPE(qs_environment_type), POINTER :: qs_env
81 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set, rho1_atom_set, &
82 rho2_atom_set
83 TYPE(qs_kind_type), DIMENSION(:), POINTER :: kind_set
84 TYPE(section_vals_type), OPTIONAL, POINTER :: xc_section
85 LOGICAL, INTENT(IN) :: is_triplet
86 INTEGER, INTENT(IN) :: accuracy
87
88 CHARACTER(LEN=*), PARAMETER :: routinen = 'fgxc_atom_calc'
89 REAL(kind=dp), PARAMETER :: epsrho = 5.e-4_dp
90
91 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
92 istep, mspins, myfun, na, natom, nf, &
93 nr, ns, nspins, nstep, num_pe
94 INTEGER, DIMENSION(2, 3) :: bounds
95 INTEGER, DIMENSION(:), POINTER :: atom_list
96 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
97 paw_atom, tau_f
98 REAL(dp) :: agr, alpha, beta, density_cut, exc_h, &
99 exc_s, gradient_cut, oeps1, oeps2, &
100 tau_cut
101 REAL(dp), DIMENSION(1, 1, 1) :: tau_d
102 REAL(dp), DIMENSION(1, 1, 1, 1) :: rho_d
103 REAL(dp), DIMENSION(:, :), POINTER :: rho_nlcc, weight_h, weight_s
104 REAL(dp), DIMENSION(:, :, :), POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
105 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
106 tau_h, tau_s, vtau_h, vtau_s, vxc_h, &
107 vxc_s
108 REAL(dp), DIMENSION(:, :, :, :), POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
109 drho_h, drho_s, vxg_h, vxg_s
110 REAL(kind=dp), DIMENSION(-4:4) :: ak, bl
111 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
112 TYPE(dft_control_type), POINTER :: dft_control
113 TYPE(grid_atom_type), POINTER :: grid_atom
114 TYPE(gto_basis_set_type), POINTER :: basis_1c
115 TYPE(harmonics_atom_type), POINTER :: harmonics
116 TYPE(mp_para_env_type), POINTER :: para_env
117 TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
118 int_ss, r_h, r_s
119 TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: r_h_d, r_s_d
120 TYPE(rho_atom_type), POINTER :: rho0_atom, rho1_atom, rho2_atom
121 TYPE(section_vals_type), POINTER :: xc_fun_section
122 TYPE(tau_basis_cache_type) :: tau_basis_cache
123 TYPE(xc_derivative_set_type) :: deriv_set
124 TYPE(xc_rho_cflags_type) :: needs
125 TYPE(xc_rho_set_type) :: rho_set_h, rho_set_s
126
127 CALL timeset(routinen, handle)
128
129 NULLIFY (vtau_h, vtau_s)
130
131 ak = 0.0_dp
132 bl = 0.0_dp
133 SELECT CASE (accuracy)
134 CASE (:4)
135 nstep = 2
136 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
137 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
138 CASE (5:7)
139 nstep = 3
140 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
141 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
142 CASE (8:)
143 nstep = 4
144 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
145 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
146 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
147 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
148 END SELECT
149 oeps1 = 1.0_dp/epsrho
150 oeps2 = 1.0_dp/(epsrho**2)
151
152 CALL get_qs_env(qs_env=qs_env, &
153 dft_control=dft_control, &
154 para_env=para_env, &
155 atomic_kind_set=atomic_kind_set)
156
157 xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
158 CALL section_vals_val_get(xc_fun_section, "_SECTION_PARAMETERS_", i_val=myfun)
159
160 accint = dft_control%qs_control%gapw_control%accurate_xcint
161
162 IF (myfun == xc_none) THEN
163 ! no action needed?
164 ELSE
165 CALL section_vals_val_get(xc_section, "DENSITY_CUTOFF", r_val=density_cut)
166 CALL section_vals_val_get(xc_section, "GRADIENT_CUTOFF", r_val=gradient_cut)
167 CALL section_vals_val_get(xc_section, "TAU_CUTOFF", r_val=tau_cut)
168
169 nlcc = has_nlcc(kind_set)
170 lsd = dft_control%lsd
171 nspins = dft_control%nspins
172 mspins = nspins
173 IF (is_triplet) THEN
174 cpassert(nspins == 1)
175 lsd = .true.
176 mspins = 2
177 END IF
178 needs = xc_functionals_get_needs(xc_fun_section, lsd=lsd, calc_potential=.true.)
179 gradient_f = (needs%drho .OR. needs%drho_spin)
180 tau_f = (needs%tau .OR. needs%tau_spin)
181
182 ! Here starts the loop over all the atoms
183 DO ikind = 1, SIZE(atomic_kind_set)
184 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
185 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
186 harmonics=harmonics, grid_atom=grid_atom)
187 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type="GAPW_1C")
188
189 IF (.NOT. paw_atom) cycle
190
191 nr = grid_atom%nr
192 na = grid_atom%ng_sphere
193
194 ! set integration weights
195 IF (accint) THEN
196 weight_h => grid_atom%weight
197 alpha = dft_control%qs_control%gapw_control%aw(ikind)
198 IF (ASSOCIATED(grid_atom%gapw_weight_s)) THEN
199 IF (grid_atom%gapw_weight_alpha /= alpha) DEALLOCATE (grid_atom%gapw_weight_s)
200 END IF
201 IF (.NOT. ASSOCIATED(grid_atom%gapw_weight_s)) THEN
202 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
203 DO ir = 1, nr
204 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
205 grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
206 END DO
207 grid_atom%gapw_weight_alpha = alpha
208 END IF
209 weight_s => grid_atom%gapw_weight_s
210 ELSE
211 weight_h => grid_atom%weight
212 weight_s => grid_atom%weight
213 END IF
214
215 ! Prepare the structures needed to calculate and store the xc derivatives
216
217 ! Array dimension: here only one dimensional arrays are used,
218 ! i.e. only the first column of deriv_data is read.
219 ! The other to dimensions are set to size equal 1
220 bounds(1:2, 1:3) = 1
221 bounds(2, 1) = na
222 bounds(2, 2) = nr
223
224 ! create a place where to put the derivatives
225 CALL xc_dset_create(deriv_set, local_bounds=bounds)
226 ! create the place where to store the argument for the functionals
227 CALL xc_rho_set_create(rho_set_h, bounds, rho_cutoff=density_cut, &
228 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
229 CALL xc_rho_set_create(rho_set_s, bounds, rho_cutoff=density_cut, &
230 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
231
232 ! allocate the required 3d arrays where to store rho and drho
233 CALL xc_rho_set_atom_update(rho_set_h, needs, mspins, bounds)
234 CALL xc_rho_set_atom_update(rho_set_s, needs, mspins, bounds)
235
236 ALLOCATE (rho_h(na, nr, mspins), rho_s(na, nr, mspins), &
237 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
238 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
239 ALLOCATE (vxc_h(na, nr, mspins), vxc_s(na, nr, mspins))
240 IF (gradient_f) THEN
241 ALLOCATE (drho_h(4, na, nr, mspins), drho_s(4, na, nr, mspins), &
242 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
243 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
244 ALLOCATE (vxg_h(3, na, nr, mspins), vxg_s(3, na, nr, mspins))
245 END IF
246 IF (tau_f) THEN
247 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
248 ALLOCATE (tau_h(na, nr, mspins), tau_s(na, nr, mspins), &
249 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
250 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
251 ALLOCATE (vtau_h(na, nr, mspins), vtau_s(na, nr, mspins))
252 END IF
253 !
254 ! NLCC: prepare rho and drho of the core charge for this KIND
255 donlcc = .false.
256 IF (nlcc) THEN
257 NULLIFY (rho_nlcc)
258 rho_nlcc => kind_set(ikind)%nlcc_pot
259 IF (ASSOCIATED(rho_nlcc)) donlcc = .true.
260 END IF
261
262 ! Distribute the atoms of this kind
263 num_pe = para_env%num_pe
264 bo = get_limit(natom, num_pe, para_env%mepos)
265
266 DO iat = bo(1), bo(2)
267 iatom = atom_list(iat)
268 !
269 NULLIFY (int_hh, int_ss)
270 rho0_atom => rho0_atom_set(iatom)
271 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
272 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
273 DO ns = 1, nspins
274 nf = SIZE(int_ss(ns)%r_coef, 1)
275 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
276 nf = SIZE(int_hh(ns)%r_coef, 1)
277 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
278 END DO
279
280 ! RHO0
281 rho0_h = 0.0_dp
282 rho0_s = 0.0_dp
283 rho0_atom => rho0_atom_set(iatom)
284 IF (gradient_f) THEN
285 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
286 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
287 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
288 drho0_h = 0.0_dp
289 drho0_s = 0.0_dp
290 ELSE
291 NULLIFY (r_h, r_s)
292 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
293 rho_d = 0.0_dp
294 END IF
295 DO ir = 1, nr
296 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
297 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
298 r_h_d, r_s_d, drho0_h, drho0_s)
299 IF (donlcc) THEN
300 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
301 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
302 END IF
303 END DO
304 IF (tau_f) THEN
305 !compute tau on the grid all at once
306 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, tau_basis_cache, nspins)
307 ELSE
308 tau_d = 0.0_dp
309 END IF
310 ! RHO1
311 rho1_h = 0.0_dp
312 rho1_s = 0.0_dp
313 rho1_atom => rho1_atom_set(iatom)
314 IF (gradient_f) THEN
315 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
316 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
317 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
318 drho1_h = 0.0_dp
319 drho1_s = 0.0_dp
320 ELSE
321 NULLIFY (r_h, r_s)
322 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
323 END IF
324 DO ir = 1, nr
325 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
326 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
327 r_h_d, r_s_d, drho1_h, drho1_s)
328 END DO
329 IF (tau_f) THEN
330 !compute tau on the grid all at once
331 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
332 END IF
333 ! RHO2
334 rho2_atom => rho2_atom_set(iatom)
335
336 DO istep = -nstep, nstep
337
338 beta = real(istep, kind=dp)*epsrho
339
340 IF (is_triplet) THEN
341 rho_h(:, :, 1) = rho0_h(:, :, 1) + beta*rho1_h(:, :, 1)
342 rho_h(:, :, 2) = rho0_h(:, :, 1)
343 rho_h = 0.5_dp*rho_h
344 rho_s(:, :, 1) = rho0_s(:, :, 1) + beta*rho1_s(:, :, 1)
345 rho_s(:, :, 2) = rho0_s(:, :, 1)
346 rho_s = 0.5_dp*rho_s
347 IF (gradient_f) THEN
348 drho_h(:, :, :, 1) = drho0_h(:, :, :, 1) + beta*drho1_h(:, :, :, 1)
349 drho_h(:, :, :, 2) = drho0_h(:, :, :, 1)
350 drho_h = 0.5_dp*drho_h
351 drho_s(:, :, :, 1) = drho0_s(:, :, :, 1) + beta*drho1_s(:, :, :, 1)
352 drho_s(:, :, :, 2) = drho0_s(:, :, :, 1)
353 drho_s = 0.5_dp*drho_s
354 END IF
355 IF (tau_f) THEN
356 tau_h(:, :, 1) = tau0_h(:, :, 1) + beta*tau1_h(:, :, 1)
357 tau_h(:, :, 2) = tau0_h(:, :, 1)
358 tau_h = 0.5_dp*tau0_h
359 tau_s(:, :, 1) = tau0_s(:, :, 1) + beta*tau1_s(:, :, 1)
360 tau_s(:, :, 2) = tau0_s(:, :, 1)
361 tau_s = 0.5_dp*tau0_s
362 END IF
363 ELSE
364 rho_h = rho0_h + beta*rho1_h
365 rho_s = rho0_s + beta*rho1_s
366 IF (gradient_f) THEN
367 drho_h = drho0_h + beta*drho1_h
368 drho_s = drho0_s + beta*drho1_s
369 END IF
370 IF (tau_f) THEN
371 tau_h = tau0_h + beta*tau1_h
372 tau_s = tau0_s + beta*tau1_s
373 END IF
374 END IF
375 !
376 IF (gradient_f) THEN
377 drho_h(4, :, :, :) = norm2(drho_h(1:3, :, :, :), 1)
378 drho_s(4, :, :, :) = norm2(drho_s(1:3, :, :, :), 1)
379 END IF
380
381 DO ir = 1, nr
382 IF (tau_f) THEN
383 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_h, na, ir)
384 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_s, na, ir)
385 ELSE IF (gradient_f) THEN
386 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_d, na, ir)
387 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_d, na, ir)
388 ELSE
389 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, rho_d, tau_d, na, ir)
390 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, rho_d, tau_d, na, ir)
391 END IF
392 END DO
393
394 ! hard atom density !
395 CALL xc_dset_zero_all(deriv_set)
396 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight_h, &
397 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
398 IF (is_triplet) THEN
399 vxc_h(:, :, 1) = vxc_h(:, :, 1) - vxc_h(:, :, 2)
400 IF (gradient_f) THEN
401 vxg_h(:, :, :, 1) = vxg_h(:, :, :, 1) - vxg_h(:, :, :, 2)
402 END IF
403 IF (tau_f) THEN
404 vtau_h(:, :, 1) = vtau_h(:, :, 1) - vtau_h(:, :, 2)
405 END IF
406 END IF
407 ! soft atom density !
408 CALL xc_dset_zero_all(deriv_set)
409 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight_s, &
410 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
411 IF (is_triplet) THEN
412 vxc_s(:, :, 1) = vxc_s(:, :, 1) - vxc_s(:, :, 2)
413 IF (gradient_f) THEN
414 vxg_s(:, :, :, 1) = vxg_s(:, :, :, 1) - vxg_s(:, :, :, 2)
415 END IF
416 IF (tau_f) THEN
417 vtau_s(:, :, 1) = vtau_s(:, :, 1) - vtau_s(:, :, 2)
418 END IF
419 END IF
420 ! potentials
421 DO ns = 1, nspins
422 fint_hh(ns)%r_coef(:, :) = 0.0_dp
423 fint_ss(ns)%r_coef(:, :) = 0.0_dp
424 END DO
425 IF (gradient_f) THEN
426 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
427 grid_atom, basis_1c, harmonics, nspins)
428 ELSE
429 CALL gavxcgb_nogc(vxc_h, vxc_s, fint_hh, fint_ss, &
430 grid_atom, basis_1c, harmonics, nspins)
431 END IF
432 IF (tau_f) THEN
433 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
434 tau_basis_cache, nspins)
435 END IF
436 ! first derivative fxc
437 NULLIFY (int_hh, int_ss)
438 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
439 DO ns = 1, nspins
440 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
441 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
442 END DO
443 ! second derivative gxc
444 NULLIFY (int_hh, int_ss)
445 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
446 DO ns = 1, nspins
447 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_ss(ns)%r_coef(:, :)
448 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_hh(ns)%r_coef(:, :)
449 END DO
450 END DO
451 !
452 DO ns = 1, nspins
453 DEALLOCATE (fint_ss(ns)%r_coef)
454 DEALLOCATE (fint_hh(ns)%r_coef)
455 END DO
456 DEALLOCATE (fint_ss, fint_hh)
457
458 END DO ! iat
459
460 ! Release the xc structure used to store the xc derivatives
461 CALL xc_dset_release(deriv_set)
462 CALL xc_rho_set_release(rho_set_h)
463 CALL xc_rho_set_release(rho_set_s)
464
465 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
466 DEALLOCATE (vxc_h, vxc_s)
467 IF (gradient_f) THEN
468 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
469 DEALLOCATE (vxg_h, vxg_s)
470 END IF
471 IF (tau_f) THEN
472 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
473 DEALLOCATE (vtau_h, vtau_s)
474 CALL release_tau_basis_cache(tau_basis_cache)
475 END IF
476 END DO ! ikind
477
478 END IF !xc_none
479
480 CALL timestop(handle)
481
482 END SUBROUTINE fgxc_atom_calc
483
484! **************************************************************************************************
485!> \brief ...
486!> \param qs_env ...
487!> \param rho0_atom_set ...
488!> \param rho1_atom_set ...
489!> \param rho2_atom_set ...
490!> \param kind_set ...
491!> \param xc_section ...
492!> \param is_triplet ...
493!> \param accuracy ...
494!> \param epsrho ...
495! **************************************************************************************************
496 SUBROUTINE fgxc_atom_diff(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, &
497 kind_set, xc_section, is_triplet, accuracy, epsrho)
498
499 TYPE(qs_environment_type), POINTER :: qs_env
500 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set, rho1_atom_set, &
501 rho2_atom_set
502 TYPE(qs_kind_type), DIMENSION(:), POINTER :: kind_set
503 TYPE(section_vals_type), OPTIONAL, POINTER :: xc_section
504 LOGICAL, INTENT(IN) :: is_triplet
505 INTEGER, INTENT(IN) :: accuracy
506 REAL(kind=dp), INTENT(IN) :: epsrho
507
508 CHARACTER(LEN=*), PARAMETER :: routinen = 'fgxc_atom_diff'
509
510 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
511 istep, mspins, myfun, na, natom, nf, &
512 nr, ns, nspins, nstep, num_pe
513 INTEGER, DIMENSION(2, 3) :: bounds
514 INTEGER, DIMENSION(:), POINTER :: atom_list
515 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
516 paw_atom, tau_f
517 REAL(dp) :: agr, alpha, beta, density_cut, &
518 gradient_cut, oeps1, tau_cut
519 REAL(dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: vtau_h, vtau_s, vxc_h, vxc_s
520 REAL(dp), DIMENSION(1, 1, 1) :: tau_d
521 REAL(dp), DIMENSION(1, 1, 1, 1) :: rho_d
522 REAL(dp), DIMENSION(:, :), POINTER :: rho_nlcc, weight_h, weight_s
523 REAL(dp), DIMENSION(:, :, :), POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
524 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
525 tau_h, tau_s
526 REAL(dp), DIMENSION(:, :, :, :), POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
527 drho_h, drho_s, vxg_h, vxg_s
528 REAL(kind=dp), DIMENSION(-4:4) :: ak
529 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
530 TYPE(dft_control_type), POINTER :: dft_control
531 TYPE(grid_atom_type), POINTER :: grid_atom
532 TYPE(gto_basis_set_type), POINTER :: basis_1c
533 TYPE(harmonics_atom_type), POINTER :: harmonics
534 TYPE(mp_para_env_type), POINTER :: para_env
535 TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
536 int_ss, r_h, r_s
537 TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: r_h_d, r_s_d
538 TYPE(rho_atom_type), POINTER :: rho0_atom, rho1_atom, rho2_atom
539 TYPE(section_vals_type), POINTER :: xc_fun_section
540 TYPE(tau_basis_cache_type) :: tau_basis_cache
541 TYPE(xc_derivative_set_type) :: deriv_set
542 TYPE(xc_rho_cflags_type) :: needs
543 TYPE(xc_rho_set_type) :: rho1_set_h, rho1_set_s, rho_set_h, &
544 rho_set_s
545
546 CALL timeset(routinen, handle)
547
548 NULLIFY (vtau_h, vtau_s)
549
550 ak = 0.0_dp
551 SELECT CASE (accuracy)
552 CASE (:4)
553 nstep = 2
554 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
555 CASE (5:7)
556 nstep = 3
557 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
558 CASE (8:)
559 nstep = 4
560 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
561 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
562 END SELECT
563 oeps1 = 1.0_dp/epsrho
564
565 CALL get_qs_env(qs_env=qs_env, &
566 dft_control=dft_control, &
567 para_env=para_env, &
568 atomic_kind_set=atomic_kind_set)
569
570 xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
571 CALL section_vals_val_get(xc_fun_section, "_SECTION_PARAMETERS_", i_val=myfun)
572
573 accint = dft_control%qs_control%gapw_control%accurate_xcint
574
575 IF (myfun == xc_none) THEN
576 ! no action needed?
577 ELSE
578 ! calculate fxc
579 CALL fxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, xc_section, para_env, &
580 do_triplet=is_triplet, kind_set_external=kind_set)
581
582 CALL section_vals_val_get(xc_section, "DENSITY_CUTOFF", r_val=density_cut)
583 CALL section_vals_val_get(xc_section, "GRADIENT_CUTOFF", r_val=gradient_cut)
584 CALL section_vals_val_get(xc_section, "TAU_CUTOFF", r_val=tau_cut)
585
586 nlcc = has_nlcc(kind_set)
587 lsd = dft_control%lsd
588 nspins = dft_control%nspins
589 mspins = nspins
590 IF (is_triplet) THEN
591 cpassert(nspins == 1)
592 lsd = .true.
593 mspins = 2
594 END IF
595 needs = xc_functionals_get_needs(xc_fun_section, lsd=lsd, calc_potential=.true.)
596 gradient_f = (needs%drho .OR. needs%drho_spin)
597 tau_f = (needs%tau .OR. needs%tau_spin)
598
599 ! Here starts the loop over all the atoms
600 DO ikind = 1, SIZE(atomic_kind_set)
601 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
602 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
603 harmonics=harmonics, grid_atom=grid_atom)
604 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type="GAPW_1C")
605
606 IF (.NOT. paw_atom) cycle
607
608 nr = grid_atom%nr
609 na = grid_atom%ng_sphere
610
611 ! set integration weights
612 IF (accint) THEN
613 weight_h => grid_atom%weight
614 alpha = dft_control%qs_control%gapw_control%aw(ikind)
615 IF (ASSOCIATED(grid_atom%gapw_weight_s)) THEN
616 IF (grid_atom%gapw_weight_alpha /= alpha) DEALLOCATE (grid_atom%gapw_weight_s)
617 END IF
618 IF (.NOT. ASSOCIATED(grid_atom%gapw_weight_s)) THEN
619 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
620 DO ir = 1, nr
621 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
622 grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
623 END DO
624 grid_atom%gapw_weight_alpha = alpha
625 END IF
626 weight_s => grid_atom%gapw_weight_s
627 ELSE
628 weight_h => grid_atom%weight
629 weight_s => grid_atom%weight
630 END IF
631
632 ! Prepare the structures needed to calculate and store the xc derivatives
633
634 ! Array dimension: here anly one dimensional arrays are used,
635 ! i.e. only the first column of deriv_data is read.
636 ! The other two dimensions are set to size equal 1
637 bounds(1:2, 1:3) = 1
638 bounds(2, 1) = na
639 bounds(2, 2) = nr
640
641 ! create a place where to put the derivatives
642 CALL xc_dset_create(deriv_set, local_bounds=bounds)
643 ! create the place where to store the argument for the functionals
644 CALL xc_rho_set_create(rho_set_h, bounds, rho_cutoff=density_cut, &
645 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
646 CALL xc_rho_set_create(rho_set_s, bounds, rho_cutoff=density_cut, &
647 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
648 CALL xc_rho_set_create(rho1_set_h, bounds, rho_cutoff=density_cut, &
649 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
650 CALL xc_rho_set_create(rho1_set_s, bounds, rho_cutoff=density_cut, &
651 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
652
653 ! allocate the required 3d arrays where to store rho and drho
654 CALL xc_rho_set_atom_update(rho_set_h, needs, mspins, bounds)
655 CALL xc_rho_set_atom_update(rho_set_s, needs, mspins, bounds)
656 CALL xc_rho_set_atom_update(rho1_set_h, needs, mspins, bounds)
657 CALL xc_rho_set_atom_update(rho1_set_s, needs, mspins, bounds)
658
659 ALLOCATE (rho_h(na, nr, nspins), rho_s(na, nr, nspins), &
660 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
661 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
662 ALLOCATE (vxc_h(na, nr, nspins), vxc_s(na, nr, nspins))
663 IF (gradient_f) THEN
664 ALLOCATE (drho_h(4, na, nr, nspins), drho_s(4, na, nr, nspins), &
665 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
666 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
667 ALLOCATE (vxg_h(3, na, nr, nspins), vxg_s(3, na, nr, nspins))
668 END IF
669 IF (tau_f) THEN
670 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
671 ALLOCATE (tau_h(na, nr, nspins), tau_s(na, nr, nspins), &
672 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
673 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
674 ALLOCATE (vtau_h(na, nr, nspins), vtau_s(na, nr, nspins))
675 END IF
676 !
677 ! NLCC: prepare rho and drho of the core charge for this KIND
678 donlcc = .false.
679 IF (nlcc) THEN
680 NULLIFY (rho_nlcc)
681 rho_nlcc => kind_set(ikind)%nlcc_pot
682 IF (ASSOCIATED(rho_nlcc)) donlcc = .true.
683 END IF
684
685 ! Distribute the atoms of this kind
686 num_pe = para_env%num_pe
687 bo = get_limit(natom, num_pe, para_env%mepos)
688
689 DO iat = bo(1), bo(2)
690 iatom = atom_list(iat)
691 !
692 NULLIFY (int_hh, int_ss)
693 rho0_atom => rho0_atom_set(iatom)
694 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
695 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
696 DO ns = 1, nspins
697 nf = SIZE(int_ss(ns)%r_coef, 1)
698 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
699 nf = SIZE(int_hh(ns)%r_coef, 1)
700 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
701 END DO
702
703 ! RHO0
704 rho0_h = 0.0_dp
705 rho0_s = 0.0_dp
706 rho0_atom => rho0_atom_set(iatom)
707 IF (gradient_f) THEN
708 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
709 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
710 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
711 drho0_h = 0.0_dp
712 drho0_s = 0.0_dp
713 ELSE
714 NULLIFY (r_h, r_s)
715 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
716 rho_d = 0.0_dp
717 END IF
718 DO ir = 1, nr
719 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
720 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
721 r_h_d, r_s_d, drho0_h, drho0_s)
722 IF (donlcc) THEN
723 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
724 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
725 END IF
726 END DO
727 IF (tau_f) THEN
728 !compute tau on the grid all at once
729 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, tau_basis_cache, nspins)
730 ELSE
731 tau_d = 0.0_dp
732 END IF
733 ! RHO1
734 rho1_h = 0.0_dp
735 rho1_s = 0.0_dp
736 rho1_atom => rho1_atom_set(iatom)
737 IF (gradient_f) THEN
738 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
739 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
740 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
741 drho1_h = 0.0_dp
742 drho1_s = 0.0_dp
743 ELSE
744 NULLIFY (r_h, r_s)
745 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
746 END IF
747 DO ir = 1, nr
748 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
749 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
750 r_h_d, r_s_d, drho1_h, drho1_s)
751 END DO
752 IF (tau_f) THEN
753 !compute tau on the grid all at once
754 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
755 END IF
756
757 DO ir = 1, nr
758 IF (tau_f) THEN
759 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
760 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
761 ELSE IF (gradient_f) THEN
762 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau_d, na, ir)
763 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau_d, na, ir)
764 ELSE
765 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rho_d, tau_d, na, ir)
766 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rho_d, tau_d, na, ir)
767 END IF
768 END DO
769
770 ! RHO2
771 rho2_atom => rho2_atom_set(iatom)
772
773 DO istep = -nstep, nstep
774
775 beta = real(istep, kind=dp)*epsrho
776
777 rho_h = rho0_h + beta*rho1_h
778 rho_s = rho0_s + beta*rho1_s
779 IF (gradient_f) THEN
780 drho_h = drho0_h + beta*drho1_h
781 drho_s = drho0_s + beta*drho1_s
782 END IF
783 IF (tau_f) THEN
784 tau_h = tau0_h + beta*tau1_h
785 tau_s = tau0_s + beta*tau1_s
786 END IF
787 !
788 IF (gradient_f) THEN
789 drho_h(4, :, :, :) = norm2(drho_h(1:3, :, :, :), 1)
790 drho_s(4, :, :, :) = norm2(drho_s(1:3, :, :, :), 1)
791 END IF
792
793 DO ir = 1, nr
794 IF (tau_f) THEN
795 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
796 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
797 ELSE IF (gradient_f) THEN
798 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
799 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
800 ELSE
801 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
802 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
803 END IF
804 END DO
805
806 ! hard atom density !
807 CALL xc_dset_zero_all(deriv_set)
808 CALL xc_2nd_deriv_of_r(xc_section=xc_section, &
809 rho_set=rho_set_h, rho1_set=rho1_set_h, &
810 deriv_set=deriv_set, &
811 w=weight_h, vxc=vxc_h, vxg=vxg_h, vtau=vtau_h, &
812 do_triplet=is_triplet)
813 ! soft atom density !
814 CALL xc_dset_zero_all(deriv_set)
815 CALL xc_2nd_deriv_of_r(xc_section=xc_section, &
816 rho_set=rho_set_s, rho1_set=rho1_set_s, &
817 deriv_set=deriv_set, &
818 w=weight_s, vxc=vxc_s, vxg=vxg_s, vtau=vtau_s, &
819 do_triplet=is_triplet)
820 ! potentials
821 DO ns = 1, nspins
822 fint_hh(ns)%r_coef(:, :) = 0.0_dp
823 fint_ss(ns)%r_coef(:, :) = 0.0_dp
824 END DO
825 IF (gradient_f) THEN
826 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
827 grid_atom, basis_1c, harmonics, nspins)
828 ELSE
829 CALL gavxcgb_nogc(vxc_h, vxc_s, fint_hh, fint_ss, &
830 grid_atom, basis_1c, harmonics, nspins)
831 END IF
832 IF (tau_f) THEN
833 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
834 tau_basis_cache, nspins)
835 END IF
836 ! second derivative gxc
837 NULLIFY (int_hh, int_ss)
838 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
839 DO ns = 1, nspins
840 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
841 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
842 END DO
843 END DO
844 !
845 DO ns = 1, nspins
846 DEALLOCATE (fint_ss(ns)%r_coef)
847 DEALLOCATE (fint_hh(ns)%r_coef)
848 END DO
849 DEALLOCATE (fint_ss, fint_hh)
850
851 END DO ! iat
852
853 ! Release the xc structure used to store the xc derivatives
854 CALL xc_dset_release(deriv_set)
855 CALL xc_rho_set_release(rho_set_h)
856 CALL xc_rho_set_release(rho_set_s)
857 CALL xc_rho_set_release(rho1_set_h)
858 CALL xc_rho_set_release(rho1_set_s)
859
860 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
861 DEALLOCATE (vxc_h, vxc_s)
862 IF (gradient_f) THEN
863 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
864 DEALLOCATE (vxg_h, vxg_s)
865 END IF
866 IF (tau_f) THEN
867 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
868 DEALLOCATE (vtau_h, vtau_s)
869 CALL release_tau_basis_cache(tau_basis_cache)
870 END IF
871 END DO ! ikind
872
873 END IF !xc_none
874
875 CALL timestop(handle)
876
877 END SUBROUTINE fgxc_atom_diff
878
879END MODULE qs_fgxc_atom
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public xc_none
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_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
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
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)
...
routines that build the integrals of the Fxc kernel calculated for the atomic density in the basis se...
Definition qs_fxc_atom.F:12
subroutine, public fxc_atom_calc(qs_env, rho_atom_set, rho1_atom_set, xc_section, para_env_ext, do_scale, do_triplet, do_sf, kind_set_external)
...
Definition qs_fxc_atom.F:75
Define the quickstep kind type and their sub types.
logical function, public has_nlcc(qs_kind_set)
finds if a given qs run needs to use nlcc
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_rho_atom(rho_atom, cpc_h, cpc_s, rho_rad_h, rho_rad_s, drho_rad_h, drho_rad_s, vrho_rad_h, vrho_rad_s, rho_rad_h_d, rho_rad_s_d, ga_vlocal_gb_h, ga_vlocal_gb_s, int_scr_h, int_scr_s)
...
Support routines for integrals of the Vxc/Fxc/Gxc potentials calculated for the atomic density in the...
subroutine, public calc_rho_angular(grid_atom, harmonics, nspins, grad_func, ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, r_h_d, r_s_d, drho_h, drho_s)
...
subroutine, public release_tau_basis_cache(tau_cache)
Release precomputed GAPW meta-GGA tau factors.
subroutine, public create_tau_basis_cache(tau_cache, grid_atom, basis_1c, harmonics)
Precompute radial and angular factors for GAPW meta-GGA tau contractions.
subroutine, public gavxcgb_nogc(vxc_h, vxc_s, int_hh, int_ss, grid_atom, basis_1c, harmonics, nspins)
...
subroutine, public gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, grid_atom, basis_1c, harmonics, nspins)
...
subroutine, public calc_rho_nlcc(grid_atom, nspins, grad_func, ir, rho_nlcc, rho_h, rho_s, drho_nlcc, drho_h, drho_s)
...
subroutine, public dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, tau_cache, nspins)
Integrates 0.5 * grad_ga .dot. (V_tau * grad_gb) on the atomic grid for meta-GGA.
subroutine, public calc_tau_atom(tau_h, tau_s, rho_atom, tau_cache, nspins)
Computes tau hard and soft on the atomic grids for meta-GGA calculations.
All kind of helpful little routines.
Definition util.F:14
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me
Definition util.F:333
subroutine, public vxc_of_r_new(xc_fun_section, rho_set, deriv_set, deriv_order, needs, w, lsd, na, nr, exc, vxc, vxg, vtau, energy_only, adiabatic_rescale_factor)
...
Definition xc_atom.F:64
subroutine, public xc_rho_set_atom_update(rho_set, needs, nspins, bo)
...
Definition xc_atom.F:523
subroutine, public xc_2nd_deriv_of_r(rho_set, rho1_set, xc_section, deriv_set, w, vxc, vxg, vtau, do_triplet, do_sf)
...
Definition xc_atom.F:419
subroutine, public fill_rho_set(rho_set, lsd, nspins, needs, rho, drho, tau, na, ir)
...
Definition xc_atom.F:683
represent a group ofunctional derivatives
subroutine, public xc_dset_zero_all(deriv_set)
...
subroutine, public xc_dset_release(derivative_set)
releases a derivative set
subroutine, public xc_dset_create(derivative_set, pw_pool, local_bounds)
creates a derivative set object
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
Provides all information about an atomic kind.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
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