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