(git:15c1bfc)
Loading...
Searching...
No Matches
qs_neighbor_lists.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Generate the atomic neighbor lists.
10!> \par History
11!> - List rebuild for sab_orb neighbor list (10.09.2002,MK)
12!> - List rebuild for all lists (25.09.2002,MK)
13!> - Row-wise parallelized version (16.06.2003,MK)
14!> - Row- and column-wise parallelized version (19.07.2003,MK)
15!> - bug fix for non-periodic case (23.02.06,MK)
16!> - major refactoring (25.07.10,jhu)
17!> \author Matthias Krack (08.10.1999,26.03.2002,16.06.2003)
18! **************************************************************************************************
27 USE cell_types, ONLY: cell_type,&
28 get_cell,&
29 pbc,&
36 USE cp_output_handling, ONLY: cp_p_file,&
49 USE input_constants, ONLY: &
57 USE kinds, ONLY: default_string_length,&
58 dp,&
59 int_8
60 USE kpoint_types, ONLY: kpoint_type
62 USE mathlib, ONLY: erfc_cutoff
68 USE periodic_table, ONLY: ptable
69 USE physcon, ONLY: bohr
76 USE qs_gcp_types, ONLY: qs_gcp_type
77 USE qs_kind_types, ONLY: get_qs_kind,&
80 USE qs_ks_types, ONLY: get_ks_env,&
83 USE qs_neighbor_list_types, ONLY: &
88 USE string_utilities, ONLY: compress,&
94 USE util, ONLY: locate,&
95 sort
96 USE xtb_types, ONLY: get_xtb_atom_param,&
98#include "./base/base_uses.f90"
99
100 IMPLICIT NONE
101
102 PRIVATE
103
104! **************************************************************************************************
106 INTEGER, DIMENSION(:), POINTER :: list => null(), &
107 list_local_a_index => null(), &
108 list_local_b_index => null(), &
109 list_1d => null(), &
110 list_a_mol => null(), &
111 list_b_mol => null()
112 END TYPE local_atoms_type
113! **************************************************************************************************
114
115 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'qs_neighbor_lists'
116
117 ! private counter, used to version qs neighbor lists
118 INTEGER, SAVE, PRIVATE :: last_qs_neighbor_list_id_nr = 0
119
120 ! Public subroutines
124CONTAINS
125
126! **************************************************************************************************
127!> \brief free the internals of atom2d
128!> \param atom2d ...
129!> \param
130! **************************************************************************************************
131 SUBROUTINE atom2d_cleanup(atom2d)
132 TYPE(local_atoms_type), DIMENSION(:) :: atom2d
133
134 CHARACTER(len=*), PARAMETER :: routinen = 'atom2d_cleanup'
135
136 INTEGER :: handle, ikind
137
138 CALL timeset(routinen, handle)
139 DO ikind = 1, SIZE(atom2d)
140 NULLIFY (atom2d(ikind)%list)
141 IF (ASSOCIATED(atom2d(ikind)%list_local_a_index)) THEN
142 DEALLOCATE (atom2d(ikind)%list_local_a_index)
143 END IF
144 IF (ASSOCIATED(atom2d(ikind)%list_local_b_index)) THEN
145 DEALLOCATE (atom2d(ikind)%list_local_b_index)
146 END IF
147 IF (ASSOCIATED(atom2d(ikind)%list_a_mol)) THEN
148 DEALLOCATE (atom2d(ikind)%list_a_mol)
149 END IF
150 IF (ASSOCIATED(atom2d(ikind)%list_b_mol)) THEN
151 DEALLOCATE (atom2d(ikind)%list_b_mol)
152 END IF
153 IF (ASSOCIATED(atom2d(ikind)%list_1d)) THEN
154 DEALLOCATE (atom2d(ikind)%list_1d)
155 END IF
156 END DO
157 CALL timestop(handle)
158
159 END SUBROUTINE atom2d_cleanup
160
161! **************************************************************************************************
162!> \brief Build some distribution structure of atoms, refactored from build_qs_neighbor_lists
163!> \param atom2d output
164!> \param distribution_1d ...
165!> \param distribution_2d ...
166!> \param atomic_kind_set ...
167!> \param molecule_set ...
168!> \param molecule_only ...
169!> \param particle_set ...
170!> \author JH
171! **************************************************************************************************
172 SUBROUTINE atom2d_build(atom2d, distribution_1d, distribution_2d, &
173 atomic_kind_set, molecule_set, molecule_only, particle_set)
174 TYPE(local_atoms_type), DIMENSION(:) :: atom2d
175 TYPE(distribution_1d_type), POINTER :: distribution_1d
176 TYPE(distribution_2d_type), POINTER :: distribution_2d
177 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
178 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
179 LOGICAL :: molecule_only
180 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
181
182 CHARACTER(len=*), PARAMETER :: routinen = 'atom2d_build'
183
184 INTEGER :: atom_a, handle, ia, iat, iatom, &
185 iatom_local, ikind, imol, natom, &
186 natom_a, natom_local_a, natom_local_b, &
187 nel, nkind
188 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom2mol, atom_of_kind, listindex, &
189 listsort
190 INTEGER, DIMENSION(:), POINTER :: local_cols_array, local_rows_array
191
192 CALL timeset(routinen, handle)
193
194 nkind = SIZE(atomic_kind_set)
195 natom = SIZE(particle_set)
196 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, atom_of_kind=atom_of_kind)
197
198 IF (molecule_only) THEN
199 ALLOCATE (atom2mol(natom))
200 DO imol = 1, SIZE(molecule_set)
201 DO iat = molecule_set(imol)%first_atom, molecule_set(imol)%last_atom
202 atom2mol(iat) = imol
203 END DO
204 END DO
205 END IF
206
207 DO ikind = 1, nkind
208 NULLIFY (atom2d(ikind)%list)
209 NULLIFY (atom2d(ikind)%list_local_a_index)
210 NULLIFY (atom2d(ikind)%list_local_b_index)
211 NULLIFY (atom2d(ikind)%list_1d)
212 NULLIFY (atom2d(ikind)%list_a_mol)
213 NULLIFY (atom2d(ikind)%list_b_mol)
214
215 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom2d(ikind)%list)
216
217 natom_a = SIZE(atom2d(ikind)%list)
218
219 natom_local_a = distribution_2d%n_local_rows(ikind)
220 natom_local_b = distribution_2d%n_local_cols(ikind)
221 local_rows_array => distribution_2d%local_rows(ikind)%array
222 local_cols_array => distribution_2d%local_cols(ikind)%array
223
224 nel = distribution_1d%n_el(ikind)
225 ALLOCATE (atom2d(ikind)%list_1d(nel))
226 DO iat = 1, nel
227 ia = distribution_1d%list(ikind)%array(iat)
228 atom2d(ikind)%list_1d(iat) = atom_of_kind(ia)
229 END DO
230
231 ALLOCATE (listsort(natom_a), listindex(natom_a))
232 listsort(1:natom_a) = atom2d(ikind)%list(1:natom_a)
233 CALL sort(listsort, natom_a, listindex)
234 ! Block rows
235 IF (natom_local_a > 0) THEN
236 ALLOCATE (atom2d(ikind)%list_local_a_index(natom_local_a))
237 ALLOCATE (atom2d(ikind)%list_a_mol(natom_local_a))
238 atom2d(ikind)%list_a_mol(:) = 0
239
240 ! Build index vector for mapping
241 DO iatom_local = 1, natom_local_a
242 atom_a = local_rows_array(iatom_local)
243 iatom = locate(listsort, atom_a)
244 atom2d(ikind)%list_local_a_index(iatom_local) = listindex(iatom)
245 IF (molecule_only) atom2d(ikind)%list_a_mol(iatom_local) = atom2mol(atom_a)
246 END DO
247
248 END IF
249
250 ! Block columns
251 IF (natom_local_b > 0) THEN
252
253 ALLOCATE (atom2d(ikind)%list_local_b_index(natom_local_b))
254 ALLOCATE (atom2d(ikind)%list_b_mol(natom_local_b))
255 atom2d(ikind)%list_b_mol(:) = 0
256
257 ! Build index vector for mapping
258 DO iatom_local = 1, natom_local_b
259 atom_a = local_cols_array(iatom_local)
260 iatom = locate(listsort, atom_a)
261 atom2d(ikind)%list_local_b_index(iatom_local) = listindex(iatom)
262 IF (molecule_only) atom2d(ikind)%list_b_mol(iatom_local) = atom2mol(atom_a)
263 END DO
264
265 END IF
266
267 DEALLOCATE (listsort, listindex)
268
269 END DO
270
271 CALL timestop(handle)
272
273 END SUBROUTINE atom2d_build
274
275! **************************************************************************************************
276!> \brief Build all the required neighbor lists for Quickstep.
277!> \param qs_env ...
278!> \param para_env ...
279!> \param molecular ...
280!> \param force_env_section ...
281!> \date 28.08.2000
282!> \par History
283!> - Major refactoring (25.07.2010,jhu)
284!> \author MK
285!> \version 1.0
286! **************************************************************************************************
287 SUBROUTINE build_qs_neighbor_lists(qs_env, para_env, molecular, force_env_section)
288 TYPE(qs_environment_type), POINTER :: qs_env
289 TYPE(mp_para_env_type), POINTER :: para_env
290 LOGICAL, OPTIONAL :: molecular
291 TYPE(section_vals_type), POINTER :: force_env_section
292
293 CHARACTER(len=*), PARAMETER :: routinen = 'build_qs_neighbor_lists'
294
295 CHARACTER(LEN=2) :: element_symbol, element_symbol2
296 CHARACTER(LEN=default_string_length) :: print_key_path
297 INTEGER :: handle, hfx_pot, ikind, ingp, iw, jkind, &
298 maxatom, ngp, nkind, zat
299 LOGICAL :: all_potential_present, almo, cneo_potential_present, dftb, do_hfx, dokp, &
300 gth_potential_present, lri_optbas, lrigpw, mic, molecule_only, nddo, paw_atom, &
301 paw_atom_present, rigpw, sgp_potential_present, xtb
302 LOGICAL, ALLOCATABLE, DIMENSION(:) :: all_present, aux_fit_present, aux_present, &
303 cneo_present, core_present, default_present, nonbond1_atom, nonbond2_atom, oce_present, &
304 orb_present, ppl_present, ppnl_present, ri_present, xb1_atom, xb2_atom
305 REAL(dp) :: almo_rcov, almo_rvdw, eps_schwarz, &
306 omega, pdist, rcut, roperator, subcells
307 REAL(dp), ALLOCATABLE, DIMENSION(:) :: all_pot_rad, aux_fit_radius, c_radius, calpha, &
308 core_radius, nuc_orb_radius, oce_radius, orb_radius, ppl_radius, ppnl_radius, ri_radius, &
309 zeff
310 REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: pair_radius, pair_radius_lb
311 TYPE(all_potential_type), POINTER :: all_potential
312 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
313 TYPE(cell_type), POINTER :: cell
314 TYPE(cneo_potential_type), POINTER :: cneo_potential
315 TYPE(cp_logger_type), POINTER :: logger
316 TYPE(dft_control_type), POINTER :: dft_control
317 TYPE(distribution_1d_type), POINTER :: distribution_1d
318 TYPE(distribution_2d_type), POINTER :: distribution_2d
319 TYPE(ewald_environment_type), POINTER :: ewald_env
320 TYPE(gth_potential_type), POINTER :: gth_potential
321 TYPE(gto_basis_set_type), POINTER :: aux_basis_set, aux_fit_basis_set, &
322 nuc_basis_set, orb_basis_set, &
323 ri_basis_set
324 TYPE(kpoint_type), POINTER :: kpoints
325 TYPE(local_atoms_type), ALLOCATABLE, DIMENSION(:) :: atom2d
326 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
327 TYPE(neighbor_list_set_p_type), DIMENSION(:), POINTER :: saa_list, sab_all, sab_almo, &
328 sab_cn, sab_cneo, sab_core, sab_gcp, sab_kp, sab_kp_nosym, sab_lrc, sab_orb, sab_scp, &
329 sab_se, sab_tbe, sab_vdw, sab_xb, sab_xtb_nonbond, sab_xtb_pp, sab_xtbe, sac_ae, sac_lri, &
330 sac_ppl, sap_oce, sap_ppnl, soa_list, soo_list
331 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
332 TYPE(paw_proj_set_type), POINTER :: paw_proj
333 TYPE(qs_dftb_atom_type), POINTER :: dftb_atom
334 TYPE(qs_dispersion_type), POINTER :: dispersion_env
335 TYPE(qs_gcp_type), POINTER :: gcp_env
336 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
337 TYPE(qs_ks_env_type), POINTER :: ks_env
338 TYPE(section_vals_type), POINTER :: hfx_sections, neighbor_list_section
339 TYPE(sgp_potential_type), POINTER :: sgp_potential
340 TYPE(xtb_atom_type), POINTER :: xtb_atom
341
342 CALL timeset(routinen, handle)
343 NULLIFY (logger)
344 logger => cp_get_default_logger()
345
346 NULLIFY (atomic_kind_set, qs_kind_set, cell, neighbor_list_section, &
347 distribution_1d, distribution_2d, gth_potential, sgp_potential, orb_basis_set, &
348 particle_set, molecule_set, dft_control, ks_env)
349
350 NULLIFY (sab_orb)
351 NULLIFY (sac_ae)
352 NULLIFY (sac_ppl)
353 NULLIFY (sac_lri)
354 NULLIFY (sap_ppnl)
355 NULLIFY (sap_oce)
356 NULLIFY (sab_se)
357 NULLIFY (sab_lrc)
358 NULLIFY (sab_tbe)
359 NULLIFY (sab_xtbe)
360 NULLIFY (sab_core)
361 NULLIFY (sab_xb)
362 NULLIFY (sab_xtb_pp)
363 NULLIFY (sab_xtb_nonbond)
364 NULLIFY (sab_all)
365 NULLIFY (sab_vdw)
366 NULLIFY (sab_cn)
367 NULLIFY (soo_list)
368 NULLIFY (sab_scp)
369 NULLIFY (sab_almo)
370 NULLIFY (sab_kp)
371 NULLIFY (sab_kp_nosym)
372 NULLIFY (sab_cneo)
373
374 CALL get_qs_env(qs_env, &
375 ks_env=ks_env, &
376 atomic_kind_set=atomic_kind_set, &
377 qs_kind_set=qs_kind_set, &
378 cell=cell, &
379 kpoints=kpoints, &
380 distribution_2d=distribution_2d, &
381 local_particles=distribution_1d, &
382 particle_set=particle_set, &
383 molecule_set=molecule_set, &
384 dft_control=dft_control)
385
386 neighbor_list_section => section_vals_get_subs_vals(force_env_section, "DFT%PRINT%NEIGHBOR_LISTS")
387
388 ! This sets the id number of the qs neighbor lists, new lists, means new version
389 ! new version implies new sparsity of the matrices
390 last_qs_neighbor_list_id_nr = last_qs_neighbor_list_id_nr + 1
391 CALL set_ks_env(ks_env=ks_env, neighbor_list_id=last_qs_neighbor_list_id_nr)
392
393 CALL get_ks_env(ks_env=ks_env, &
394 sab_orb=sab_orb, &
395 sac_ae=sac_ae, &
396 sac_ppl=sac_ppl, &
397 sac_lri=sac_lri, &
398 sab_vdw=sab_vdw, &
399 sap_ppnl=sap_ppnl, &
400 sap_oce=sap_oce, &
401 sab_se=sab_se, &
402 sab_lrc=sab_lrc, &
403 sab_tbe=sab_tbe, &
404 sab_xtbe=sab_xtbe, &
405 sab_core=sab_core, &
406 sab_xb=sab_xb, &
407 sab_xtb_pp=sab_xtb_pp, &
408 sab_xtb_nonbond=sab_xtb_nonbond, &
409 sab_scp=sab_scp, &
410 sab_all=sab_all, &
411 sab_almo=sab_almo, &
412 sab_kp=sab_kp, &
413 sab_kp_nosym=sab_kp_nosym, &
414 sab_cneo=sab_cneo)
415
416 dokp = (kpoints%nkp > 0)
417 nddo = dft_control%qs_control%semi_empirical
418 dftb = dft_control%qs_control%dftb
419 xtb = dft_control%qs_control%xtb
420 almo = dft_control%qs_control%do_almo_scf
421 lrigpw = (dft_control%qs_control%method_id == do_method_lrigpw)
422 rigpw = (dft_control%qs_control%method_id == do_method_rigpw)
423 lri_optbas = dft_control%qs_control%lri_optbas
424
425 ! molecular lists
426 molecule_only = .false.
427 IF (PRESENT(molecular)) molecule_only = molecular
428 ! minimum image convention (MIC)
429 mic = molecule_only
430 IF (dokp) THEN
431 ! no MIC for kpoints
432 mic = .false.
433 ELSEIF (nddo) THEN
434 ! enforce MIC for interaction lists in SE
435 mic = .true.
436 END IF
437 pdist = dft_control%qs_control%pairlist_radius
438
439 hfx_sections => section_vals_get_subs_vals(qs_env%input, "DFT%XC%HF")
440 CALL section_vals_get(hfx_sections, explicit=do_hfx)
441
442 CALL get_atomic_kind_set(atomic_kind_set, maxatom=maxatom)
443 CALL get_qs_kind_set(qs_kind_set, paw_atom_present=paw_atom_present, &
444 gth_potential_present=gth_potential_present, &
445 sgp_potential_present=sgp_potential_present, &
446 all_potential_present=all_potential_present, &
447 cneo_potential_present=cneo_potential_present)
448
449 CALL section_vals_val_get(qs_env%input, "DFT%SUBCELLS", r_val=subcells)
450
451 ! Allocate work storage
452 nkind = SIZE(atomic_kind_set)
453 ALLOCATE (orb_present(nkind), aux_fit_present(nkind), aux_present(nkind), &
454 default_present(nkind), core_present(nkind))
455 ALLOCATE (orb_radius(nkind), aux_fit_radius(nkind), c_radius(nkind), &
456 core_radius(nkind), calpha(nkind), zeff(nkind))
457 orb_radius(:) = 0.0_dp
458 aux_fit_radius(:) = 0.0_dp
459 c_radius(:) = 0.0_dp
460 core_radius(:) = 0.0_dp
461 calpha(:) = 0.0_dp
462 zeff(:) = 0.0_dp
463
464 ALLOCATE (pair_radius(nkind, nkind))
465 IF (gth_potential_present .OR. sgp_potential_present) THEN
466 ALLOCATE (ppl_present(nkind), ppl_radius(nkind))
467 ppl_radius = 0.0_dp
468 ALLOCATE (ppnl_present(nkind), ppnl_radius(nkind))
469 ppnl_radius = 0.0_dp
470 END IF
471 IF (paw_atom_present) THEN
472 ALLOCATE (oce_present(nkind), oce_radius(nkind))
473 oce_radius = 0.0_dp
474 END IF
475 IF (all_potential_present .OR. sgp_potential_present) THEN
476 ALLOCATE (all_present(nkind), all_pot_rad(nkind))
477 all_pot_rad = 0.0_dp
478 END IF
479 IF (cneo_potential_present) THEN
480 ALLOCATE (cneo_present(nkind), nuc_orb_radius(nkind))
481 nuc_orb_radius = 0.0_dp
482 END IF
483
484 ! Initialize the local data structures
485 ALLOCATE (atom2d(nkind))
486 CALL atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, &
487 molecule_set, molecule_only, particle_set=particle_set)
488
489 DO ikind = 1, nkind
490
491 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom2d(ikind)%list)
492
493 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type="ORB")
494 CALL get_qs_kind(qs_kind_set(ikind), basis_set=aux_basis_set, basis_type="AUX")
495 CALL get_qs_kind(qs_kind_set(ikind), basis_set=aux_fit_basis_set, basis_type="AUX_FIT")
496 CALL get_qs_kind(qs_kind_set(ikind), basis_set=nuc_basis_set, basis_type="NUC")
497
498 CALL get_qs_kind(qs_kind_set(ikind), &
499 paw_proj_set=paw_proj, &
500 paw_atom=paw_atom, &
501 all_potential=all_potential, &
502 gth_potential=gth_potential, &
503 sgp_potential=sgp_potential, &
504 cneo_potential=cneo_potential)
505
506 IF (dftb) THEN
507 ! Set the interaction radius for the neighbor lists (DFTB case)
508 ! This includes all interactions (orbitals and short range pair potential) except vdW
509 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_atom)
510 CALL get_dftb_atom_param(dftb_parameter=dftb_atom, &
511 cutoff=orb_radius(ikind), &
512 defined=orb_present(ikind))
513 ELSE
514 IF (ASSOCIATED(orb_basis_set)) THEN
515 orb_present(ikind) = .true.
516 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, kind_radius=orb_radius(ikind))
517 ELSE
518 orb_present(ikind) = .false.
519 END IF
520 END IF
521
522 IF (ASSOCIATED(aux_basis_set)) THEN
523 aux_present(ikind) = .true.
524 ELSE
525 aux_present(ikind) = .false.
526 END IF
527
528 IF (ASSOCIATED(aux_fit_basis_set)) THEN
529 aux_fit_present(ikind) = .true.
530 CALL get_gto_basis_set(gto_basis_set=aux_fit_basis_set, kind_radius=aux_fit_radius(ikind))
531 ELSE
532 aux_fit_present(ikind) = .false.
533 END IF
534
535 core_present(ikind) = .false.
536 IF (ASSOCIATED(cneo_potential) .AND. ASSOCIATED(nuc_basis_set)) THEN
537 cneo_present(ikind) = .true.
538 CALL get_gto_basis_set(gto_basis_set=nuc_basis_set, kind_radius=nuc_orb_radius(ikind))
539 ELSE
540 IF (cneo_potential_present) cneo_present(ikind) = .false.
541 ! core overlap
542 CALL get_qs_kind(qs_kind_set(ikind), &
543 alpha_core_charge=calpha(ikind), &
544 core_charge_radius=core_radius(ikind), &
545 zeff=zeff(ikind))
546 IF (zeff(ikind) /= 0._dp .AND. calpha(ikind) /= 0._dp) THEN
547 core_present(ikind) = .true.
548 ELSE
549 core_present(ikind) = .false.
550 END IF
551 END IF
552
553 ! Pseudopotentials
554 IF (gth_potential_present .OR. sgp_potential_present) THEN
555 IF (ASSOCIATED(gth_potential)) THEN
556 CALL get_potential(potential=gth_potential, &
557 ppl_present=ppl_present(ikind), &
558 ppl_radius=ppl_radius(ikind), &
559 ppnl_present=ppnl_present(ikind), &
560 ppnl_radius=ppnl_radius(ikind))
561 ELSE IF (ASSOCIATED(sgp_potential)) THEN
562 CALL get_potential(potential=sgp_potential, &
563 ppl_present=ppl_present(ikind), &
564 ppl_radius=ppl_radius(ikind), &
565 ppnl_present=ppnl_present(ikind), &
566 ppnl_radius=ppnl_radius(ikind))
567 ELSE
568 ppl_present(ikind) = .false.
569 ppnl_present(ikind) = .false.
570 END IF
571 END IF
572
573 ! GAPW
574 IF (paw_atom_present) THEN
575 IF (paw_atom) THEN
576 oce_present(ikind) = .true.
577 CALL get_paw_proj_set(paw_proj_set=paw_proj, rcprj=oce_radius(ikind))
578 ELSE
579 oce_present(ikind) = .false.
580 END IF
581 END IF
582
583 ! Check the presence of an all electron potential or ERFC potential
584 IF (all_potential_present .OR. sgp_potential_present) THEN
585 all_present(ikind) = .false.
586 all_pot_rad(ikind) = 0.0_dp
587 IF (ASSOCIATED(all_potential)) THEN
588 all_present(ikind) = .true.
589 CALL get_potential(potential=all_potential, core_charge_radius=all_pot_rad(ikind))
590 ELSE IF (ASSOCIATED(sgp_potential)) THEN
591 IF (sgp_potential%ecp_local) THEN
592 all_present(ikind) = .true.
593 CALL get_potential(potential=sgp_potential, core_charge_radius=all_pot_rad(ikind))
594 END IF
595 END IF
596 END IF
597
598 END DO
599
600 ! Build the orbital-orbital overlap neighbor lists
601 IF (pdist < 0.0_dp) THEN
602 pdist = max(plane_distance(1, 0, 0, cell), &
603 plane_distance(0, 1, 0, cell), &
604 plane_distance(0, 0, 1, cell))
605 END IF
606 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius, pdist)
607 CALL build_neighbor_lists(sab_orb, particle_set, atom2d, cell, pair_radius, &
608 mic=mic, subcells=subcells, molecular=molecule_only, nlname="sab_orb")
609 CALL set_ks_env(ks_env=ks_env, sab_orb=sab_orb)
610 CALL write_neighbor_lists(sab_orb, particle_set, cell, para_env, neighbor_list_section, &
611 "/SAB_ORB", "sab_orb", "ORBITAL ORBITAL")
612
613 ! Build orbital-orbital list containing all the pairs, to be used with
614 ! non-symmetric operators. Beware: the cutoff of the orbital-orbital overlap
615 ! might not be optimal. It should be verified for each operator.
616 IF (.NOT. (nddo .OR. dftb .OR. xtb)) THEN
617 CALL build_neighbor_lists(sab_all, particle_set, atom2d, cell, pair_radius, &
618 mic=mic, symmetric=.false., subcells=subcells, molecular=molecule_only, nlname="sab_all")
619 CALL set_ks_env(ks_env=ks_env, sab_all=sab_all)
620 END IF
621
622 ! Build the core-core overlap neighbor lists
623 IF (.NOT. (nddo .OR. dftb .OR. xtb)) THEN
624 CALL pair_radius_setup(core_present, core_present, core_radius, core_radius, pair_radius)
625 CALL build_neighbor_lists(sab_core, particle_set, atom2d, cell, pair_radius, subcells=subcells, &
626 operator_type="PP", nlname="sab_core")
627 CALL set_ks_env(ks_env=ks_env, sab_core=sab_core)
628 CALL write_neighbor_lists(sab_core, particle_set, cell, para_env, neighbor_list_section, &
629 "/SAB_CORE", "sab_core", "CORE CORE")
630 END IF
631
632 IF (dokp) THEN
633 ! We try to guess an integration radius for K-points
634 ! For non-HFX calculations we use the overlap list
635 ! For HFX we use the interaction radius of kinds (ORB or ADMM basis)
636 ! plus a range for the operator
637 IF (do_hfx) THEN
638
639 !case study on the HFX potential: TC, SR or Overlap?
640 CALL section_vals_val_get(hfx_sections, "INTERACTION_POTENTIAL%POTENTIAL_TYPE", i_val=hfx_pot)
641
642 SELECT CASE (hfx_pot)
643 CASE (do_potential_id)
644 roperator = 0.0_dp
646 CALL section_vals_val_get(hfx_sections, "INTERACTION_POTENTIAL%CUTOFF_RADIUS", r_val=roperator)
648 CALL section_vals_val_get(hfx_sections, "INTERACTION_POTENTIAL%CUTOFF_RADIUS", r_val=roperator)
649 CASE (do_potential_short)
650 CALL section_vals_val_get(hfx_sections, "INTERACTION_POTENTIAL%OMEGA", r_val=omega)
651 CALL section_vals_val_get(hfx_sections, "SCREENING%EPS_SCHWARZ", r_val=eps_schwarz)
652 CALL erfc_cutoff(eps_schwarz, omega, roperator)
653 CASE DEFAULT
654 cpabort("HFX potential not available for K-points (NYI)")
655 END SELECT
656
657 IF (dft_control%do_admm) THEN
658 CALL pair_radius_setup(aux_fit_present, aux_fit_present, aux_fit_radius, aux_fit_radius, &
659 pair_radius)
660
661 !We cannot accept a pair radius smaller than the ORB overlap, for sanity reasons
662 ALLOCATE (pair_radius_lb(nkind, nkind))
663 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius_lb)
664 DO jkind = 1, nkind
665 DO ikind = 1, nkind
666 IF (pair_radius(ikind, jkind) + cutoff_screen_factor*roperator .LE. pair_radius_lb(ikind, jkind)) &
667 pair_radius(ikind, jkind) = pair_radius_lb(ikind, jkind) - roperator
668 END DO
669 END DO
670 ELSE
671 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
672 END IF
673 pair_radius = pair_radius + cutoff_screen_factor*roperator
674 ELSE
675 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
676 END IF
677 CALL build_neighbor_lists(sab_kp, particle_set, atom2d, cell, pair_radius, &
678 subcells=subcells, nlname="sab_kp")
679 CALL set_ks_env(ks_env=ks_env, sab_kp=sab_kp)
680
681 IF (do_hfx) THEN
682 CALL build_neighbor_lists(sab_kp_nosym, particle_set, atom2d, cell, pair_radius, &
683 subcells=subcells, nlname="sab_kp_nosym", symmetric=.false.)
684 CALL set_ks_env(ks_env=ks_env, sab_kp_nosym=sab_kp_nosym)
685 END IF
686 END IF
687
688 ! Build orbital GTH-PPL operator overlap list
689 IF (gth_potential_present .OR. sgp_potential_present) THEN
690 IF (any(ppl_present)) THEN
691 CALL pair_radius_setup(orb_present, ppl_present, orb_radius, ppl_radius, pair_radius)
692 CALL build_neighbor_lists(sac_ppl, particle_set, atom2d, cell, pair_radius, &
693 subcells=subcells, operator_type="ABC", nlname="sac_ppl")
694 CALL set_ks_env(ks_env=ks_env, sac_ppl=sac_ppl)
695 CALL write_neighbor_lists(sac_ppl, particle_set, cell, para_env, neighbor_list_section, &
696 "/SAC_PPL", "sac_ppl", "ORBITAL GTH-PPL")
697 IF (lrigpw) THEN
698 IF (qs_env%lri_env%ppl_ri) THEN
699 CALL build_neighbor_lists(sac_lri, particle_set, atom2d, cell, pair_radius, &
700 subcells=subcells, symmetric=.false., operator_type="PP", nlname="sac_lri")
701 CALL set_ks_env(ks_env=ks_env, sac_lri=sac_lri)
702 END IF
703 END IF
704 END IF
705
706 IF (any(ppnl_present)) THEN
707 CALL pair_radius_setup(orb_present, ppnl_present, orb_radius, ppnl_radius, pair_radius)
708 CALL build_neighbor_lists(sap_ppnl, particle_set, atom2d, cell, pair_radius, &
709 subcells=subcells, operator_type="ABBA", nlname="sap_ppnl")
710 CALL set_ks_env(ks_env=ks_env, sap_ppnl=sap_ppnl)
711 CALL write_neighbor_lists(sap_ppnl, particle_set, cell, para_env, neighbor_list_section, &
712 "/SAP_PPNL", "sap_ppnl", "ORBITAL GTH-PPNL")
713 END IF
714 END IF
715
716 IF (paw_atom_present) THEN
717 ! Build orbital-GAPW projector overlap list
718 IF (any(oce_present)) THEN
719 CALL pair_radius_setup(orb_present, oce_present, orb_radius, oce_radius, pair_radius)
720 CALL build_neighbor_lists(sap_oce, particle_set, atom2d, cell, pair_radius, &
721 subcells=subcells, operator_type="ABBA", nlname="sap_oce")
722 CALL set_ks_env(ks_env=ks_env, sap_oce=sap_oce)
723 CALL write_neighbor_lists(sap_oce, particle_set, cell, para_env, neighbor_list_section, &
724 "/SAP_OCE", "sap_oce", "ORBITAL(A) PAW-PRJ")
725 END IF
726 END IF
727
728 ! Build orbital-ERFC potential list
729 IF (.NOT. (nddo .OR. dftb .OR. xtb)) THEN
730 IF (all_potential_present .OR. sgp_potential_present) THEN
731 CALL pair_radius_setup(orb_present, all_present, orb_radius, all_pot_rad, pair_radius)
732 CALL build_neighbor_lists(sac_ae, particle_set, atom2d, cell, pair_radius, &
733 subcells=subcells, operator_type="ABC", nlname="sac_ae")
734 CALL set_ks_env(ks_env=ks_env, sac_ae=sac_ae)
735 CALL write_neighbor_lists(sac_ae, particle_set, cell, para_env, neighbor_list_section, &
736 "/SAC_AE", "sac_ae", "ORBITAL ERFC POTENTIAL")
737 END IF
738 END IF
739
740 ! Build quantum nuclear orbital-classical nuclear ERFC potential list for CNEO
741 IF (cneo_potential_present) THEN
742 CALL pair_radius_setup(cneo_present, core_present, nuc_orb_radius, core_radius, pair_radius)
743 CALL build_neighbor_lists(sab_cneo, particle_set, atom2d, cell, pair_radius, &
744 subcells=subcells, symmetric=.false., operator_type="PP", nlname="sab_cneo")
745 CALL set_ks_env(ks_env=ks_env, sab_cneo=sab_cneo)
746 CALL write_neighbor_lists(sab_cneo, particle_set, cell, para_env, neighbor_list_section, &
747 "/SAB_CNEO", "sab_cneo", "NUCLEAR ORBITAL ERFC POTENTIAL")
748 END IF
749
750 IF (nddo) THEN
751 ! Semi-empirical neighbor lists
752 default_present = .true.
753 c_radius = dft_control%qs_control%se_control%cutoff_cou
754 ! Build the neighbor lists for the Hartree terms
755 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
756 IF (dft_control%qs_control%se_control%do_ewald_gks) THEN
757 ! Use MIC for the periodic code of GKS
758 CALL build_neighbor_lists(sab_se, particle_set, atom2d, cell, pair_radius, mic=mic, &
759 subcells=subcells, nlname="sab_se")
760 ELSE
761 CALL build_neighbor_lists(sab_se, particle_set, atom2d, cell, pair_radius, &
762 subcells=subcells, nlname="sab_se")
763 END IF
764 CALL set_ks_env(ks_env=ks_env, sab_se=sab_se)
765 CALL write_neighbor_lists(sab_se, particle_set, cell, para_env, neighbor_list_section, &
766 "/SAB_SE", "sab_se", "HARTREE INTERACTIONS")
767
768 ! If requested build the SE long-range correction neighbor list
769 IF ((dft_control%qs_control%se_control%do_ewald) .AND. &
770 (dft_control%qs_control%se_control%integral_screening /= do_se_is_slater)) THEN
771 c_radius = dft_control%qs_control%se_control%cutoff_lrc
772 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
773 CALL build_neighbor_lists(sab_lrc, particle_set, atom2d, cell, pair_radius, &
774 subcells=subcells, nlname="sab_lrc")
775 CALL set_ks_env(ks_env=ks_env, sab_lrc=sab_lrc)
776 CALL write_neighbor_lists(sab_lrc, particle_set, cell, para_env, neighbor_list_section, &
777 "/SAB_LRC", "sab_lrc", "SE LONG-RANGE CORRECTION")
778 END IF
779 END IF
780
781 IF (dftb) THEN
782 ! Build the neighbor lists for the DFTB Ewald methods
783 IF (dft_control%qs_control%dftb_control%do_ewald) THEN
784 CALL get_qs_env(qs_env=qs_env, ewald_env=ewald_env)
785 CALL ewald_env_get(ewald_env, rcut=rcut)
786 c_radius = rcut
787 CALL pair_radius_setup(orb_present, orb_present, c_radius, c_radius, pair_radius)
788 CALL build_neighbor_lists(sab_tbe, particle_set, atom2d, cell, pair_radius, mic=mic, &
789 subcells=subcells, nlname="sab_tbe")
790 CALL set_ks_env(ks_env=ks_env, sab_tbe=sab_tbe)
791 END IF
792
793 ! Build the neighbor lists for the DFTB vdW pair potential
794 IF (dft_control%qs_control%dftb_control%dispersion) THEN
795 IF (dft_control%qs_control%dftb_control%dispersion_type == dispersion_uff) THEN
796 DO ikind = 1, nkind
797 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_atom)
798 CALL get_dftb_atom_param(dftb_parameter=dftb_atom, rcdisp=c_radius(ikind))
799 END DO
800 default_present = .true.
801 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
802 CALL build_neighbor_lists(sab_vdw, particle_set, atom2d, cell, pair_radius, &
803 subcells=subcells, nlname="sab_vdw")
804 CALL set_ks_env(ks_env=ks_env, sab_vdw=sab_vdw)
805 END IF
806 END IF
807 END IF
808
809 IF (xtb .AND. (.NOT. dft_control%qs_control%xtb_control%do_tblite)) THEN
810 ! Build the neighbor lists for the xTB Ewald method
811 IF (dft_control%qs_control%xtb_control%do_ewald) THEN
812 CALL get_qs_env(qs_env=qs_env, ewald_env=ewald_env)
813 CALL ewald_env_get(ewald_env, rcut=rcut)
814 c_radius = rcut
815 CALL pair_radius_setup(orb_present, orb_present, c_radius, c_radius, pair_radius)
816 CALL build_neighbor_lists(sab_tbe, particle_set, atom2d, cell, pair_radius, mic=mic, &
817 subcells=subcells, nlname="sab_tbe")
818 CALL set_ks_env(ks_env=ks_env, sab_tbe=sab_tbe)
819 END IF
820 ! Repulsive Potential
821 pair_radius(1:nkind, 1:nkind) = dft_control%qs_control%xtb_control%rcpair(1:nkind, 1:nkind)
822 default_present = .true.
823 CALL build_neighbor_lists(sab_xtb_pp, particle_set, atom2d, cell, pair_radius, &
824 subcells=subcells, nlname="sab_xtb_pp")
825 CALL set_ks_env(ks_env=ks_env, sab_xtb_pp=sab_xtb_pp)
826 ! SR part of Coulomb interaction
827 DO ikind = 1, nkind
828 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_atom)
829 CALL get_xtb_atom_param(xtb_parameter=xtb_atom, rcut=c_radius(ikind))
830 END DO
831 default_present = .true.
832 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
833 CALL build_neighbor_lists(sab_xtbe, particle_set, atom2d, cell, pair_radius, &
834 subcells=subcells, nlname="sab_xtbe")
835 CALL set_ks_env(ks_env=ks_env, sab_xtbe=sab_xtbe)
836 ! XB list
837 ALLOCATE (xb1_atom(nkind), xb2_atom(nkind))
838 c_radius = 0.5_dp*dft_control%qs_control%xtb_control%xb_radius
839 DO ikind = 1, nkind
840 CALL get_atomic_kind(atomic_kind_set(ikind), z=zat)
841 IF (zat == 17 .OR. zat == 35 .OR. zat == 53 .OR. zat == 85) THEN
842 xb1_atom(ikind) = .true.
843 ELSE
844 xb1_atom(ikind) = .false.
845 END IF
846 IF (zat == 7 .OR. zat == 8 .OR. zat == 15 .OR. zat == 16) THEN
847 xb2_atom(ikind) = .true.
848 ELSE
849 xb2_atom(ikind) = .false.
850 END IF
851 END DO
852 CALL pair_radius_setup(xb1_atom, xb2_atom, c_radius, c_radius, pair_radius)
853 CALL build_neighbor_lists(sab_xb, particle_set, atom2d, cell, pair_radius, &
854 symmetric=.false., subcells=subcells, operator_type="PP", nlname="sab_xb")
855 CALL set_ks_env(ks_env=ks_env, sab_xb=sab_xb)
856 CALL write_neighbor_lists(sab_xb, particle_set, cell, para_env, neighbor_list_section, &
857 "/SAB_XB", "sab_xb", "XB bonding")
858
859 ! nonbonded interactions list
860 IF (dft_control%qs_control%xtb_control%do_nonbonded &
861 .AND. (.NOT. dft_control%qs_control%xtb_control%do_tblite)) THEN
862 ngp = SIZE(dft_control%qs_control%xtb_control%nonbonded%pot)
863 ALLOCATE (nonbond1_atom(nkind), nonbond2_atom(nkind))
864 nonbond1_atom = .false.
865 nonbond2_atom = .false.
866 DO ingp = 1, ngp
867 DO ikind = 1, nkind
868 rcut = sqrt(dft_control%qs_control%xtb_control%nonbonded%pot(ingp)%pot%rcutsq)
869 c_radius = rcut
870 CALL get_atomic_kind(atomic_kind_set(ikind), element_symbol=element_symbol)
871 CALL uppercase(element_symbol)
872 IF (trim(dft_control%qs_control%xtb_control%nonbonded%pot(ingp)%pot%at1) == trim(element_symbol)) THEN
873 nonbond1_atom(ikind) = .true.
874 DO jkind = 1, nkind
875 CALL get_atomic_kind(atomic_kind_set(jkind), element_symbol=element_symbol2)
876 CALL uppercase(element_symbol2)
877 IF (trim(dft_control%qs_control%xtb_control%nonbonded%pot(ingp)%pot%at2) == trim(element_symbol2)) THEN
878 nonbond2_atom(jkind) = .true.
879 END IF
880 END DO
881 END IF
882 END DO
883 CALL pair_radius_setup(nonbond1_atom, nonbond2_atom, c_radius, c_radius, pair_radius)
884 CALL build_neighbor_lists(sab_xtb_nonbond, particle_set, atom2d, cell, pair_radius, &
885 symmetric=.false., subcells=subcells, operator_type="PP", nlname="sab_xtb_nonbond")
886 CALL set_ks_env(ks_env=ks_env, sab_xtb_nonbond=sab_xtb_nonbond)
887 CALL write_neighbor_lists(sab_xtb_nonbond, particle_set, cell, para_env, neighbor_list_section, &
888 "/SAB_XTB_NONBOND", "sab_xtb_nonbond", "XTB NONBONDED INTERACTIONS")
889 END DO
890 END IF
891 END IF
892
893 ! Build the neighbor lists for the vdW pair potential
894 IF (.NOT. dft_control%qs_control%xtb_control%do_tblite) THEN
895 CALL get_qs_env(qs_env=qs_env, dispersion_env=dispersion_env)
896 sab_vdw => dispersion_env%sab_vdw
897 sab_cn => dispersion_env%sab_cn
898 IF (dispersion_env%type == xc_vdw_fun_pairpot .OR. xtb) THEN
899 IF (dispersion_env%pp_type == vdw_pairpot_dftd4) THEN
900 c_radius(:) = dispersion_env%rc_d4
901 ELSE
902 c_radius(:) = dispersion_env%rc_disp
903 END IF
904 default_present = .true. !include all atoms in vdW (even without basis)
905 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
906 CALL build_neighbor_lists(sab_vdw, particle_set, atom2d, cell, pair_radius, &
907 subcells=subcells, operator_type="PP", nlname="sab_vdw")
908 dispersion_env%sab_vdw => sab_vdw
909
910 ! Build the neighbor lists for coordination numbers as needed by the DFT-D3/D4 method
911 ! This is also needed for the xTB Hamiltonian
912 DO ikind = 1, nkind
913 CALL get_atomic_kind(atomic_kind_set(ikind), z=zat)
914 c_radius(ikind) = 4._dp*ptable(zat)%covalent_radius*bohr
915 END DO
916 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
917 CALL build_neighbor_lists(sab_cn, particle_set, atom2d, cell, pair_radius, &
918 subcells=subcells, operator_type="PP", nlname="sab_cn")
919 dispersion_env%sab_cn => sab_cn
920 END IF
921 END IF
922
923 ! Build the neighbor lists for the gCP pair potential
924 NULLIFY (gcp_env)
925 CALL get_qs_env(qs_env=qs_env, gcp_env=gcp_env)
926 IF (ASSOCIATED(gcp_env)) THEN
927 IF (gcp_env%do_gcp) THEN
928 sab_gcp => gcp_env%sab_gcp
929 DO ikind = 1, nkind
930 c_radius(ikind) = gcp_env%gcp_kind(ikind)%rcsto
931 END DO
932 CALL pair_radius_setup(orb_present, orb_present, c_radius, c_radius, pair_radius)
933 CALL build_neighbor_lists(sab_gcp, particle_set, atom2d, cell, pair_radius, &
934 subcells=subcells, operator_type="PP", nlname="sab_gcp")
935 gcp_env%sab_gcp => sab_gcp
936 ELSE
937 NULLIFY (gcp_env%sab_gcp)
938 END IF
939 END IF
940
941 IF (lrigpw .OR. lri_optbas) THEN
942 ! set neighborlists in lri_env environment
943 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
944 soo_list => qs_env%lri_env%soo_list
945 CALL build_neighbor_lists(soo_list, particle_set, atom2d, cell, pair_radius, &
946 mic=mic, molecular=molecule_only, subcells=subcells, nlname="soo_list")
947 qs_env%lri_env%soo_list => soo_list
948 CALL write_neighbor_lists(soo_list, particle_set, cell, para_env, neighbor_list_section, &
949 "/SOO_LIST", "soo_list", "ORBITAL ORBITAL (RI)")
950 ELSEIF (rigpw) THEN
951 ALLOCATE (ri_present(nkind), ri_radius(nkind))
952 ri_present = .false.
953 ri_radius = 0.0_dp
954 DO ikind = 1, nkind
955 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis_set, basis_type="RI_HXC")
956 IF (ASSOCIATED(ri_basis_set)) THEN
957 ri_present(ikind) = .true.
958 CALL get_gto_basis_set(gto_basis_set=ri_basis_set, kind_radius=ri_radius(ikind))
959 ELSE
960 ri_present(ikind) = .false.
961 END IF
962 END DO
963 ! set neighborlists in lri_env environment
964 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
965 soo_list => qs_env%lri_env%soo_list
966 CALL build_neighbor_lists(soo_list, particle_set, atom2d, cell, pair_radius, &
967 mic=mic, molecular=molecule_only, subcells=subcells, nlname="soo_list")
968 qs_env%lri_env%soo_list => soo_list
969 !
970 CALL pair_radius_setup(ri_present, ri_present, ri_radius, ri_radius, pair_radius)
971 saa_list => qs_env%lri_env%saa_list
972 CALL build_neighbor_lists(saa_list, particle_set, atom2d, cell, pair_radius, &
973 mic=mic, molecular=molecule_only, subcells=subcells, nlname="saa_list")
974 qs_env%lri_env%saa_list => saa_list
975 !
976 CALL pair_radius_setup(ri_present, orb_present, ri_radius, orb_radius, pair_radius)
977 soa_list => qs_env%lri_env%soa_list
978 CALL build_neighbor_lists(soa_list, particle_set, atom2d, cell, pair_radius, &
979 mic=mic, symmetric=.false., molecular=molecule_only, &
980 subcells=subcells, operator_type="ABC", nlname="saa_list")
981 qs_env%lri_env%soa_list => soa_list
982 END IF
983
984 ! Build the neighbor lists for the ALMO delocalization
985 IF (almo) THEN
986 DO ikind = 1, nkind
987 CALL get_atomic_kind(atomic_kind_set(ikind), rcov=almo_rcov, rvdw=almo_rvdw)
988 ! multiply the radius by some hard-coded number
989 c_radius(ikind) = max(almo_rcov, almo_rvdw)*bohr* &
991 END DO
992 default_present = .true. !include all atoms (even without basis)
993 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
994 CALL build_neighbor_lists(sab_almo, particle_set, atom2d, cell, pair_radius, &
995 subcells=subcells, operator_type="PP", nlname="sab_almo")
996 CALL set_ks_env(ks_env=ks_env, sab_almo=sab_almo)
997 END IF
998
999 ! Print particle distribution
1000 print_key_path = "PRINT%DISTRIBUTION"
1001 IF (btest(cp_print_key_should_output(logger%iter_info, force_env_section, &
1002 print_key_path), &
1003 cp_p_file)) THEN
1004 iw = cp_print_key_unit_nr(logger=logger, &
1005 basis_section=force_env_section, &
1006 print_key_path=print_key_path, &
1007 extension=".out")
1008 CALL write_neighbor_distribution(sab_orb, qs_kind_set, iw, para_env)
1009 CALL cp_print_key_finished_output(unit_nr=iw, &
1010 logger=logger, &
1011 basis_section=force_env_section, &
1012 print_key_path=print_key_path)
1013 END IF
1014
1015 ! Release work storage
1016 CALL atom2d_cleanup(atom2d)
1017
1018 DEALLOCATE (atom2d)
1019 DEALLOCATE (orb_present, default_present, core_present)
1020 DEALLOCATE (orb_radius, aux_fit_radius, c_radius, core_radius)
1021 DEALLOCATE (calpha, zeff)
1022 DEALLOCATE (pair_radius)
1023 IF (gth_potential_present .OR. sgp_potential_present) THEN
1024 DEALLOCATE (ppl_present, ppl_radius)
1025 DEALLOCATE (ppnl_present, ppnl_radius)
1026 END IF
1027 IF (paw_atom_present) THEN
1028 DEALLOCATE (oce_present, oce_radius)
1029 END IF
1030 IF (all_potential_present .OR. sgp_potential_present) THEN
1031 DEALLOCATE (all_present, all_pot_rad)
1032 END IF
1033 IF (cneo_potential_present) THEN
1034 DEALLOCATE (cneo_present, nuc_orb_radius)
1035 END IF
1036
1037 CALL timestop(handle)
1038
1039 END SUBROUTINE build_qs_neighbor_lists
1040
1041! **************************************************************************************************
1042!> \brief Build simple pair neighbor lists.
1043!> \param ab_list ...
1044!> \param particle_set ...
1045!> \param atom ...
1046!> \param cell ...
1047!> \param pair_radius ...
1048!> \param subcells ...
1049!> \param mic ...
1050!> \param symmetric ...
1051!> \param molecular ...
1052!> \param subset_of_mol ...
1053!> \param current_subset ...
1054!> \param operator_type ...
1055!> \param nlname ...
1056!> \param atomb_to_keep the list of atom indices to keep for pairs from the atom2d%b_list
1057!> \date 20.03.2002
1058!> \par History
1059!> - Major refactoring (25.07.2010,jhu)
1060!> - Added option to filter out atoms from list_b (08.2018, A. Bussy)
1061!> \author MK
1062!> \version 2.0
1063! **************************************************************************************************
1064 SUBROUTINE build_neighbor_lists(ab_list, particle_set, atom, cell, pair_radius, subcells, &
1065 mic, symmetric, molecular, subset_of_mol, current_subset, &
1066 operator_type, nlname, atomb_to_keep)
1067
1068 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1069 POINTER :: ab_list
1070 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1071 TYPE(local_atoms_type), DIMENSION(:), INTENT(IN) :: atom
1072 TYPE(cell_type), POINTER :: cell
1073 REAL(dp), DIMENSION(:, :), INTENT(IN) :: pair_radius
1074 REAL(dp), INTENT(IN) :: subcells
1075 LOGICAL, INTENT(IN), OPTIONAL :: mic, symmetric, molecular
1076 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: subset_of_mol
1077 INTEGER, OPTIONAL :: current_subset
1078 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: operator_type
1079 CHARACTER(LEN=*), INTENT(IN) :: nlname
1080 INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL :: atomb_to_keep
1081
1082 CHARACTER(len=*), PARAMETER :: routinen = 'build_neighbor_lists'
1083
1084 TYPE local_lists
1085 INTEGER, DIMENSION(:), POINTER :: list
1086 END TYPE local_lists
1087
1088 INTEGER :: atom_a, atom_b, handle, i, iab, iatom, iatom_local, &
1089 iatom_subcell, icell, ikind, j, jatom, jatom_local, jcell, jkind, k, &
1090 kcell, maxat, mol_a, mol_b, nkind, otype, natom, inode, nnode, nentry
1091 INTEGER, DIMENSION(3) :: cell_b, ncell, nsubcell, periodic
1092 INTEGER, DIMENSION(:), POINTER :: index_list
1093 LOGICAL :: include_ab, my_mic, &
1094 my_molecular, my_symmetric, my_sort_atomb
1095 LOGICAL, ALLOCATABLE, DIMENSION(:) :: pres_a, pres_b
1096 REAL(dp) :: rab2, rab2_max, rab_max, rabm, deth, subcell_scale
1097 REAL(dp), DIMENSION(3) :: r, rab, ra, rb, sab_max, sb, &
1098 sb_pbc, sb_min, sb_max, rab_pbc, pd, sab_max_guard
1099 INTEGER, ALLOCATABLE, DIMENSION(:) :: nlista, nlistb
1100 TYPE(local_lists), DIMENSION(:), POINTER :: lista, listb
1101 TYPE(neighbor_list_p_type), &
1102 ALLOCATABLE, DIMENSION(:) :: kind_a
1103 TYPE(neighbor_list_set_type), POINTER :: neighbor_list_set
1104 TYPE(subcell_type), DIMENSION(:, :, :), &
1105 POINTER :: subcell
1106 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: r_pbc
1108 DIMENSION(:), POINTER :: nl_iterator
1109
1110 CALL timeset(routinen//"_"//trim(nlname), handle)
1111
1112 ! input options
1113 my_mic = .false.
1114 IF (PRESENT(mic)) my_mic = mic
1115 my_symmetric = .true.
1116 IF (PRESENT(symmetric)) my_symmetric = symmetric
1117 my_molecular = .false.
1118 ! if we have a molecular NL, MIC has to be used
1119 IF (PRESENT(molecular)) my_molecular = molecular
1120 ! check for operator types
1121 IF (PRESENT(operator_type)) THEN
1122 SELECT CASE (operator_type)
1123 CASE ("AB")
1124 otype = 1 ! simple overlap
1125 CASE ("ABC")
1126 otype = 2 ! for three center operators
1127 cpassert(.NOT. my_molecular)
1128 my_symmetric = .false.
1129 CASE ("ABBA")
1130 otype = 3 ! for separable nonlocal operators
1131 my_symmetric = .false.
1132 CASE ("PP")
1133 otype = 4 ! simple atomic pair potential list
1134 CASE default
1135 cpabort("")
1136 END SELECT
1137 ELSE
1138 ! default is a simple AB neighbor list
1139 otype = 1
1140 END IF
1141 my_sort_atomb = .false.
1142 IF (PRESENT(atomb_to_keep)) THEN
1143 my_sort_atomb = .true.
1144 END IF
1145
1146 nkind = SIZE(atom)
1147 ! Deallocate the old neighbor list structure
1148 CALL release_neighbor_list_sets(ab_list)
1149 ! Allocate and initialize the new neighbor list structure
1150 ALLOCATE (ab_list(nkind*nkind))
1151 DO iab = 1, SIZE(ab_list)
1152 NULLIFY (ab_list(iab)%neighbor_list_set)
1153 ab_list(iab)%nl_size = -1
1154 ab_list(iab)%nl_start = -1
1155 ab_list(iab)%nl_end = -1
1156 NULLIFY (ab_list(iab)%nlist_task)
1157 END DO
1158
1159 ! Allocate and initialize the kind availability
1160 ALLOCATE (pres_a(nkind), pres_b(nkind))
1161 DO ikind = 1, nkind
1162 pres_a(ikind) = any(pair_radius(ikind, :) > 0._dp)
1163 pres_b(ikind) = any(pair_radius(:, ikind) > 0._dp)
1164 END DO
1165
1166 ! create a copy of the pbc'ed coordinates
1167 natom = SIZE(particle_set)
1168 ALLOCATE (r_pbc(3, natom))
1169 DO i = 1, natom
1170 r_pbc(1:3, i) = pbc(particle_set(i)%r(1:3), cell)
1171 END DO
1172
1173 ! setup the local lists of atoms
1174 maxat = 0
1175 DO ikind = 1, nkind
1176 maxat = max(maxat, SIZE(atom(ikind)%list))
1177 END DO
1178 ALLOCATE (index_list(maxat))
1179 DO i = 1, maxat
1180 index_list(i) = i
1181 END DO
1182 ALLOCATE (lista(nkind), listb(nkind), nlista(nkind), nlistb(nkind))
1183 nlista = 0
1184 nlistb = 0
1185 DO ikind = 1, nkind
1186 NULLIFY (lista(ikind)%list, listb(ikind)%list)
1187 SELECT CASE (otype)
1188 CASE (1)
1189 IF (ASSOCIATED(atom(ikind)%list_local_a_index)) THEN
1190 lista(ikind)%list => atom(ikind)%list_local_a_index
1191 nlista(ikind) = SIZE(lista(ikind)%list)
1192 END IF
1193 IF (ASSOCIATED(atom(ikind)%list_local_b_index)) THEN
1194 listb(ikind)%list => atom(ikind)%list_local_b_index
1195 nlistb(ikind) = SIZE(listb(ikind)%list)
1196 END IF
1197 CASE (2)
1198 IF (ASSOCIATED(atom(ikind)%list_local_a_index)) THEN
1199 lista(ikind)%list => atom(ikind)%list_local_a_index
1200 nlista(ikind) = SIZE(lista(ikind)%list)
1201 END IF
1202 nlistb(ikind) = SIZE(atom(ikind)%list)
1203 listb(ikind)%list => index_list
1204 CASE (3)
1205 CALL combine_lists(lista(ikind)%list, nlista(ikind), ikind, atom)
1206 nlistb(ikind) = SIZE(atom(ikind)%list)
1207 listb(ikind)%list => index_list
1208 CASE (4)
1209 nlista(ikind) = SIZE(atom(ikind)%list_1d)
1210 lista(ikind)%list => atom(ikind)%list_1d
1211 nlistb(ikind) = SIZE(atom(ikind)%list)
1212 listb(ikind)%list => index_list
1213 CASE default
1214 cpabort("")
1215 END SELECT
1216 END DO
1217
1218 ! Determine max. number of local atoms
1219 maxat = 0
1220 DO ikind = 1, nkind
1221 maxat = max(maxat, nlista(ikind), nlistb(ikind))
1222 END DO
1223 ALLOCATE (kind_a(2*maxat))
1224
1225 ! Load informations about the simulation cell
1226 CALL get_cell(cell=cell, periodic=periodic, deth=deth)
1227
1228 ! Loop over all atomic kind pairs
1229 DO ikind = 1, nkind
1230 IF (.NOT. pres_a(ikind)) cycle
1231
1232 DO jkind = 1, nkind
1233 IF (.NOT. pres_b(jkind)) cycle
1234
1235 iab = ikind + nkind*(jkind - 1)
1236
1237 ! Calculate the square of the maximum interaction distance
1238 IF (pair_radius(ikind, jkind) <= 0._dp) cycle
1239 rab_max = pair_radius(ikind, jkind)
1240 IF (otype == 3) THEN
1241 ! Calculate the square of the maximum interaction distance
1242 ! for sac_max / ncell this must be the maximum over all kinds
1243 ! to be correct for three center terms involving different kinds
1244 rabm = maxval(pair_radius(:, jkind))
1245 ELSE
1246 rabm = rab_max
1247 END IF
1248 rab2_max = rabm*rabm
1249
1250 pd(1) = plane_distance(1, 0, 0, cell)
1251 pd(2) = plane_distance(0, 1, 0, cell)
1252 pd(3) = plane_distance(0, 0, 1, cell)
1253
1254 sab_max = rabm/pd
1255 sab_max_guard = 15.0_dp/pd
1256
1257 ! It makes sense to have fewer subcells for larger systems
1258 subcell_scale = ((125.0_dp**3)/deth)**(1.0_dp/6.0_dp)
1259
1260 ! guess the number of subcells for optimal performance,
1261 ! guard against crazy stuff triggered by very small rabm
1262 nsubcell(:) = int(max(1.0_dp, min(0.5_dp*subcells*subcell_scale/sab_max(:), &
1263 0.5_dp*subcells*subcell_scale/sab_max_guard(:))))
1264
1265 ! number of image cells to be considered
1266 ncell(:) = (int(sab_max(:)) + 1)*periodic(:)
1267
1268 CALL allocate_neighbor_list_set(neighbor_list_set=ab_list(iab)%neighbor_list_set, &
1269 symmetric=my_symmetric)
1270 neighbor_list_set => ab_list(iab)%neighbor_list_set
1271
1272 DO iatom_local = 1, nlista(ikind)
1273 iatom = lista(ikind)%list(iatom_local)
1274 atom_a = atom(ikind)%list(iatom)
1275 CALL add_neighbor_list(neighbor_list_set=neighbor_list_set, &
1276 atom=atom_a, &
1277 neighbor_list=kind_a(iatom_local)%neighbor_list)
1278 END DO
1279
1280 CALL allocate_subcell(subcell, nsubcell)
1281 DO iatom_local = 1, nlista(ikind)
1282 iatom = lista(ikind)%list(iatom_local)
1283 atom_a = atom(ikind)%list(iatom)
1284 r = r_pbc(:, atom_a)
1285 CALL give_ijk_subcell(r, i, j, k, cell, nsubcell)
1286 subcell(i, j, k)%natom = subcell(i, j, k)%natom + 1
1287 END DO
1288 DO k = 1, nsubcell(3)
1289 DO j = 1, nsubcell(2)
1290 DO i = 1, nsubcell(1)
1291 maxat = subcell(i, j, k)%natom + subcell(i, j, k)%natom/10
1292 ALLOCATE (subcell(i, j, k)%atom_list(maxat))
1293 subcell(i, j, k)%natom = 0
1294 END DO
1295 END DO
1296 END DO
1297 DO iatom_local = 1, nlista(ikind)
1298 iatom = lista(ikind)%list(iatom_local)
1299 atom_a = atom(ikind)%list(iatom)
1300 r = r_pbc(:, atom_a)
1301 CALL give_ijk_subcell(r, i, j, k, cell, nsubcell)
1302 subcell(i, j, k)%natom = subcell(i, j, k)%natom + 1
1303 subcell(i, j, k)%atom_list(subcell(i, j, k)%natom) = iatom_local
1304 END DO
1305
1306 DO jatom_local = 1, nlistb(jkind)
1307 jatom = listb(jkind)%list(jatom_local)
1308 atom_b = atom(jkind)%list(jatom)
1309 IF (my_sort_atomb .AND. .NOT. my_symmetric) THEN
1310 IF (.NOT. any(atomb_to_keep == atom_b)) cycle
1311 END IF
1312 IF (my_molecular) THEN
1313 mol_b = atom(jkind)%list_b_mol(jatom_local)
1314 IF (PRESENT(subset_of_mol)) THEN
1315 IF (subset_of_mol(mol_b) .NE. current_subset) cycle
1316 END IF
1317 END IF
1318 r = r_pbc(:, atom_b)
1319 CALL real_to_scaled(sb_pbc(:), r(:), cell)
1320
1321 loop2_kcell: DO kcell = -ncell(3), ncell(3)
1322 sb(3) = sb_pbc(3) + real(kcell, dp)
1323 sb_min(3) = sb(3) - sab_max(3)
1324 sb_max(3) = sb(3) + sab_max(3)
1325 IF (periodic(3) /= 0) THEN
1326 IF (sb_min(3) >= 0.5_dp) EXIT loop2_kcell
1327 IF (sb_max(3) < -0.5_dp) cycle loop2_kcell
1328 END IF
1329 cell_b(3) = kcell
1330
1331 loop2_jcell: DO jcell = -ncell(2), ncell(2)
1332 sb(2) = sb_pbc(2) + real(jcell, dp)
1333 sb_min(2) = sb(2) - sab_max(2)
1334 sb_max(2) = sb(2) + sab_max(2)
1335 IF (periodic(2) /= 0) THEN
1336 IF (sb_min(2) >= 0.5_dp) EXIT loop2_jcell
1337 IF (sb_max(2) < -0.5_dp) cycle loop2_jcell
1338 END IF
1339 cell_b(2) = jcell
1340
1341 loop2_icell: DO icell = -ncell(1), ncell(1)
1342 sb(1) = sb_pbc(1) + real(icell, dp)
1343 sb_min(1) = sb(1) - sab_max(1)
1344 sb_max(1) = sb(1) + sab_max(1)
1345 IF (periodic(1) /= 0) THEN
1346 IF (sb_min(1) >= 0.5_dp) EXIT loop2_icell
1347 IF (sb_max(1) < -0.5_dp) cycle loop2_icell
1348 END IF
1349 cell_b(1) = icell
1350
1351 CALL scaled_to_real(rb, sb, cell)
1352
1353 loop_k: DO k = 1, nsubcell(3)
1354 loop_j: DO j = 1, nsubcell(2)
1355 loop_i: DO i = 1, nsubcell(1)
1356
1357 ! FIXME for non-periodic systems, the whole subcell trick is skipped
1358 ! yielding a Natom**2 pair list build.
1359 IF (periodic(3) /= 0) THEN
1360 IF (sb_max(3) < subcell(i, j, k)%s_min(3)) EXIT loop_k
1361 IF (sb_min(3) >= subcell(i, j, k)%s_max(3)) cycle loop_k
1362 END IF
1363
1364 IF (periodic(2) /= 0) THEN
1365 IF (sb_max(2) < subcell(i, j, k)%s_min(2)) EXIT loop_j
1366 IF (sb_min(2) >= subcell(i, j, k)%s_max(2)) cycle loop_j
1367 END IF
1368
1369 IF (periodic(1) /= 0) THEN
1370 IF (sb_max(1) < subcell(i, j, k)%s_min(1)) EXIT loop_i
1371 IF (sb_min(1) >= subcell(i, j, k)%s_max(1)) cycle loop_i
1372 END IF
1373
1374 IF (subcell(i, j, k)%natom == 0) cycle
1375
1376 DO iatom_subcell = 1, subcell(i, j, k)%natom
1377 iatom_local = subcell(i, j, k)%atom_list(iatom_subcell)
1378 iatom = lista(ikind)%list(iatom_local)
1379 atom_a = atom(ikind)%list(iatom)
1380 IF (my_molecular) THEN
1381 mol_a = atom(ikind)%list_a_mol(iatom_local)
1382 IF (mol_a /= mol_b) cycle
1383 END IF
1384 IF (my_symmetric) THEN
1385 IF (atom_a > atom_b) THEN
1386 include_ab = (modulo(atom_a + atom_b, 2) /= 0)
1387 ELSE
1388 include_ab = (modulo(atom_a + atom_b, 2) == 0)
1389 END IF
1390 IF (my_sort_atomb) THEN
1391 IF ((.NOT. any(atomb_to_keep == atom_b)) .AND. &
1392 (.NOT. any(atomb_to_keep == atom_a))) THEN
1393 include_ab = .false.
1394 END IF
1395 END IF
1396 ELSE
1397 include_ab = .true.
1398 END IF
1399 IF (include_ab) THEN
1400 ra(:) = r_pbc(:, atom_a)
1401 rab(:) = rb(:) - ra(:)
1402 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
1403 IF (rab2 < rab2_max) THEN
1404 include_ab = .true.
1405 IF (my_mic) THEN
1406 ! only if rab is minimum image the pair will be included
1407 ! ideally the range of the pair list is < L/2 so
1408 ! that this never triggers
1409 rab_pbc(:) = pbc(rab(:), cell)
1410 IF (sum((rab_pbc - rab)**2) > epsilon(1.0_dp)) THEN
1411 include_ab = .false.
1412 END IF
1413 END IF
1414 IF (include_ab) THEN
1415 CALL add_neighbor_node( &
1416 neighbor_list=kind_a(iatom_local)%neighbor_list, &
1417 neighbor=atom_b, &
1418 cell=cell_b, &
1419 r=rab, &
1420 nkind=nkind)
1421 END IF
1422 END IF
1423 END IF
1424 END DO
1425
1426 END DO loop_i
1427 END DO loop_j
1428 END DO loop_k
1429
1430 END DO loop2_icell
1431 END DO loop2_jcell
1432 END DO loop2_kcell
1433
1434 END DO
1435
1436 CALL deallocate_subcell(subcell)
1437
1438 END DO
1439 END DO
1440
1441 SELECT CASE (otype)
1442 CASE (1:2, 4)
1443 CASE (3)
1444 DO ikind = 1, nkind
1445 DEALLOCATE (lista(ikind)%list)
1446 END DO
1447 CASE default
1448 cpabort("")
1449 END SELECT
1450 DEALLOCATE (kind_a, pres_a, pres_b, lista, listb, nlista, nlistb)
1451 DEALLOCATE (index_list)
1452 DEALLOCATE (r_pbc)
1453
1454 nentry = 0
1455 CALL neighbor_list_iterator_create(nl_iterator, ab_list)
1456 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1457 CALL get_iterator_info(nl_iterator, inode=inode, nnode=nnode)
1458 IF (inode == 1) nentry = nentry + nnode
1459 END DO
1460 CALL neighbor_list_iterator_release(nl_iterator)
1461 !
1462 ALLOCATE (ab_list(1)%nlist_task(nentry))
1463 ab_list(1)%nl_size = nentry
1464 DO iab = 2, SIZE(ab_list)
1465 ab_list(iab)%nl_size = nentry
1466 ab_list(iab)%nlist_task => ab_list(1)%nlist_task
1467 END DO
1468 !
1469 nentry = 0
1470 CALL neighbor_list_iterator_create(nl_iterator, ab_list)
1471 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1472 nentry = nentry + 1
1473 CALL get_iterator_task(nl_iterator, ab_list(1)%nlist_task(nentry))
1474 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, nkind=nkind)
1475 iab = (ikind - 1)*nkind + jkind
1476 IF (ab_list(iab)%nl_start < 0) ab_list(iab)%nl_start = nentry
1477 IF (ab_list(iab)%nl_end < 0) THEN
1478 ab_list(iab)%nl_end = nentry
1479 ELSE
1480 cpassert(ab_list(iab)%nl_end + 1 == nentry)
1481 ab_list(iab)%nl_end = nentry
1482 END IF
1483 END DO
1484 CALL neighbor_list_iterator_release(nl_iterator)
1485
1486 CALL timestop(handle)
1487
1488 END SUBROUTINE build_neighbor_lists
1489
1490! **************************************************************************************************
1491!> \brief Build a neighborlist
1492!> \param ab_list ...
1493!> \param basis_set_a ...
1494!> \param basis_set_b ...
1495!> \param qs_env ...
1496!> \param mic ...
1497!> \param symmetric ...
1498!> \param molecular ...
1499!> \param operator_type ...
1500!> \date 14.03.2016
1501!> \author JGH
1502! **************************************************************************************************
1503 SUBROUTINE setup_neighbor_list(ab_list, basis_set_a, basis_set_b, qs_env, &
1504 mic, symmetric, molecular, operator_type)
1505
1506 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1507 POINTER :: ab_list
1508 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_a
1509 TYPE(gto_basis_set_p_type), DIMENSION(:), &
1510 OPTIONAL, POINTER :: basis_set_b
1511 TYPE(qs_environment_type), POINTER :: qs_env
1512 LOGICAL, INTENT(IN), OPTIONAL :: mic, symmetric, molecular
1513 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: operator_type
1514
1515 CHARACTER(LEN=4) :: otype
1516 INTEGER :: ikind, nkind
1517 LOGICAL :: my_mic, my_molecular, my_symmetric
1518 LOGICAL, ALLOCATABLE, DIMENSION(:) :: a_present, b_present
1519 REAL(dp), ALLOCATABLE, DIMENSION(:) :: a_radius, b_radius
1520 REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: pair_radius
1521 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1522 TYPE(cell_type), POINTER :: cell
1523 TYPE(distribution_1d_type), POINTER :: distribution_1d
1524 TYPE(distribution_2d_type), POINTER :: distribution_2d
1525 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_a, basis_b
1526 TYPE(gto_basis_set_type), POINTER :: abas, bbas
1527 TYPE(local_atoms_type), ALLOCATABLE, DIMENSION(:) :: atom2d
1528 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
1529 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1530
1531 basis_a => basis_set_a
1532 IF (PRESENT(basis_set_b)) THEN
1533 basis_b => basis_set_b
1534 my_symmetric = .false.
1535 ELSE
1536 basis_b => basis_set_a
1537 my_symmetric = .true.
1538 END IF
1539 IF (PRESENT(symmetric)) my_symmetric = symmetric
1540
1541 IF (PRESENT(mic)) THEN
1542 my_mic = mic
1543 ELSE
1544 my_mic = .false.
1545 END IF
1546
1547 IF (PRESENT(molecular)) THEN
1548 my_molecular = molecular
1549 ELSE
1550 my_molecular = .false.
1551 END IF
1552
1553 IF (PRESENT(operator_type)) THEN
1554 otype = operator_type
1555 ELSE
1556 ! default is a simple AB neighbor list
1557 otype = "AB"
1558 END IF
1559
1560 nkind = SIZE(basis_a)
1561 ALLOCATE (a_present(nkind), b_present(nkind))
1562 a_present = .false.
1563 b_present = .false.
1564 ALLOCATE (a_radius(nkind), b_radius(nkind))
1565 a_radius = 0.0_dp
1566 b_radius = 0.0_dp
1567 DO ikind = 1, nkind
1568 IF (ASSOCIATED(basis_a(ikind)%gto_basis_set)) THEN
1569 a_present(ikind) = .true.
1570 abas => basis_a(ikind)%gto_basis_set
1571 CALL get_gto_basis_set(gto_basis_set=abas, kind_radius=a_radius(ikind))
1572 END IF
1573 IF (ASSOCIATED(basis_b(ikind)%gto_basis_set)) THEN
1574 b_present(ikind) = .true.
1575 bbas => basis_b(ikind)%gto_basis_set
1576 CALL get_gto_basis_set(gto_basis_set=bbas, kind_radius=b_radius(ikind))
1577 END IF
1578 END DO
1579
1580 ALLOCATE (pair_radius(nkind, nkind))
1581 pair_radius = 0.0_dp
1582 CALL pair_radius_setup(a_present, b_present, a_radius, b_radius, pair_radius)
1583
1584 CALL get_qs_env(qs_env, &
1585 atomic_kind_set=atomic_kind_set, &
1586 cell=cell, &
1587 distribution_2d=distribution_2d, &
1588 local_particles=distribution_1d, &
1589 particle_set=particle_set, &
1590 molecule_set=molecule_set)
1591
1592 ALLOCATE (atom2d(nkind))
1593 CALL atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, &
1594 molecule_set, my_molecular, particle_set=particle_set)
1595 CALL build_neighbor_lists(ab_list, particle_set, atom2d, cell, pair_radius, &
1596 mic=my_mic, symmetric=my_symmetric, molecular=my_molecular, &
1597 subcells=2.0_dp, nlname="AUX_NL")
1598
1599 CALL atom2d_cleanup(atom2d)
1600
1601 DEALLOCATE (a_present, b_present, a_radius, b_radius, pair_radius, atom2d)
1602
1603 END SUBROUTINE setup_neighbor_list
1604
1605! **************************************************************************************************
1606!> \brief ...
1607!> \param list ...
1608!> \param n ...
1609!> \param ikind ...
1610!> \param atom ...
1611! **************************************************************************************************
1612 SUBROUTINE combine_lists(list, n, ikind, atom)
1613 INTEGER, DIMENSION(:), POINTER :: list
1614 INTEGER, INTENT(OUT) :: n
1615 INTEGER, INTENT(IN) :: ikind
1616 TYPE(local_atoms_type), DIMENSION(:), INTENT(IN) :: atom
1617
1618 INTEGER :: i, ib, na, nb
1619 INTEGER, DIMENSION(:), POINTER :: lista, listb
1620
1621 cpassert(.NOT. ASSOCIATED(list))
1622
1623 lista => atom(ikind)%list_local_a_index
1624 listb => atom(ikind)%list_local_b_index
1625
1626 IF (ASSOCIATED(lista)) THEN
1627 na = SIZE(lista)
1628 ELSE
1629 na = 0
1630 END IF
1631
1632 IF (ASSOCIATED(listb)) THEN
1633 nb = SIZE(listb)
1634 ELSE
1635 nb = 0
1636 END IF
1637
1638 ALLOCATE (list(na + nb))
1639
1640 n = na
1641 IF (na .GT. 0) list(1:na) = lista(1:na)
1642 IF (nb .GT. 0) THEN
1643 loopb: DO ib = 1, nb
1644 DO i = 1, na
1645 IF (listb(ib) == list(i)) cycle loopb
1646 END DO
1647 n = n + 1
1648 list(n) = listb(ib)
1649 END DO loopb
1650 END IF
1651 END SUBROUTINE combine_lists
1652
1653! **************************************************************************************************
1654
1655! **************************************************************************************************
1656!> \brief ...
1657!> \param present_a ...
1658!> \param present_b ...
1659!> \param radius_a ...
1660!> \param radius_b ...
1661!> \param pair_radius ...
1662!> \param prmin ...
1663! **************************************************************************************************
1664 SUBROUTINE pair_radius_setup(present_a, present_b, radius_a, radius_b, pair_radius, prmin)
1665 LOGICAL, DIMENSION(:), INTENT(IN) :: present_a, present_b
1666 REAL(dp), DIMENSION(:), INTENT(IN) :: radius_a, radius_b
1667 REAL(dp), DIMENSION(:, :), INTENT(OUT) :: pair_radius
1668 REAL(dp), INTENT(IN), OPTIONAL :: prmin
1669
1670 INTEGER :: i, j, nkind
1671 REAL(dp) :: rrmin
1672
1673 nkind = SIZE(present_a)
1674
1675 pair_radius = 0._dp
1676
1677 rrmin = 0.0_dp
1678 IF (PRESENT(prmin)) rrmin = prmin
1679
1680 DO i = 1, nkind
1681 IF (.NOT. present_a(i)) cycle
1682 DO j = 1, nkind
1683 IF (.NOT. present_b(j)) cycle
1684 pair_radius(i, j) = radius_a(i) + radius_b(j)
1685 pair_radius(i, j) = max(pair_radius(i, j), rrmin)
1686 END DO
1687 END DO
1688
1689 END SUBROUTINE pair_radius_setup
1690
1691! **************************************************************************************************
1692!> \brief Print the distribution of the simple pair neighbor list.
1693!> \param ab ...
1694!> \param qs_kind_set ...
1695!> \param output_unit ...
1696!> \param para_env ...
1697!> \date 19.06.2003
1698!> \author MK
1699!> \version 1.0
1700! **************************************************************************************************
1701 SUBROUTINE write_neighbor_distribution(ab, qs_kind_set, output_unit, para_env)
1702 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1703 POINTER :: ab
1704 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1705 INTEGER, INTENT(in) :: output_unit
1706 TYPE(mp_para_env_type), POINTER :: para_env
1707
1708 CHARACTER(len=*), PARAMETER :: routinen = 'write_neighbor_distribution'
1709 LOGICAL, PARAMETER :: full_output = .false.
1710
1711 INTEGER :: handle, ikind, inode, ipe, jkind, n, &
1712 nkind, nnode
1713 INTEGER(int_8) :: nblock_max, nblock_sum, nelement_max, &
1714 nelement_sum, tmp(2)
1715 INTEGER, ALLOCATABLE, DIMENSION(:) :: nblock, nelement, nnsgf
1716 TYPE(gto_basis_set_type), POINTER :: orb_basis_set
1718 DIMENSION(:), POINTER :: nl_iterator
1719
1720 CALL timeset(routinen, handle)
1721 associate(mype => para_env%mepos + 1, npe => para_env%num_pe)
1722
1723 ! Allocate work storage
1724 ALLOCATE (nblock(npe), nelement(npe))
1725 nblock(:) = 0
1726 nelement(:) = 0
1727 nkind = SIZE(qs_kind_set)
1728 ALLOCATE (nnsgf(nkind))
1729 nnsgf = 1
1730 DO ikind = 1, nkind
1731 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1732 IF (ASSOCIATED(orb_basis_set)) THEN
1733 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, nsgf=nnsgf(ikind))
1734 END IF
1735 END DO
1736
1737 CALL neighbor_list_iterator_create(nl_iterator, ab)
1738 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1739 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, inode=inode, nnode=nnode)
1740 IF (inode == 1) THEN
1741 n = nnsgf(ikind)*nnsgf(jkind)
1742 nblock(mype) = nblock(mype) + nnode
1743 nelement(mype) = nelement(mype) + n*nnode
1744 END IF
1745 END DO
1746 CALL neighbor_list_iterator_release(nl_iterator)
1747
1748 IF (full_output) THEN
1749 ! XXXXXXXX should gather/scatter this on ionode
1750 CALL para_env%sum(nblock)
1751 CALL para_env%sum(nelement)
1752
1753 nblock_sum = sum(int(nblock, kind=int_8))
1754 nelement_sum = sum(int(nelement, kind=int_8))
1755 ELSE
1756 nblock_sum = nblock(mype)
1757 nblock_max = nblock(mype)
1758 nelement_sum = nelement(mype)
1759 nelement_max = nelement(mype)
1760 tmp = (/nblock_sum, nelement_sum/)
1761 CALL para_env%sum(tmp)
1762 nblock_sum = tmp(1); nelement_sum = tmp(2)
1763 tmp = (/nblock_max, nelement_max/)
1764 CALL para_env%max(tmp)
1765 nblock_max = tmp(1); nelement_max = tmp(2)
1766 END IF
1767
1768 IF (output_unit > 0) THEN
1769 IF (full_output) THEN
1770 WRITE (unit=output_unit, &
1771 fmt="(/,/,T2,A,/,/,T3,A,/,/,(T4,I6,T27,I10,T55,I10))") &
1772 "DISTRIBUTION OF THE NEIGHBOR LISTS", &
1773 "Process Number of particle pairs Number of matrix elements", &
1774 (ipe - 1, nblock(ipe), nelement(ipe), ipe=1, npe)
1775 WRITE (unit=output_unit, fmt="(/,T7,A3,T27,I10,T55,I10)") &
1776 "Sum", sum(nblock), sum(nelement)
1777 ELSE
1778 WRITE (unit=output_unit, fmt="(/,T2,A)") "DISTRIBUTION OF THE NEIGHBOR LISTS"
1779 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Total number of particle pairs:", nblock_sum
1780 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Total number of matrix elements:", nelement_sum
1781 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Average number of particle pairs:", (nblock_sum + npe - 1)/npe
1782 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Maximum number of particle pairs:", nblock_max
1783 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Average number of matrix element:", (nelement_sum + npe - 1)/npe
1784 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Maximum number of matrix elements:", nelement_max
1785 END IF
1786 END IF
1787 END associate
1788
1789 ! Release work storage
1790
1791 DEALLOCATE (nblock, nelement, nnsgf)
1792
1793 CALL timestop(handle)
1794
1795 END SUBROUTINE write_neighbor_distribution
1796
1797! **************************************************************************************************
1798!> \brief Write a set of neighbor lists to the output unit.
1799!> \param ab ...
1800!> \param particle_set ...
1801!> \param cell ...
1802!> \param para_env ...
1803!> \param neighbor_list_section ...
1804!> \param nl_type ...
1805!> \param middle_name ...
1806!> \param nlname ...
1807!> \date 04.03.2002
1808!> \par History
1809!> - Adapted to the new parallelized neighbor list version
1810!> (26.06.2003,MK)
1811!> \author MK
1812!> \version 1.0
1813! **************************************************************************************************
1814 SUBROUTINE write_neighbor_lists(ab, particle_set, cell, para_env, neighbor_list_section, &
1815 nl_type, middle_name, nlname)
1816
1817 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1818 POINTER :: ab
1819 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1820 TYPE(cell_type), POINTER :: cell
1821 TYPE(mp_para_env_type), POINTER :: para_env
1822 TYPE(section_vals_type), POINTER :: neighbor_list_section
1823 CHARACTER(LEN=*), INTENT(IN) :: nl_type, middle_name, nlname
1824
1825 CHARACTER(LEN=default_string_length) :: string, unit_str
1826 INTEGER :: iatom, inode, iw, jatom, nneighbor, nnode
1827 INTEGER, DIMENSION(3) :: cell_b
1828 REAL(dp) :: dab, unit_conv
1829 REAL(dp), DIMENSION(3) :: ra, rab, rb
1830 TYPE(cp_logger_type), POINTER :: logger
1831 TYPE(neighbor_list_iterator_p_type), &
1832 DIMENSION(:), POINTER :: nl_iterator
1833
1834 NULLIFY (logger)
1835 logger => cp_get_default_logger()
1836 IF (btest(cp_print_key_should_output(logger%iter_info, neighbor_list_section, &
1837 trim(nl_type)), &
1838 cp_p_file)) THEN
1839 iw = cp_print_key_unit_nr(logger=logger, &
1840 basis_section=neighbor_list_section, &
1841 print_key_path=trim(nl_type), &
1842 extension=".out", &
1843 middle_name=trim(middle_name), &
1844 local=.true., &
1845 log_filename=.false., &
1846 file_position="REWIND")
1847 associate(mype => para_env%mepos)
1848 CALL section_vals_val_get(neighbor_list_section, "UNIT", c_val=unit_str)
1849 unit_conv = cp_unit_from_cp2k(1.0_dp, trim(unit_str))
1850
1851 ! Print headline
1852 string = ""
1853 WRITE (unit=string, fmt="(A,I5,A)") &
1854 trim(nlname)//" IN "//trim(unit_str)//" (PROCESS", mype, ")"
1855 CALL compress(string)
1856 IF (iw > 0) WRITE (unit=iw, fmt="(/,/,T2,A)") trim(string)
1857
1858 nneighbor = 0
1859
1860 CALL neighbor_list_iterator_create(nl_iterator, ab)
1861 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1862 CALL get_iterator_info(nl_iterator, inode=inode, nnode=nnode, &
1863 iatom=iatom, jatom=jatom, cell=cell_b, r=rab)
1864 nneighbor = nneighbor + 1
1865 ra(:) = pbc(particle_set(iatom)%r, cell)
1866 rb(:) = ra(:) + rab(:)
1867 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
1868 IF (iw > 0) THEN
1869 IF (inode == 1) THEN
1870 WRITE (unit=iw, fmt="(/,T2,I5,3X,I6,3X,3F12.6)") &
1871 iatom, nnode, ra(1:3)*unit_conv
1872 END IF
1873 WRITE (unit=iw, fmt="(T10,I6,3X,3I4,3F12.6,2X,F12.6)") &
1874 jatom, cell_b(1:3), rb(1:3)*unit_conv, dab*unit_conv
1875 END IF
1876 END DO
1877 CALL neighbor_list_iterator_release(nl_iterator)
1878
1879 string = ""
1880 WRITE (unit=string, fmt="(A,I12,A,I12)") &
1881 "Total number of neighbor interactions for process", mype, ":", &
1882 nneighbor
1883 CALL compress(string)
1884 IF (iw > 0) WRITE (unit=iw, fmt="(/,T2,A)") trim(string)
1885 CALL cp_print_key_finished_output(unit_nr=iw, &
1886 logger=logger, &
1887 basis_section=neighbor_list_section, &
1888 print_key_path=trim(nl_type), &
1889 local=.true.)
1890 END associate
1891 END IF
1892
1893 END SUBROUTINE write_neighbor_lists
1894
1895END MODULE qs_neighbor_lists
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Types for all ALMO-based methods.
real(kind=dp), parameter, public almo_max_cutoff_multiplier
Definition atom.F:9
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)
...
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
Definition cell_types.F:516
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
Definition cell_types.F:486
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
Definition cell_types.F:195
real(kind=dp) function, public plane_distance(h, k, l, cell)
Calculate the distance between two lattice planes as defined by a triple of Miller indices (hkl).
Definition cell_types.F:252
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Definition cp_units.F:1178
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
subroutine, public ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
Definition of the atomic potential types.
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_method_rigpw
integer, parameter, public dispersion_uff
integer, parameter, public vdw_pairpot_dftd4
integer, parameter, public do_potential_truncated
integer, parameter, public do_potential_id
integer, parameter, public do_method_lrigpw
integer, parameter, public do_potential_short
integer, parameter, public do_se_is_slater
integer, parameter, public do_potential_mix_cl_trunc
integer, parameter, public xc_vdw_fun_pairpot
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public int_8
Definition kinds.F:54
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Types and basic routines needed for a kpoint calculation.
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
real(kind=dp), parameter, public cutoff_screen_factor
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition list.F:24
Collection of simple mathematical functions and subroutines.
Definition mathlib.F:15
subroutine, public erfc_cutoff(eps, omg, r_cutoff)
compute a truncation radius for the shortrange operator
Definition mathlib.F:1686
Interface to the message passing library MPI.
Define the data structure for the molecule information.
Define the data structure for the particle information.
subroutine, public get_paw_proj_set(paw_proj_set, csprj, chprj, first_prj, first_prjs, last_prj, local_oce_sphi_h, local_oce_sphi_s, maxl, ncgauprj, nsgauprj, nsatbas, nsotot, nprj, o2nindex, n2oindex, rcprj, rzetprj, zisomin, zetprj)
Get informations about a paw projectors set.
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public bohr
Definition physcon.F:147
Types used by CNEO-DFT (see J. Chem. Theory Comput. 2025, 21, 16, 7865–7877)
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
Definition of disperson types for DFT calculations.
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, 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, 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, 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.
Definition of gCP types for DFT calculations.
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, 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, init_u_ramping_each_scf, reltmat, ghost, 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, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public get_iterator_task(iterator_set, task, mepos)
Captures the current state of the iterator in a neighbor_list_task_type.
subroutine, public release_neighbor_list_sets(nlists)
releases an array of neighbor_list_sets
subroutine, public add_neighbor_node(neighbor_list, neighbor, cell, r, exclusion_list, nkind)
Add a new neighbor list node to a neighbor list.
subroutine, public add_neighbor_list(neighbor_list_set, atom, neighbor_list)
Add a new neighbor list to a neighbor list set.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public allocate_neighbor_list_set(neighbor_list_set, symmetric)
Allocate and initialize a set of neighbor lists.
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
Generate the atomic neighbor lists.
subroutine, public atom2d_cleanup(atom2d)
free the internals of atom2d
subroutine, public build_qs_neighbor_lists(qs_env, para_env, molecular, force_env_section)
Build all the required neighbor lists for Quickstep.
subroutine, public pair_radius_setup(present_a, present_b, radius_a, radius_b, pair_radius, prmin)
...
subroutine, public build_neighbor_lists(ab_list, particle_set, atom, cell, pair_radius, subcells, mic, symmetric, molecular, subset_of_mol, current_subset, operator_type, nlname, atomb_to_keep)
Build simple pair neighbor lists.
subroutine, public setup_neighbor_list(ab_list, basis_set_a, basis_set_b, qs_env, mic, symmetric, molecular, operator_type)
Build a neighborlist.
subroutine, public write_neighbor_lists(ab, particle_set, cell, para_env, neighbor_list_section, nl_type, middle_name, nlname)
Write a set of neighbor lists to the output unit.
subroutine, public atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, molecule_set, molecule_only, particle_set)
Build some distribution structure of atoms, refactored from build_qs_neighbor_lists.
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
subcell types and allocation routines
subroutine, public deallocate_subcell(subcell)
Deallocate a subcell grid structure.
subroutine, public give_ijk_subcell(r, i, j, k, cell, nsubcell)
...
subroutine, public allocate_subcell(subcell, nsubcell, maxatom, cell)
Allocate and initialize a subcell grid structure for the atomic neighbor search.
All kind of helpful little routines.
Definition util.F:14
pure integer function, public locate(array, x)
Purpose: Given an array array(1:n), and given a value x, a value x_index is returned which is the ind...
Definition util.F:61
Definition of the xTB parameter types.
Definition xtb_types.F:20
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, xi, kappa0, alpg, occupation, electronegativity, chmax, en, kqat2, kcn, kq)
...
Definition xtb_types.F:199
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
type of a logger, at the moment it contains just a print level starting at which level it should be l...
structure to store local (to a processor) ordered lists of integers.
distributes pairs on a 2d grid of processors
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...