(git:27c966b)
Loading...
Searching...
No Matches
qs_rho_atom_methods.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!--------------------------------------------------------------------------------------------------!
8
20 USE kinds, ONLY: dp
21 USE kpoint_types, ONLY: get_kpoint_info,&
27 USE mathconstants, ONLY: fourpi,&
28 pi
31 USE orbital_pointers, ONLY: indso,&
32 nsoset
42 USE qs_kind_types, ONLY: get_qs_kind,&
47 USE qs_oce_methods, ONLY: proj_blk
56 USE util, ONLY: get_limit
57 USE whittaker, ONLY: whittaker_c0a,&
59
60!$ USE OMP_LIB, ONLY: omp_lock_kind, &
61!$ omp_init_lock, omp_set_lock, &
62!$ omp_unset_lock, omp_destroy_lock
63
64#include "./base/base_uses.f90"
65
66 IMPLICIT NONE
67
68 PRIVATE
69
70! *** Global parameters (only in this module)
71
72 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_rho_atom_methods'
73 INTEGER, PARAMETER, PRIVATE :: l2_chunk_dp = 16000
74
75! *** Public subroutines ***
76
82
83CONTAINS
84
85! **************************************************************************************************
86!> \brief ...
87!> \param para_env ...
88!> \param rho_atom_set ...
89!> \param qs_kind ...
90!> \param atom_list ...
91!> \param natom ...
92!> \param nspins ...
93!> \param tot_rho1_h ...
94!> \param tot_rho1_s ...
95!> \param rho1_h_spin ...
96!> \param rho1_s_spin ...
97!> \param rho1_h_aspin ...
98!> \param rho1_s_aspin ...
99! **************************************************************************************************
100 SUBROUTINE calculate_rho_atom(para_env, rho_atom_set, qs_kind, atom_list, &
101 natom, nspins, tot_rho1_h, tot_rho1_s, &
102 rho1_h_spin, rho1_s_spin, rho1_h_aspin, rho1_s_aspin)
103
104 TYPE(mp_para_env_type), POINTER :: para_env
105 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
106 TYPE(qs_kind_type), INTENT(IN) :: qs_kind
107 INTEGER, DIMENSION(:), INTENT(IN) :: atom_list
108 INTEGER, INTENT(IN) :: natom, nspins
109 REAL(dp), DIMENSION(:), INTENT(INOUT) :: tot_rho1_h, tot_rho1_s
110 REAL(dp), INTENT(INOUT) :: rho1_h_spin, rho1_s_spin, rho1_h_aspin, &
111 rho1_s_aspin
112
113 CHARACTER(len=*), PARAMETER :: routinen = 'calculate_rho_atom'
114
115 INTEGER :: damax_iso_not0_local, handle, i, i1, i2, iat, iatom, icg, ipgf1, ipgf2, ir, &
116 iset1, iset2, iso, iso1, iso1_coeff, iso1_first, iso1_last, iso2, iso2_coeff, iso2_first, &
117 iso2_last, j, l, l_iso, l_sub, l_sum, lmax12, lmax_expansion, lmin12, m1s, m2s, &
118 max_iso_not0, max_iso_not0_local, max_npgf, max_s_harm, maxl, maxso, mepos, n1s, n2s, na, &
119 nr, nset, num_pe, size1, size2
120 INTEGER, ALLOCATABLE, DIMENSION(:) :: cg_n_list, dacg_n_list
121 INTEGER, ALLOCATABLE, DIMENSION(:, :, :) :: cg_list, dacg_list
122 INTEGER, DIMENSION(2) :: bo
123 INTEGER, DIMENSION(:), POINTER :: lmax, lmin, npgf, o2nindex
124 LOGICAL, ALLOCATABLE, DIMENSION(:, :) :: done_vgg
125 REAL(dp) :: c1, c2, cpc_h, cpc_s, rfun, rho_h, &
126 rho_s, root_zet12, zet12
127 REAL(dp), ALLOCATABLE, DIMENSION(:) :: erf_zet12, g1, g2, gg0, int1, int2
128 REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: dgg, gg, gg_lm1, sfun_h, sfun_s
129 REAL(dp), ALLOCATABLE, DIMENSION(:, :, :) :: g_rad, vgg
130 REAL(dp), DIMENSION(:, :), POINTER :: coeff_h, coeff_s, zet
131 REAL(dp), DIMENSION(:, :, :), POINTER :: my_cg
132 REAL(dp), DIMENSION(:, :, :, :), POINTER :: my_cg_dxyz
133 TYPE(grid_atom_type), POINTER :: grid_atom
134 TYPE(gto_basis_set_type), POINTER :: basis_1c
135 TYPE(harmonics_atom_type), POINTER :: harmonics
136
137 CALL timeset(routinen, handle)
138
139 !Note: tau is taken care of separately in qs_vxc_atom.F
140
141 NULLIFY (basis_1c)
142 NULLIFY (harmonics, grid_atom)
143 NULLIFY (lmin, lmax, npgf, zet, my_cg, my_cg_dxyz, coeff_h, coeff_s)
144
145 CALL get_qs_kind(qs_kind, grid_atom=grid_atom, harmonics=harmonics)
146 CALL get_qs_kind(qs_kind, basis_set=basis_1c, basis_type="GAPW_1C")
147
148 CALL get_gto_basis_set(gto_basis_set=basis_1c, lmax=lmax, lmin=lmin, &
149 maxl=maxl, npgf=npgf, nset=nset, zet=zet, &
150 maxso=maxso)
151
152 CALL get_paw_basis_info(basis_1c, o2nindex=o2nindex)
153
154 max_iso_not0 = harmonics%max_iso_not0
155 max_s_harm = harmonics%max_s_harm
156
157 nr = grid_atom%nr
158 max_npgf = maxval(npgf(1:nset))
159 lmax_expansion = indso(1, max_iso_not0)
160 ! Distribute the atoms of this kind
161 num_pe = para_env%num_pe
162 mepos = para_env%mepos
163 bo = get_limit(natom, num_pe, mepos)
164
165 my_cg => harmonics%my_CG
166 my_cg_dxyz => harmonics%my_CG_dxyz
167
168 ALLOCATE (g1(nr), g2(nr), gg0(nr), gg(nr, 0:2*maxl), dgg(nr, 0:2*maxl), gg_lm1(nr, 0:2*maxl))
169 ALLOCATE (erf_zet12(nr), vgg(nr, 0:2*maxl, 0:indso(1, max_iso_not0)))
170 ALLOCATE (done_vgg(0:2*maxl, 0:indso(1, max_iso_not0)))
171 ALLOCATE (int1(nr), int2(nr))
172 ALLOCATE (cg_list(2, nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm), &
173 dacg_list(2, nsoset(maxl)**2, max_s_harm), dacg_n_list(max_s_harm))
174 ALLOCATE (g_rad(nr, max_npgf, nset))
175
176 DO iset1 = 1, nset
177 DO ipgf1 = 1, npgf(iset1)
178 g_rad(1:nr, ipgf1, iset1) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
179 END DO
180 END DO
181
182 DO iat = bo(1), bo(2)
183 iatom = atom_list(iat)
184 DO i = 1, nspins
185 IF (.NOT. ASSOCIATED(rho_atom_set(iatom)%rho_rad_h(i)%r_coef)) THEN
186 CALL allocate_rho_atom_rad(rho_atom_set, iatom, i, nr, max_iso_not0)
187 ELSE
188 CALL set2zero_rho_atom_rad(rho_atom_set, iatom, i)
189 END IF
190 END DO
191 END DO
192
193 m1s = 0
194 DO iset1 = 1, nset
195 m2s = 0
196 DO iset2 = 1, nset
197
198 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
199 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
200 cpassert(max_iso_not0_local <= max_iso_not0)
201 CALL get_none0_cg_list(my_cg_dxyz, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
202 max_s_harm, lmax_expansion, dacg_list, dacg_n_list, damax_iso_not0_local)
203 n1s = nsoset(lmax(iset1))
204
205 DO ipgf1 = 1, npgf(iset1)
206 iso1_first = nsoset(lmin(iset1) - 1) + 1 + n1s*(ipgf1 - 1) + m1s
207 iso1_last = nsoset(lmax(iset1)) + n1s*(ipgf1 - 1) + m1s
208 size1 = iso1_last - iso1_first + 1
209 iso1_first = o2nindex(iso1_first)
210 iso1_last = o2nindex(iso1_last)
211 i1 = iso1_last - iso1_first + 1
212 cpassert(size1 == i1)
213 i1 = nsoset(lmin(iset1) - 1) + 1
214
215 g1(1:nr) = g_rad(1:nr, ipgf1, iset1)
216
217 n2s = nsoset(lmax(iset2))
218 DO ipgf2 = 1, npgf(iset2)
219 iso2_first = nsoset(lmin(iset2) - 1) + 1 + n2s*(ipgf2 - 1) + m2s
220 iso2_last = nsoset(lmax(iset2)) + n2s*(ipgf2 - 1) + m2s
221 size2 = iso2_last - iso2_first + 1
222 iso2_first = o2nindex(iso2_first)
223 iso2_last = o2nindex(iso2_last)
224 i2 = iso2_last - iso2_first + 1
225 cpassert(size2 == i2)
226 i2 = nsoset(lmin(iset2) - 1) + 1
227
228 g2(1:nr) = g_rad(1:nr, ipgf2, iset2)
229 lmin12 = lmin(iset1) + lmin(iset2)
230 lmax12 = lmax(iset1) + lmax(iset2)
231
232 zet12 = zet(ipgf1, iset1) + zet(ipgf2, iset2)
233 root_zet12 = sqrt(zet(ipgf1, iset1) + zet(ipgf2, iset2))
234 DO ir = 1, nr
235 erf_zet12(ir) = erf(root_zet12*grid_atom%rad(ir))
236 END DO
237
238 gg = 0.0_dp
239 dgg = 0.0_dp
240 gg_lm1 = 0.0_dp
241 vgg = 0.0_dp
242 done_vgg = .false.
243 ! reduce the number of terms in the expansion local densities
244 IF (lmin12 <= lmax_expansion) THEN
245 IF (lmin12 == 0) THEN
246 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
247 gg_lm1(1:nr, lmin12) = 0.0_dp
248 gg0(1:nr) = gg(1:nr, lmin12)
249 ELSE
250 gg0(1:nr) = g1(1:nr)*g2(1:nr)
251 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
252 gg_lm1(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12 - 1)*g1(1:nr)*g2(1:nr)
253 END IF
254
255 ! reduce the number of terms in the expansion local densities
256 IF (lmax12 > lmax_expansion) lmax12 = lmax_expansion
257
258 DO l = lmin12 + 1, lmax12
259 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(1:nr, l - 1)
260 gg_lm1(1:nr, l) = gg(1:nr, l - 1)
261 dgg(1:nr, l - 1) = -2.0_dp*(zet(ipgf1, iset1) + zet(ipgf2, iset2))*gg(1:nr, l)
262
263 END DO
264 dgg(1:nr, lmax12) = -2.0_dp*(zet(ipgf1, iset1) + &
265 zet(ipgf2, iset2))*grid_atom%rad(1:nr)*gg(1:nr, lmax12)
266
267 c2 = sqrt(pi*pi*pi/(zet12*zet12*zet12))
268
269 DO iso = 1, max_iso_not0_local
270 l_iso = indso(1, iso)
271 c1 = fourpi/(2._dp*real(l_iso, dp) + 1._dp)
272 DO icg = 1, cg_n_list(iso)
273 iso1 = cg_list(1, icg, iso)
274 iso2 = cg_list(2, icg, iso)
275
276 l = indso(1, iso1) + indso(1, iso2)
277 cpassert(l <= lmax_expansion)
278 IF (done_vgg(l, l_iso)) cycle
279 l_sum = l + l_iso
280 l_sub = l - l_iso
281
282 IF (l_sum == 0) THEN
283 vgg(1:nr, l, l_iso) = erf_zet12(1:nr)*grid_atom%oorad2l(1:nr, 1)*c2
284 ELSE
285 CALL whittaker_c0a(int1, grid_atom%rad, gg0, erf_zet12, zet12, l, l_iso, nr)
286 CALL whittaker_ci(int2, grid_atom%rad, gg0, zet12, l_sub, nr)
287
288 DO ir = 1, nr
289 int2(ir) = grid_atom%rad2l(ir, l_iso)*int2(ir)
290 vgg(ir, l, l_iso) = c1*(int1(ir) + int2(ir))
291 END DO
292 END IF
293 done_vgg(l, l_iso) = .true.
294 END DO
295 END DO
296 END IF ! lmax_expansion
297
298 DO iat = bo(1), bo(2)
299 iatom = atom_list(iat)
300
301 DO i = 1, nspins
302 coeff_h => rho_atom_set(iatom)%cpc_h(i)%r_coef
303 coeff_s => rho_atom_set(iatom)%cpc_s(i)%r_coef
304
305 DO iso = 1, max_iso_not0_local
306 l_iso = indso(1, iso)
307 DO icg = 1, cg_n_list(iso)
308 iso1 = cg_list(1, icg, iso)
309 iso2 = cg_list(2, icg, iso)
310
311 l = indso(1, iso1) + indso(1, iso2)
312 cpassert(l <= lmax_expansion)
313 iso1_coeff = iso1_first + iso1 - i1
314 iso2_coeff = iso2_first + iso2 - i2
315 cpc_h = coeff_h(iso1_coeff, iso2_coeff)*my_cg(iso1, iso2, iso)
316 cpc_s = coeff_s(iso1_coeff, iso2_coeff)*my_cg(iso1, iso2, iso)
317
318 rho_atom_set(iatom)%rho_rad_h(i)%r_coef(1:nr, iso) = &
319 rho_atom_set(iatom)%rho_rad_h(i)%r_coef(1:nr, iso) + &
320 gg(1:nr, l)*cpc_h
321
322 rho_atom_set(iatom)%rho_rad_s(i)%r_coef(1:nr, iso) = &
323 rho_atom_set(iatom)%rho_rad_s(i)%r_coef(1:nr, iso) + &
324 gg(1:nr, l)*cpc_s
325
326 rho_atom_set(iatom)%drho_rad_h(i)%r_coef(1:nr, iso) = &
327 rho_atom_set(iatom)%drho_rad_h(i)%r_coef(1:nr, iso) + &
328 dgg(1:nr, l)*cpc_h
329
330 rho_atom_set(iatom)%drho_rad_s(i)%r_coef(1:nr, iso) = &
331 rho_atom_set(iatom)%drho_rad_s(i)%r_coef(1:nr, iso) + &
332 dgg(1:nr, l)*cpc_s
333
334 rho_atom_set(iatom)%vrho_rad_h(i)%r_coef(1:nr, iso) = &
335 rho_atom_set(iatom)%vrho_rad_h(i)%r_coef(1:nr, iso) + &
336 vgg(1:nr, l, l_iso)*cpc_h
337
338 rho_atom_set(iatom)%vrho_rad_s(i)%r_coef(1:nr, iso) = &
339 rho_atom_set(iatom)%vrho_rad_s(i)%r_coef(1:nr, iso) + &
340 vgg(1:nr, l, l_iso)*cpc_s
341
342 END DO ! icg
343
344 END DO ! iso
345
346 DO iso = 1, max_iso_not0 !damax_iso_not0_local
347 l_iso = indso(1, iso)
348 DO icg = 1, dacg_n_list(iso)
349 iso1 = dacg_list(1, icg, iso)
350 iso2 = dacg_list(2, icg, iso)
351 l = indso(1, iso1) + indso(1, iso2)
352 cpassert(l <= lmax_expansion)
353 iso1_coeff = iso1_first + iso1 - i1
354 iso2_coeff = iso2_first + iso2 - i2
355 cpc_h = coeff_h(iso1_coeff, iso2_coeff)
356 cpc_s = coeff_s(iso1_coeff, iso2_coeff)
357 DO j = 1, 3
358 rho_atom_set(iatom)%rho_rad_h_d(j, i)%r_coef(1:nr, iso) = &
359 rho_atom_set(iatom)%rho_rad_h_d(j, i)%r_coef(1:nr, iso) + &
360 gg_lm1(1:nr, l)*cpc_h*my_cg_dxyz(j, iso1, iso2, iso)
361
362 rho_atom_set(iatom)%rho_rad_s_d(j, i)%r_coef(1:nr, iso) = &
363 rho_atom_set(iatom)%rho_rad_s_d(j, i)%r_coef(1:nr, iso) + &
364 gg_lm1(1:nr, l)*cpc_s*my_cg_dxyz(j, iso1, iso2, iso)
365 END DO
366 END DO ! icg
367
368 END DO ! iso
369
370 END DO ! i
371 END DO ! iat
372
373 END DO ! ipgf2
374 END DO ! ipgf1
375 m2s = m2s + maxso
376 END DO ! iset2
377 m1s = m1s + maxso
378 END DO ! iset1
379
380 DO iat = bo(1), bo(2)
381 iatom = atom_list(iat)
382
383 DO i = 1, nspins
384
385 DO iso = 1, max_iso_not0
386 rho_s = 0.0_dp
387 rho_h = 0.0_dp
388 DO ir = 1, nr
389 rho_h = rho_h + rho_atom_set(iatom)%rho_rad_h(i)%r_coef(ir, iso)*grid_atom%wr(ir)
390 rho_s = rho_s + rho_atom_set(iatom)%rho_rad_s(i)%r_coef(ir, iso)*grid_atom%wr(ir)
391 END DO ! ir
392 tot_rho1_h(i) = tot_rho1_h(i) + rho_h*harmonics%slm_int(iso)
393 tot_rho1_s(i) = tot_rho1_s(i) + rho_s*harmonics%slm_int(iso)
394 END DO ! iso
395
396 END DO ! ispin
397
398 IF (nspins == 2) THEN
399 na = SIZE(harmonics%slm, 1)
400 ALLOCATE (sfun_h(nr, na), sfun_s(nr, na))
401 sfun_h = 0.0_dp
402 sfun_s = 0.0_dp
403 DO iso = 1, max_iso_not0
404 DO ir = 1, nr
405 rfun = grid_atom%wr(ir)*(rho_atom_set(iatom)%rho_rad_h(1)%r_coef(ir, iso) - &
406 rho_atom_set(iatom)%rho_rad_h(2)%r_coef(ir, iso))
407 sfun_h(ir, 1:na) = sfun_h(ir, 1:na) + rfun*harmonics%slm(1:na, iso)*grid_atom%wa(1:na)
408 rfun = grid_atom%wr(ir)*(rho_atom_set(iatom)%rho_rad_s(1)%r_coef(ir, iso) - &
409 rho_atom_set(iatom)%rho_rad_s(2)%r_coef(ir, iso))
410 sfun_s(ir, 1:na) = sfun_s(ir, 1:na) + rfun*harmonics%slm(1:na, iso)*grid_atom%wa(1:na)
411 END DO
412 END DO
413 rho1_h_spin = rho1_h_spin + sum(sfun_h(1:nr, 1:na))
414 rho1_s_spin = rho1_s_spin + sum(sfun_s(1:nr, 1:na))
415 rho1_h_aspin = rho1_h_aspin + sum(abs(sfun_h(1:nr, 1:na)))
416 rho1_s_aspin = rho1_s_aspin + sum(abs(sfun_s(1:nr, 1:na)))
417 DEALLOCATE (sfun_h, sfun_s)
418 END IF
419
420 END DO ! iat
421
422 DEALLOCATE (g1, g2, gg0, gg, gg_lm1, dgg, vgg, done_vgg, erf_zet12, int1, int2, g_rad)
423 DEALLOCATE (cg_list, cg_n_list, dacg_list, dacg_n_list)
424 DEALLOCATE (o2nindex)
425
426 CALL timestop(handle)
427
428 END SUBROUTINE calculate_rho_atom
429
430! **************************************************************************************************
431!> \brief Replicate the radial hard/soft density data needed to evaluate one-center tails on
432!> rank-local target grids. The compact one-center density matrices are already global;
433!> this routine performs one packed reduction for the derived radial fields of a kind.
434!> \param para_env ...
435!> \param rho_atom_set ...
436!> \param qs_kind ...
437!> \param atom_list ...
438!> \param natom ...
439!> \param nspins ...
440! **************************************************************************************************
441 SUBROUTINE replicate_rho_atom_radial(para_env, rho_atom_set, qs_kind, atom_list, natom, nspins)
442 TYPE(mp_para_env_type), POINTER :: para_env
443 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
444 TYPE(qs_kind_type), INTENT(IN) :: qs_kind
445 INTEGER, DIMENSION(:), INTENT(IN) :: atom_list
446 INTEGER, INTENT(IN) :: natom, nspins
447
448 CHARACTER(len=*), PARAMETER :: routinen = 'replicate_rho_atom_radial'
449
450 INTEGER :: block_size, bo(2), cursor, handle, iat, &
451 iatom, ispin, j, max_iso_not0, ncoeff, &
452 nr
453 REAL(dp), ALLOCATABLE, DIMENSION(:) :: buffer
454 TYPE(grid_atom_type), POINTER :: grid_atom
455 TYPE(harmonics_atom_type), POINTER :: harmonics
456
457 CALL timeset(routinen, handle)
458
459 NULLIFY (grid_atom, harmonics)
460 CALL get_qs_kind(qs_kind, grid_atom=grid_atom, harmonics=harmonics)
461 cpassert(ASSOCIATED(grid_atom))
462 cpassert(ASSOCIATED(harmonics))
463 nr = grid_atom%nr
464 max_iso_not0 = harmonics%max_iso_not0
465 ncoeff = nr*max_iso_not0
466 block_size = 10*nspins*ncoeff
467 ALLOCATE (buffer(block_size*natom))
468 buffer = 0.0_dp
469
470 bo = get_limit(natom, para_env%num_pe, para_env%mepos)
471 DO iat = bo(1), bo(2)
472 iatom = atom_list(iat)
473 cursor = (iat - 1)*block_size
474 DO ispin = 1, nspins
475 buffer(cursor + 1:cursor + ncoeff) = &
476 reshape(rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef, [ncoeff])
477 cursor = cursor + ncoeff
478 buffer(cursor + 1:cursor + ncoeff) = &
479 reshape(rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef, [ncoeff])
480 cursor = cursor + ncoeff
481 buffer(cursor + 1:cursor + ncoeff) = &
482 reshape(rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef, [ncoeff])
483 cursor = cursor + ncoeff
484 buffer(cursor + 1:cursor + ncoeff) = &
485 reshape(rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef, [ncoeff])
486 cursor = cursor + ncoeff
487 DO j = 1, 3
488 buffer(cursor + 1:cursor + ncoeff) = &
489 reshape(rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef, [ncoeff])
490 cursor = cursor + ncoeff
491 buffer(cursor + 1:cursor + ncoeff) = &
492 reshape(rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef, [ncoeff])
493 cursor = cursor + ncoeff
494 END DO
495 END DO
496 cpassert(cursor == iat*block_size)
497 END DO
498 CALL para_env%sum(buffer)
499
500 DO iat = 1, natom
501 iatom = atom_list(iat)
502 cursor = (iat - 1)*block_size
503 DO ispin = 1, nspins
504 IF (.NOT. ASSOCIATED(rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef)) THEN
505 CALL allocate_rho_atom_rad(rho_atom_set, iatom, ispin, nr, max_iso_not0)
506 END IF
507 rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef = &
508 reshape(buffer(cursor + 1:cursor + ncoeff), [nr, max_iso_not0])
509 cursor = cursor + ncoeff
510 rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef = &
511 reshape(buffer(cursor + 1:cursor + ncoeff), [nr, max_iso_not0])
512 cursor = cursor + ncoeff
513 rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef = &
514 reshape(buffer(cursor + 1:cursor + ncoeff), [nr, max_iso_not0])
515 cursor = cursor + ncoeff
516 rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef = &
517 reshape(buffer(cursor + 1:cursor + ncoeff), [nr, max_iso_not0])
518 cursor = cursor + ncoeff
519 DO j = 1, 3
520 rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef = &
521 reshape(buffer(cursor + 1:cursor + ncoeff), [nr, max_iso_not0])
522 cursor = cursor + ncoeff
523 rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef = &
524 reshape(buffer(cursor + 1:cursor + ncoeff), [nr, max_iso_not0])
525 cursor = cursor + ncoeff
526 END DO
527 END DO
528 cpassert(cursor == iat*block_size)
529 END DO
530 DEALLOCATE (buffer)
531
532 CALL timestop(handle)
533
534 END SUBROUTINE replicate_rho_atom_radial
535
536! **************************************************************************************************
537!> \brief ...
538!> \param qs_env QuickStep environment
539!> (accessed components: atomic_kind_set, dft_control%nimages,
540!> dft_control%nspins, kpoints%cell_to_index)
541!> \param rho_ao density matrix in atomic basis set
542!> \param rho_atom_set ...
543!> \param qs_kind_set list of QuickStep kinds
544!> \param oce one-centre expansion coefficients
545!> \param sab neighbour pair list
546!> \param para_env parallel environment
547!> \par History
548!> Add OpenMP [Apr 2016, EPCC]
549!> Use automatic arrays [Sep 2016, M Tucker]
550!> Allow for external non-default kind_set, oce and sab [Dec 2019, A Bussy]
551!> \note Consider to declare 'rho_ao' dummy argument as a pointer to the two-dimensional
552!> (1:nspins, 1:nimages) set of matrices.
553! **************************************************************************************************
554 SUBROUTINE calculate_rho_atom_coeff(qs_env, rho_ao, rho_atom_set, qs_kind_set, oce, sab, para_env)
555
556 TYPE(qs_environment_type), POINTER :: qs_env
557 TYPE(dbcsr_p_type), DIMENSION(*) :: rho_ao
558 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
559 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
560 TYPE(oce_matrix_type), POINTER :: oce
561 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
562 POINTER :: sab
563 TYPE(mp_para_env_type), POINTER :: para_env
564
565 CHARACTER(len=*), PARAMETER :: routinen = 'calculate_rho_atom_coeff'
566
567 INTEGER :: bo(2), handle, i, iac, iatom, ibc, ikind, img, inb, ispin, jatom, jkind, kac, &
568 kac_hi, kac_lo, katom, kbc, kkind, len_pc1, max_gau, max_nb, max_nclist, max_nsgf, mepos, &
569 n_cont_a, n_cont_b, n_nb, nat_kind, natom, nimages, nkind, nl_size, nsoctot, nspins, &
570 num_pe, slot, w_alloc, w_total
571 INTEGER, ALLOCATABLE, DIMENSION(:) :: ia_ptr, ia_work, nsatbas_kind, &
572 slot_order, w_offset
573 INTEGER, DIMENSION(3) :: cell_b
574 INTEGER, DIMENSION(:), POINTER :: a_list, list_a, list_b
575 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index
576 LOGICAL :: dista, distb, found, paw_atom
577 LOGICAL, ALLOCATABLE, DIMENSION(:) :: has_intac, paw_kind
578 LOGICAL, ALLOCATABLE, DIMENSION(:, :) :: w_touched
579 REAL(kind=dp) :: beta, eps_cpc, factor, pmax
580 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: nb_pmax, proj_work1
581 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: p_matrix, proj_work2, w_buf
582 REAL(kind=dp), DIMENSION(:, :), POINTER :: c_coeff_hh_a, c_coeff_hh_b, &
583 c_coeff_ss_a, c_coeff_ss_b, r_coef_h, &
584 r_coef_s
585 TYPE(alist_type), POINTER :: alist_ac, alist_bc
586 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
587 TYPE(clist_type), POINTER :: clist_a, clist_b
588 TYPE(dft_control_type), POINTER :: dft_control
589 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_list
590 TYPE(gto_basis_set_type), POINTER :: basis_1c, basis_set_a
591 TYPE(kpoint_type), POINTER :: kpoints
592 TYPE(neighbor_list_task_type), POINTER :: task
593 TYPE(rho_atom_coeff), ALLOCATABLE, DIMENSION(:, :) :: nb_pblk
594
595!$ INTEGER(kind=omp_lock_kind), ALLOCATABLE, DIMENSION(:) :: locks
596!$ INTEGER :: lock, number_of_locks
597
598 CALL timeset(routinen, handle)
599
600 CALL get_qs_env(qs_env=qs_env, &
601 dft_control=dft_control, &
602 atomic_kind_set=atomic_kind_set)
603
604 eps_cpc = dft_control%qs_control%gapw_control%eps_cpc
605
606 cpassert(ASSOCIATED(qs_kind_set))
607 cpassert(ASSOCIATED(rho_atom_set))
608 cpassert(ASSOCIATED(oce))
609 cpassert(ASSOCIATED(sab))
610
611 nspins = dft_control%nspins
612 nimages = dft_control%nimages
613
614 NULLIFY (cell_to_index)
615 IF (nimages > 1) THEN
616 CALL get_qs_env(qs_env=qs_env, kpoints=kpoints)
617 CALL get_kpoint_info(kpoint=kpoints, cell_to_index=cell_to_index)
618 END IF
619
620 CALL get_atomic_kind_set(atomic_kind_set, natom=natom)
621 CALL get_qs_kind_set(qs_kind_set, maxsgf=max_nsgf, maxgtops=max_gau, basis_type='GAPW_1C')
622
623 nkind = SIZE(atomic_kind_set)
624 ! Initialize to 0 the CPC coefficients and the local density arrays
625 DO ikind = 1, nkind
626 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=a_list, natom=nat_kind)
627 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
628
629 IF (.NOT. paw_atom) cycle
630 DO i = 1, nat_kind
631 iatom = a_list(i)
632 DO ispin = 1, nspins
633 rho_atom_set(iatom)%cpc_h(ispin)%r_coef = 0.0_dp
634 rho_atom_set(iatom)%cpc_s(ispin)%r_coef = 0.0_dp
635 END DO ! ispin
636 END DO ! i
637
638 num_pe = para_env%num_pe
639 mepos = para_env%mepos
640 bo = get_limit(nat_kind, num_pe, mepos)
641 DO i = bo(1), bo(2)
642 iatom = a_list(i)
643 DO ispin = 1, nspins
644 rho_atom_set(iatom)%ga_Vlocal_gb_h(ispin)%r_coef = 0.0_dp
645 rho_atom_set(iatom)%ga_Vlocal_gb_s(ispin)%r_coef = 0.0_dp
646 END DO ! ispin
647 END DO ! i
648 END DO ! ikind
649
650 ALLOCATE (basis_set_list(nkind))
651 ALLOCATE (paw_kind(nkind), nsatbas_kind(nkind), has_intac(nkind*nkind))
652 paw_kind(:) = .false.
653 nsatbas_kind(:) = 0
654 has_intac(:) = .false.
655 DO ikind = 1, nkind
656 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_set_a)
657 IF (ASSOCIATED(basis_set_a)) THEN
658 basis_set_list(ikind)%gto_basis_set => basis_set_a
659 ELSE
660 NULLIFY (basis_set_list(ikind)%gto_basis_set)
661 END IF
662 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_1c, basis_type="GAPW_1C", &
663 paw_atom=paw_kind(ikind))
664 IF (paw_kind(ikind)) CALL get_paw_basis_info(basis_1c, nsatbas=nsatbas_kind(ikind))
665 END DO
666 DO ikind = 1, nkind*nkind
667 has_intac(ikind) = ASSOCIATED(oce%intac(ikind)%alist)
668 END DO
669
670 len_pc1 = max(1, max_nsgf*max_gau)
671 w_alloc = max(1, l2_chunk_dp/nspins, len_pc1) ! 16k-double L2 chunk across spins
672 max_nclist = 1
673 DO iac = 1, nkind*nkind
674 IF (.NOT. has_intac(iac)) cycle
675 DO i = 1, SIZE(oce%intac(iac)%alist)
676 max_nclist = max(max_nclist, oce%intac(iac)%alist(i)%nclist)
677 END DO
678 END DO
679
680 cpassert(ASSOCIATED(sab(1)%nlist_task))
681 nl_size = sab(1)%nl_size
682 ALLOCATE (ia_ptr(natom + 1), ia_work(natom), slot_order(max(1, nl_size)))
683 ia_work(:) = 0
684 DO i = 1, 2
685 DO slot = 1, nl_size
686 task => sab(1)%nlist_task(slot)
687 IF (.NOT. ASSOCIATED(basis_set_list(task%ikind)%gto_basis_set)) cycle
688 IF (.NOT. ASSOCIATED(basis_set_list(task%jkind)%gto_basis_set)) cycle
689 iatom = min(task%iatom, task%jatom)
690 IF (i == 2) slot_order(ia_work(iatom)) = slot
691 ia_work(iatom) = ia_work(iatom) + 1
692 END DO
693 IF (i == 2) EXIT
694 ia_ptr(1) = 1
695 max_nb = max(1, maxval(ia_work))
696 DO iatom = 1, natom
697 ia_ptr(iatom + 1) = ia_ptr(iatom) + ia_work(iatom)
698 ia_work(iatom) = ia_ptr(iatom)
699 END DO
700 END DO
701 DEALLOCATE (ia_work)
702
703!$OMP PARALLEL DEFAULT(NONE) &
704!$OMP SHARED(natom, nkind, nspins, nimages, cell_to_index, rho_ao, max_nsgf, max_gau, max_nb, &
705!$OMP max_nclist, w_alloc, len_PC1, ia_ptr, slot_order, sab, paw_kind, nsatbas_kind, &
706!$OMP has_intac, oce, eps_cpc, rho_atom_set, locks, number_of_locks) &
707!$OMP PRIVATE(nb_pblk, nb_pmax, p_matrix, proj_work1, proj_work2, w_buf, w_offset, w_touched, &
708!$OMP iatom, ikind, n_nb, inb, TASK, jatom, cell_b, img, pmax, ispin, found, kkind, &
709!$OMP nsoctot, iac, alist_ac, kac_lo, kac_hi, w_total, kac, clist_a, n_cont_a, katom, &
710!$OMP jkind, ibc, alist_bc, factor, kbc, clist_b, n_cont_b, list_a, list_b, dista, &
711!$OMP distb, C_coeff_hh_a, C_coeff_ss_a, C_coeff_hh_b, C_coeff_ss_b, beta, r_coef_h, r_coef_s)
712
713 ALLOCATE (nb_pblk(nspins, max_nb), nb_pmax(max_nb), w_buf(w_alloc, nspins), w_offset(max_nclist))
714 ALLOCATE (p_matrix(max(1, max_nsgf), max(1, max_nsgf)), proj_work1(len_pc1), &
715 proj_work2(max(1, max_gau), max(1, max_gau)), w_touched(max_nclist, nspins))
716
717!$OMP SINGLE
718!$ number_of_locks = nspins*natom
719!$ ALLOCATE (locks(number_of_locks))
720!$OMP END SINGLE
721
722!$OMP DO
723!$ DO lock = 1, number_of_locks
724!$ call omp_init_lock(locks(lock))
725!$ END DO
726!$OMP END DO
727
728 ! Factor sum_(A,B) C_A^T P_AB C_B = sum_A C_A^T (sum_B P_AB C_B) across offsite B /= K.
729!$OMP DO SCHEDULE(DYNAMIC, 1)
730 DO iatom = 1, natom
731 n_nb = ia_ptr(iatom + 1) - ia_ptr(iatom)
732 IF (n_nb == 0) cycle
733 task => sab(1)%nlist_task(slot_order(ia_ptr(iatom)))
734 ikind = merge(task%jkind, task%ikind, task%iatom > task%jatom)
735
736 DO inb = 1, n_nb
737 task => sab(1)%nlist_task(slot_order(ia_ptr(iatom) + inb - 1))
738 jatom = max(task%iatom, task%jatom)
739 img = 1
740 IF (nimages > 1) img = cell_to_index(task%cell(1), task%cell(2), task%cell(3))
741 cpassert(img > 0)
742 pmax = 0.0_dp
743 DO ispin = 1, nspins
744 CALL dbcsr_get_block_p(rho_ao(nspins*(img - 1) + ispin)%matrix, iatom, jatom, &
745 nb_pblk(ispin, inb)%r_coef, found)
746 cpassert(found)
747 pmax = pmax + maxval(abs(nb_pblk(ispin, inb)%r_coef))
748 END DO
749 nb_pmax(inb) = pmax
750 END DO
751
752 DO kkind = 1, nkind
753 IF (.NOT. paw_kind(kkind)) cycle
754 nsoctot = nsatbas_kind(kkind)
755 iac = ikind + nkind*(kkind - 1)
756 IF (.NOT. has_intac(iac)) cycle
757 CALL get_alist(oce%intac(iac), alist_ac, iatom)
758 IF (.NOT. ASSOCIATED(alist_ac)) cycle
759
760 kac_lo = 1
761 DO WHILE (kac_lo <= alist_ac%nclist)
762 w_total = 0
763 DO kac = kac_lo, alist_ac%nclist
764 n_cont_a = alist_ac%clist(kac)%nsgf_cnt
765 IF (n_cont_a == 0) cycle
766 IF (w_total > 0 .AND. w_total + n_cont_a*nsoctot > w_alloc) EXIT
767 w_offset(kac) = w_total + 1
768 w_total = w_total + n_cont_a*nsoctot
769 END DO
770 kac_hi = kac - 1
771
772 IF (w_total > 0) THEN
773 w_touched(kac_lo:kac_hi, 1:nspins) = .false.
774 DO inb = 1, n_nb
775 pmax = nb_pmax(inb)
776 IF (pmax <= 0.0_dp) cycle
777 task => sab(1)%nlist_task(slot_order(ia_ptr(iatom) + inb - 1))
778 jkind = merge(task%ikind, task%jkind, task%iatom > task%jatom)
779 jatom = max(task%iatom, task%jatom)
780 cell_b = merge(-task%cell, task%cell, task%iatom > task%jatom)
781 ibc = jkind + nkind*(kkind - 1)
782 IF (.NOT. has_intac(ibc)) cycle
783 CALL get_alist(oce%intac(ibc), alist_bc, jatom)
784 IF (.NOT. ASSOCIATED(alist_bc)) cycle
785 factor = merge(0.5_dp, 1.0_dp, iatom == jatom)
786
787 DO kbc = 1, alist_bc%nclist
788 clist_b => alist_bc%clist(kbc)
789 n_cont_b = clist_b%nsgf_cnt
790 IF (n_cont_b == 0) cycle
791 katom = clist_b%catom
792 DO kac = kac_lo, kac_hi
793 IF (alist_ac%clist(kac)%catom /= katom) cycle
794 IF (all(cell_b + clist_b%cell == alist_ac%clist(kac)%cell)) EXIT
795 END DO
796 IF (kac > kac_hi) cycle
797 clist_a => alist_ac%clist(kac)
798 n_cont_a = clist_a%nsgf_cnt
799 IF (n_cont_a == 0 .OR. pmax*clist_b%maxac*clist_a%maxac < eps_cpc) cycle
800
801 list_a => clist_a%sgf_list
802 list_b => clist_b%sgf_list
803 dista = (iatom /= katom .OR. any(clist_a%cell /= 0))
804 distb = (jatom /= katom .OR. any(clist_b%cell /= 0))
805 c_coeff_ss_b => clist_b%acint(:, :, 1)
806 IF (.NOT. distb) THEN
807 c_coeff_ss_a => clist_a%acint(:, :, 1)
808 c_coeff_hh_a => c_coeff_ss_a
809 IF (.NOT. dista) c_coeff_hh_a => clist_a%achint(:, :, 1)
810 c_coeff_hh_b => clist_b%achint(:, :, 1)
811 END IF
812
813 DO ispin = 1, nspins
814 CALL alist_pre_align_blk(nb_pblk(ispin, inb)%r_coef, &
815 SIZE(nb_pblk(ispin, inb)%r_coef, 1), p_matrix, SIZE(p_matrix, 1), &
816 list_a, n_cont_a, list_b, n_cont_b)
817 IF (distb) THEN
818 beta = merge(1.0_dp, 0.0_dp, w_touched(kac, ispin))
819 w_touched(kac, ispin) = .true.
820 CALL dgemm('N', 'N', n_cont_a, nsoctot, n_cont_b, factor, p_matrix, SIZE(p_matrix, 1), &
821 c_coeff_ss_b, n_cont_b, beta, w_buf(w_offset(kac):, ispin), n_cont_a)
822 cycle
823 END IF
824 r_coef_h => rho_atom_set(katom)%cpc_h(ispin)%r_coef
825 r_coef_s => rho_atom_set(katom)%cpc_s(ispin)%r_coef
826!$ CALL omp_set_lock(locks((katom - 1)*nspins + ispin))
827 CALL proj_blk(c_coeff_hh_a, c_coeff_ss_a, n_cont_a, c_coeff_hh_b, c_coeff_ss_b, n_cont_b, &
828 p_matrix, SIZE(p_matrix, 1), r_coef_h, r_coef_s, nsoctot, len_pc1, &
829 SIZE(proj_work2), factor, .false., proj_work1, proj_work2)
830!$ CALL omp_unset_lock(locks((katom - 1)*nspins + ispin))
831 END DO
832 END DO
833 END DO
834
835 DO kac = kac_lo, kac_hi
836 clist_a => alist_ac%clist(kac)
837 n_cont_a = clist_a%nsgf_cnt
838 IF (n_cont_a == 0) cycle
839 katom = clist_a%catom
840 dista = (iatom /= katom .OR. any(clist_a%cell /= 0))
841 c_coeff_ss_a => clist_a%acint(:, :, 1)
842 DO ispin = 1, nspins
843 IF (.NOT. w_touched(kac, ispin)) cycle
844 r_coef_h => rho_atom_set(katom)%cpc_h(ispin)%r_coef
845 r_coef_s => rho_atom_set(katom)%cpc_s(ispin)%r_coef
846 CALL dgemm('T', 'N', nsoctot, nsoctot, n_cont_a, 1.0_dp, c_coeff_ss_a, n_cont_a, &
847 w_buf(w_offset(kac):, ispin), n_cont_a, 0.0_dp, proj_work2, SIZE(proj_work2, 1))
848!$ CALL omp_set_lock(locks((katom - 1)*nspins + ispin))
849 r_coef_s = r_coef_s + proj_work2(1:nsoctot, 1:nsoctot)
850 IF (dista) r_coef_h = r_coef_h + proj_work2(1:nsoctot, 1:nsoctot)
851 IF (.NOT. dista) CALL dgemm('T', 'N', nsoctot, nsoctot, n_cont_a, 1.0_dp, &
852 clist_a%achint(:, :, 1), n_cont_a, w_buf(w_offset(kac):, ispin), &
853 n_cont_a, 1.0_dp, r_coef_h, SIZE(r_coef_h, 1))
854!$ CALL omp_unset_lock(locks((katom - 1)*nspins + ispin))
855 END DO
856 END DO
857 END IF
858 kac_lo = kac_hi + 1
859 END DO
860 END DO
861 END DO
862!$OMP END DO
863 ! Wait for all threads to finish the loop before locks can be freed
864!$OMP BARRIER
865
866!$OMP DO
867!$ DO lock = 1, number_of_locks
868!$ call omp_destroy_lock(locks(lock))
869!$ END DO
870!$OMP END DO
871!$OMP SINGLE
872!$ DEALLOCATE (locks)
873!$OMP END SINGLE NOWAIT
874
875 DEALLOCATE (nb_pblk, nb_pmax, p_matrix, proj_work1, proj_work2, w_buf, w_offset, w_touched)
876!$OMP END PARALLEL
877
878 DEALLOCATE (ia_ptr, slot_order)
879 CALL reduce_symmetrize_cpc(rho_atom_set, natom, nspins, max_gau, para_env)
880
881 DEALLOCATE (basis_set_list, paw_kind, nsatbas_kind, has_intac)
882
883 CALL timestop(handle)
884
885 END SUBROUTINE calculate_rho_atom_coeff
886
887! **************************************************************************************************
888!> \brief ...
889!> \param rho_atom_set the type to initialize
890!> \param atomic_kind_set list of atomic kinds
891!> \param qs_kind_set the kind set from which to take quantum numbers and basis info
892!> \param dft_control DFT control type
893!> \param para_env parallel environment
894!> \par History:
895!> - Generalised by providing the rho_atom_set and the qs_kind_set 12.2019 (A.Bussy)
896! **************************************************************************************************
897 SUBROUTINE init_rho_atom(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
898
899 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
900 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
901 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
902 TYPE(dft_control_type), POINTER :: dft_control
903 TYPE(mp_para_env_type), POINTER :: para_env
904
905 CHARACTER(len=*), PARAMETER :: routinen = 'init_rho_atom'
906
907 CHARACTER(LEN=4) :: my_ikind, my_la, my_llmax
908 INTEGER :: handle, ikind, la, ll, llmax, &
909 lmax_sphere, max_s_harm, max_s_set, &
910 maxl, maxlgto, maxs, na, nat, natom, &
911 nr, nspins, quadrature
912 INTEGER, DIMENSION(:), POINTER :: atom_list
913 LOGICAL :: paw_atom
914 REAL(dp), DIMENSION(:, :, :), POINTER :: my_cg
915 TYPE(gapw_control_type), POINTER :: gapw_control
916 TYPE(grid_atom_type), POINTER :: grid_atom
917 TYPE(gto_basis_set_type), POINTER :: basis_1c_set
918 TYPE(harmonics_atom_type), POINTER :: harmonics
919
920 CALL timeset(routinen, handle)
921
922 NULLIFY (basis_1c_set)
923 NULLIFY (my_cg, grid_atom, harmonics, atom_list)
924
925 cpassert(ASSOCIATED(atomic_kind_set))
926 cpassert(ASSOCIATED(dft_control))
927 cpassert(ASSOCIATED(para_env))
928 cpassert(ASSOCIATED(qs_kind_set))
929
930 CALL get_atomic_kind_set(atomic_kind_set, natom=natom)
931
932 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto, basis_type="GAPW_1C")
933
934 nspins = dft_control%nspins
935 gapw_control => dft_control%qs_control%gapw_control
936
937 lmax_sphere = gapw_control%lmax_sphere
938
939 llmax = min(lmax_sphere, 2*maxlgto)
940 max_s_harm = nsoset(llmax)
941 max_s_set = nsoset(maxlgto)
942
943! *** calculate the Gaunt coefficients up to the maxl ***
944 CALL real_gaunt_coefficients(my_cg, maxlgto, maxlgto, llmax)
945
946! *** initialize the Lebedev grids ***
947 CALL init_lebedev_grids()
948 quadrature = gapw_control%quadrature
949
950 DO ikind = 1, SIZE(atomic_kind_set)
951 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=nat)
952 CALL get_qs_kind(qs_kind_set(ikind), &
953 paw_atom=paw_atom, &
954 grid_atom=grid_atom, &
955 harmonics=harmonics, &
956 ngrid_rad=nr, ngrid_ang=na)
957
958! *** determine the Lebedev grid for this kind ***
959
961 na = lebedev_grid(ll)%n
962 la = lebedev_grid(ll)%l
963 grid_atom%ng_sphere = na
964 grid_atom%nr = nr
965
966 IF (llmax > la) THEN
967 IF (para_env%is_source()) THEN
968 WRITE (my_la, "(I4)") la
969 WRITE (my_ikind, "(I4)") ikind
970 WRITE (my_llmax, "(I4)") llmax
971 CALL cp_warn(__location__, &
972 "The Lebedev grid has been built for angular momentum l up "// &
973 "to "//trim(my_la)//" for atom kind "//trim(my_ikind)//", "// &
974 "but the max l of spherical harmonics "//trim(my_llmax)//" is "// &
975 "larger and good integration cannot be guaranteed")
976 END IF
977 END IF
978
979! *** calculate the radial grid ***
980 CALL create_grid_atom(grid_atom, nr, na, llmax, ll, quadrature)
981
982! *** calculate the spherical harmonics on the grid ***
983
984 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_1c_set, basis_type="GAPW_1C")
985 CALL get_gto_basis_set(gto_basis_set=basis_1c_set, maxl=maxl)
986 maxs = nsoset(maxl)
987 CALL create_harmonics_atom(harmonics, &
988 my_cg, na, llmax, maxs, max_s_harm, ll, grid_atom%wa, &
989 grid_atom%azi, grid_atom%pol)
990 CALL get_maxl_cg(harmonics, basis_1c_set, llmax, max_s_harm)
991
992 END DO
993
995 DEALLOCATE (my_cg)
996
997 CALL allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
998
999 CALL timestop(handle)
1000
1001 END SUBROUTINE init_rho_atom
1002
1003! **************************************************************************************************
1004!> \brief ...
1005!> \param rho_atom_set ...
1006!> \param atomic_kind_set list of atomic kinds
1007!> \param qs_kind_set the kind set from which to take quantum numbers and basis info
1008!> \param dft_control DFT control type
1009!> \param para_env parallel environment
1010! **************************************************************************************************
1011 SUBROUTINE allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
1012
1013 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
1014 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1015 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1016 TYPE(dft_control_type), POINTER :: dft_control
1017 TYPE(mp_para_env_type), POINTER :: para_env
1018
1019 CHARACTER(len=*), PARAMETER :: routinen = 'allocate_rho_atom_internals'
1020
1021 INTEGER :: bo(2), handle, iat, iatom, ikind, ispin, &
1022 max_iso_not0, maxso, mepos, nat, &
1023 natom, nsatbas, nset, nsotot, nspins, &
1024 num_pe
1025 INTEGER, DIMENSION(:), POINTER :: atom_list
1026 LOGICAL :: paw_atom
1027 TYPE(gto_basis_set_type), POINTER :: basis_1c
1028 TYPE(harmonics_atom_type), POINTER :: harmonics
1029
1030 CALL timeset(routinen, handle)
1031
1032 cpassert(ASSOCIATED(atomic_kind_set))
1033 cpassert(ASSOCIATED(dft_control))
1034 cpassert(ASSOCIATED(para_env))
1035 cpassert(ASSOCIATED(qs_kind_set))
1036
1037 CALL get_atomic_kind_set(atomic_kind_set, natom=natom)
1038
1039 nspins = dft_control%nspins
1040
1041 IF (ASSOCIATED(rho_atom_set)) THEN
1042 CALL deallocate_rho_atom_set(rho_atom_set)
1043 END IF
1044 ALLOCATE (rho_atom_set(natom))
1045
1046 DO ikind = 1, SIZE(atomic_kind_set)
1047
1048 NULLIFY (atom_list, harmonics)
1049 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=nat)
1050 CALL get_qs_kind(qs_kind_set(ikind), &
1051 paw_atom=paw_atom, &
1052 harmonics=harmonics)
1053
1054 IF (paw_atom) THEN
1055 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_1c, basis_type="GAPW_1C")
1056 CALL get_gto_basis_set(gto_basis_set=basis_1c, nset=nset, maxso=maxso)
1057 nsotot = nset*maxso
1058 CALL get_paw_basis_info(basis_1c, nsatbas=nsatbas)
1059 END IF
1060
1061 max_iso_not0 = harmonics%max_iso_not0
1062 DO iat = 1, nat
1063 iatom = atom_list(iat)
1064 ! *** allocate the radial density for each LM,for each atom ***
1065
1066 ALLOCATE (rho_atom_set(iatom)%rho_rad_h(nspins))
1067 ALLOCATE (rho_atom_set(iatom)%rho_rad_s(nspins))
1068 ALLOCATE (rho_atom_set(iatom)%vrho_rad_h(nspins))
1069 ALLOCATE (rho_atom_set(iatom)%vrho_rad_s(nspins))
1070
1071 ALLOCATE (rho_atom_set(iatom)%cpc_h(nspins), &
1072 rho_atom_set(iatom)%cpc_s(nspins), &
1073 rho_atom_set(iatom)%drho_rad_h(nspins), &
1074 rho_atom_set(iatom)%drho_rad_s(nspins), &
1075 rho_atom_set(iatom)%rho_rad_h_d(3, nspins), &
1076 rho_atom_set(iatom)%rho_rad_s_d(3, nspins))
1077 ALLOCATE (rho_atom_set(iatom)%int_scr_h(nspins), &
1078 rho_atom_set(iatom)%int_scr_s(nspins))
1079
1080 IF (paw_atom) THEN
1081 DO ispin = 1, nspins
1082 ALLOCATE (rho_atom_set(iatom)%cpc_h(ispin)%r_coef(1:nsatbas, 1:nsatbas), &
1083 rho_atom_set(iatom)%cpc_s(ispin)%r_coef(1:nsatbas, 1:nsatbas))
1084 ALLOCATE (rho_atom_set(iatom)%int_scr_h(ispin)%r_coef(1:nsatbas, 1:nsatbas), &
1085 rho_atom_set(iatom)%int_scr_s(ispin)%r_coef(1:nsatbas, 1:nsatbas))
1086
1087 rho_atom_set(iatom)%cpc_h(ispin)%r_coef = 0.0_dp
1088 rho_atom_set(iatom)%cpc_s(ispin)%r_coef = 0.0_dp
1089 END DO
1090 END IF
1091
1092 END DO ! iat
1093
1094 num_pe = para_env%num_pe
1095 mepos = para_env%mepos
1096 bo = get_limit(nat, num_pe, mepos)
1097 DO iat = bo(1), bo(2)
1098 iatom = atom_list(iat)
1099 ALLOCATE (rho_atom_set(iatom)%ga_Vlocal_gb_h(nspins), &
1100 rho_atom_set(iatom)%ga_Vlocal_gb_s(nspins))
1101 IF (paw_atom) THEN
1102 DO ispin = 1, nspins
1103 CALL reallocate(rho_atom_set(iatom)%ga_Vlocal_gb_h(ispin)%r_coef, &
1104 1, nsotot, 1, nsotot)
1105 CALL reallocate(rho_atom_set(iatom)%ga_Vlocal_gb_s(ispin)%r_coef, &
1106 1, nsotot, 1, nsotot)
1107
1108 rho_atom_set(iatom)%ga_Vlocal_gb_h(ispin)%r_coef = 0.0_dp
1109 rho_atom_set(iatom)%ga_Vlocal_gb_s(ispin)%r_coef = 0.0_dp
1110 END DO
1111 END IF
1112
1113 END DO ! iat
1114
1115 END DO
1116
1117 CALL timestop(handle)
1118
1119 END SUBROUTINE allocate_rho_atom_internals
1120
1121! **************************************************************************************************
1122!> \brief ...
1123!> \param rho_atom_set ...
1124!> \param iatom ...
1125!> \param ispin ...
1126!> \param nr ...
1127!> \param max_iso_not0 ...
1128! **************************************************************************************************
1129 SUBROUTINE allocate_rho_atom_rad(rho_atom_set, iatom, ispin, nr, max_iso_not0)
1130
1131 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
1132 INTEGER, INTENT(IN) :: iatom, ispin, nr, max_iso_not0
1133
1134 CHARACTER(len=*), PARAMETER :: routinen = 'allocate_rho_atom_rad'
1135
1136 INTEGER :: handle, j
1137
1138 CALL timeset(routinen, handle)
1139
1140 ALLOCATE (rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef(1:nr, 1:max_iso_not0), &
1141 rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef(1:nr, 1:max_iso_not0), &
1142 rho_atom_set(iatom)%vrho_rad_h(ispin)%r_coef(1:nr, 1:max_iso_not0), &
1143 rho_atom_set(iatom)%vrho_rad_s(ispin)%r_coef(1:nr, 1:max_iso_not0))
1144
1145 rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef = 0.0_dp
1146 rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef = 0.0_dp
1147 rho_atom_set(iatom)%vrho_rad_h(ispin)%r_coef = 0.0_dp
1148 rho_atom_set(iatom)%vrho_rad_s(ispin)%r_coef = 0.0_dp
1149
1150 ALLOCATE (rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef(nr, max_iso_not0), &
1151 rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef(nr, max_iso_not0))
1152 rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef = 0.0_dp
1153 rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef = 0.0_dp
1154
1155 DO j = 1, 3
1156 ALLOCATE (rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef(nr, max_iso_not0), &
1157 rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef(nr, max_iso_not0))
1158 rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef = 0.0_dp
1159 rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef = 0.0_dp
1160 END DO
1161
1162 CALL timestop(handle)
1163
1164 END SUBROUTINE allocate_rho_atom_rad
1165
1166! **************************************************************************************************
1167!> \brief ...
1168!> \param rho_atom_set ...
1169!> \param iatom ...
1170!> \param ispin ...
1171! **************************************************************************************************
1172 SUBROUTINE set2zero_rho_atom_rad(rho_atom_set, iatom, ispin)
1173
1174 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
1175 INTEGER, INTENT(IN) :: iatom, ispin
1176
1177 INTEGER :: j
1178
1179 rho_atom_set(iatom)%rho_rad_h(ispin)%r_coef = 0.0_dp
1180 rho_atom_set(iatom)%rho_rad_s(ispin)%r_coef = 0.0_dp
1181
1182 rho_atom_set(iatom)%vrho_rad_h(ispin)%r_coef = 0.0_dp
1183 rho_atom_set(iatom)%vrho_rad_s(ispin)%r_coef = 0.0_dp
1184
1185 rho_atom_set(iatom)%drho_rad_h(ispin)%r_coef = 0.0_dp
1186 rho_atom_set(iatom)%drho_rad_s(ispin)%r_coef = 0.0_dp
1187
1188 DO j = 1, 3
1189 rho_atom_set(iatom)%rho_rad_h_d(j, ispin)%r_coef = 0.0_dp
1190 rho_atom_set(iatom)%rho_rad_s_d(j, ispin)%r_coef = 0.0_dp
1191 END DO
1192
1193 END SUBROUTINE set2zero_rho_atom_rad
1194
1195! **************************************************************************************************
1196!> \brief Symmetrize PAW cpc_h/cpc_s blocks and MPI-sum packed lower triangles in L2-sized chunks.
1197!> \param rho_atom_set atomic PAW density set holding cpc_h and cpc_s blocks
1198!> \param natom total number of atoms
1199!> \param nspins number of spin components
1200!> \param max_gau maximum size of the one-center basis
1201!> \param para_env MPI parallel environment
1202! **************************************************************************************************
1203 SUBROUTINE reduce_symmetrize_cpc(rho_atom_set, natom, nspins, max_gau, para_env)
1204 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
1205 INTEGER, INTENT(IN) :: natom, nspins, max_gau
1206 TYPE(mp_para_env_type), POINTER :: para_env
1207
1208 INTEGER :: b_end, b_lo, iat, ispin, jj, m1, n, off, &
1209 p
1210 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: buf
1211 REAL(kind=dp), DIMENSION(:, :), POINTER :: r_h, r_s
1212
1213 ALLOCATE (buf(max(l2_chunk_dp, nspins*max_gau*(max_gau + 1))))
1214 b_lo = 1
1215 DO WHILE (b_lo <= natom)
1216 b_end = natom
1217 DO p = 1, 2
1218 off = 0
1219 DO iat = b_lo, b_end
1220 IF (.NOT. ASSOCIATED(rho_atom_set(iat)%cpc_h(1)%r_coef)) cycle
1221 m1 = SIZE(rho_atom_set(iat)%cpc_h(1)%r_coef, 1)
1222 IF (p == 1 .AND. off > 0 .AND. off + nspins*m1*(m1 + 1) > SIZE(buf)) EXIT
1223 DO ispin = 1, nspins
1224 r_h => rho_atom_set(iat)%cpc_h(ispin)%r_coef
1225 r_s => rho_atom_set(iat)%cpc_s(ispin)%r_coef
1226 DO jj = 1, m1
1227 n = m1 - jj + 1
1228 IF (p == 1) buf(off + 1:off + n) = r_h(jj:m1, jj) + r_h(jj, jj:m1)
1229 IF (p == 1) buf(off + n + 1:off + 2*n) = r_s(jj:m1, jj) + r_s(jj, jj:m1)
1230 IF (p == 2) r_h(jj:m1, jj) = buf(off + 1:off + n)
1231 IF (p == 2) r_h(jj, jj:m1) = buf(off + 1:off + n)
1232 IF (p == 2) r_s(jj:m1, jj) = buf(off + n + 1:off + 2*n)
1233 IF (p == 2) r_s(jj, jj:m1) = buf(off + n + 1:off + 2*n)
1234 off = off + 2*n
1235 END DO
1236 END DO
1237 END DO
1238 b_end = iat - 1
1239 IF (p == 1 .AND. off > 0) CALL para_env%sum(buf(1:off))
1240 END DO
1241 b_lo = b_end + 1
1242 END DO
1243 DEALLOCATE (buf)
1244 END SUBROUTINE reduce_symmetrize_cpc
1245
1246END MODULE qs_rho_atom_methods
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
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.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
Expansion of the product of two real spherical harmonics in real spherical harmonics.
subroutine, public real_gaunt_coefficients(my_cg, maxl1, maxl2, llmax, cg_none0_list, ncg_none0)
Calculate the expansion of the product of two real spherical harmonics in real spherical harmonics,...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, lattice_fft)
Retrieve information from a kpoint environment.
Generation of the spherical Lebedev grids. All Lebedev grids were generated with a precision of at le...
Definition lebedev.F:57
subroutine, public deallocate_lebedev_grids()
...
Definition lebedev.F:324
type(oh_grid), dimension(nlg), target, public lebedev_grid
Definition lebedev.F:85
integer function, public get_number_of_lebedev_grid(l, n)
Get the number of the Lebedev grid, which has the requested angular momentum quantnum number l or siz...
Definition lebedev.F:114
subroutine, public init_lebedev_grids()
Load the coordinates and weights of the nonredundant Lebedev grid points.
Definition lebedev.F:344
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), parameter, public fourpi
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nsoset
integer, dimension(:, :), allocatable, public indso
subroutine, public get_paw_basis_info(basis_1c, o2nindex, n2oindex, nsatbas)
Return some info on the PAW basis derived from a GTO basis set.
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.
subroutine, public create_grid_atom(grid_atom, nr, na, llmax, ll, quadrature)
...
subroutine, public get_maxl_cg(harmonics, orb_basis, llmax, max_s_harm)
...
subroutine, public create_harmonics_atom(harmonics, my_cg, na, llmax, maxs, max_s_harm, ll, wa, azi, pol)
...
Define the quickstep kind type and their sub types.
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_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
Define the neighbor list data types and the corresponding functionality.
Routines for the construction of the coefficients for the expansion of the atomic densities rho1_hard...
subroutine, public proj_blk(h_a, s_a, na, h_b, s_b, nb, blk, ldb, proj_h, proj_s, nso, len1, len2, fac, distab, work1, work2)
Project a matrix block onto the local atomic functions.
subroutine, public calculate_rho_atom(para_env, rho_atom_set, qs_kind, atom_list, natom, nspins, tot_rho1_h, tot_rho1_s, rho1_h_spin, rho1_s_spin, rho1_h_aspin, rho1_s_aspin)
...
subroutine, public allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
subroutine, public replicate_rho_atom_radial(para_env, rho_atom_set, qs_kind, atom_list, natom, nspins)
Replicate the radial hard/soft density data needed to evaluate one-center tails on rank-local target ...
subroutine, public init_rho_atom(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
subroutine, public calculate_rho_atom_coeff(qs_env, rho_ao, rho_atom_set, qs_kind_set, oce, sab, para_env)
...
subroutine, public deallocate_rho_atom_set(rho_atom_set)
...
General overlap type integrals containers.
subroutine, public alist_pre_align_blk(blk_in, ldin, blk_out, ldout, ilist, in, jlist, jn)
...
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
Calculates special integrals.
Definition whittaker.F:12
subroutine, public whittaker_c0a(wc, r, expa, erfa, alpha, l1, l2, n)
int(y^(2+l1+l2) * exp(-alpha*y*y),y=0..x) / x^(l2+1); wc(:) :: output r(:) :: coordinate expa(:) :: e...
Definition whittaker.F:52
subroutine, public whittaker_ci(wc, r, expa, alpha, l, n)
int(y^(l+1) * exp(-alpha*y*y),y=x..infinity);
Definition whittaker.F:340
Provides all information about an atomic kind.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.