(git:3d5d2e5)
Loading...
Searching...
No Matches
qs_ks_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 Kohn-Sham matrix contributions
10!> coming from local atomic densities
11! **************************************************************************************************
13
14 USE ao_util, ONLY: trace_r_axb
24 USE kinds, ONLY: dp
25 USE kpoint_types, ONLY: get_kpoint_info,&
31 USE qs_kind_types, ONLY: get_qs_kind,&
36 USE qs_oce_methods, ONLY: prj_gather
46 USE util, ONLY: get_limit
48 USE virial_types, ONLY: virial_type
49
50!$ USE OMP_LIB, ONLY: omp_lock_kind, &
51!$ omp_init_lock, omp_set_lock, &
52!$ omp_unset_lock, omp_destroy_lock
53
54#include "./base/base_uses.f90"
55
56 IMPLICIT NONE
57
58 PRIVATE
59
60 CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'qs_ks_atom'
61 INTEGER, PARAMETER, PRIVATE :: l2_chunk_dp = 16000
62
63 PUBLIC :: update_ks_atom
64
65CONTAINS
66
67! **************************************************************************************************
68!> \brief Sum zero-padded rank-owned PAW potential blocks across MPI ranks in L2-sized chunks.
69!> \param my_rho_atom atomic PAW data holding local potential integral blocks
70!> \param natom total number of atoms
71!> \param nspins number of spin components
72!> \param max_gau maximum size of the one-center basis
73!> \param para_env MPI parallel environment
74! **************************************************************************************************
75 SUBROUTINE replicate_int_scr(my_rho_atom, natom, nspins, max_gau, para_env)
76 TYPE(rho_atom_type), DIMENSION(:), POINTER :: my_rho_atom
77 INTEGER, INTENT(IN) :: natom, nspins, max_gau
78 TYPE(mp_para_env_type), POINTER :: para_env
79
80 INTEGER :: b_end, b_lo, iat, ispin, jj, m1, off, p
81 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: buf
82 REAL(KIND=dp), DIMENSION(:, :), POINTER :: scr_h, scr_s
83
84 ALLOCATE (buf(max(l2_chunk_dp, 2*nspins*max_gau*max_gau)))
85 b_lo = 1
86 DO WHILE (b_lo <= natom)
87 b_end = natom
88 DO p = 1, 2
89 off = 0
90 DO iat = b_lo, b_end
91 IF (.NOT. ASSOCIATED(my_rho_atom(iat)%int_scr_h(1)%r_coef)) cycle
92 m1 = SIZE(my_rho_atom(iat)%int_scr_h(1)%r_coef, 1)
93 IF (p == 1 .AND. off > 0 .AND. off + 2*nspins*m1*m1 > SIZE(buf)) EXIT
94 DO ispin = 1, nspins
95 scr_h => my_rho_atom(iat)%int_scr_h(ispin)%r_coef
96 scr_s => my_rho_atom(iat)%int_scr_s(ispin)%r_coef
97 DO jj = 1, m1
98 IF (p == 1) buf(off + 1:off + m1) = scr_h(1:m1, jj)
99 IF (p == 1) buf(off + m1 + 1:off + 2*m1) = scr_s(1:m1, jj)
100 IF (p == 2) scr_h(1:m1, jj) = buf(off + 1:off + m1)
101 IF (p == 2) scr_s(1:m1, jj) = buf(off + m1 + 1:off + 2*m1)
102 off = off + 2*m1
103 END DO
104 END DO
105 END DO
106 b_end = iat - 1
107 IF (p == 1 .AND. off > 0) CALL para_env%sum(buf(1:off))
108 END DO
109 b_lo = b_end + 1
110 END DO
111 DEALLOCATE (buf)
112 END SUBROUTINE replicate_int_scr
113
114! **************************************************************************************************
115!> \brief The correction to the KS matrix due to the GAPW local terms to the hartree and
116!> XC contributions is here added. The correspondig forces contribution are also calculated
117!> if required. Each sparse-matrix block A-B is corrected by all the atomic contributions
118!> centered on atoms C for which the triplet A-C-B exists (they are close enough)
119!> To this end special lists are used
120!> \param qs_env qs environment, for the lists, the contraction coefficients and the
121!> pre calculated integrals of the potential with the atomic orbitals
122!> \param ksmat KS matrix, sparse matrix
123!> \param pmat density matrix, sparse matrix, needed only for the forces
124!> \param forces switch for the calculation of the forces on atoms
125!> \param tddft switch for TDDFT linear response
126!> \param rho_atom_external ...
127!> \param kind_set_external ...
128!> \param oce_external ...
129!> \param sab_external ...
130!> \param kscale ...
131!> \param kintegral ...
132!> \param kforce ...
133!> \param fscale ...
134!> \par History
135!> created [MI]
136!> the loop over the spins is done internally [03-05,MI]
137!> Rewrite using new OCE matrices [08.02.09, jhu]
138!> Add OpenMP [Apr 2016, EPCC]
139!> Allow for external kind_set, rho_atom_set, oce, sab 12.2019 (A. Bussy)
140! **************************************************************************************************
141 SUBROUTINE update_ks_atom(qs_env, ksmat, pmat, forces, tddft, rho_atom_external, &
142 kind_set_external, oce_external, sab_external, kscale, &
143 kintegral, kforce, fscale)
144
145 TYPE(qs_environment_type), POINTER :: qs_env
146 TYPE(dbcsr_p_type), DIMENSION(*), INTENT(INOUT) :: ksmat, pmat
147 LOGICAL, INTENT(IN) :: forces
148 LOGICAL, INTENT(IN), OPTIONAL :: tddft
149 TYPE(rho_atom_type), DIMENSION(:), OPTIONAL, &
150 POINTER :: rho_atom_external
151 TYPE(qs_kind_type), DIMENSION(:), OPTIONAL, &
152 POINTER :: kind_set_external
153 TYPE(oce_matrix_type), OPTIONAL, POINTER :: oce_external
154 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
155 OPTIONAL, POINTER :: sab_external
156 REAL(kind=dp), INTENT(IN), OPTIONAL :: kscale, kintegral, kforce
157 REAL(kind=dp), DIMENSION(2), INTENT(IN), OPTIONAL :: fscale
158
159 CHARACTER(LEN=*), PARAMETER :: routinen = 'update_ks_atom'
160
161 INTEGER :: bo(2), dir, handle, i, ia_kind, iac, iat, iatom, ibc, ikind, img, inb, ip, ispin, &
162 ja_kind, jatom, jkind, k_total, ka_kind, kac, kac_hi, kac_lo, katom, kbc, kkind, &
163 ku_alloc, max_gau, max_nb, max_nclist, max_nsgf, n_cont_a, n_cont_b, n_nb, nat, natom, &
164 nimages, nkind, nl_size, nsoctot, nspins, slot
165 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom_of_kind, ia_ptr, ia_work, k_offset, &
166 slot_order
167 INTEGER, DIMENSION(3) :: cell_b
168 INTEGER, DIMENSION(:), POINTER :: atom_list, list_a, list_b
169 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index
170 LOGICAL :: dista, do_forces, found, my_tddft, &
171 paw_atom, use_virial
172 LOGICAL, ALLOCATABLE, DIMENSION(:) :: has_intac, paw_kind
173 LOGICAL, ALLOCATABLE, DIMENSION(:, :) :: u_touched
174 REAL(kind=dp) :: beta, factor1, factor2, ieqj, trace
175 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: c_int_h, c_int_s
176 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: a_matrix, coc, f_katom, k_buf, p_matrix, &
177 u_buf
178 REAL(kind=dp), DIMENSION(2) :: force_fac
179 REAL(kind=dp), DIMENSION(3) :: f_jatom, fb_triple, rac, rbc
180 REAL(kind=dp), DIMENSION(3, 3) :: force_tmp, pv_virial_thread
181 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: c_coeff_hh_a, c_coeff_hh_b, &
182 c_coeff_ss_a, c_coeff_ss_b
183 TYPE(alist_type), POINTER :: alist_ac, alist_bc
184 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
185 TYPE(clist_type), POINTER :: clist_a, clist_b
186 TYPE(cp_2d_r_p_type), ALLOCATABLE, DIMENSION(:, :) :: nb_hblk, nb_pblk
187 TYPE(dft_control_type), POINTER :: dft_control
188 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_list
189 TYPE(gto_basis_set_type), POINTER :: basis_set_a
190 TYPE(kpoint_type), POINTER :: kpoints
191 TYPE(mp_para_env_type), POINTER :: para_env
192 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
193 POINTER :: my_sab
194 TYPE(neighbor_list_task_type), POINTER :: task
195 TYPE(oce_matrix_type), POINTER :: my_oce
196 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
197 TYPE(qs_kind_type), DIMENSION(:), POINTER :: my_kind_set
198 TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: int_local_h, int_local_s
199 TYPE(rho_atom_type), DIMENSION(:), POINTER :: my_rho_atom
200 TYPE(virial_type), POINTER :: virial
201
202!$ INTEGER(kind=omp_lock_kind), ALLOCATABLE, DIMENSION(:) :: locks
203!$ INTEGER :: lock_num
204
205 CALL timeset(routinen, handle)
206
207 NULLIFY (my_kind_set, atomic_kind_set, force, my_oce, para_env, my_rho_atom, my_sab, dft_control)
208
209 CALL get_qs_env(qs_env=qs_env, &
210 qs_kind_set=my_kind_set, &
211 atomic_kind_set=atomic_kind_set, &
212 force=force, &
213 oce=my_oce, &
214 para_env=para_env, &
215 rho_atom_set=my_rho_atom, &
216 virial=virial, &
217 sab_orb=my_sab, &
218 dft_control=dft_control)
219
220 nspins = dft_control%nspins
221 nimages = dft_control%nimages
222
223 factor1 = 1.0_dp
224 factor2 = 1.0_dp
225
226 !deal with externals
227 my_tddft = .false.
228 IF (PRESENT(tddft)) my_tddft = tddft
229 IF (my_tddft) THEN
230 IF (nspins == 1) factor1 = 2.0_dp
231 cpassert(nimages == 1)
232 END IF
233 IF (PRESENT(kscale)) THEN
234 factor1 = factor1*kscale
235 factor2 = factor2*kscale
236 END IF
237 IF (PRESENT(kintegral)) factor1 = kintegral
238 IF (PRESENT(kforce)) factor2 = kforce
239 force_fac = 1.0_dp
240 IF (PRESENT(fscale)) force_fac(:) = fscale(:)
241
242 IF (PRESENT(rho_atom_external)) my_rho_atom => rho_atom_external
243 IF (PRESENT(kind_set_external)) my_kind_set => kind_set_external
244 IF (PRESENT(oce_external)) my_oce => oce_external
245 IF (PRESENT(sab_external)) my_sab => sab_external
246
247 ! kpoint images
248 NULLIFY (cell_to_index)
249 IF (nimages > 1) THEN
250 CALL get_qs_env(qs_env=qs_env, kpoints=kpoints)
251 CALL get_kpoint_info(kpoint=kpoints, cell_to_index=cell_to_index)
252 END IF
253
254 CALL get_atomic_kind_set(atomic_kind_set, natom=natom)
255 CALL get_qs_kind_set(my_kind_set, maxsgf=max_nsgf, maxgtops=max_gau, basis_type="GAPW_1C")
256
257 IF (forces) THEN
258 CALL get_atomic_kind_set(atomic_kind_set, atom_of_kind=atom_of_kind)
259 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
260 ELSE
261 use_virial = .false.
262 END IF
263
264 pv_virial_thread(:, :) = 0.0_dp ! always initialize to avoid floating point exceptions in OMP REDUCTION
265
266 nkind = SIZE(my_kind_set, 1)
267 ! Collect the local potential contributions from all the processors
268 associate(mepos => para_env%mepos, num_pe => para_env%num_pe)
269 DO ikind = 1, nkind
270 NULLIFY (atom_list)
271 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=nat)
272 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom)
273 IF (paw_atom) THEN
274 ! gather the atomic block integrals in a more compressed format
275 bo = get_limit(nat, num_pe, mepos)
276 DO iat = bo(1), bo(2)
277 iatom = atom_list(iat)
278 DO ispin = 1, nspins
279 CALL prj_gather(my_rho_atom(iatom)%ga_Vlocal_gb_h(ispin)%r_coef, &
280 my_rho_atom(iatom)%int_scr_h(ispin)%r_coef, my_kind_set(ikind))
281 CALL prj_gather(my_rho_atom(iatom)%ga_Vlocal_gb_s(ispin)%r_coef, &
282 my_rho_atom(iatom)%int_scr_s(ispin)%r_coef, my_kind_set(ikind))
283 END DO
284 END DO
285 ! Zero non-local PAW blocks and sum across ranks to replicate int_scr_h/s
286 DO ip = 1, merge(nat, 0, num_pe > 1)
287 IF (ip >= bo(1) .AND. ip <= bo(2)) cycle
288 DO ispin = 1, nspins
289 my_rho_atom(atom_list(ip))%int_scr_h(ispin)%r_coef = 0.0_dp
290 my_rho_atom(atom_list(ip))%int_scr_s(ispin)%r_coef = 0.0_dp
291 END DO
292 END DO
293 END IF
294 END DO
295 IF (num_pe > 1) CALL replicate_int_scr(my_rho_atom, natom, nspins, max_gau, para_env)
296 END associate
297
298 ALLOCATE (basis_set_list(nkind))
299 ALLOCATE (paw_kind(nkind), has_intac(nkind*nkind))
300 paw_kind(:) = .false.
301 has_intac(:) = .false.
302 DO ikind = 1, nkind
303 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_set_a, paw_atom=paw_kind(ikind))
304 IF (ASSOCIATED(basis_set_a)) THEN
305 basis_set_list(ikind)%gto_basis_set => basis_set_a
306 ELSE
307 NULLIFY (basis_set_list(ikind)%gto_basis_set)
308 END IF
309 END DO
310 DO ikind = 1, nkind*nkind
311 has_intac(ikind) = ASSOCIATED(my_oce%intac(ikind)%alist)
312 END DO
313
314 ku_alloc = max(1, l2_chunk_dp/nspins, max_nsgf*max_gau) ! 16k-double L2 chunk across spins
315 max_nclist = 1
316 DO iac = 1, nkind*nkind
317 IF (.NOT. has_intac(iac)) cycle
318 DO i = 1, SIZE(my_oce%intac(iac)%alist)
319 max_nclist = max(max_nclist, my_oce%intac(iac)%alist(i)%nclist)
320 END DO
321 END DO
322
323 cpassert(ASSOCIATED(my_sab(1)%nlist_task))
324 nl_size = my_sab(1)%nl_size
325 ALLOCATE (ia_ptr(natom + 1), ia_work(natom), slot_order(max(1, nl_size)))
326 ia_work(:) = 0
327 DO i = 1, 2
328 DO slot = 1, nl_size
329 task => my_sab(1)%nlist_task(slot)
330 IF (.NOT. ASSOCIATED(basis_set_list(task%ikind)%gto_basis_set)) cycle
331 IF (.NOT. ASSOCIATED(basis_set_list(task%jkind)%gto_basis_set)) cycle
332 iatom = min(task%iatom, task%jatom)
333 IF (i == 2) slot_order(ia_work(iatom)) = slot
334 ia_work(iatom) = ia_work(iatom) + 1
335 END DO
336 IF (i == 2) EXIT
337 ia_ptr(1) = 1
338 max_nb = max(1, maxval(ia_work))
339 DO iatom = 1, natom
340 ia_ptr(iatom + 1) = ia_ptr(iatom) + ia_work(iatom)
341 ia_work(iatom) = ia_ptr(iatom)
342 END DO
343 END DO
344 DEALLOCATE (ia_work)
345
346!$OMP PARALLEL DEFAULT(NONE) &
347!$OMP SHARED(natom, nkind, nspins, nimages, cell_to_index, ksmat, pmat, forces, max_gau, &
348!$OMP max_nsgf, max_nb, max_nclist, ku_alloc, ia_ptr, slot_order, my_sab, paw_kind, &
349!$OMP has_intac, my_oce, my_rho_atom, factor1, factor2, force_fac, use_virial, &
350!$OMP atom_of_kind, force, locks) &
351!$OMP PRIVATE(nb_hblk, nb_pblk, C_int_h, C_int_s, coc, a_matrix, p_matrix, k_buf, k_offset, &
352!$OMP u_buf, u_touched, f_katom, f_jatom, fb_triple, beta, dir, ieqj, trace, iatom, &
353!$OMP n_nb, ikind, TASK, inb, jatom, cell_b, img, ispin, found, kkind, iac, &
354!$OMP alist_ac, kac_lo, kac_hi, k_total, kac, clist_a, n_cont_a, nsoctot, katom, &
355!$OMP int_local_h, int_local_s, C_coeff_hh_a, C_coeff_ss_a, jkind, ibc, alist_bc, &
356!$OMP kbc, clist_b, n_cont_b, list_a, list_b, dista, C_coeff_hh_b, C_coeff_ss_b, &
357!$OMP rac, rbc, do_forces, force_tmp, ia_kind, ja_kind, ka_kind, lock_num) &
358!$OMP REDUCTION(+:pv_virial_thread)
359
360 ALLOCATE (nb_hblk(nspins, max_nb), nb_pblk(nspins, max_nb), k_buf(ku_alloc, nspins), &
361 k_offset(max_nclist), c_int_h(max(1, max_gau*max_nsgf)), &
362 c_int_s(max(1, max_gau*max_nsgf)), coc(max(1, max_gau), max(1, max_gau)), &
363 a_matrix(max(1, max_nsgf), max(1, max_nsgf)), p_matrix(max(1, max_nsgf), max(1, max_nsgf)))
364 IF (forces) ALLOCATE (u_buf(ku_alloc, nspins), u_touched(max_nclist, nspins), f_katom(3, max_nclist))
365
366 IF (forces) THEN
367!$OMP SINGLE
368!$ ALLOCATE (locks(natom*nkind))
369!$OMP END SINGLE
370
371!$OMP DO
372!$ do lock_num = 1, natom*nkind
373!$ call omp_init_lock(locks(lock_num))
374!$ end do
375!$OMP END DO
376 END IF
377
378!$OMP DO SCHEDULE(DYNAMIC, 1)
379 DO iatom = 1, natom
380 n_nb = ia_ptr(iatom + 1) - ia_ptr(iatom)
381 IF (n_nb == 0) cycle
382 task => my_sab(1)%nlist_task(slot_order(ia_ptr(iatom)))
383 ikind = merge(task%jkind, task%ikind, task%iatom > task%jatom)
384
385 DO inb = 1, n_nb
386 task => my_sab(1)%nlist_task(slot_order(ia_ptr(iatom) + inb - 1))
387 jatom = max(task%iatom, task%jatom)
388 img = 1
389 IF (nimages > 1) img = cell_to_index(task%cell(1), task%cell(2), task%cell(3))
390 cpassert(img > 0)
391 DO ispin = 1, nspins
392 CALL dbcsr_get_block_p(ksmat(nspins*(img - 1) + ispin)%matrix, iatom, jatom, nb_hblk(ispin, inb)%array, found)
393 cpassert(found)
394 IF (forces) THEN
395 CALL dbcsr_get_block_p(pmat(nspins*(img - 1) + ispin)%matrix, iatom, jatom, nb_pblk(ispin, inb)%array, found)
396 cpassert(found)
397 END IF
398 END DO
399 END DO
400
401 DO kkind = 1, nkind
402 IF (.NOT. paw_kind(kkind)) cycle
403 iac = ikind + nkind*(kkind - 1)
404 IF (.NOT. has_intac(iac)) cycle
405 CALL get_alist(my_oce%intac(iac), alist_ac, iatom)
406 IF (.NOT. ASSOCIATED(alist_ac)) cycle
407
408 ! Precompute K_a = C_a^h V_h - C_a^s V_s and accumulate U_a = sum_(B/=K) f P_AB C_b^s.
409 kac_lo = 1
410 DO WHILE (kac_lo <= alist_ac%nclist)
411 k_total = 0
412 DO kac = kac_lo, alist_ac%nclist
413 clist_a => alist_ac%clist(kac)
414 n_cont_a = clist_a%nsgf_cnt
415 IF (n_cont_a == 0) cycle
416 nsoctot = SIZE(clist_a%acint, 2)
417 IF (k_total > 0 .AND. k_total + n_cont_a*nsoctot > ku_alloc) EXIT
418 katom = clist_a%catom
419 k_offset(kac) = k_total + 1
420 k_total = k_total + n_cont_a*nsoctot
421 CALL get_rho_atom(rho_atom=my_rho_atom(katom), int_scr_h=int_local_h, int_scr_s=int_local_s)
422 c_coeff_ss_a => clist_a%acint
423 IF (iatom == katom .AND. all(clist_a%cell == 0)) THEN
424 c_coeff_hh_a => clist_a%achint
425 DO ispin = 1, nspins
426 CALL dgemm('N', 'N', n_cont_a, nsoctot, nsoctot, 1.0_dp, c_coeff_hh_a(:, :, 1), n_cont_a, &
427 int_local_h(ispin)%r_coef, nsoctot, 0.0_dp, k_buf(k_offset(kac):, ispin), n_cont_a)
428 CALL dgemm('N', 'N', n_cont_a, nsoctot, nsoctot, -1.0_dp, c_coeff_ss_a(:, :, 1), n_cont_a, &
429 int_local_s(ispin)%r_coef, nsoctot, 1.0_dp, k_buf(k_offset(kac):, ispin), n_cont_a)
430 END DO
431 ELSE
432 DO ispin = 1, nspins
433 coc(1:nsoctot, 1:nsoctot) = int_local_h(ispin)%r_coef - int_local_s(ispin)%r_coef
434 CALL dgemm('N', 'N', n_cont_a, nsoctot, nsoctot, 1.0_dp, c_coeff_ss_a(:, :, 1), n_cont_a, &
435 coc, SIZE(coc, 1), 0.0_dp, k_buf(k_offset(kac):, ispin), n_cont_a)
436 END DO
437 END IF
438 END DO
439 kac_hi = kac - 1
440
441 IF (k_total > 0) THEN
442 IF (forces) THEN
443 u_touched(kac_lo:kac_hi, 1:nspins) = .false.
444 f_katom(1:3, kac_lo:kac_hi) = 0.0_dp
445 END IF
446 DO inb = 1, n_nb
447 task => my_sab(1)%nlist_task(slot_order(ia_ptr(iatom) + inb - 1))
448 jkind = merge(task%ikind, task%jkind, task%iatom > task%jatom)
449 jatom = max(task%iatom, task%jatom)
450 cell_b = merge(-task%cell, task%cell, task%iatom > task%jatom)
451 ibc = jkind + nkind*(kkind - 1)
452 IF (.NOT. has_intac(ibc)) cycle
453 CALL get_alist(my_oce%intac(ibc), alist_bc, jatom)
454 IF (.NOT. ASSOCIATED(alist_bc)) cycle
455
456 f_jatom = 0.0_dp
457 ieqj = merge(1.0_dp, 2.0_dp, iatom == jatom)
458
459 DO kbc = 1, alist_bc%nclist
460 clist_b => alist_bc%clist(kbc)
461 n_cont_b = clist_b%nsgf_cnt
462 IF (n_cont_b == 0) cycle
463 katom = clist_b%catom
464 DO kac = kac_lo, kac_hi
465 IF (alist_ac%clist(kac)%catom /= katom) cycle
466 IF (all(cell_b + clist_b%cell == alist_ac%clist(kac)%cell)) EXIT
467 END DO
468 IF (kac > kac_hi) cycle
469 clist_a => alist_ac%clist(kac)
470 n_cont_a = clist_a%nsgf_cnt
471 IF (n_cont_a == 0) cycle
472 list_a => clist_a%sgf_list
473 list_b => clist_b%sgf_list
474
475 IF (jatom /= katom .OR. any(clist_b%cell /= 0)) THEN
476 nsoctot = SIZE(clist_a%acint, 2)
477 c_coeff_ss_b => clist_b%acint
478 DO ispin = 1, nspins
479 CALL dgemm('N', 'T', n_cont_a, n_cont_b, nsoctot, factor1, k_buf(k_offset(kac):, ispin), &
480 n_cont_a, c_coeff_ss_b(:, :, 1), n_cont_b, 0.0_dp, a_matrix, SIZE(a_matrix, 1))
481 CALL alist_post_align_blk(a_matrix, SIZE(a_matrix, 1), nb_hblk(ispin, inb)%array, &
482 SIZE(nb_hblk(ispin, inb)%array, 1), list_a, n_cont_a, list_b, n_cont_b)
483 END DO
484 IF (forces) THEN
485 dista = (iatom /= katom .OR. any(clist_a%cell /= 0))
486 fb_triple = 0.0_dp
487 DO ispin = 1, nspins
488 CALL alist_pre_align_blk(nb_pblk(ispin, inb)%array, SIZE(nb_pblk(ispin, inb)%array, 1), &
489 p_matrix, SIZE(p_matrix, 1), list_a, n_cont_a, list_b, n_cont_b)
490 CALL dgemm('T', 'N', n_cont_b, nsoctot, n_cont_a, 1.0_dp, p_matrix, SIZE(p_matrix, 1), &
491 k_buf(k_offset(kac):, ispin), n_cont_a, 0.0_dp, c_int_s, n_cont_b)
492 IF (dista) THEN
493 beta = merge(1.0_dp, 0.0_dp, u_touched(kac, ispin))
494 u_touched(kac, ispin) = .true.
495 CALL dgemm('N', 'N', n_cont_a, nsoctot, n_cont_b, ieqj*force_fac(ispin), p_matrix, &
496 SIZE(p_matrix, 1), c_coeff_ss_b(:, :, 1), n_cont_b, beta, &
497 u_buf(k_offset(kac):, ispin), n_cont_a)
498 END IF
499 DO dir = 2, 4
500 trace = factor2*ieqj*force_fac(ispin)* &
501 trace_r_axb(c_int_s, n_cont_b, c_coeff_ss_b(:, :, dir), n_cont_b, n_cont_b, nsoctot)
502 f_katom(dir - 1, kac) = f_katom(dir - 1, kac) + trace
503 fb_triple(dir - 1) = fb_triple(dir - 1) - trace
504 END DO
505 END DO
506 f_jatom = f_jatom + fb_triple
507 IF (use_virial) CALL virial_pair_force(pv_virial_thread, 1.0_dp, fb_triple, clist_b%rac)
508 END IF
509 ELSE
510 c_coeff_ss_a => clist_a%acint
511 IF (iatom == katom .AND. all(clist_a%cell == 0)) THEN
512 c_coeff_hh_a => clist_a%achint
513 dista = .false.
514 ELSE
515 c_coeff_hh_a => clist_a%acint
516 dista = .true.
517 END IF
518 c_coeff_hh_b => clist_b%achint
519 c_coeff_ss_b => clist_b%acint
520 nsoctot = SIZE(c_coeff_ss_a, 2)
521 CALL get_rho_atom(rho_atom=my_rho_atom(katom), int_scr_h=int_local_h, int_scr_s=int_local_s)
522 do_forces = forces .AND. dista
523 ! Use the stored block ordering for both KS and force contractions.
524 CALL add_vhxca(nb_hblk(:, inb), nb_pblk(:, inb), c_coeff_hh_a, c_coeff_hh_b, &
525 c_coeff_ss_a, c_coeff_ss_b, int_local_h, int_local_s, nspins, &
526 iatom, jatom, nsoctot, factor1, list_a, n_cont_a, list_b, n_cont_b, &
527 dista, .false., c_int_h, c_int_s, max(1, max_nsgf), coc, a_matrix, &
528 p_matrix, do_forces, force_tmp, force_fac)
529
530 IF (do_forces) THEN
531 IF (use_virial) THEN
532 rac = alist_ac%clist(kac)%rac
533 rbc = alist_bc%clist(kbc)%rac
534 END IF
535 ia_kind = atom_of_kind(iatom)
536 ja_kind = atom_of_kind(jatom)
537 ka_kind = atom_of_kind(katom)
538 force_tmp = factor2*force_tmp
539!$ CALL omp_set_lock(locks((ka_kind - 1)*nkind + kkind))
540 force(kkind)%vhxc_atom(1:3, ka_kind) = force(kkind)%vhxc_atom(1:3, ka_kind) + force_tmp(1:3, 3)
541!$ CALL omp_unset_lock(locks((ka_kind - 1)*nkind + kkind))
542!$ CALL omp_set_lock(locks((ia_kind - 1)*nkind + ikind))
543 force(ikind)%vhxc_atom(1:3, ia_kind) = force(ikind)%vhxc_atom(1:3, ia_kind) + force_tmp(1:3, 1)
544!$ CALL omp_unset_lock(locks((ia_kind - 1)*nkind + ikind))
545!$ CALL omp_set_lock(locks((ja_kind - 1)*nkind + jkind))
546 force(jkind)%vhxc_atom(1:3, ja_kind) = force(jkind)%vhxc_atom(1:3, ja_kind) + force_tmp(1:3, 2)
547!$ CALL omp_unset_lock(locks((ja_kind - 1)*nkind + jkind))
548 IF (use_virial) THEN
549 CALL virial_pair_force(pv_virial_thread, 1._dp, force_tmp(1:3, 1), rac)
550 CALL virial_pair_force(pv_virial_thread, 1._dp, force_tmp(1:3, 2), rbc)
551 END IF
552 END IF
553 END IF
554 END DO ! kbc
555
556 IF (forces .AND. any(f_jatom /= 0.0_dp)) THEN
557 ja_kind = atom_of_kind(jatom)
558!$ CALL omp_set_lock(locks((ja_kind - 1)*nkind + jkind))
559 force(jkind)%vhxc_atom(:, ja_kind) = force(jkind)%vhxc_atom(:, ja_kind) + f_jatom
560!$ CALL omp_unset_lock(locks((ja_kind - 1)*nkind + jkind))
561 END IF
562 END DO
563
564 IF (forces) THEN
565 ia_kind = atom_of_kind(iatom)
566 DO kac = kac_lo, kac_hi
567 clist_a => alist_ac%clist(kac)
568 n_cont_a = clist_a%nsgf_cnt
569 katom = clist_a%catom
570 IF (any(u_touched(kac, 1:nspins))) THEN
571 CALL get_rho_atom(rho_atom=my_rho_atom(katom), int_scr_h=int_local_h, int_scr_s=int_local_s)
572 c_coeff_ss_a => clist_a%acint
573 nsoctot = SIZE(c_coeff_ss_a, 2)
574 fb_triple = 0.0_dp
575 DO ispin = 1, nspins
576 IF (.NOT. u_touched(kac, ispin)) cycle
577 coc(1:nsoctot, 1:nsoctot) = int_local_h(ispin)%r_coef - int_local_s(ispin)%r_coef
578 CALL dgemm('N', 'N', n_cont_a, nsoctot, nsoctot, 1.0_dp, u_buf(k_offset(kac):, ispin), &
579 n_cont_a, coc, SIZE(coc, 1), 0.0_dp, c_int_s, n_cont_a)
580 DO dir = 2, 4
581 trace = factor2*trace_r_axb(c_int_s, n_cont_a, c_coeff_ss_a(:, :, dir), &
582 n_cont_a, n_cont_a, nsoctot)
583 f_katom(dir - 1, kac) = f_katom(dir - 1, kac) + trace
584 fb_triple(dir - 1) = fb_triple(dir - 1) - trace
585 END DO
586 END DO
587!$ CALL omp_set_lock(locks((ia_kind - 1)*nkind + ikind))
588 force(ikind)%vhxc_atom(:, ia_kind) = force(ikind)%vhxc_atom(:, ia_kind) + fb_triple
589!$ CALL omp_unset_lock(locks((ia_kind - 1)*nkind + ikind))
590 IF (use_virial) CALL virial_pair_force(pv_virial_thread, 1.0_dp, fb_triple, clist_a%rac)
591 END IF
592 IF (any(f_katom(:, kac) /= 0.0_dp)) THEN
593 ka_kind = atom_of_kind(katom)
594!$ CALL omp_set_lock(locks((ka_kind - 1)*nkind + kkind))
595 force(kkind)%vhxc_atom(:, ka_kind) = force(kkind)%vhxc_atom(:, ka_kind) + f_katom(:, kac)
596!$ CALL omp_unset_lock(locks((ka_kind - 1)*nkind + kkind))
597 END IF
598 END DO
599 END IF
600 END IF
601 kac_lo = kac_hi + 1
602 END DO
603 END DO
604 END DO
605!$OMP END DO
606
607 DEALLOCATE (nb_hblk, nb_pblk, k_buf, k_offset, c_int_h, c_int_s, a_matrix, p_matrix, coc)
608 IF (forces) DEALLOCATE (u_buf, u_touched, f_katom)
609
610 IF (forces) THEN
611 ! Implicit barrier at end of OMP DO, so locks can be freed
612!$OMP DO
613!$ DO lock_num = 1, natom*nkind
614!$ call omp_destroy_lock(locks(lock_num))
615!$ END DO
616!$OMP END DO
617
618!$OMP SINGLE
619!$ DEALLOCATE (locks)
620!$OMP END SINGLE NOWAIT
621 END IF
622
623!$OMP END PARALLEL
624
625 IF (use_virial) THEN
626 virial%pv_gapw(1:3, 1:3) = virial%pv_gapw(1:3, 1:3) + pv_virial_thread(1:3, 1:3)
627 virial%pv_virial(1:3, 1:3) = virial%pv_virial(1:3, 1:3) + pv_virial_thread(1:3, 1:3)
628 END IF
629
630 DEALLOCATE (ia_ptr, slot_order)
631
632 DEALLOCATE (basis_set_list, paw_kind, has_intac)
633
634 CALL timestop(handle)
635
636 END SUBROUTINE update_ks_atom
637
638! **************************************************************************************************
639!> \brief Add one-center hard-minus-soft KS and coefficient-derivative force contributions.
640!> Real symmetric one-center potentials allow the same unscaled C*V intermediates
641!> to be used for KS assembly and forces within each spin.
642!> \param mat_h KS blocks in stored (A <= B) order
643!> \param mat_p density blocks in the same order, used only for forces
644!> \param C_hh_a hard coefficients and derivatives on A
645!> \param C_hh_b hard coefficients and derivatives on B
646!> \param C_ss_a soft coefficients and derivatives on A
647!> \param C_ss_b soft coefficients and derivatives on B
648!> \param int_local_h hard one-center potentials by spin
649!> \param int_local_s soft one-center potentials by spin
650!> \param nspins number of spins
651!> \param ia atom A
652!> \param ja atom B
653!> \param nsp size of the one-center basis
654!> \param factor KS scaling, kept separate from the force scaling
655!> \param lista contracted basis indices on A
656!> \param nconta number of contracted functions on A
657!> \param listb contracted basis indices on B
658!> \param ncontb number of contracted functions on B
659!> \param dista true if A is offsite relative to the expansion center
660!> \param distb true if B is offsite relative to the expansion center
661!> \param work_h workspace for unscaled potential-weighted coefficients
662!> \param work_s workspace for soft or density-weighted coefficients
663!> \param ldwork leading dimension of the coefficient workspaces
664!> \param int_diff workspace for the hard-minus-soft potential
665!> \param a_matrix workspace for the contracted KS block
666!> \param p_matrix workspace for the aligned density block
667!> \param do_forces whether nonzero coefficient-derivative contributions are needed
668!> \param force forces on A, B, and the expansion center
669!> \param force_scaling force scaling by spin
670! **************************************************************************************************
671 SUBROUTINE add_vhxca(mat_h, mat_p, C_hh_a, C_hh_b, C_ss_a, C_ss_b, &
672 int_local_h, int_local_s, nspins, ia, ja, nsp, factor, &
673 lista, nconta, listb, ncontb, dista, distb, &
674 work_h, work_s, ldwork, int_diff, a_matrix, p_matrix, &
675 do_forces, force, force_scaling)
676 TYPE(cp_2d_r_p_type), DIMENSION(:), INTENT(IN) :: mat_h, mat_p
677 REAL(kind=dp), DIMENSION(:, :, :), INTENT(IN) :: c_hh_a, c_hh_b, c_ss_a, c_ss_b
678 TYPE(rho_atom_coeff), DIMENSION(:), INTENT(IN) :: int_local_h, int_local_s
679 INTEGER, INTENT(IN) :: nspins, ia, ja, nsp
680 REAL(kind=dp), INTENT(IN) :: factor
681 INTEGER, DIMENSION(:), INTENT(IN) :: lista
682 INTEGER, INTENT(IN) :: nconta
683 INTEGER, DIMENSION(:), INTENT(IN) :: listb
684 INTEGER, INTENT(IN) :: ncontb
685 LOGICAL, INTENT(IN) :: dista, distb
686 INTEGER, INTENT(IN) :: ldwork
687 REAL(kind=dp), INTENT(OUT) :: work_s(ldwork, nsp), &
688 work_h(ldwork, nsp), int_diff(nsp, nsp)
689 REAL(dp), DIMENSION(:, :), INTENT(OUT) :: a_matrix, p_matrix
690 LOGICAL, INTENT(IN) :: do_forces
691 REAL(dp), DIMENSION(3, 3), INTENT(OUT) :: force
692 REAL(kind=dp), DIMENSION(2), INTENT(IN) :: force_scaling
693
694 INTEGER :: dir, ispin
695 REAL(dp), DIMENSION(:, :), POINTER :: h_block, int_hard, int_soft, p_block
696 REAL(kind=dp) :: ieqj, trace
697
698 force(:, :) = 0.0_dp
699 ! Factor 2 because only half of the pairs with ia /= ja are considered.
700 ieqj = 2.0_dp
701 IF (ia == ja) ieqj = 1.0_dp
702
703 DO ispin = 1, nspins
704 h_block => mat_h(ispin)%array
705 int_hard => int_local_h(ispin)%r_coef
706 int_soft => int_local_s(ispin)%r_coef
707
708 IF (dista .AND. distb) int_diff(:, :) = int_hard(1:nsp, 1:nsp) - int_soft(1:nsp, 1:nsp)
709
710 IF (distb .AND. .NOT. dista) THEN
711 ! B is offsite: H_ab = (C_a^h V_h - C_a^s V_s) C_b^T.
712 CALL dgemm('N', 'N', nconta, nsp, nsp, 1.0_dp, c_hh_a(:, :, 1), SIZE(c_hh_a, 1), &
713 int_hard, SIZE(int_hard, 1), 0.0_dp, work_h, ldwork)
714 CALL dgemm('N', 'N', nconta, nsp, nsp, -1.0_dp, c_ss_a(:, :, 1), SIZE(c_ss_a, 1), &
715 int_soft, SIZE(int_soft, 1), 1.0_dp, work_h, ldwork)
716 CALL dgemm('N', 'T', nconta, ncontb, nsp, factor, work_h, ldwork, &
717 c_hh_b(:, :, 1), SIZE(c_hh_b, 1), 0.0_dp, a_matrix, SIZE(a_matrix, 1))
718 ELSE
719 IF (distb) THEN
720 ! Both ends are offsite: C_h = C_s, including their derivatives.
721 CALL dgemm('N', 'N', ncontb, nsp, nsp, 1.0_dp, c_hh_b(:, :, 1), SIZE(c_hh_b, 1), &
722 int_diff, nsp, 0.0_dp, work_h, ldwork)
723 ELSE
724 CALL dgemm('N', 'N', ncontb, nsp, nsp, 1.0_dp, c_hh_b(:, :, 1), SIZE(c_hh_b, 1), &
725 int_hard, SIZE(int_hard, 1), 0.0_dp, work_h, ldwork)
726 IF (dista) THEN
727 CALL dgemm('N', 'N', ncontb, nsp, nsp, -1.0_dp, c_ss_b(:, :, 1), SIZE(c_ss_b, 1), &
728 int_soft, SIZE(int_soft, 1), 1.0_dp, work_h, ldwork)
729 ELSE
730 CALL dgemm('N', 'N', ncontb, nsp, nsp, 1.0_dp, c_ss_b(:, :, 1), SIZE(c_ss_b, 1), &
731 int_soft, SIZE(int_soft, 1), 0.0_dp, work_s, ldwork)
732 END IF
733 END IF
734 CALL dgemm('N', 'T', nconta, ncontb, nsp, factor, c_hh_a(:, :, 1), SIZE(c_hh_a, 1), &
735 work_h, ldwork, 0.0_dp, a_matrix, SIZE(a_matrix, 1))
736 IF (.NOT. dista) THEN
737 CALL dgemm('N', 'T', nconta, ncontb, nsp, -factor, c_ss_a(:, :, 1), SIZE(c_ss_a, 1), &
738 work_s, ldwork, 1.0_dp, a_matrix, SIZE(a_matrix, 1))
739 END IF
740 END IF
741
742 CALL alist_post_align_blk(a_matrix, SIZE(a_matrix, 1), h_block, SIZE(h_block, 1), &
743 lista, nconta, listb, ncontb)
744
745 IF (.NOT. do_forces) cycle
746 p_block => mat_p(ispin)%array
747 CALL alist_pre_align_blk(p_block, SIZE(p_block, 1), p_matrix, SIZE(p_matrix, 1), &
748 lista, nconta, listb, ncontb)
749
750 ! Onsite coefficient derivatives are zero (see build_oce_matrices).
751 ! The offsite derivative is common to hard and soft coefficients.
752 IF (dista) THEN
753 ! Reuse K_b = C_b^h V_h - C_b^s V_s from KS assembly.
754 CALL dgemm('N', 'N', nconta, nsp, ncontb, 1.0_dp, p_matrix, SIZE(p_matrix, 1), &
755 work_h, ldwork, 0.0_dp, work_s, ldwork)
756 ! <(P C_b)^T dC_a, V>_F = <dC_a, P (C_b V)>_F.
757 DO dir = 2, 4
758 trace = trace_r_axb(work_s, ldwork, c_hh_a(:, :, dir), SIZE(c_hh_a, 1), nconta, nsp)
759 trace = ieqj*trace*force_scaling(ispin)
760 force(dir - 1, 3) = force(dir - 1, 3) + trace
761 force(dir - 1, 1) = force(dir - 1, 1) - trace
762 END DO
763 END IF
764
765 IF (distb) THEN
766 IF (dista) THEN
767 ! A force used K_b; now form K_a = C_a (V_h - V_s).
768 CALL dgemm('N', 'N', nconta, nsp, nsp, 1.0_dp, c_hh_a(:, :, 1), SIZE(c_hh_a, 1), &
769 int_diff, nsp, 0.0_dp, work_h, ldwork)
770 END IF
771 ! For an onsite A, K_a is already available from KS assembly.
772 CALL dgemm('T', 'N', ncontb, nsp, nconta, 1.0_dp, p_matrix, SIZE(p_matrix, 1), &
773 work_h, ldwork, 0.0_dp, work_s, ldwork)
774 DO dir = 2, 4
775 trace = trace_r_axb(work_s, ldwork, c_hh_b(:, :, dir), SIZE(c_hh_b, 1), ncontb, nsp)
776 trace = ieqj*trace*force_scaling(ispin)
777 force(dir - 1, 3) = force(dir - 1, 3) + trace
778 force(dir - 1, 2) = force(dir - 1, 2) - trace
779 END DO
780 END IF
781 END DO
782 END SUBROUTINE add_vhxca
783
784END MODULE qs_ks_atom
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.
All kind of helpful little routines.
Definition ao_util.F:14
pure real(dp) function, public trace_r_axb(a, lda, b, ldb, m, n)
...
Definition ao_util.F:330
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.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
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)
...
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, rskp_transform)
Retrieve information from a kpoint environment.
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, matrix_metric, matrix_metric_kp)
Get the QUICKSTEP environment.
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.
routines that build the Kohn-Sham matrix contributions coming from local atomic densities
Definition qs_ks_atom.F:12
subroutine, public update_ks_atom(qs_env, ksmat, pmat, forces, tddft, rho_atom_external, kind_set_external, oce_external, sab_external, kscale, kintegral, kforce, fscale)
The correction to the KS matrix due to the GAPW local terms to the hartree and XC contributions is he...
Definition qs_ks_atom.F:144
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 prj_gather(ain, aout, atom)
...
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)
...
General overlap type integrals containers.
subroutine, public alist_post_align_blk(blk_in, ldin, blk_out, ldout, ilist, in, jlist, jn)
...
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
pure subroutine, public virial_pair_force(pv_virial, f0, force, rab)
Computes the contribution to the stress tensor from two-body pair-wise forces.
Provides all information about an atomic kind.
represent a pointer to a 2d array
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.