(git:d3d49ac)
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: &
58 USE kinds, ONLY: default_string_length,&
59 dp,&
60 int_8
61 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 IF (lrigpw .OR. lri_optbas) THEN
957 ! set neighborlists in lri_env environment
958 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
959 soo_list => qs_env%lri_env%soo_list
960 CALL build_neighbor_lists(soo_list, particle_set, atom2d, cell, pair_radius, &
961 mic=mic, molecular=molecule_only, subcells=subcells, nlname="soo_list")
962 qs_env%lri_env%soo_list => soo_list
963 CALL write_neighbor_lists(soo_list, particle_set, cell, para_env, neighbor_list_section, &
964 "/SOO_LIST", "soo_list", "ORBITAL ORBITAL (RI)")
965 ELSE IF (rigpw) THEN
966 ALLOCATE (ri_present(nkind), ri_radius(nkind))
967 ri_present = .false.
968 ri_radius = 0.0_dp
969 DO ikind = 1, nkind
970 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis_set, basis_type="RI_HXC")
971 IF (ASSOCIATED(ri_basis_set)) THEN
972 ri_present(ikind) = .true.
973 CALL get_gto_basis_set(gto_basis_set=ri_basis_set, kind_radius=ri_radius(ikind))
974 ELSE
975 ri_present(ikind) = .false.
976 END IF
977 END DO
978 ! set neighborlists in lri_env environment
979 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
980 soo_list => qs_env%lri_env%soo_list
981 CALL build_neighbor_lists(soo_list, particle_set, atom2d, cell, pair_radius, &
982 mic=mic, molecular=molecule_only, subcells=subcells, nlname="soo_list")
983 qs_env%lri_env%soo_list => soo_list
984 !
985 CALL pair_radius_setup(ri_present, ri_present, ri_radius, ri_radius, pair_radius)
986 saa_list => qs_env%lri_env%saa_list
987 CALL build_neighbor_lists(saa_list, particle_set, atom2d, cell, pair_radius, &
988 mic=mic, molecular=molecule_only, subcells=subcells, nlname="saa_list")
989 qs_env%lri_env%saa_list => saa_list
990 !
991 CALL pair_radius_setup(ri_present, orb_present, ri_radius, orb_radius, pair_radius)
992 soa_list => qs_env%lri_env%soa_list
993 CALL build_neighbor_lists(soa_list, particle_set, atom2d, cell, pair_radius, &
994 mic=mic, symmetric=.false., molecular=molecule_only, &
995 subcells=subcells, operator_type="ABC", nlname="saa_list")
996 qs_env%lri_env%soa_list => soa_list
997 END IF
998
999 ! Build the neighbor lists for the ALMO delocalization
1000 IF (almo) THEN
1001 DO ikind = 1, nkind
1002 CALL get_atomic_kind(atomic_kind_set(ikind), rcov=almo_rcov, rvdw=almo_rvdw)
1003 ! multiply the radius by some hard-coded number
1004 c_radius(ikind) = max(almo_rcov, almo_rvdw)*bohr* &
1006 END DO
1007 default_present = .true. !include all atoms (even without basis)
1008 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
1009 CALL build_neighbor_lists(sab_almo, particle_set, atom2d, cell, pair_radius, &
1010 subcells=subcells, operator_type="PP", nlname="sab_almo")
1011 CALL set_ks_env(ks_env=ks_env, sab_almo=sab_almo)
1012 END IF
1013
1014 ! Print particle distribution
1015 print_key_path = "PRINT%DISTRIBUTION"
1016 IF (btest(cp_print_key_should_output(logger%iter_info, force_env_section, &
1017 print_key_path), &
1018 cp_p_file)) THEN
1019 iw = cp_print_key_unit_nr(logger=logger, &
1020 basis_section=force_env_section, &
1021 print_key_path=print_key_path, &
1022 extension=".out")
1023 CALL write_neighbor_distribution(sab_orb, qs_kind_set, iw, para_env)
1024 CALL cp_print_key_finished_output(unit_nr=iw, &
1025 logger=logger, &
1026 basis_section=force_env_section, &
1027 print_key_path=print_key_path)
1028 END IF
1029
1030 ! Release work storage
1031 CALL atom2d_cleanup(atom2d)
1032
1033 DEALLOCATE (atom2d)
1034 DEALLOCATE (orb_present, default_present, core_present)
1035 DEALLOCATE (orb_radius, aux_fit_radius, c_radius, core_radius)
1036 DEALLOCATE (calpha, zeff)
1037 DEALLOCATE (pair_radius)
1038 IF (gth_potential_present .OR. sgp_potential_present) THEN
1039 DEALLOCATE (ppl_present, ppl_radius)
1040 DEALLOCATE (ppnl_present, ppnl_radius)
1041 END IF
1042 IF (paw_atom_present) THEN
1043 DEALLOCATE (oce_present, oce_radius)
1044 END IF
1045 IF (all_potential_present .OR. sgp_potential_present) THEN
1046 DEALLOCATE (all_present, all_pot_rad)
1047 END IF
1048 IF (cneo_potential_present) THEN
1049 DEALLOCATE (cneo_present, nuc_orb_radius)
1050 END IF
1051
1052 CALL timestop(handle)
1053
1054 END SUBROUTINE build_qs_neighbor_lists
1055
1056! **************************************************************************************************
1057!> \brief Build simple pair neighbor lists.
1058!> \param ab_list ...
1059!> \param particle_set ...
1060!> \param atom ...
1061!> \param cell ...
1062!> \param pair_radius ...
1063!> \param subcells ...
1064!> \param mic ...
1065!> \param symmetric ...
1066!> \param molecular ...
1067!> \param subset_of_mol ...
1068!> \param current_subset ...
1069!> \param operator_type ...
1070!> \param nlname ...
1071!> \param atomb_to_keep the list of atom indices to keep for pairs from the atom2d%b_list
1072!> \param stable_images use a deterministic half-cell convention for atom images
1073!> \date 20.03.2002
1074!> \par History
1075!> - Major refactoring (25.07.2010,jhu)
1076!> - Added option to filter out atoms from list_b (08.2018, A. Bussy)
1077!> \author MK
1078!> \version 2.0
1079! **************************************************************************************************
1080 SUBROUTINE build_neighbor_lists(ab_list, particle_set, atom, cell, pair_radius, subcells, &
1081 mic, symmetric, molecular, subset_of_mol, current_subset, &
1082 operator_type, nlname, atomb_to_keep, stable_images)
1083
1084 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1085 POINTER :: ab_list
1086 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1087 TYPE(local_atoms_type), DIMENSION(:), INTENT(IN) :: atom
1088 TYPE(cell_type), POINTER :: cell
1089 REAL(dp), DIMENSION(:, :), INTENT(IN) :: pair_radius
1090 REAL(dp), INTENT(IN) :: subcells
1091 LOGICAL, INTENT(IN), OPTIONAL :: mic, symmetric, molecular
1092 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: subset_of_mol
1093 INTEGER, OPTIONAL :: current_subset
1094 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: operator_type
1095 CHARACTER(LEN=*), INTENT(IN) :: nlname
1096 INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL :: atomb_to_keep
1097 LOGICAL, INTENT(IN), OPTIONAL :: stable_images
1098
1099 CHARACTER(len=*), PARAMETER :: routinen = 'build_neighbor_lists'
1100
1101 INTEGER :: atom_a, atom_b, handle, i, iab, iatom, iatom_local, iatom_subcell, icell, ikind, &
1102 inode, j, jatom, jatom_local, jcell, jkind, k, kcell, maxat, mol_a, mol_b, natom, nentry, &
1103 nkind, nnode, otype
1104 INTEGER, ALLOCATABLE, DIMENSION(:) :: nlista, nlistb
1105 INTEGER, DIMENSION(3) :: cell_b, ncell, nsubcell, periodic
1106 INTEGER, DIMENSION(:), POINTER :: index_list
1107 LOGICAL :: include_ab, my_mic, my_molecular, &
1108 my_sort_atomb, my_stable_images, &
1109 my_symmetric
1110 LOGICAL, ALLOCATABLE, DIMENSION(:) :: pres_a, pres_b
1111 REAL(dp) :: deth, rab2, rab2_max, rab_max, rabm, &
1112 subcell_scale
1113 REAL(dp), DIMENSION(3) :: pd, r, ra, rab, rab_pbc, rb, sab_max, &
1114 sab_max_guard, sb, sb_max, sb_min, &
1115 sb_pbc
1116 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: r_pbc
1117 TYPE(local_lists), DIMENSION(:), POINTER :: lista, listb
1119 DIMENSION(:), POINTER :: nl_iterator
1120 TYPE(neighbor_list_p_type), ALLOCATABLE, &
1121 DIMENSION(:) :: kind_a
1122 TYPE(neighbor_list_set_type), POINTER :: neighbor_list_set
1123 TYPE(subcell_type), DIMENSION(:, :, :), POINTER :: subcell
1124
1125 CALL timeset(routinen//"_"//trim(nlname), handle)
1126
1127 ! input options
1128 my_mic = .false.
1129 IF (PRESENT(mic)) my_mic = mic
1130 my_symmetric = .true.
1131 IF (PRESENT(symmetric)) my_symmetric = symmetric
1132 my_molecular = .false.
1133 ! if we have a molecular NL, MIC has to be used
1134 IF (PRESENT(molecular)) my_molecular = molecular
1135 my_stable_images = .false.
1136 IF (PRESENT(stable_images)) my_stable_images = stable_images
1137 ! check for operator types
1138 IF (PRESENT(operator_type)) THEN
1139 SELECT CASE (operator_type)
1140 CASE ("AB")
1141 otype = 1 ! simple overlap
1142 CASE ("ABC")
1143 otype = 2 ! for three center operators
1144 cpassert(.NOT. my_molecular)
1145 my_symmetric = .false.
1146 CASE ("ABBA")
1147 otype = 3 ! for separable nonlocal operators
1148 my_symmetric = .false.
1149 CASE ("PP")
1150 otype = 4 ! simple atomic pair potential list
1151 CASE default
1152 CALL cp_abort(__location__, &
1153 "<AB>, <ABC>, <ABBA>, <PP> are supported as the <operator_type> "// &
1154 "for build_neighbor_lists, found unknown option "// &
1155 "<"//trim(operator_type)//">")
1156 END SELECT
1157 ELSE
1158 ! default is a simple AB neighbor list
1159 otype = 1
1160 END IF
1161 my_sort_atomb = .false.
1162 IF (PRESENT(atomb_to_keep)) THEN
1163 my_sort_atomb = .true.
1164 END IF
1165
1166 nkind = SIZE(atom)
1167 ! Deallocate the old neighbor list structure
1168 CALL release_neighbor_list_sets(ab_list)
1169 ! Allocate and initialize the new neighbor list structure
1170 ALLOCATE (ab_list(nkind*nkind))
1171 DO iab = 1, SIZE(ab_list)
1172 NULLIFY (ab_list(iab)%neighbor_list_set)
1173 ab_list(iab)%nl_size = -1
1174 ab_list(iab)%nl_start = -1
1175 ab_list(iab)%nl_end = -1
1176 NULLIFY (ab_list(iab)%nlist_task)
1177 END DO
1178
1179 ! Allocate and initialize the kind availability
1180 ALLOCATE (pres_a(nkind), pres_b(nkind))
1181 DO ikind = 1, nkind
1182 pres_a(ikind) = any(pair_radius(ikind, :) > 0._dp)
1183 pres_b(ikind) = any(pair_radius(:, ikind) > 0._dp)
1184 END DO
1185
1186 ! create a copy of the pbc'ed coordinates
1187 natom = SIZE(particle_set)
1188 ALLOCATE (r_pbc(3, natom))
1189 DO i = 1, natom
1190 IF (my_stable_images) THEN
1191 r_pbc(1:3, i) = pbc_stable(particle_set(i)%r(1:3), cell)
1192 ELSE
1193 r_pbc(1:3, i) = pbc(particle_set(i)%r(1:3), cell)
1194 END IF
1195 END DO
1196
1197 ! setup the local lists of atoms
1198 maxat = 0
1199 DO ikind = 1, nkind
1200 maxat = max(maxat, SIZE(atom(ikind)%list))
1201 END DO
1202 ALLOCATE (index_list(maxat))
1203 DO i = 1, maxat
1204 index_list(i) = i
1205 END DO
1206 ALLOCATE (lista(nkind), listb(nkind), nlista(nkind), nlistb(nkind))
1207 nlista = 0
1208 nlistb = 0
1209 DO ikind = 1, nkind
1210 NULLIFY (lista(ikind)%list, listb(ikind)%list)
1211 SELECT CASE (otype)
1212 CASE (1)
1213 IF (ASSOCIATED(atom(ikind)%list_local_a_index)) THEN
1214 lista(ikind)%list => atom(ikind)%list_local_a_index
1215 nlista(ikind) = SIZE(lista(ikind)%list)
1216 END IF
1217 IF (ASSOCIATED(atom(ikind)%list_local_b_index)) THEN
1218 listb(ikind)%list => atom(ikind)%list_local_b_index
1219 nlistb(ikind) = SIZE(listb(ikind)%list)
1220 END IF
1221 CASE (2)
1222 IF (ASSOCIATED(atom(ikind)%list_local_a_index)) THEN
1223 lista(ikind)%list => atom(ikind)%list_local_a_index
1224 nlista(ikind) = SIZE(lista(ikind)%list)
1225 END IF
1226 nlistb(ikind) = SIZE(atom(ikind)%list)
1227 listb(ikind)%list => index_list
1228 CASE (3)
1229 CALL combine_lists(lista(ikind)%list, nlista(ikind), ikind, atom)
1230 nlistb(ikind) = SIZE(atom(ikind)%list)
1231 listb(ikind)%list => index_list
1232 CASE (4)
1233 nlista(ikind) = SIZE(atom(ikind)%list_1d)
1234 lista(ikind)%list => atom(ikind)%list_1d
1235 nlistb(ikind) = SIZE(atom(ikind)%list)
1236 listb(ikind)%list => index_list
1237 CASE default
1238 cpabort("Only 1, 2, 3, 4 are supported as otype for the operator")
1239 END SELECT
1240 END DO
1241
1242 ! Determine max. number of local atoms
1243 maxat = 0
1244 DO ikind = 1, nkind
1245 maxat = max(maxat, nlista(ikind), nlistb(ikind))
1246 END DO
1247 ALLOCATE (kind_a(2*maxat))
1248
1249 ! Load informations about the simulation cell
1250 CALL get_cell(cell=cell, periodic=periodic, deth=deth)
1251
1252 ! Loop over all atomic kind pairs
1253 DO ikind = 1, nkind
1254 IF (.NOT. pres_a(ikind)) cycle
1255
1256 DO jkind = 1, nkind
1257 IF (.NOT. pres_b(jkind)) cycle
1258
1259 iab = ikind + nkind*(jkind - 1)
1260
1261 ! Calculate the square of the maximum interaction distance
1262 IF (pair_radius(ikind, jkind) <= 0._dp) cycle
1263 rab_max = pair_radius(ikind, jkind)
1264 IF (otype == 3) THEN
1265 ! Calculate the square of the maximum interaction distance
1266 ! for sac_max / ncell this must be the maximum over all kinds
1267 ! to be correct for three center terms involving different kinds
1268 rabm = maxval(pair_radius(:, jkind))
1269 ELSE
1270 rabm = rab_max
1271 END IF
1272 rab2_max = rabm*rabm
1273
1274 pd(1) = plane_distance(1, 0, 0, cell)
1275 pd(2) = plane_distance(0, 1, 0, cell)
1276 pd(3) = plane_distance(0, 0, 1, cell)
1277
1278 sab_max = rabm/pd
1279 sab_max_guard = 15.0_dp/pd
1280
1281 ! It makes sense to have fewer subcells for larger systems
1282 subcell_scale = ((125.0_dp**3)/deth)**(1.0_dp/6.0_dp)
1283
1284 ! guess the number of subcells for optimal performance,
1285 ! guard against crazy stuff triggered by very small rabm
1286 nsubcell(:) = int(max(1.0_dp, min(0.5_dp*subcells*subcell_scale/sab_max(:), &
1287 0.5_dp*subcells*subcell_scale/sab_max_guard(:))))
1288
1289 ! number of image cells to be considered
1290 ncell(:) = (int(sab_max(:)) + 1)*periodic(:)
1291
1292 CALL allocate_neighbor_list_set(neighbor_list_set=ab_list(iab)%neighbor_list_set, &
1293 symmetric=my_symmetric)
1294 neighbor_list_set => ab_list(iab)%neighbor_list_set
1295
1296 DO iatom_local = 1, nlista(ikind)
1297 iatom = lista(ikind)%list(iatom_local)
1298 atom_a = atom(ikind)%list(iatom)
1299 CALL add_neighbor_list(neighbor_list_set=neighbor_list_set, &
1300 atom=atom_a, &
1301 neighbor_list=kind_a(iatom_local)%neighbor_list)
1302 END DO
1303
1304 CALL allocate_subcell(subcell, nsubcell)
1305 DO iatom_local = 1, nlista(ikind)
1306 iatom = lista(ikind)%list(iatom_local)
1307 atom_a = atom(ikind)%list(iatom)
1308 r = r_pbc(:, atom_a)
1309 CALL give_ijk_subcell(r, i, j, k, cell, nsubcell)
1310 subcell(i, j, k)%natom = subcell(i, j, k)%natom + 1
1311 END DO
1312 DO k = 1, nsubcell(3)
1313 DO j = 1, nsubcell(2)
1314 DO i = 1, nsubcell(1)
1315 maxat = subcell(i, j, k)%natom + subcell(i, j, k)%natom/10
1316 ALLOCATE (subcell(i, j, k)%atom_list(maxat))
1317 subcell(i, j, k)%natom = 0
1318 END DO
1319 END DO
1320 END DO
1321 DO iatom_local = 1, nlista(ikind)
1322 iatom = lista(ikind)%list(iatom_local)
1323 atom_a = atom(ikind)%list(iatom)
1324 r = r_pbc(:, atom_a)
1325 CALL give_ijk_subcell(r, i, j, k, cell, nsubcell)
1326 subcell(i, j, k)%natom = subcell(i, j, k)%natom + 1
1327 subcell(i, j, k)%atom_list(subcell(i, j, k)%natom) = iatom_local
1328 END DO
1329
1330 DO jatom_local = 1, nlistb(jkind)
1331 jatom = listb(jkind)%list(jatom_local)
1332 atom_b = atom(jkind)%list(jatom)
1333 IF (my_sort_atomb .AND. .NOT. my_symmetric) THEN
1334 IF (.NOT. any(atomb_to_keep == atom_b)) cycle
1335 END IF
1336 IF (my_molecular) THEN
1337 mol_b = atom(jkind)%list_b_mol(jatom_local)
1338 IF (PRESENT(subset_of_mol)) THEN
1339 IF (subset_of_mol(mol_b) /= current_subset) cycle
1340 END IF
1341 END IF
1342 r = r_pbc(:, atom_b)
1343 CALL real_to_scaled(sb_pbc(:), r(:), cell)
1344
1345 loop2_kcell: DO kcell = -ncell(3), ncell(3)
1346 sb(3) = sb_pbc(3) + real(kcell, dp)
1347 sb_min(3) = sb(3) - sab_max(3)
1348 sb_max(3) = sb(3) + sab_max(3)
1349 IF (periodic(3) /= 0) THEN
1350 IF (sb_min(3) >= 0.5_dp) EXIT loop2_kcell
1351 IF (sb_max(3) < -0.5_dp) cycle loop2_kcell
1352 END IF
1353 cell_b(3) = kcell
1354
1355 loop2_jcell: DO jcell = -ncell(2), ncell(2)
1356 sb(2) = sb_pbc(2) + real(jcell, dp)
1357 sb_min(2) = sb(2) - sab_max(2)
1358 sb_max(2) = sb(2) + sab_max(2)
1359 IF (periodic(2) /= 0) THEN
1360 IF (sb_min(2) >= 0.5_dp) EXIT loop2_jcell
1361 IF (sb_max(2) < -0.5_dp) cycle loop2_jcell
1362 END IF
1363 cell_b(2) = jcell
1364
1365 loop2_icell: DO icell = -ncell(1), ncell(1)
1366 sb(1) = sb_pbc(1) + real(icell, dp)
1367 sb_min(1) = sb(1) - sab_max(1)
1368 sb_max(1) = sb(1) + sab_max(1)
1369 IF (periodic(1) /= 0) THEN
1370 IF (sb_min(1) >= 0.5_dp) EXIT loop2_icell
1371 IF (sb_max(1) < -0.5_dp) cycle loop2_icell
1372 END IF
1373 cell_b(1) = icell
1374
1375 CALL scaled_to_real(rb, sb, cell)
1376
1377 loop_k: DO k = 1, nsubcell(3)
1378 loop_j: DO j = 1, nsubcell(2)
1379 loop_i: DO i = 1, nsubcell(1)
1380
1381 ! FIXME for non-periodic systems, the whole subcell trick is skipped
1382 ! yielding a Natom**2 pair list build.
1383 IF (periodic(3) /= 0) THEN
1384 IF (sb_max(3) < subcell(i, j, k)%s_min(3)) EXIT loop_k
1385 IF (sb_min(3) >= subcell(i, j, k)%s_max(3)) cycle loop_k
1386 END IF
1387
1388 IF (periodic(2) /= 0) THEN
1389 IF (sb_max(2) < subcell(i, j, k)%s_min(2)) EXIT loop_j
1390 IF (sb_min(2) >= subcell(i, j, k)%s_max(2)) cycle loop_j
1391 END IF
1392
1393 IF (periodic(1) /= 0) THEN
1394 IF (sb_max(1) < subcell(i, j, k)%s_min(1)) EXIT loop_i
1395 IF (sb_min(1) >= subcell(i, j, k)%s_max(1)) cycle loop_i
1396 END IF
1397
1398 IF (subcell(i, j, k)%natom == 0) cycle loop_i
1399
1400 DO iatom_subcell = 1, subcell(i, j, k)%natom
1401 iatom_local = subcell(i, j, k)%atom_list(iatom_subcell)
1402 iatom = lista(ikind)%list(iatom_local)
1403 atom_a = atom(ikind)%list(iatom)
1404 IF (my_molecular) THEN
1405 mol_a = atom(ikind)%list_a_mol(iatom_local)
1406 IF (mol_a /= mol_b) cycle
1407 END IF
1408 IF (my_symmetric) THEN
1409 IF (atom_a > atom_b) THEN
1410 include_ab = (modulo(atom_a + atom_b, 2) /= 0)
1411 ELSE
1412 include_ab = (modulo(atom_a + atom_b, 2) == 0)
1413 END IF
1414 IF (my_sort_atomb) THEN
1415 IF ((.NOT. any(atomb_to_keep == atom_b)) .AND. &
1416 (.NOT. any(atomb_to_keep == atom_a))) THEN
1417 include_ab = .false.
1418 END IF
1419 END IF
1420 ELSE
1421 include_ab = .true.
1422 END IF
1423 IF (include_ab) THEN
1424 ra(:) = r_pbc(:, atom_a)
1425 rab(:) = rb(:) - ra(:)
1426 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
1427 IF (rab2 < rab2_max) THEN
1428 include_ab = .true.
1429 IF (my_mic) THEN
1430 ! only if rab is minimum image the pair will be included
1431 ! ideally the range of the pair list is < L/2 so
1432 ! that this never triggers
1433 rab_pbc(:) = pbc(rab(:), cell)
1434 IF (sum((rab_pbc - rab)**2) > epsilon(1.0_dp)) THEN
1435 include_ab = .false.
1436 END IF
1437 END IF
1438 IF (include_ab) THEN
1439 CALL add_neighbor_node( &
1440 neighbor_list=kind_a(iatom_local)%neighbor_list, &
1441 neighbor=atom_b, &
1442 cell=cell_b, &
1443 r=rab, &
1444 nkind=nkind)
1445 END IF
1446 END IF
1447 END IF
1448 END DO
1449
1450 END DO loop_i
1451 END DO loop_j
1452 END DO loop_k
1453
1454 END DO loop2_icell
1455 END DO loop2_jcell
1456 END DO loop2_kcell
1457
1458 END DO
1459
1460 CALL deallocate_subcell(subcell)
1461
1462 END DO
1463 END DO
1464
1465 SELECT CASE (otype)
1466 CASE (1:2, 4)
1467 CASE (3)
1468 DO ikind = 1, nkind
1469 DEALLOCATE (lista(ikind)%list)
1470 END DO
1471 CASE default
1472 cpabort("Only 1, 2, 3, 4 are supported as otype for the operator")
1473 END SELECT
1474 DEALLOCATE (kind_a, pres_a, pres_b, lista, listb, nlista, nlistb)
1475 DEALLOCATE (index_list)
1476 DEALLOCATE (r_pbc)
1477
1478 nentry = 0
1479 CALL neighbor_list_iterator_create(nl_iterator, ab_list)
1480 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1481 CALL get_iterator_info(nl_iterator, inode=inode, nnode=nnode)
1482 IF (inode == 1) nentry = nentry + nnode
1483 END DO
1484 CALL neighbor_list_iterator_release(nl_iterator)
1485 !
1486 ALLOCATE (ab_list(1)%nlist_task(nentry))
1487 ab_list(1)%nl_size = nentry
1488 DO iab = 2, SIZE(ab_list)
1489 ab_list(iab)%nl_size = nentry
1490 ab_list(iab)%nlist_task => ab_list(1)%nlist_task
1491 END DO
1492 !
1493 nentry = 0
1494 CALL neighbor_list_iterator_create(nl_iterator, ab_list)
1495 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1496 nentry = nentry + 1
1497 CALL get_iterator_task(nl_iterator, ab_list(1)%nlist_task(nentry))
1498 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, nkind=nkind)
1499 iab = (ikind - 1)*nkind + jkind
1500 IF (ab_list(iab)%nl_start < 0) ab_list(iab)%nl_start = nentry
1501 IF (ab_list(iab)%nl_end < 0) THEN
1502 ab_list(iab)%nl_end = nentry
1503 ELSE
1504 cpassert(ab_list(iab)%nl_end + 1 == nentry)
1505 ab_list(iab)%nl_end = nentry
1506 END IF
1507 END DO
1508 CALL neighbor_list_iterator_release(nl_iterator)
1509
1510 CALL timestop(handle)
1511
1512 END SUBROUTINE build_neighbor_lists
1513
1514! **************************************************************************************************
1515!> \brief Build a neighborlist
1516!> \param ab_list ...
1517!> \param basis_set_a ...
1518!> \param basis_set_b ...
1519!> \param qs_env ...
1520!> \param mic ...
1521!> \param symmetric ...
1522!> \param molecular ...
1523!> \param operator_type ...
1524!> \date 14.03.2016
1525!> \author JGH
1526! **************************************************************************************************
1527 SUBROUTINE setup_neighbor_list(ab_list, basis_set_a, basis_set_b, qs_env, &
1528 mic, symmetric, molecular, operator_type)
1529
1530 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1531 POINTER :: ab_list
1532 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_a
1533 TYPE(gto_basis_set_p_type), DIMENSION(:), &
1534 OPTIONAL, POINTER :: basis_set_b
1535 TYPE(qs_environment_type), POINTER :: qs_env
1536 LOGICAL, INTENT(IN), OPTIONAL :: mic, symmetric, molecular
1537 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: operator_type
1538
1539 CHARACTER(LEN=4) :: otype
1540 INTEGER :: ikind, nkind
1541 LOGICAL :: my_mic, my_molecular, my_symmetric
1542 LOGICAL, ALLOCATABLE, DIMENSION(:) :: a_present, b_present
1543 REAL(dp), ALLOCATABLE, DIMENSION(:) :: a_radius, b_radius
1544 REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: pair_radius
1545 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1546 TYPE(cell_type), POINTER :: cell
1547 TYPE(distribution_1d_type), POINTER :: distribution_1d
1548 TYPE(distribution_2d_type), POINTER :: distribution_2d
1549 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_a, basis_b
1550 TYPE(gto_basis_set_type), POINTER :: abas, bbas
1551 TYPE(local_atoms_type), ALLOCATABLE, DIMENSION(:) :: atom2d
1552 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
1553 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1554
1555 basis_a => basis_set_a
1556 IF (PRESENT(basis_set_b)) THEN
1557 basis_b => basis_set_b
1558 my_symmetric = .false.
1559 ELSE
1560 basis_b => basis_set_a
1561 my_symmetric = .true.
1562 END IF
1563 IF (PRESENT(symmetric)) my_symmetric = symmetric
1564
1565 IF (PRESENT(mic)) THEN
1566 my_mic = mic
1567 ELSE
1568 my_mic = .false.
1569 END IF
1570
1571 IF (PRESENT(molecular)) THEN
1572 my_molecular = molecular
1573 ELSE
1574 my_molecular = .false.
1575 END IF
1576
1577 IF (PRESENT(operator_type)) THEN
1578 otype = operator_type
1579 ELSE
1580 ! default is a simple AB neighbor list
1581 otype = "AB"
1582 END IF
1583
1584 nkind = SIZE(basis_a)
1585 ALLOCATE (a_present(nkind), b_present(nkind))
1586 a_present = .false.
1587 b_present = .false.
1588 ALLOCATE (a_radius(nkind), b_radius(nkind))
1589 a_radius = 0.0_dp
1590 b_radius = 0.0_dp
1591 DO ikind = 1, nkind
1592 IF (ASSOCIATED(basis_a(ikind)%gto_basis_set)) THEN
1593 a_present(ikind) = .true.
1594 abas => basis_a(ikind)%gto_basis_set
1595 CALL get_gto_basis_set(gto_basis_set=abas, kind_radius=a_radius(ikind))
1596 END IF
1597 IF (ASSOCIATED(basis_b(ikind)%gto_basis_set)) THEN
1598 b_present(ikind) = .true.
1599 bbas => basis_b(ikind)%gto_basis_set
1600 CALL get_gto_basis_set(gto_basis_set=bbas, kind_radius=b_radius(ikind))
1601 END IF
1602 END DO
1603
1604 ALLOCATE (pair_radius(nkind, nkind))
1605 pair_radius = 0.0_dp
1606 CALL pair_radius_setup(a_present, b_present, a_radius, b_radius, pair_radius)
1607
1608 CALL get_qs_env(qs_env, &
1609 atomic_kind_set=atomic_kind_set, &
1610 cell=cell, &
1611 distribution_2d=distribution_2d, &
1612 local_particles=distribution_1d, &
1613 particle_set=particle_set, &
1614 molecule_set=molecule_set)
1615
1616 ALLOCATE (atom2d(nkind))
1617 CALL atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, &
1618 molecule_set, my_molecular, particle_set=particle_set)
1619 CALL build_neighbor_lists(ab_list, particle_set, atom2d, cell, pair_radius, &
1620 mic=my_mic, symmetric=my_symmetric, molecular=my_molecular, &
1621 subcells=2.0_dp, nlname="AUX_NL")
1622
1623 CALL atom2d_cleanup(atom2d)
1624
1625 DEALLOCATE (a_present, b_present, a_radius, b_radius, pair_radius, atom2d)
1626
1627 END SUBROUTINE setup_neighbor_list
1628
1629! **************************************************************************************************
1630!> \brief ...
1631!> \param list ...
1632!> \param n ...
1633!> \param ikind ...
1634!> \param atom ...
1635! **************************************************************************************************
1636 SUBROUTINE combine_lists(list, n, ikind, atom)
1637 INTEGER, DIMENSION(:), POINTER :: list
1638 INTEGER, INTENT(OUT) :: n
1639 INTEGER, INTENT(IN) :: ikind
1640 TYPE(local_atoms_type), DIMENSION(:), INTENT(IN) :: atom
1641
1642 INTEGER :: i, ib, na, nb
1643 INTEGER, DIMENSION(:), POINTER :: lista, listb
1644
1645 cpassert(.NOT. ASSOCIATED(list))
1646
1647 lista => atom(ikind)%list_local_a_index
1648 listb => atom(ikind)%list_local_b_index
1649
1650 IF (ASSOCIATED(lista)) THEN
1651 na = SIZE(lista)
1652 ELSE
1653 na = 0
1654 END IF
1655
1656 IF (ASSOCIATED(listb)) THEN
1657 nb = SIZE(listb)
1658 ELSE
1659 nb = 0
1660 END IF
1661
1662 ALLOCATE (list(na + nb))
1663
1664 n = na
1665 IF (na > 0) list(1:na) = lista(1:na)
1666 IF (nb > 0) THEN
1667 loopb: DO ib = 1, nb
1668 DO i = 1, na
1669 IF (listb(ib) == list(i)) cycle loopb
1670 END DO
1671 n = n + 1
1672 list(n) = listb(ib)
1673 END DO loopb
1674 END IF
1675 END SUBROUTINE combine_lists
1676
1677! **************************************************************************************************
1678
1679! **************************************************************************************************
1680!> \brief ...
1681!> \param present_a ...
1682!> \param present_b ...
1683!> \param radius_a ...
1684!> \param radius_b ...
1685!> \param pair_radius ...
1686!> \param prmin ...
1687! **************************************************************************************************
1688 SUBROUTINE pair_radius_setup(present_a, present_b, radius_a, radius_b, pair_radius, prmin)
1689 LOGICAL, DIMENSION(:), INTENT(IN) :: present_a, present_b
1690 REAL(dp), DIMENSION(:), INTENT(IN) :: radius_a, radius_b
1691 REAL(dp), DIMENSION(:, :), INTENT(OUT) :: pair_radius
1692 REAL(dp), INTENT(IN), OPTIONAL :: prmin
1693
1694 INTEGER :: i, j, nkind
1695 REAL(dp) :: rrmin
1696
1697 nkind = SIZE(present_a)
1698
1699 pair_radius = 0._dp
1700
1701 rrmin = 0.0_dp
1702 IF (PRESENT(prmin)) rrmin = prmin
1703
1704 DO i = 1, nkind
1705 IF (.NOT. present_a(i)) cycle
1706 DO j = 1, nkind
1707 IF (.NOT. present_b(j)) cycle
1708 pair_radius(i, j) = radius_a(i) + radius_b(j)
1709 pair_radius(i, j) = max(pair_radius(i, j), rrmin)
1710 END DO
1711 END DO
1712
1713 END SUBROUTINE pair_radius_setup
1714
1715! **************************************************************************************************
1716!> \brief Print the distribution of the simple pair neighbor list.
1717!> \param ab ...
1718!> \param qs_kind_set ...
1719!> \param output_unit ...
1720!> \param para_env ...
1721!> \date 19.06.2003
1722!> \author MK
1723!> \version 1.0
1724! **************************************************************************************************
1725 SUBROUTINE write_neighbor_distribution(ab, qs_kind_set, output_unit, para_env)
1726 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1727 POINTER :: ab
1728 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1729 INTEGER, INTENT(in) :: output_unit
1730 TYPE(mp_para_env_type), POINTER :: para_env
1731
1732 CHARACTER(len=*), PARAMETER :: routinen = 'write_neighbor_distribution'
1733 LOGICAL, PARAMETER :: full_output = .false.
1734
1735 INTEGER :: handle, ikind, inode, ipe, jkind, n, &
1736 nkind, nnode
1737 INTEGER(int_8) :: nblock_max, nblock_sum, nelement_max, &
1738 nelement_sum, tmp(2)
1739 INTEGER, ALLOCATABLE, DIMENSION(:) :: nblock, nelement, nnsgf
1740 TYPE(gto_basis_set_type), POINTER :: orb_basis_set
1742 DIMENSION(:), POINTER :: nl_iterator
1743
1744 CALL timeset(routinen, handle)
1745 associate(mype => para_env%mepos + 1, npe => para_env%num_pe)
1746
1747 ! Allocate work storage
1748 ALLOCATE (nblock(npe), nelement(npe))
1749 nblock(:) = 0
1750 nelement(:) = 0
1751 nkind = SIZE(qs_kind_set)
1752 ALLOCATE (nnsgf(nkind))
1753 nnsgf = 1
1754 DO ikind = 1, nkind
1755 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1756 IF (ASSOCIATED(orb_basis_set)) THEN
1757 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, nsgf=nnsgf(ikind))
1758 END IF
1759 END DO
1760
1761 CALL neighbor_list_iterator_create(nl_iterator, ab)
1762 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1763 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, inode=inode, nnode=nnode)
1764 IF (inode == 1) THEN
1765 n = nnsgf(ikind)*nnsgf(jkind)
1766 nblock(mype) = nblock(mype) + nnode
1767 nelement(mype) = nelement(mype) + n*nnode
1768 END IF
1769 END DO
1770 CALL neighbor_list_iterator_release(nl_iterator)
1771
1772 IF (full_output) THEN
1773 ! XXXXXXXX should gather/scatter this on ionode
1774 CALL para_env%sum(nblock)
1775 CALL para_env%sum(nelement)
1776
1777 nblock_sum = sum(int(nblock, kind=int_8))
1778 nelement_sum = sum(int(nelement, kind=int_8))
1779 ELSE
1780 nblock_sum = nblock(mype)
1781 nblock_max = nblock(mype)
1782 nelement_sum = nelement(mype)
1783 nelement_max = nelement(mype)
1784 tmp = [nblock_sum, nelement_sum]
1785 CALL para_env%sum(tmp)
1786 nblock_sum = tmp(1); nelement_sum = tmp(2)
1787 tmp = [nblock_max, nelement_max]
1788 CALL para_env%max(tmp)
1789 nblock_max = tmp(1); nelement_max = tmp(2)
1790 END IF
1791
1792 IF (output_unit > 0) THEN
1793 IF (full_output) THEN
1794 WRITE (unit=output_unit, &
1795 fmt="(/,/,T2,A,/,/,T3,A,/,/,(T4,I6,T27,I10,T55,I10))") &
1796 "DISTRIBUTION OF THE NEIGHBOR LISTS", &
1797 "Process Number of particle pairs Number of matrix elements", &
1798 (ipe - 1, nblock(ipe), nelement(ipe), ipe=1, npe)
1799 WRITE (unit=output_unit, fmt="(/,T7,A3,T27,I10,T55,I10)") &
1800 "Sum", sum(nblock), sum(nelement)
1801 ELSE
1802 WRITE (unit=output_unit, fmt="(/,T2,A)") "DISTRIBUTION OF THE NEIGHBOR LISTS"
1803 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Total number of particle pairs:", nblock_sum
1804 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Total number of matrix elements:", nelement_sum
1805 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Average number of particle pairs:", (nblock_sum + npe - 1)/npe
1806 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Maximum number of particle pairs:", nblock_max
1807 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Average number of matrix element:", (nelement_sum + npe - 1)/npe
1808 WRITE (unit=output_unit, fmt="(T15,A,T68,I13)") "Maximum number of matrix elements:", nelement_max
1809 END IF
1810 END IF
1811 END associate
1812
1813 ! Release work storage
1814
1815 DEALLOCATE (nblock, nelement, nnsgf)
1816
1817 CALL timestop(handle)
1818
1819 END SUBROUTINE write_neighbor_distribution
1820
1821! **************************************************************************************************
1822!> \brief Write a set of neighbor lists to the output unit.
1823!> \param ab ...
1824!> \param particle_set ...
1825!> \param cell ...
1826!> \param para_env ...
1827!> \param neighbor_list_section ...
1828!> \param nl_type ...
1829!> \param middle_name ...
1830!> \param nlname ...
1831!> \date 04.03.2002
1832!> \par History
1833!> - Adapted to the new parallelized neighbor list version
1834!> (26.06.2003,MK)
1835!> \author MK
1836!> \version 1.0
1837! **************************************************************************************************
1838 SUBROUTINE write_neighbor_lists(ab, particle_set, cell, para_env, neighbor_list_section, &
1839 nl_type, middle_name, nlname)
1840
1841 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1842 POINTER :: ab
1843 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1844 TYPE(cell_type), POINTER :: cell
1845 TYPE(mp_para_env_type), POINTER :: para_env
1846 TYPE(section_vals_type), POINTER :: neighbor_list_section
1847 CHARACTER(LEN=*), INTENT(IN) :: nl_type, middle_name, nlname
1848
1849 CHARACTER(LEN=default_string_length) :: string, unit_str
1850 INTEGER :: iatom, inode, iw, jatom, nneighbor, nnode
1851 INTEGER, DIMENSION(3) :: cell_b
1852 REAL(dp) :: dab, unit_conv
1853 REAL(dp), DIMENSION(3) :: ra, rab, rb
1854 TYPE(cp_logger_type), POINTER :: logger
1855 TYPE(neighbor_list_iterator_p_type), &
1856 DIMENSION(:), POINTER :: nl_iterator
1857
1858 NULLIFY (logger)
1859 logger => cp_get_default_logger()
1860 IF (btest(cp_print_key_should_output(logger%iter_info, neighbor_list_section, &
1861 trim(nl_type)), &
1862 cp_p_file)) THEN
1863 iw = cp_print_key_unit_nr(logger=logger, &
1864 basis_section=neighbor_list_section, &
1865 print_key_path=trim(nl_type), &
1866 extension=".out", &
1867 middle_name=trim(middle_name), &
1868 local=.true., &
1869 log_filename=.false., &
1870 file_position="REWIND")
1871 associate(mype => para_env%mepos)
1872 CALL section_vals_val_get(neighbor_list_section, "UNIT", c_val=unit_str)
1873 unit_conv = cp_unit_from_cp2k(1.0_dp, trim(unit_str))
1874
1875 ! Print headline
1876 string = ""
1877 WRITE (unit=string, fmt="(A,I5,A)") &
1878 trim(nlname)//" IN "//trim(unit_str)//" (PROCESS", mype, ")"
1879 CALL compress(string)
1880 IF (iw > 0) WRITE (unit=iw, fmt="(/,/,T2,A)") trim(string)
1881
1882 nneighbor = 0
1883
1884 CALL neighbor_list_iterator_create(nl_iterator, ab)
1885 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1886 CALL get_iterator_info(nl_iterator, inode=inode, nnode=nnode, &
1887 iatom=iatom, jatom=jatom, cell=cell_b, r=rab)
1888 nneighbor = nneighbor + 1
1889 ra(:) = pbc(particle_set(iatom)%r, cell)
1890 rb(:) = ra(:) + rab(:)
1891 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
1892 IF (iw > 0) THEN
1893 IF (inode == 1) THEN
1894 WRITE (unit=iw, fmt="(/,T2,I5,3X,I6,3X,3F12.6)") &
1895 iatom, nnode, ra(1:3)*unit_conv
1896 END IF
1897 WRITE (unit=iw, fmt="(T10,I6,3X,3I4,3F12.6,2X,F12.6)") &
1898 jatom, cell_b(1:3), rb(1:3)*unit_conv, dab*unit_conv
1899 END IF
1900 END DO
1901 CALL neighbor_list_iterator_release(nl_iterator)
1902
1903 string = ""
1904 WRITE (unit=string, fmt="(A,I12,A,I12)") &
1905 "Total number of neighbor interactions for process", mype, ":", &
1906 nneighbor
1907 CALL compress(string)
1908 IF (iw > 0) WRITE (unit=iw, fmt="(/,T2,A)") trim(string)
1909 CALL cp_print_key_finished_output(unit_nr=iw, &
1910 logger=logger, &
1911 basis_section=neighbor_list_section, &
1912 print_key_path=trim(nl_type), &
1913 local=.true.)
1914 END associate
1915 END IF
1916
1917 END SUBROUTINE write_neighbor_lists
1918
1919END 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:625
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
Definition cell_types.F:595
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:233
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:422
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:324
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:1251
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:1823
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, electronegativity, chmax, en, kqat2, kcn, kq)
...
Definition xtb_types.F:203
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 ...