(git:6344619)
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: &
38 USE util, ONLY: get_limit
39 USE xc_atom, ONLY: fill_rho_set,&
52#include "./base/base_uses.f90"
53
54 IMPLICIT NONE
55
56 PRIVATE
57
58 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_fgxc_atom'
59
60 PUBLIC :: fgxc_atom_calc, &
62
63! **************************************************************************************************
64
65CONTAINS
66
67! **************************************************************************************************
68!> \brief ...
69!> \param qs_env ...
70!> \param rho0_atom_set ...
71!> \param rho1_atom_set ...
72!> \param rho2_atom_set ...
73!> \param kind_set ...
74!> \param xc_section ...
75!> \param is_triplet ...
76!> \param accuracy ...
77! **************************************************************************************************
78 SUBROUTINE fgxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, &
79 kind_set, xc_section, is_triplet, accuracy)
80
81 TYPE(qs_environment_type), POINTER :: qs_env
82 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set, rho1_atom_set, &
83 rho2_atom_set
84 TYPE(qs_kind_type), DIMENSION(:), POINTER :: kind_set
85 TYPE(section_vals_type), OPTIONAL, POINTER :: xc_section
86 LOGICAL, INTENT(IN) :: is_triplet
87 INTEGER, INTENT(IN) :: accuracy
88
89 CHARACTER(LEN=*), PARAMETER :: routinen = 'fgxc_atom_calc'
90 REAL(kind=dp), PARAMETER :: epsrho = 5.e-4_dp
91
92 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
93 istep, mspins, myfun, na, natom, nf, &
94 nr, ns, nspins, nstep, num_pe, on
95 INTEGER, DIMENSION(2, 3) :: bounds
96 INTEGER, DIMENSION(:), POINTER :: atom_list
97 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
98 paw_atom, tau_f
99 REAL(dp) :: agr, alpha, beta, density_cut, exc_h, &
100 exc_s, gradient_cut, oeps1, oeps2, &
101 tau_cut
102 REAL(dp), ALLOCATABLE, DIMENSION(:) :: fw
103 REAL(dp), DIMENSION(1, 1, 1) :: tau_d
104 REAL(dp), DIMENSION(1, 1, 1, 1) :: rho_d
105 REAL(dp), DIMENSION(:, :), POINTER :: rho_nlcc, weight_h, weight_s
106 REAL(dp), DIMENSION(:, :, :), POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
107 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
108 tau_h, tau_s, vtau_h, vtau_s, vxc_h, &
109 vxc_s
110 REAL(dp), DIMENSION(:, :, :, :), POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
111 drho_h, drho_s, vxg_h, vxg_s
112 REAL(kind=dp), DIMENSION(-4:4) :: ak, bl
113 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
114 TYPE(dft_control_type), POINTER :: dft_control
115 TYPE(grid_atom_type), POINTER :: grid_atom
116 TYPE(gto_basis_set_type), POINTER :: basis_1c
117 TYPE(harmonics_atom_type), POINTER :: harmonics
118 TYPE(mp_para_env_type), POINTER :: para_env
119 TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
120 int_ss, r_h, r_s
121 TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: r_h_d, r_s_d
122 TYPE(rho_atom_type), POINTER :: rho0_atom, rho1_atom, rho2_atom
123 TYPE(section_vals_type), POINTER :: xc_fun_section
124 TYPE(tau_basis_cache_type) :: tau_basis_cache
125 TYPE(xc_derivative_set_type) :: deriv_set
126 TYPE(xc_rho_cflags_type) :: needs
127 TYPE(xc_rho_set_type) :: rho_set_h, rho_set_s
128
129 CALL timeset(routinen, handle)
130
131 NULLIFY (vtau_h, vtau_s)
132
133 ak = 0.0_dp
134 bl = 0.0_dp
135 SELECT CASE (accuracy)
136 CASE (:4)
137 nstep = 2
138 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
139 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
140 CASE (5:7)
141 nstep = 3
142 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
143 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
144 CASE (8:)
145 nstep = 4
146 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
147 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
148 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
149 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
150 END SELECT
151 oeps1 = 1.0_dp/epsrho
152 oeps2 = 1.0_dp/(epsrho**2)
153
154 CALL get_qs_env(qs_env=qs_env, &
155 dft_control=dft_control, &
156 para_env=para_env, &
157 atomic_kind_set=atomic_kind_set)
158
159 xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
160 CALL section_vals_val_get(xc_fun_section, "_SECTION_PARAMETERS_", i_val=myfun)
161
162 accint = dft_control%qs_control%gapw_control%accurate_xcint
163
164 IF (myfun == xc_none) THEN
165 ! no action needed?
166 ELSE
167 CALL section_vals_val_get(xc_section, "DENSITY_CUTOFF", r_val=density_cut)
168 CALL section_vals_val_get(xc_section, "GRADIENT_CUTOFF", r_val=gradient_cut)
169 CALL section_vals_val_get(xc_section, "TAU_CUTOFF", r_val=tau_cut)
170
171 nlcc = has_nlcc(kind_set)
172 lsd = dft_control%lsd
173 nspins = dft_control%nspins
174 mspins = nspins
175 IF (is_triplet) THEN
176 cpassert(nspins == 1)
177 lsd = .true.
178 mspins = 2
179 END IF
180 needs = xc_functionals_get_needs(xc_fun_section, lsd=lsd, calc_potential=.true.)
181 gradient_f = (needs%drho .OR. needs%drho_spin)
182 tau_f = (needs%tau .OR. needs%tau_spin)
183
184 ! Here starts the loop over all the atoms
185 DO ikind = 1, SIZE(atomic_kind_set)
186 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
187 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
188 harmonics=harmonics, grid_atom=grid_atom)
189 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type="GAPW_1C")
190
191 IF (.NOT. paw_atom) cycle
192
193 nr = grid_atom%nr
194 na = grid_atom%ng_sphere
195
196 ! set integration weights
197 weight_h => grid_atom%weight
198 weight_s => grid_atom%weight
199 IF (accint) THEN
200 on = dft_control%qs_control%gapw_control%oweights
201 alpha = dft_control%qs_control%gapw_control%aw(ikind)
202 IF (ASSOCIATED(grid_atom%gapw_weight_s)) THEN
203 IF (grid_atom%gapw_weight_alpha /= alpha) DEALLOCATE (grid_atom%gapw_weight_s)
204 END IF
205 IF (.NOT. ASSOCIATED(grid_atom%gapw_weight_s)) THEN
206 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
207 ALLOCATE (fw(nr))
208 CALL calc_weight_function(fw, grid_atom%rad2, on, alpha)
209 DO ir = 1, nr
210 agr = 1.0_dp - fw(ir)
211 grid_atom%gapw_weight_s(:, ir) = agr*grid_atom%weight(:, ir)
212 END DO
213 DEALLOCATE (fw)
214 grid_atom%gapw_weight_alpha = alpha
215 END IF
216 weight_s => grid_atom%gapw_weight_s
217 END IF
218
219 ! Prepare the structures needed to calculate and store the xc derivatives
220
221 ! Array dimension: here only one dimensional arrays are used,
222 ! i.e. only the first column of deriv_data is read.
223 ! The other to dimensions are set to size equal 1
224 bounds(1:2, 1:3) = 1
225 bounds(2, 1) = na
226 bounds(2, 2) = nr
227
228 ! create a place where to put the derivatives
229 CALL xc_dset_create(deriv_set, local_bounds=bounds)
230 ! create the place where to store the argument for the functionals
231 CALL xc_rho_set_create(rho_set_h, bounds, rho_cutoff=density_cut, &
232 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
233 CALL xc_rho_set_create(rho_set_s, bounds, rho_cutoff=density_cut, &
234 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
235
236 ! allocate the required 3d arrays where to store rho and drho
237 CALL xc_rho_set_atom_update(rho_set_h, needs, mspins, bounds)
238 CALL xc_rho_set_atom_update(rho_set_s, needs, mspins, bounds)
239
240 ALLOCATE (rho_h(na, nr, mspins), rho_s(na, nr, mspins), &
241 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
242 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
243 ALLOCATE (vxc_h(na, nr, mspins), vxc_s(na, nr, mspins))
244 IF (gradient_f) THEN
245 ALLOCATE (drho_h(4, na, nr, mspins), drho_s(4, na, nr, mspins), &
246 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
247 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
248 ALLOCATE (vxg_h(3, na, nr, mspins), vxg_s(3, na, nr, mspins))
249 END IF
250 IF (tau_f) THEN
251 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
252 ALLOCATE (tau_h(na, nr, mspins), tau_s(na, nr, mspins), &
253 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
254 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
255 ALLOCATE (vtau_h(na, nr, mspins), vtau_s(na, nr, mspins))
256 END IF
257 !
258 ! NLCC: prepare rho and drho of the core charge for this KIND
259 donlcc = .false.
260 IF (nlcc) THEN
261 NULLIFY (rho_nlcc)
262 rho_nlcc => kind_set(ikind)%nlcc_pot
263 IF (ASSOCIATED(rho_nlcc)) donlcc = .true.
264 END IF
265
266 ! Distribute the atoms of this kind
267 num_pe = para_env%num_pe
268 bo = get_limit(natom, num_pe, para_env%mepos)
269
270 DO iat = bo(1), bo(2)
271 iatom = atom_list(iat)
272 !
273 NULLIFY (int_hh, int_ss)
274 rho0_atom => rho0_atom_set(iatom)
275 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
276 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
277 DO ns = 1, nspins
278 nf = SIZE(int_ss(ns)%r_coef, 1)
279 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
280 nf = SIZE(int_hh(ns)%r_coef, 1)
281 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
282 END DO
283
284 ! RHO0
285 rho0_h = 0.0_dp
286 rho0_s = 0.0_dp
287 rho0_atom => rho0_atom_set(iatom)
288 IF (gradient_f) THEN
289 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
290 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
291 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
292 drho0_h = 0.0_dp
293 drho0_s = 0.0_dp
294 ELSE
295 NULLIFY (r_h, r_s)
296 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
297 rho_d = 0.0_dp
298 END IF
299 DO ir = 1, nr
300 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
301 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
302 r_h_d, r_s_d, drho0_h, drho0_s)
303 IF (donlcc) THEN
304 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
305 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
306 END IF
307 END DO
308 IF (tau_f) THEN
309 !compute tau on the grid all at once
310 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, tau_basis_cache, nspins)
311 ELSE
312 tau_d = 0.0_dp
313 END IF
314 ! RHO1
315 rho1_h = 0.0_dp
316 rho1_s = 0.0_dp
317 rho1_atom => rho1_atom_set(iatom)
318 IF (gradient_f) THEN
319 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
320 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
321 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
322 drho1_h = 0.0_dp
323 drho1_s = 0.0_dp
324 ELSE
325 NULLIFY (r_h, r_s)
326 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
327 END IF
328 DO ir = 1, nr
329 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
330 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
331 r_h_d, r_s_d, drho1_h, drho1_s)
332 END DO
333 IF (tau_f) THEN
334 !compute tau on the grid all at once
335 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
336 END IF
337 ! RHO2
338 rho2_atom => rho2_atom_set(iatom)
339
340 DO istep = -nstep, nstep
341
342 beta = real(istep, kind=dp)*epsrho
343
344 IF (is_triplet) THEN
345 rho_h(:, :, 1) = rho0_h(:, :, 1) + beta*rho1_h(:, :, 1)
346 rho_h(:, :, 2) = rho0_h(:, :, 1)
347 rho_h = 0.5_dp*rho_h
348 rho_s(:, :, 1) = rho0_s(:, :, 1) + beta*rho1_s(:, :, 1)
349 rho_s(:, :, 2) = rho0_s(:, :, 1)
350 rho_s = 0.5_dp*rho_s
351 IF (gradient_f) THEN
352 drho_h(:, :, :, 1) = drho0_h(:, :, :, 1) + beta*drho1_h(:, :, :, 1)
353 drho_h(:, :, :, 2) = drho0_h(:, :, :, 1)
354 drho_h = 0.5_dp*drho_h
355 drho_s(:, :, :, 1) = drho0_s(:, :, :, 1) + beta*drho1_s(:, :, :, 1)
356 drho_s(:, :, :, 2) = drho0_s(:, :, :, 1)
357 drho_s = 0.5_dp*drho_s
358 END IF
359 IF (tau_f) THEN
360 tau_h(:, :, 1) = tau0_h(:, :, 1) + beta*tau1_h(:, :, 1)
361 tau_h(:, :, 2) = tau0_h(:, :, 1)
362 tau_h = 0.5_dp*tau0_h
363 tau_s(:, :, 1) = tau0_s(:, :, 1) + beta*tau1_s(:, :, 1)
364 tau_s(:, :, 2) = tau0_s(:, :, 1)
365 tau_s = 0.5_dp*tau0_s
366 END IF
367 ELSE
368 rho_h = rho0_h + beta*rho1_h
369 rho_s = rho0_s + beta*rho1_s
370 IF (gradient_f) THEN
371 drho_h = drho0_h + beta*drho1_h
372 drho_s = drho0_s + beta*drho1_s
373 END IF
374 IF (tau_f) THEN
375 tau_h = tau0_h + beta*tau1_h
376 tau_s = tau0_s + beta*tau1_s
377 END IF
378 END IF
379 !
380 IF (gradient_f) THEN
381 drho_h(4, :, :, :) = norm2(drho_h(1:3, :, :, :), 1)
382 drho_s(4, :, :, :) = norm2(drho_s(1:3, :, :, :), 1)
383 END IF
384
385 DO ir = 1, nr
386 IF (tau_f) THEN
387 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_h, na, ir)
388 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_s, na, ir)
389 ELSE IF (gradient_f) THEN
390 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_d, na, ir)
391 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_d, na, ir)
392 ELSE
393 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, rho_d, tau_d, na, ir)
394 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, rho_d, tau_d, na, ir)
395 END IF
396 END DO
397
398 ! hard atom density !
399 CALL xc_dset_zero_all(deriv_set)
400 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight_h, &
401 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
402 IF (is_triplet) THEN
403 vxc_h(:, :, 1) = vxc_h(:, :, 1) - vxc_h(:, :, 2)
404 IF (gradient_f) THEN
405 vxg_h(:, :, :, 1) = vxg_h(:, :, :, 1) - vxg_h(:, :, :, 2)
406 END IF
407 IF (tau_f) THEN
408 vtau_h(:, :, 1) = vtau_h(:, :, 1) - vtau_h(:, :, 2)
409 END IF
410 END IF
411 ! soft atom density !
412 CALL xc_dset_zero_all(deriv_set)
413 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight_s, &
414 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
415 IF (is_triplet) THEN
416 vxc_s(:, :, 1) = vxc_s(:, :, 1) - vxc_s(:, :, 2)
417 IF (gradient_f) THEN
418 vxg_s(:, :, :, 1) = vxg_s(:, :, :, 1) - vxg_s(:, :, :, 2)
419 END IF
420 IF (tau_f) THEN
421 vtau_s(:, :, 1) = vtau_s(:, :, 1) - vtau_s(:, :, 2)
422 END IF
423 END IF
424 ! potentials
425 DO ns = 1, nspins
426 fint_hh(ns)%r_coef(:, :) = 0.0_dp
427 fint_ss(ns)%r_coef(:, :) = 0.0_dp
428 END DO
429 IF (gradient_f) THEN
430 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
431 grid_atom, basis_1c, harmonics, nspins)
432 ELSE
433 CALL gavxcgb_nogc(vxc_h, vxc_s, fint_hh, fint_ss, &
434 grid_atom, basis_1c, harmonics, nspins)
435 END IF
436 IF (tau_f) THEN
437 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
438 tau_basis_cache, nspins)
439 END IF
440 ! first derivative fxc
441 NULLIFY (int_hh, int_ss)
442 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
443 DO ns = 1, nspins
444 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
445 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
446 END DO
447 ! second derivative gxc
448 NULLIFY (int_hh, int_ss)
449 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
450 DO ns = 1, nspins
451 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_ss(ns)%r_coef(:, :)
452 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_hh(ns)%r_coef(:, :)
453 END DO
454 END DO
455 !
456 DO ns = 1, nspins
457 DEALLOCATE (fint_ss(ns)%r_coef)
458 DEALLOCATE (fint_hh(ns)%r_coef)
459 END DO
460 DEALLOCATE (fint_ss, fint_hh)
461
462 END DO ! iat
463
464 ! Release the xc structure used to store the xc derivatives
465 CALL xc_dset_release(deriv_set)
466 CALL xc_rho_set_release(rho_set_h)
467 CALL xc_rho_set_release(rho_set_s)
468
469 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
470 DEALLOCATE (vxc_h, vxc_s)
471 IF (gradient_f) THEN
472 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
473 DEALLOCATE (vxg_h, vxg_s)
474 END IF
475 IF (tau_f) THEN
476 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
477 DEALLOCATE (vtau_h, vtau_s)
478 CALL release_tau_basis_cache(tau_basis_cache)
479 END IF
480 END DO ! ikind
481
482 END IF !xc_none
483
484 CALL timestop(handle)
485
486 END SUBROUTINE fgxc_atom_calc
487
488! **************************************************************************************************
489!> \brief ...
490!> \param qs_env ...
491!> \param rho0_atom_set ...
492!> \param rho1_atom_set ...
493!> \param rho2_atom_set ...
494!> \param kind_set ...
495!> \param xc_section ...
496!> \param is_triplet ...
497!> \param accuracy ...
498!> \param epsrho ...
499! **************************************************************************************************
500 SUBROUTINE fgxc_atom_diff(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, &
501 kind_set, xc_section, is_triplet, accuracy, epsrho)
502
503 TYPE(qs_environment_type), POINTER :: qs_env
504 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho0_atom_set, rho1_atom_set, &
505 rho2_atom_set
506 TYPE(qs_kind_type), DIMENSION(:), POINTER :: kind_set
507 TYPE(section_vals_type), OPTIONAL, POINTER :: xc_section
508 LOGICAL, INTENT(IN) :: is_triplet
509 INTEGER, INTENT(IN) :: accuracy
510 REAL(kind=dp), INTENT(IN) :: epsrho
511
512 CHARACTER(LEN=*), PARAMETER :: routinen = 'fgxc_atom_diff'
513
514 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
515 istep, mspins, myfun, na, natom, nf, &
516 nr, ns, nspins, nstep, num_pe, on
517 INTEGER, DIMENSION(2, 3) :: bounds
518 INTEGER, DIMENSION(:), POINTER :: atom_list
519 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
520 paw_atom, tau_f
521 REAL(dp) :: agr, alpha, beta, density_cut, &
522 gradient_cut, oeps1, tau_cut
523 REAL(dp), ALLOCATABLE, DIMENSION(:) :: fw
524 REAL(dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: vtau_h, vtau_s, vxc_h, vxc_s
525 REAL(dp), DIMENSION(1, 1, 1) :: tau_d
526 REAL(dp), DIMENSION(1, 1, 1, 1) :: rho_d
527 REAL(dp), DIMENSION(:, :), POINTER :: rho_nlcc, weight_h, weight_s
528 REAL(dp), DIMENSION(:, :, :), POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
529 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
530 tau_h, tau_s
531 REAL(dp), DIMENSION(:, :, :, :), POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
532 drho_h, drho_s, vxg_h, vxg_s
533 REAL(kind=dp), DIMENSION(-4:4) :: ak
534 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
535 TYPE(dft_control_type), POINTER :: dft_control
536 TYPE(grid_atom_type), POINTER :: grid_atom
537 TYPE(gto_basis_set_type), POINTER :: basis_1c
538 TYPE(harmonics_atom_type), POINTER :: harmonics
539 TYPE(mp_para_env_type), POINTER :: para_env
540 TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
541 int_ss, r_h, r_s
542 TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: r_h_d, r_s_d
543 TYPE(rho_atom_type), POINTER :: rho0_atom, rho1_atom, rho2_atom
544 TYPE(section_vals_type), POINTER :: xc_fun_section
545 TYPE(tau_basis_cache_type) :: tau_basis_cache
546 TYPE(xc_derivative_set_type) :: deriv_set
547 TYPE(xc_rho_cflags_type) :: needs
548 TYPE(xc_rho_set_type) :: rho1_set_h, rho1_set_s, rho_set_h, &
549 rho_set_s
550
551 CALL timeset(routinen, handle)
552
553 NULLIFY (vtau_h, vtau_s)
554
555 ak = 0.0_dp
556 SELECT CASE (accuracy)
557 CASE (:4)
558 nstep = 2
559 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
560 CASE (5:7)
561 nstep = 3
562 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
563 CASE (8:)
564 nstep = 4
565 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
566 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
567 END SELECT
568 oeps1 = 1.0_dp/epsrho
569
570 CALL get_qs_env(qs_env=qs_env, &
571 dft_control=dft_control, &
572 para_env=para_env, &
573 atomic_kind_set=atomic_kind_set)
574
575 xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
576 CALL section_vals_val_get(xc_fun_section, "_SECTION_PARAMETERS_", i_val=myfun)
577
578 accint = dft_control%qs_control%gapw_control%accurate_xcint
579
580 IF (myfun == xc_none) THEN
581 ! no action needed?
582 ELSE
583 ! calculate fxc
584 CALL fxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, xc_section, para_env, &
585 do_triplet=is_triplet, kind_set_external=kind_set)
586
587 CALL section_vals_val_get(xc_section, "DENSITY_CUTOFF", r_val=density_cut)
588 CALL section_vals_val_get(xc_section, "GRADIENT_CUTOFF", r_val=gradient_cut)
589 CALL section_vals_val_get(xc_section, "TAU_CUTOFF", r_val=tau_cut)
590
591 nlcc = has_nlcc(kind_set)
592 lsd = dft_control%lsd
593 nspins = dft_control%nspins
594 mspins = nspins
595 IF (is_triplet) THEN
596 cpassert(nspins == 1)
597 lsd = .true.
598 mspins = 2
599 END IF
600 needs = xc_functionals_get_needs(xc_fun_section, lsd=lsd, calc_potential=.true.)
601 gradient_f = (needs%drho .OR. needs%drho_spin)
602 tau_f = (needs%tau .OR. needs%tau_spin)
603
604 ! Here starts the loop over all the atoms
605 DO ikind = 1, SIZE(atomic_kind_set)
606 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
607 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
608 harmonics=harmonics, grid_atom=grid_atom)
609 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type="GAPW_1C")
610
611 IF (.NOT. paw_atom) cycle
612
613 nr = grid_atom%nr
614 na = grid_atom%ng_sphere
615
616 ! set integration weights
617 weight_h => grid_atom%weight
618 weight_s => grid_atom%weight
619 IF (accint) THEN
620 on = dft_control%qs_control%gapw_control%oweights
621 alpha = dft_control%qs_control%gapw_control%aw(ikind)
622 IF (ASSOCIATED(grid_atom%gapw_weight_s)) THEN
623 IF (grid_atom%gapw_weight_alpha /= alpha) DEALLOCATE (grid_atom%gapw_weight_s)
624 END IF
625 IF (.NOT. ASSOCIATED(grid_atom%gapw_weight_s)) THEN
626 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
627 ALLOCATE (fw(nr))
628 CALL calc_weight_function(fw, grid_atom%rad2, on, alpha)
629 DO ir = 1, nr
630 agr = 1.0_dp - fw(ir)
631 grid_atom%gapw_weight_s(:, ir) = agr*grid_atom%weight(:, ir)
632 END DO
633 DEALLOCATE (fw)
634 grid_atom%gapw_weight_alpha = alpha
635 END IF
636 weight_s => grid_atom%gapw_weight_s
637 END IF
638
639 ! Prepare the structures needed to calculate and store the xc derivatives
640
641 ! Array dimension: here anly one dimensional arrays are used,
642 ! i.e. only the first column of deriv_data is read.
643 ! The other two dimensions are set to size equal 1
644 bounds(1:2, 1:3) = 1
645 bounds(2, 1) = na
646 bounds(2, 2) = nr
647
648 ! create a place where to put the derivatives
649 CALL xc_dset_create(deriv_set, local_bounds=bounds)
650 ! create the place where to store the argument for the functionals
651 CALL xc_rho_set_create(rho_set_h, bounds, rho_cutoff=density_cut, &
652 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
653 CALL xc_rho_set_create(rho_set_s, bounds, rho_cutoff=density_cut, &
654 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
655 CALL xc_rho_set_create(rho1_set_h, bounds, rho_cutoff=density_cut, &
656 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
657 CALL xc_rho_set_create(rho1_set_s, bounds, rho_cutoff=density_cut, &
658 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
659
660 ! allocate the required 3d arrays where to store rho and drho
661 CALL xc_rho_set_atom_update(rho_set_h, needs, mspins, bounds)
662 CALL xc_rho_set_atom_update(rho_set_s, needs, mspins, bounds)
663 CALL xc_rho_set_atom_update(rho1_set_h, needs, mspins, bounds)
664 CALL xc_rho_set_atom_update(rho1_set_s, needs, mspins, bounds)
665
666 ALLOCATE (rho_h(na, nr, nspins), rho_s(na, nr, nspins), &
667 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
668 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
669 ALLOCATE (vxc_h(na, nr, nspins), vxc_s(na, nr, nspins))
670 IF (gradient_f) THEN
671 ALLOCATE (drho_h(4, na, nr, nspins), drho_s(4, na, nr, nspins), &
672 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
673 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
674 ALLOCATE (vxg_h(3, na, nr, nspins), vxg_s(3, na, nr, nspins))
675 END IF
676 IF (tau_f) THEN
677 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
678 ALLOCATE (tau_h(na, nr, nspins), tau_s(na, nr, nspins), &
679 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
680 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
681 ALLOCATE (vtau_h(na, nr, nspins), vtau_s(na, nr, nspins))
682 END IF
683 !
684 ! NLCC: prepare rho and drho of the core charge for this KIND
685 donlcc = .false.
686 IF (nlcc) THEN
687 NULLIFY (rho_nlcc)
688 rho_nlcc => kind_set(ikind)%nlcc_pot
689 IF (ASSOCIATED(rho_nlcc)) donlcc = .true.
690 END IF
691
692 ! Distribute the atoms of this kind
693 num_pe = para_env%num_pe
694 bo = get_limit(natom, num_pe, para_env%mepos)
695
696 DO iat = bo(1), bo(2)
697 iatom = atom_list(iat)
698 !
699 NULLIFY (int_hh, int_ss)
700 rho0_atom => rho0_atom_set(iatom)
701 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
702 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
703 DO ns = 1, nspins
704 nf = SIZE(int_ss(ns)%r_coef, 1)
705 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
706 nf = SIZE(int_hh(ns)%r_coef, 1)
707 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
708 END DO
709
710 ! RHO0
711 rho0_h = 0.0_dp
712 rho0_s = 0.0_dp
713 rho0_atom => rho0_atom_set(iatom)
714 IF (gradient_f) THEN
715 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
716 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
717 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
718 drho0_h = 0.0_dp
719 drho0_s = 0.0_dp
720 ELSE
721 NULLIFY (r_h, r_s)
722 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
723 rho_d = 0.0_dp
724 END IF
725 DO ir = 1, nr
726 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
727 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
728 r_h_d, r_s_d, drho0_h, drho0_s)
729 IF (donlcc) THEN
730 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
731 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
732 END IF
733 END DO
734 IF (tau_f) THEN
735 !compute tau on the grid all at once
736 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, tau_basis_cache, nspins)
737 ELSE
738 tau_d = 0.0_dp
739 END IF
740 ! RHO1
741 rho1_h = 0.0_dp
742 rho1_s = 0.0_dp
743 rho1_atom => rho1_atom_set(iatom)
744 IF (gradient_f) THEN
745 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
746 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
747 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
748 drho1_h = 0.0_dp
749 drho1_s = 0.0_dp
750 ELSE
751 NULLIFY (r_h, r_s)
752 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
753 END IF
754 DO ir = 1, nr
755 CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_f, &
756 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
757 r_h_d, r_s_d, drho1_h, drho1_s)
758 END DO
759 IF (tau_f) THEN
760 !compute tau on the grid all at once
761 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
762 END IF
763
764 DO ir = 1, nr
765 IF (tau_f) THEN
766 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
767 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
768 ELSE IF (gradient_f) THEN
769 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau_d, na, ir)
770 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau_d, na, ir)
771 ELSE
772 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rho_d, tau_d, na, ir)
773 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rho_d, tau_d, na, ir)
774 END IF
775 END DO
776
777 ! RHO2
778 rho2_atom => rho2_atom_set(iatom)
779
780 DO istep = -nstep, nstep
781
782 beta = real(istep, kind=dp)*epsrho
783
784 rho_h = rho0_h + beta*rho1_h
785 rho_s = rho0_s + beta*rho1_s
786 IF (gradient_f) THEN
787 drho_h = drho0_h + beta*drho1_h
788 drho_s = drho0_s + beta*drho1_s
789 END IF
790 IF (tau_f) THEN
791 tau_h = tau0_h + beta*tau1_h
792 tau_s = tau0_s + beta*tau1_s
793 END IF
794 !
795 IF (gradient_f) THEN
796 drho_h(4, :, :, :) = norm2(drho_h(1:3, :, :, :), 1)
797 drho_s(4, :, :, :) = norm2(drho_s(1:3, :, :, :), 1)
798 END IF
799
800 DO ir = 1, nr
801 IF (tau_f) THEN
802 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
803 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
804 ELSE IF (gradient_f) THEN
805 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
806 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
807 ELSE
808 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
809 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
810 END IF
811 END DO
812
813 ! hard 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_h, rho1_set=rho1_set_h, &
817 deriv_set=deriv_set, &
818 w=weight_h, vxc=vxc_h, vxg=vxg_h, vtau=vtau_h, &
819 do_triplet=is_triplet)
820 ! soft atom density !
821 CALL xc_dset_zero_all(deriv_set)
822 CALL xc_2nd_deriv_of_r(xc_section=xc_section, &
823 rho_set=rho_set_s, rho1_set=rho1_set_s, &
824 deriv_set=deriv_set, &
825 w=weight_s, vxc=vxc_s, vxg=vxg_s, vtau=vtau_s, &
826 do_triplet=is_triplet)
827 ! potentials
828 DO ns = 1, nspins
829 fint_hh(ns)%r_coef(:, :) = 0.0_dp
830 fint_ss(ns)%r_coef(:, :) = 0.0_dp
831 END DO
832 IF (gradient_f) THEN
833 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
834 grid_atom, basis_1c, harmonics, nspins)
835 ELSE
836 CALL gavxcgb_nogc(vxc_h, vxc_s, fint_hh, fint_ss, &
837 grid_atom, basis_1c, harmonics, nspins)
838 END IF
839 IF (tau_f) THEN
840 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
841 tau_basis_cache, nspins)
842 END IF
843 ! second derivative gxc
844 NULLIFY (int_hh, int_ss)
845 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
846 DO ns = 1, nspins
847 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
848 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
849 END DO
850 END DO
851 !
852 DO ns = 1, nspins
853 DEALLOCATE (fint_ss(ns)%r_coef)
854 DEALLOCATE (fint_hh(ns)%r_coef)
855 END DO
856 DEALLOCATE (fint_ss, fint_hh)
857
858 END DO ! iat
859
860 ! Release the xc structure used to store the xc derivatives
861 CALL xc_dset_release(deriv_set)
862 CALL xc_rho_set_release(rho_set_h)
863 CALL xc_rho_set_release(rho_set_s)
864 CALL xc_rho_set_release(rho1_set_h)
865 CALL xc_rho_set_release(rho1_set_s)
866
867 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
868 DEALLOCATE (vxc_h, vxc_s)
869 IF (gradient_f) THEN
870 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
871 DEALLOCATE (vxg_h, vxg_s)
872 END IF
873 IF (tau_f) THEN
874 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
875 DEALLOCATE (vtau_h, vtau_s)
876 CALL release_tau_basis_cache(tau_basis_cache)
877 END IF
878 END DO ! ikind
879
880 END IF !xc_none
881
882 CALL timestop(handle)
883
884 END SUBROUTINE fgxc_atom_diff
885
886END 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:76
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_weight_function(fun, r2, order, alpha)
Calculates the radial weight function for accurate XC integration.
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