25 gto_basis_set_p_type,&
44 ewald_environment_type
97 #include "./base/base_uses.f90"
104 TYPE local_atoms_type
105 INTEGER,
DIMENSION(:),
POINTER :: list, &
106 list_local_a_index, &
107 list_local_b_index, &
111 END TYPE local_atoms_type
114 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_neighbor_lists'
117 INTEGER,
SAVE,
PRIVATE :: last_qs_neighbor_list_id_nr = 0
131 TYPE(local_atoms_type),
DIMENSION(:) :: atom2d
133 CHARACTER(len=*),
PARAMETER :: routinen =
'atom2d_cleanup'
135 INTEGER :: handle, ikind
137 CALL timeset(routinen, handle)
138 DO ikind = 1,
SIZE(atom2d)
139 NULLIFY (atom2d(ikind)%list)
140 IF (
ASSOCIATED(atom2d(ikind)%list_local_a_index))
THEN
141 DEALLOCATE (atom2d(ikind)%list_local_a_index)
143 IF (
ASSOCIATED(atom2d(ikind)%list_local_b_index))
THEN
144 DEALLOCATE (atom2d(ikind)%list_local_b_index)
146 IF (
ASSOCIATED(atom2d(ikind)%list_a_mol))
THEN
147 DEALLOCATE (atom2d(ikind)%list_a_mol)
149 IF (
ASSOCIATED(atom2d(ikind)%list_b_mol))
THEN
150 DEALLOCATE (atom2d(ikind)%list_b_mol)
152 IF (
ASSOCIATED(atom2d(ikind)%list_1d))
THEN
153 DEALLOCATE (atom2d(ikind)%list_1d)
156 CALL timestop(handle)
172 atomic_kind_set, molecule_set, molecule_only, particle_set)
173 TYPE(local_atoms_type),
DIMENSION(:) :: atom2d
174 TYPE(distribution_1d_type),
POINTER :: distribution_1d
175 TYPE(distribution_2d_type),
POINTER :: distribution_2d
176 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
177 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
178 LOGICAL :: molecule_only
179 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
181 CHARACTER(len=*),
PARAMETER :: routinen =
'atom2d_build'
183 INTEGER :: atom_a, handle, ia, iat, iatom, &
184 iatom_local, ikind, imol, natom, &
185 natom_a, natom_local_a, natom_local_b, &
187 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom2mol, atom_of_kind, listindex, &
189 INTEGER,
DIMENSION(:),
POINTER :: local_cols_array, local_rows_array
191 CALL timeset(routinen, handle)
193 nkind =
SIZE(atomic_kind_set)
194 natom =
SIZE(particle_set)
197 IF (molecule_only)
THEN
198 ALLOCATE (atom2mol(natom))
199 DO imol = 1,
SIZE(molecule_set)
200 DO iat = molecule_set(imol)%first_atom, molecule_set(imol)%last_atom
207 NULLIFY (atom2d(ikind)%list)
208 NULLIFY (atom2d(ikind)%list_local_a_index)
209 NULLIFY (atom2d(ikind)%list_local_b_index)
210 NULLIFY (atom2d(ikind)%list_1d)
211 NULLIFY (atom2d(ikind)%list_a_mol)
212 NULLIFY (atom2d(ikind)%list_b_mol)
214 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom2d(ikind)%list)
216 natom_a =
SIZE(atom2d(ikind)%list)
218 natom_local_a = distribution_2d%n_local_rows(ikind)
219 natom_local_b = distribution_2d%n_local_cols(ikind)
220 local_rows_array => distribution_2d%local_rows(ikind)%array
221 local_cols_array => distribution_2d%local_cols(ikind)%array
223 nel = distribution_1d%n_el(ikind)
224 ALLOCATE (atom2d(ikind)%list_1d(nel))
226 ia = distribution_1d%list(ikind)%array(iat)
227 atom2d(ikind)%list_1d(iat) = atom_of_kind(ia)
230 ALLOCATE (listsort(natom_a), listindex(natom_a))
231 listsort(1:natom_a) = atom2d(ikind)%list(1:natom_a)
232 CALL sort(listsort, natom_a, listindex)
234 IF (natom_local_a > 0)
THEN
235 ALLOCATE (atom2d(ikind)%list_local_a_index(natom_local_a))
236 ALLOCATE (atom2d(ikind)%list_a_mol(natom_local_a))
237 atom2d(ikind)%list_a_mol(:) = 0
240 DO iatom_local = 1, natom_local_a
241 atom_a = local_rows_array(iatom_local)
242 iatom =
locate(listsort, atom_a)
243 atom2d(ikind)%list_local_a_index(iatom_local) = listindex(iatom)
244 IF (molecule_only) atom2d(ikind)%list_a_mol(iatom_local) = atom2mol(atom_a)
250 IF (natom_local_b > 0)
THEN
252 ALLOCATE (atom2d(ikind)%list_local_b_index(natom_local_b))
253 ALLOCATE (atom2d(ikind)%list_b_mol(natom_local_b))
254 atom2d(ikind)%list_b_mol(:) = 0
257 DO iatom_local = 1, natom_local_b
258 atom_a = local_cols_array(iatom_local)
259 iatom =
locate(listsort, atom_a)
260 atom2d(ikind)%list_local_b_index(iatom_local) = listindex(iatom)
261 IF (molecule_only) atom2d(ikind)%list_b_mol(iatom_local) = atom2mol(atom_a)
266 DEALLOCATE (listsort, listindex)
270 CALL timestop(handle)
287 TYPE(qs_environment_type),
POINTER :: qs_env
288 TYPE(mp_para_env_type),
POINTER :: para_env
289 LOGICAL,
OPTIONAL :: molecular
290 TYPE(section_vals_type),
POINTER :: force_env_section
292 CHARACTER(len=*),
PARAMETER :: routinen =
'build_qs_neighbor_lists'
294 CHARACTER(LEN=2) :: element_symbol, element_symbol2
295 CHARACTER(LEN=default_string_length) :: print_key_path
296 INTEGER :: handle, hfx_pot, ikind, ingp, iw, jkind, &
297 maxatom, ngp, nkind, zat
298 LOGICAL :: all_potential_present, almo, dftb, do_hfx, dokp, gth_potential_present, &
299 lri_optbas, lrigpw, mic, molecule_only, nddo, paw_atom, paw_atom_present, rigpw, &
300 sgp_potential_present, xtb
301 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: all_present, aux_fit_present, aux_present, &
302 core_present, default_present, nonbond1_atom, nonbond2_atom, oce_present, orb_present, &
303 ppl_present, ppnl_present, ri_present, xb1_atom, xb2_atom
304 REAL(
dp) :: almo_rcov, almo_rvdw, eps_schwarz, &
305 omega, pdist, rcut, roperator, subcells
306 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: all_pot_rad, aux_fit_radius, c_radius, calpha, &
307 core_radius, oce_radius, orb_radius, ppl_radius, ppnl_radius, ri_radius, zeff
308 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pair_radius, pair_radius_lb
309 TYPE(all_potential_type),
POINTER :: all_potential
310 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
311 TYPE(cell_type),
POINTER :: cell
312 TYPE(cp_logger_type),
POINTER :: logger
313 TYPE(dft_control_type),
POINTER :: dft_control
314 TYPE(distribution_1d_type),
POINTER :: distribution_1d
315 TYPE(distribution_2d_type),
POINTER :: distribution_2d
316 TYPE(ewald_environment_type),
POINTER :: ewald_env
317 TYPE(gth_potential_type),
POINTER :: gth_potential
318 TYPE(gto_basis_set_type),
POINTER ::
aux_basis_set, aux_fit_basis_set, &
319 orb_basis_set, ri_basis_set
320 TYPE(kpoint_type),
POINTER :: kpoints
321 TYPE(local_atoms_type),
ALLOCATABLE,
DIMENSION(:) :: atom2d
322 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
323 TYPE(neighbor_list_set_p_type),
DIMENSION(:),
POINTER :: saa_list, sab_all, sab_almo, &
324 sab_cn, sab_core, sab_gcp, sab_kp, sab_kp_nosym, sab_lrc, sab_orb, sab_scp, sab_se, &
325 sab_tbe, sab_vdw, sab_xb, sab_xtb_nonbond, sab_xtbe, sac_ae, sac_lri, sac_ppl, sap_oce, &
326 sap_ppnl, soa_list, soo_list
327 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
328 TYPE(paw_proj_set_type),
POINTER :: paw_proj
329 TYPE(qs_dftb_atom_type),
POINTER :: dftb_atom
330 TYPE(qs_dispersion_type),
POINTER :: dispersion_env
331 TYPE(qs_gcp_type),
POINTER :: gcp_env
332 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
333 TYPE(qs_ks_env_type),
POINTER :: ks_env
334 TYPE(section_vals_type),
POINTER :: hfx_sections, neighbor_list_section
335 TYPE(sgp_potential_type),
POINTER :: sgp_potential
336 TYPE(xtb_atom_type),
POINTER :: xtb_atom
338 CALL timeset(routinen, handle)
342 NULLIFY (atomic_kind_set, qs_kind_set, cell, neighbor_list_section, &
343 distribution_1d, distribution_2d, gth_potential, sgp_potential, orb_basis_set, &
344 particle_set, molecule_set, dft_control, ks_env)
358 NULLIFY (sab_xtb_nonbond)
366 NULLIFY (sab_kp_nosym)
370 atomic_kind_set=atomic_kind_set, &
371 qs_kind_set=qs_kind_set, &
374 distribution_2d=distribution_2d, &
375 local_particles=distribution_1d, &
376 particle_set=particle_set, &
377 molecule_set=molecule_set, &
378 dft_control=dft_control)
384 last_qs_neighbor_list_id_nr = last_qs_neighbor_list_id_nr + 1
385 CALL set_ks_env(ks_env=ks_env, neighbor_list_id=last_qs_neighbor_list_id_nr)
401 sab_xtb_nonbond=sab_xtb_nonbond, &
406 sab_kp_nosym=sab_kp_nosym)
408 dokp = (kpoints%nkp > 0)
409 nddo = dft_control%qs_control%semi_empirical
410 dftb = dft_control%qs_control%dftb
411 xtb = dft_control%qs_control%xtb
412 almo = dft_control%qs_control%do_almo_scf
415 lri_optbas = dft_control%qs_control%lri_optbas
418 molecule_only = .false.
419 IF (
PRESENT(molecular)) molecule_only = molecular
429 pdist = dft_control%qs_control%pairlist_radius
436 gth_potential_present=gth_potential_present, &
437 sgp_potential_present=sgp_potential_present, &
438 all_potential_present=all_potential_present)
443 nkind =
SIZE(atomic_kind_set)
444 ALLOCATE (orb_present(nkind), aux_fit_present(nkind), aux_present(nkind), &
445 default_present(nkind), core_present(nkind))
446 ALLOCATE (orb_radius(nkind), aux_fit_radius(nkind), c_radius(nkind), &
447 core_radius(nkind), calpha(nkind), zeff(nkind))
448 orb_radius(:) = 0.0_dp
449 aux_fit_radius(:) = 0.0_dp
451 core_radius(:) = 0.0_dp
455 ALLOCATE (pair_radius(nkind, nkind))
456 IF (gth_potential_present .OR. sgp_potential_present)
THEN
457 ALLOCATE (ppl_present(nkind), ppl_radius(nkind))
459 ALLOCATE (ppnl_present(nkind), ppnl_radius(nkind))
462 IF (paw_atom_present)
THEN
463 ALLOCATE (oce_present(nkind), oce_radius(nkind))
466 IF (all_potential_present .OR. sgp_potential_present)
THEN
467 ALLOCATE (all_present(nkind), all_pot_rad(nkind))
472 ALLOCATE (atom2d(nkind))
473 CALL atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, &
474 molecule_set, molecule_only, particle_set=particle_set)
478 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom2d(ikind)%list)
480 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=
"ORB")
482 CALL get_qs_kind(qs_kind_set(ikind), basis_set=aux_fit_basis_set, basis_type=
"AUX_FIT")
485 paw_proj_set=paw_proj, &
487 all_potential=all_potential, &
488 gth_potential=gth_potential, &
489 sgp_potential=sgp_potential)
494 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_atom)
496 cutoff=orb_radius(ikind), &
497 defined=orb_present(ikind))
499 IF (
ASSOCIATED(orb_basis_set))
THEN
500 orb_present(ikind) = .true.
501 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, kind_radius=orb_radius(ikind))
503 orb_present(ikind) = .false.
508 aux_present(ikind) = .true.
510 aux_present(ikind) = .false.
513 IF (
ASSOCIATED(aux_fit_basis_set))
THEN
514 aux_fit_present(ikind) = .true.
515 CALL get_gto_basis_set(gto_basis_set=aux_fit_basis_set, kind_radius=aux_fit_radius(ikind))
517 aux_fit_present(ikind) = .false.
522 alpha_core_charge=calpha(ikind), &
523 core_charge_radius=core_radius(ikind), &
525 IF (zeff(ikind) /= 0._dp .AND. calpha(ikind) /= 0._dp)
THEN
526 core_present(ikind) = .true.
528 core_present(ikind) = .false.
532 IF (gth_potential_present .OR. sgp_potential_present)
THEN
533 IF (
ASSOCIATED(gth_potential))
THEN
534 CALL get_potential(potential=gth_potential, &
535 ppl_present=ppl_present(ikind), &
536 ppl_radius=ppl_radius(ikind), &
537 ppnl_present=ppnl_present(ikind), &
538 ppnl_radius=ppnl_radius(ikind))
539 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
540 CALL get_potential(potential=sgp_potential, &
541 ppl_present=ppl_present(ikind), &
542 ppl_radius=ppl_radius(ikind), &
543 ppnl_present=ppnl_present(ikind), &
544 ppnl_radius=ppnl_radius(ikind))
546 ppl_present(ikind) = .false.
547 ppnl_present(ikind) = .false.
552 IF (paw_atom_present)
THEN
554 oce_present(ikind) = .true.
557 oce_present(ikind) = .false.
562 IF (all_potential_present .OR. sgp_potential_present)
THEN
563 all_present(ikind) = .false.
564 all_pot_rad(ikind) = 0.0_dp
565 IF (
ASSOCIATED(all_potential))
THEN
566 all_present(ikind) = .true.
567 CALL get_potential(potential=all_potential, core_charge_radius=all_pot_rad(ikind))
568 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
569 IF (sgp_potential%ecp_local)
THEN
570 all_present(ikind) = .true.
571 CALL get_potential(potential=sgp_potential, core_charge_radius=all_pot_rad(ikind))
579 IF (pdist < 0.0_dp)
THEN
584 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius, pdist)
586 mic=mic, subcells=subcells, molecular=molecule_only, nlname=
"sab_orb")
587 CALL set_ks_env(ks_env=ks_env, sab_orb=sab_orb)
589 "/SAB_ORB",
"sab_orb",
"ORBITAL ORBITAL")
594 IF (.NOT. (nddo .OR. dftb .OR. xtb))
THEN
596 mic=mic, symmetric=.false., subcells=subcells, molecular=molecule_only, nlname=
"sab_all")
597 CALL set_ks_env(ks_env=ks_env, sab_all=sab_all)
601 IF (.NOT. (nddo .OR. dftb .OR. xtb))
THEN
602 CALL pair_radius_setup(core_present, core_present, core_radius, core_radius, pair_radius)
603 CALL build_neighbor_lists(sab_core, particle_set, atom2d, cell, pair_radius, subcells=subcells, &
604 operator_type=
"PP", nlname=
"sab_core")
605 CALL set_ks_env(ks_env=ks_env, sab_core=sab_core)
607 "/SAB_CORE",
"sab_core",
"CORE CORE")
620 SELECT CASE (hfx_pot)
630 cpabort(
"HFX potential not available for K-points (NYI)")
633 IF (dft_control%do_admm)
THEN
634 CALL pair_radius_setup(aux_fit_present, aux_fit_present, aux_fit_radius, aux_fit_radius, &
638 ALLOCATE (pair_radius_lb(nkind, nkind))
639 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius_lb)
642 IF (pair_radius(ikind, jkind) +
cutoff_screen_factor*roperator .LE. pair_radius_lb(ikind, jkind)) &
643 pair_radius(ikind, jkind) = pair_radius_lb(ikind, jkind) - roperator
647 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
651 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
654 subcells=subcells, nlname=
"sab_kp")
659 subcells=subcells, nlname=
"sab_kp_nosym", symmetric=.false.)
660 CALL set_ks_env(ks_env=ks_env, sab_kp_nosym=sab_kp_nosym)
665 IF (gth_potential_present .OR. sgp_potential_present)
THEN
666 IF (any(ppl_present))
THEN
667 CALL pair_radius_setup(orb_present, ppl_present, orb_radius, ppl_radius, pair_radius)
669 subcells=subcells, operator_type=
"ABC", nlname=
"sac_ppl")
670 CALL set_ks_env(ks_env=ks_env, sac_ppl=sac_ppl)
672 "/SAC_PPL",
"sac_ppl",
"ORBITAL GTH-PPL")
674 IF (qs_env%lri_env%ppl_ri)
THEN
676 subcells=subcells, symmetric=.false., operator_type=
"PP", nlname=
"sac_lri")
677 CALL set_ks_env(ks_env=ks_env, sac_lri=sac_lri)
682 IF (any(ppnl_present))
THEN
683 CALL pair_radius_setup(orb_present, ppnl_present, orb_radius, ppnl_radius, pair_radius)
685 subcells=subcells, operator_type=
"ABBA", nlname=
"sap_ppnl")
686 CALL set_ks_env(ks_env=ks_env, sap_ppnl=sap_ppnl)
688 "/SAP_PPNL",
"sap_ppnl",
"ORBITAL GTH-PPNL")
692 IF (paw_atom_present)
THEN
694 IF (any(oce_present))
THEN
695 CALL pair_radius_setup(orb_present, oce_present, orb_radius, oce_radius, pair_radius)
697 subcells=subcells, operator_type=
"ABBA", nlname=
"sap_oce")
698 CALL set_ks_env(ks_env=ks_env, sap_oce=sap_oce)
700 "/SAP_OCE",
"sap_oce",
"ORBITAL(A) PAW-PRJ")
705 IF (.NOT. (nddo .OR. dftb .OR. xtb))
THEN
706 IF (all_potential_present .OR. sgp_potential_present)
THEN
707 CALL pair_radius_setup(orb_present, all_present, orb_radius, all_pot_rad, pair_radius)
709 subcells=subcells, operator_type=
"ABC", nlname=
"sac_ae")
712 "/SAC_AE",
"sac_ae",
"ORBITAL ERFC POTENTIAL")
718 default_present = .true.
719 c_radius = dft_control%qs_control%se_control%cutoff_cou
721 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
722 IF (dft_control%qs_control%se_control%do_ewald_gks)
THEN
725 subcells=subcells, nlname=
"sab_se")
728 subcells=subcells, nlname=
"sab_se")
732 "/SAB_SE",
"sab_se",
"HARTREE INTERACTIONS")
735 IF ((dft_control%qs_control%se_control%do_ewald) .AND. &
736 (dft_control%qs_control%se_control%integral_screening /=
do_se_is_slater))
THEN
737 c_radius = dft_control%qs_control%se_control%cutoff_lrc
738 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
740 subcells=subcells, nlname=
"sab_lrc")
741 CALL set_ks_env(ks_env=ks_env, sab_lrc=sab_lrc)
743 "/SAB_LRC",
"sab_lrc",
"SE LONG-RANGE CORRECTION")
749 IF (dft_control%qs_control%dftb_control%do_ewald)
THEN
750 CALL get_qs_env(qs_env=qs_env, ewald_env=ewald_env)
753 CALL pair_radius_setup(orb_present, orb_present, c_radius, c_radius, pair_radius)
755 subcells=subcells, nlname=
"sab_tbe")
756 CALL set_ks_env(ks_env=ks_env, sab_tbe=sab_tbe)
760 IF (dft_control%qs_control%dftb_control%dispersion)
THEN
761 IF (dft_control%qs_control%dftb_control%dispersion_type ==
dispersion_uff)
THEN
763 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_atom)
766 default_present = .true.
767 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
769 subcells=subcells, nlname=
"sab_vdw")
770 CALL set_ks_env(ks_env=ks_env, sab_vdw=sab_vdw)
777 IF (dft_control%qs_control%xtb_control%do_ewald)
THEN
778 CALL get_qs_env(qs_env=qs_env, ewald_env=ewald_env)
781 CALL pair_radius_setup(orb_present, orb_present, c_radius, c_radius, pair_radius)
783 subcells=subcells, nlname=
"sab_tbe")
784 CALL set_ks_env(ks_env=ks_env, sab_tbe=sab_tbe)
788 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_atom)
791 default_present = .true.
792 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
794 subcells=subcells, nlname=
"sab_xtbe")
795 CALL set_ks_env(ks_env=ks_env, sab_xtbe=sab_xtbe)
797 ALLOCATE (xb1_atom(nkind), xb2_atom(nkind))
798 c_radius = 0.5_dp*dft_control%qs_control%xtb_control%xb_radius
801 IF (zat == 17 .OR. zat == 35 .OR. zat == 53 .OR. zat == 85)
THEN
802 xb1_atom(ikind) = .true.
804 xb1_atom(ikind) = .false.
806 IF (zat == 7 .OR. zat == 8 .OR. zat == 15 .OR. zat == 16)
THEN
807 xb2_atom(ikind) = .true.
809 xb2_atom(ikind) = .false.
814 symmetric=.false., subcells=subcells, operator_type=
"PP", nlname=
"sab_xb")
817 "/SAB_XB",
"sab_xb",
"XB bonding")
820 IF (dft_control%qs_control%xtb_control%do_nonbonded)
THEN
821 ngp =
SIZE(dft_control%qs_control%xtb_control%nonbonded%pot)
822 ALLOCATE (nonbond1_atom(nkind), nonbond2_atom(nkind))
823 nonbond1_atom = .false.
824 nonbond2_atom = .false.
827 rcut = sqrt(dft_control%qs_control%xtb_control%nonbonded%pot(ingp)%pot%rcutsq)
829 CALL get_atomic_kind(atomic_kind_set(ikind), element_symbol=element_symbol)
831 IF (trim(dft_control%qs_control%xtb_control%nonbonded%pot(ingp)%pot%at1) == trim(element_symbol))
THEN
832 nonbond1_atom(ikind) = .true.
834 CALL get_atomic_kind(atomic_kind_set(jkind), element_symbol=element_symbol2)
836 IF (trim(dft_control%qs_control%xtb_control%nonbonded%pot(ingp)%pot%at2) == trim(element_symbol2))
THEN
837 nonbond2_atom(jkind) = .true.
842 CALL pair_radius_setup(nonbond1_atom, nonbond2_atom, c_radius, c_radius, pair_radius)
844 symmetric=.false., subcells=subcells, operator_type=
"PP", nlname=
"sab_xtb_nonbond")
845 CALL set_ks_env(ks_env=ks_env, sab_xtb_nonbond=sab_xtb_nonbond)
846 CALL write_neighbor_lists(sab_xtb_nonbond, particle_set, cell, para_env, neighbor_list_section, &
847 "/SAB_XTB_NONBOND",
"sab_xtb_nonbond",
"XTB NONBONDED INTERACTIONS")
853 CALL get_qs_env(qs_env=qs_env, dispersion_env=dispersion_env)
854 sab_vdw => dispersion_env%sab_vdw
855 sab_cn => dispersion_env%sab_cn
857 c_radius(:) = dispersion_env%rc_disp
858 default_present = .true.
859 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
861 subcells=subcells, operator_type=
"PP", nlname=
"sab_vdw")
862 dispersion_env%sab_vdw => sab_vdw
870 c_radius(ikind) = 4._dp*
ptable(zat)%covalent_radius*
bohr
872 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
874 subcells=subcells, operator_type=
"PP", nlname=
"sab_cn")
875 dispersion_env%sab_cn => sab_cn
881 CALL get_qs_env(qs_env=qs_env, gcp_env=gcp_env)
882 IF (
ASSOCIATED(gcp_env))
THEN
883 IF (gcp_env%do_gcp)
THEN
884 sab_gcp => gcp_env%sab_gcp
886 c_radius(ikind) = gcp_env%gcp_kind(ikind)%rcsto
888 CALL pair_radius_setup(orb_present, orb_present, c_radius, c_radius, pair_radius)
890 subcells=subcells, operator_type=
"PP", nlname=
"sab_gcp")
891 gcp_env%sab_gcp => sab_gcp
893 NULLIFY (gcp_env%sab_gcp)
897 IF (lrigpw .OR. lri_optbas)
THEN
899 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
900 soo_list => qs_env%lri_env%soo_list
902 mic=mic, molecular=molecule_only, subcells=subcells, nlname=
"soo_list")
903 qs_env%lri_env%soo_list => soo_list
905 "/SOO_LIST",
"soo_list",
"ORBITAL ORBITAL (RI)")
907 ALLOCATE (ri_present(nkind), ri_radius(nkind))
911 CALL get_qs_kind(qs_kind_set(ikind), basis_set=ri_basis_set, basis_type=
"RI_HXC")
912 IF (
ASSOCIATED(ri_basis_set))
THEN
913 ri_present(ikind) = .true.
916 ri_present(ikind) = .false.
920 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
921 soo_list => qs_env%lri_env%soo_list
923 mic=mic, molecular=molecule_only, subcells=subcells, nlname=
"soo_list")
924 qs_env%lri_env%soo_list => soo_list
926 CALL pair_radius_setup(ri_present, ri_present, ri_radius, ri_radius, pair_radius)
927 saa_list => qs_env%lri_env%saa_list
929 mic=mic, molecular=molecule_only, subcells=subcells, nlname=
"saa_list")
930 qs_env%lri_env%saa_list => saa_list
932 CALL pair_radius_setup(ri_present, orb_present, ri_radius, orb_radius, pair_radius)
933 soa_list => qs_env%lri_env%soa_list
935 mic=mic, symmetric=.false., molecular=molecule_only, &
936 subcells=subcells, operator_type=
"ABC", nlname=
"saa_list")
937 qs_env%lri_env%soa_list => soa_list
943 CALL get_atomic_kind(atomic_kind_set(ikind), rcov=almo_rcov, rvdw=almo_rvdw)
945 c_radius(ikind) = max(almo_rcov, almo_rvdw)*
bohr* &
948 default_present = .true.
949 CALL pair_radius_setup(default_present, default_present, c_radius, c_radius, pair_radius)
951 subcells=subcells, operator_type=
"PP", nlname=
"sab_almo")
952 CALL set_ks_env(ks_env=ks_env, sab_almo=sab_almo)
956 print_key_path =
"PRINT%DISTRIBUTION"
961 basis_section=force_env_section, &
962 print_key_path=print_key_path, &
964 CALL write_neighbor_distribution(sab_orb, qs_kind_set, iw, para_env)
967 basis_section=force_env_section, &
968 print_key_path=print_key_path)
975 DEALLOCATE (orb_present, default_present, core_present)
976 DEALLOCATE (orb_radius, aux_fit_radius, c_radius, core_radius)
977 DEALLOCATE (calpha, zeff)
978 DEALLOCATE (pair_radius)
979 IF (gth_potential_present .OR. sgp_potential_present)
THEN
980 DEALLOCATE (ppl_present, ppl_radius)
981 DEALLOCATE (ppnl_present, ppnl_radius)
983 IF (paw_atom_present)
THEN
984 DEALLOCATE (oce_present, oce_radius)
986 IF (all_potential_present .OR. sgp_potential_present)
THEN
987 DEALLOCATE (all_present, all_pot_rad)
990 CALL timestop(handle)
1018 mic, symmetric, molecular, subset_of_mol, current_subset, &
1019 operator_type, nlname, atomb_to_keep)
1021 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1023 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1024 TYPE(local_atoms_type),
DIMENSION(:),
INTENT(IN) ::
atom
1025 TYPE(cell_type),
POINTER :: cell
1026 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: pair_radius
1027 REAL(
dp),
INTENT(IN) :: subcells
1028 LOGICAL,
INTENT(IN),
OPTIONAL :: mic, symmetric, molecular
1029 INTEGER,
DIMENSION(:),
OPTIONAL,
POINTER :: subset_of_mol
1030 INTEGER,
OPTIONAL :: current_subset
1031 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: operator_type
1032 CHARACTER(LEN=*),
INTENT(IN) :: nlname
1033 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: atomb_to_keep
1035 CHARACTER(len=*),
PARAMETER :: routinen =
'build_neighbor_lists'
1038 INTEGER,
DIMENSION(:),
POINTER ::
list
1039 END TYPE local_lists
1041 INTEGER :: atom_a, atom_b, handle, i, iab, iatom, iatom_local, &
1042 iatom_subcell, icell, ikind, j, jatom, jatom_local, jcell, jkind, k, &
1043 kcell, maxat, mol_a, mol_b, nkind, otype, natom, inode, nnode, nentry
1044 INTEGER,
DIMENSION(3) :: cell_b, ncell, nsubcell, periodic
1045 INTEGER,
DIMENSION(:),
POINTER :: index_list
1046 LOGICAL :: include_ab, my_mic, &
1047 my_molecular, my_symmetric, my_sort_atomb
1048 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: pres_a, pres_b
1049 REAL(
dp) :: rab2, rab2_max, rab_max, rabm, deth, subcell_scale
1050 REAL(
dp),
DIMENSION(3) :: r, rab, ra, rb, sab_max, sb, &
1051 sb_pbc, sb_min, sb_max, rab_pbc, pd, sab_max_guard
1052 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nlista, nlistb
1053 TYPE(local_lists),
DIMENSION(:),
POINTER :: lista, listb
1054 TYPE(neighbor_list_p_type), &
1055 ALLOCATABLE,
DIMENSION(:) :: kind_a
1056 TYPE(neighbor_list_set_type),
POINTER :: neighbor_list_set
1057 TYPE(subcell_type),
DIMENSION(:, :, :), &
1059 REAL(kind=
dp),
DIMENSION(:, :),
ALLOCATABLE :: r_pbc
1060 TYPE(neighbor_list_iterator_p_type), &
1061 DIMENSION(:),
POINTER :: nl_iterator
1063 CALL timeset(routinen//
"_"//trim(nlname), handle)
1067 IF (
PRESENT(mic)) my_mic = mic
1068 my_symmetric = .true.
1069 IF (
PRESENT(symmetric)) my_symmetric = symmetric
1070 my_molecular = .false.
1072 IF (
PRESENT(molecular)) my_molecular = molecular
1074 IF (
PRESENT(operator_type))
THEN
1075 SELECT CASE (operator_type)
1080 cpassert(.NOT. my_molecular)
1081 my_symmetric = .false.
1084 my_symmetric = .false.
1094 my_sort_atomb = .false.
1095 IF (
PRESENT(atomb_to_keep))
THEN
1096 my_sort_atomb = .true.
1103 ALLOCATE (ab_list(nkind*nkind))
1104 DO iab = 1,
SIZE(ab_list)
1105 NULLIFY (ab_list(iab)%neighbor_list_set)
1106 ab_list(iab)%nl_size = -1
1107 ab_list(iab)%nl_start = -1
1108 ab_list(iab)%nl_end = -1
1109 NULLIFY (ab_list(iab)%nlist_task)
1113 ALLOCATE (pres_a(nkind), pres_b(nkind))
1115 pres_a(ikind) = any(pair_radius(ikind, :) > 0._dp)
1116 pres_b(ikind) = any(pair_radius(:, ikind) > 0._dp)
1120 natom =
SIZE(particle_set)
1121 ALLOCATE (r_pbc(3, natom))
1123 r_pbc(1:3, i) =
pbc(particle_set(i)%r(1:3), cell)
1129 maxat = max(maxat,
SIZE(
atom(ikind)%list))
1131 ALLOCATE (index_list(maxat))
1135 ALLOCATE (lista(nkind), listb(nkind), nlista(nkind), nlistb(nkind))
1139 NULLIFY (lista(ikind)%list, listb(ikind)%list)
1142 IF (
ASSOCIATED(
atom(ikind)%list_local_a_index))
THEN
1143 lista(ikind)%list =>
atom(ikind)%list_local_a_index
1144 nlista(ikind) =
SIZE(lista(ikind)%list)
1146 IF (
ASSOCIATED(
atom(ikind)%list_local_b_index))
THEN
1147 listb(ikind)%list =>
atom(ikind)%list_local_b_index
1148 nlistb(ikind) =
SIZE(listb(ikind)%list)
1151 IF (
ASSOCIATED(
atom(ikind)%list_local_a_index))
THEN
1152 lista(ikind)%list =>
atom(ikind)%list_local_a_index
1153 nlista(ikind) =
SIZE(lista(ikind)%list)
1155 nlistb(ikind) =
SIZE(
atom(ikind)%list)
1156 listb(ikind)%list => index_list
1158 CALL combine_lists(lista(ikind)%list, nlista(ikind), ikind,
atom)
1159 nlistb(ikind) =
SIZE(
atom(ikind)%list)
1160 listb(ikind)%list => index_list
1162 nlista(ikind) =
SIZE(
atom(ikind)%list_1d)
1163 lista(ikind)%list =>
atom(ikind)%list_1d
1164 nlistb(ikind) =
SIZE(
atom(ikind)%list)
1165 listb(ikind)%list => index_list
1174 maxat = max(maxat, nlista(ikind), nlistb(ikind))
1176 ALLOCATE (kind_a(2*maxat))
1179 CALL get_cell(cell=cell, periodic=periodic, deth=deth)
1183 IF (.NOT. pres_a(ikind)) cycle
1186 IF (.NOT. pres_b(jkind)) cycle
1188 iab = ikind + nkind*(jkind - 1)
1191 IF (pair_radius(ikind, jkind) <= 0._dp) cycle
1192 rab_max = pair_radius(ikind, jkind)
1193 IF (otype == 3)
THEN
1197 rabm = maxval(pair_radius(:, jkind))
1201 rab2_max = rabm*rabm
1208 sab_max_guard = 15.0_dp/pd
1211 subcell_scale = ((125.0_dp**3)/deth)**(1.0_dp/6.0_dp)
1215 nsubcell(:) = int(max(1.0_dp, min(0.5_dp*subcells*subcell_scale/sab_max(:), &
1216 0.5_dp*subcells*subcell_scale/sab_max_guard(:))))
1219 ncell(:) = (int(sab_max(:)) + 1)*periodic(:)
1222 symmetric=my_symmetric)
1223 neighbor_list_set => ab_list(iab)%neighbor_list_set
1225 DO iatom_local = 1, nlista(ikind)
1226 iatom = lista(ikind)%list(iatom_local)
1227 atom_a =
atom(ikind)%list(iatom)
1230 neighbor_list=kind_a(iatom_local)%neighbor_list)
1234 DO iatom_local = 1, nlista(ikind)
1235 iatom = lista(ikind)%list(iatom_local)
1236 atom_a =
atom(ikind)%list(iatom)
1237 r = r_pbc(:, atom_a)
1239 subcell(i, j, k)%natom = subcell(i, j, k)%natom + 1
1241 DO k = 1, nsubcell(3)
1242 DO j = 1, nsubcell(2)
1243 DO i = 1, nsubcell(1)
1244 maxat = subcell(i, j, k)%natom + subcell(i, j, k)%natom/10
1245 ALLOCATE (subcell(i, j, k)%atom_list(maxat))
1246 subcell(i, j, k)%natom = 0
1250 DO iatom_local = 1, nlista(ikind)
1251 iatom = lista(ikind)%list(iatom_local)
1252 atom_a =
atom(ikind)%list(iatom)
1253 r = r_pbc(:, atom_a)
1255 subcell(i, j, k)%natom = subcell(i, j, k)%natom + 1
1256 subcell(i, j, k)%atom_list(subcell(i, j, k)%natom) = iatom_local
1259 DO jatom_local = 1, nlistb(jkind)
1260 jatom = listb(jkind)%list(jatom_local)
1261 atom_b =
atom(jkind)%list(jatom)
1262 IF (my_sort_atomb .AND. .NOT. my_symmetric)
THEN
1263 IF (.NOT. any(atomb_to_keep == atom_b)) cycle
1265 IF (my_molecular)
THEN
1266 mol_b =
atom(jkind)%list_b_mol(jatom_local)
1267 IF (
PRESENT(subset_of_mol))
THEN
1268 IF (subset_of_mol(mol_b) .NE. current_subset) cycle
1271 r = r_pbc(:, atom_b)
1274 loop2_kcell:
DO kcell = -ncell(3), ncell(3)
1275 sb(3) = sb_pbc(3) + real(kcell,
dp)
1276 sb_min(3) = sb(3) - sab_max(3)
1277 sb_max(3) = sb(3) + sab_max(3)
1278 IF (periodic(3) /= 0)
THEN
1279 IF (sb_min(3) >= 0.5_dp)
EXIT loop2_kcell
1280 IF (sb_max(3) < -0.5_dp) cycle loop2_kcell
1284 loop2_jcell:
DO jcell = -ncell(2), ncell(2)
1285 sb(2) = sb_pbc(2) + real(jcell,
dp)
1286 sb_min(2) = sb(2) - sab_max(2)
1287 sb_max(2) = sb(2) + sab_max(2)
1288 IF (periodic(2) /= 0)
THEN
1289 IF (sb_min(2) >= 0.5_dp)
EXIT loop2_jcell
1290 IF (sb_max(2) < -0.5_dp) cycle loop2_jcell
1294 loop2_icell:
DO icell = -ncell(1), ncell(1)
1295 sb(1) = sb_pbc(1) + real(icell,
dp)
1296 sb_min(1) = sb(1) - sab_max(1)
1297 sb_max(1) = sb(1) + sab_max(1)
1298 IF (periodic(1) /= 0)
THEN
1299 IF (sb_min(1) >= 0.5_dp)
EXIT loop2_icell
1300 IF (sb_max(1) < -0.5_dp) cycle loop2_icell
1306 loop_k:
DO k = 1, nsubcell(3)
1307 loop_j:
DO j = 1, nsubcell(2)
1308 loop_i:
DO i = 1, nsubcell(1)
1312 IF (periodic(3) /= 0)
THEN
1313 IF (sb_max(3) < subcell(i, j, k)%s_min(3))
EXIT loop_k
1314 IF (sb_min(3) >= subcell(i, j, k)%s_max(3)) cycle loop_k
1317 IF (periodic(2) /= 0)
THEN
1318 IF (sb_max(2) < subcell(i, j, k)%s_min(2))
EXIT loop_j
1319 IF (sb_min(2) >= subcell(i, j, k)%s_max(2)) cycle loop_j
1322 IF (periodic(1) /= 0)
THEN
1323 IF (sb_max(1) < subcell(i, j, k)%s_min(1))
EXIT loop_i
1324 IF (sb_min(1) >= subcell(i, j, k)%s_max(1)) cycle loop_i
1327 IF (subcell(i, j, k)%natom == 0) cycle
1329 DO iatom_subcell = 1, subcell(i, j, k)%natom
1330 iatom_local = subcell(i, j, k)%atom_list(iatom_subcell)
1331 iatom = lista(ikind)%list(iatom_local)
1332 atom_a =
atom(ikind)%list(iatom)
1333 IF (my_molecular)
THEN
1334 mol_a =
atom(ikind)%list_a_mol(iatom_local)
1335 IF (mol_a /= mol_b) cycle
1337 IF (my_symmetric)
THEN
1338 IF (atom_a > atom_b)
THEN
1339 include_ab = (
modulo(atom_a + atom_b, 2) /= 0)
1341 include_ab = (
modulo(atom_a + atom_b, 2) == 0)
1343 IF (my_sort_atomb)
THEN
1344 IF ((.NOT. any(atomb_to_keep == atom_b)) .AND. &
1345 (.NOT. any(atomb_to_keep == atom_a)))
THEN
1346 include_ab = .false.
1352 IF (include_ab)
THEN
1353 ra(:) = r_pbc(:, atom_a)
1354 rab(:) = rb(:) - ra(:)
1355 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
1356 IF (rab2 < rab2_max)
THEN
1362 rab_pbc(:) =
pbc(rab(:), cell)
1363 IF (sum((rab_pbc - rab)**2) > epsilon(1.0_dp))
THEN
1364 include_ab = .false.
1367 IF (include_ab)
THEN
1369 neighbor_list=kind_a(iatom_local)%neighbor_list, &
1398 DEALLOCATE (lista(ikind)%list)
1403 DEALLOCATE (kind_a, pres_a, pres_b, lista, listb, nlista, nlistb)
1404 DEALLOCATE (index_list)
1411 IF (inode == 1) nentry = nentry + nnode
1415 ALLOCATE (ab_list(1)%nlist_task(nentry))
1416 ab_list(1)%nl_size = nentry
1417 DO iab = 2,
SIZE(ab_list)
1418 ab_list(iab)%nl_size = nentry
1419 ab_list(iab)%nlist_task => ab_list(1)%nlist_task
1428 iab = (ikind - 1)*nkind + jkind
1429 IF (ab_list(iab)%nl_start < 0) ab_list(iab)%nl_start = nentry
1430 IF (ab_list(iab)%nl_end < 0)
THEN
1431 ab_list(iab)%nl_end = nentry
1433 cpassert(ab_list(iab)%nl_end + 1 == nentry)
1434 ab_list(iab)%nl_end = nentry
1439 CALL timestop(handle)
1457 mic, symmetric, molecular, operator_type)
1459 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1461 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_a
1462 TYPE(gto_basis_set_p_type),
DIMENSION(:), &
1463 OPTIONAL,
POINTER :: basis_set_b
1464 TYPE(qs_environment_type),
POINTER :: qs_env
1465 LOGICAL,
INTENT(IN),
OPTIONAL :: mic, symmetric, molecular
1466 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: operator_type
1468 CHARACTER(LEN=4) :: otype
1469 INTEGER :: ikind, nkind
1470 LOGICAL :: my_mic, my_molecular, my_symmetric
1471 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: a_present, b_present
1472 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: a_radius, b_radius
1473 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pair_radius
1474 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1475 TYPE(cell_type),
POINTER :: cell
1476 TYPE(distribution_1d_type),
POINTER :: distribution_1d
1477 TYPE(distribution_2d_type),
POINTER :: distribution_2d
1478 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_a, basis_b
1479 TYPE(gto_basis_set_type),
POINTER :: abas, bbas
1480 TYPE(local_atoms_type),
ALLOCATABLE,
DIMENSION(:) :: atom2d
1481 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1482 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1484 basis_a => basis_set_a
1485 IF (
PRESENT(basis_set_b))
THEN
1486 basis_b => basis_set_b
1487 my_symmetric = .false.
1489 basis_b => basis_set_a
1490 my_symmetric = .true.
1492 IF (
PRESENT(symmetric)) my_symmetric = symmetric
1494 IF (
PRESENT(mic))
THEN
1500 IF (
PRESENT(molecular))
THEN
1501 my_molecular = molecular
1503 my_molecular = .false.
1506 IF (
PRESENT(operator_type))
THEN
1507 otype = operator_type
1513 nkind =
SIZE(basis_a)
1514 ALLOCATE (a_present(nkind), b_present(nkind))
1517 ALLOCATE (a_radius(nkind), b_radius(nkind))
1521 IF (
ASSOCIATED(basis_a(ikind)%gto_basis_set))
THEN
1522 a_present(ikind) = .true.
1523 abas => basis_a(ikind)%gto_basis_set
1526 IF (
ASSOCIATED(basis_b(ikind)%gto_basis_set))
THEN
1527 b_present(ikind) = .true.
1528 bbas => basis_b(ikind)%gto_basis_set
1533 ALLOCATE (pair_radius(nkind, nkind))
1534 pair_radius = 0.0_dp
1538 atomic_kind_set=atomic_kind_set, &
1540 distribution_2d=distribution_2d, &
1541 local_particles=distribution_1d, &
1542 particle_set=particle_set, &
1543 molecule_set=molecule_set)
1545 ALLOCATE (atom2d(nkind))
1546 CALL atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, &
1547 molecule_set, my_molecular, particle_set=particle_set)
1549 mic=my_mic, symmetric=my_symmetric, molecular=my_molecular, &
1550 subcells=2.0_dp, nlname=
"AUX_NL")
1554 DEALLOCATE (a_present, b_present, a_radius, b_radius, pair_radius, atom2d)
1565 SUBROUTINE combine_lists(list, n, ikind, atom)
1566 INTEGER,
DIMENSION(:),
POINTER ::
list
1567 INTEGER,
INTENT(OUT) :: n
1568 INTEGER,
INTENT(IN) :: ikind
1569 TYPE(local_atoms_type),
DIMENSION(:),
INTENT(IN) ::
atom
1571 INTEGER :: i, ib, na, nb
1572 INTEGER,
DIMENSION(:),
POINTER :: lista, listb
1574 cpassert(.NOT.
ASSOCIATED(
list))
1576 lista =>
atom(ikind)%list_local_a_index
1577 listb =>
atom(ikind)%list_local_b_index
1579 IF (
ASSOCIATED(lista))
THEN
1585 IF (
ASSOCIATED(listb))
THEN
1591 ALLOCATE (
list(na + nb))
1594 IF (na .GT. 0)
list(1:na) = lista(1:na)
1596 loopb:
DO ib = 1, nb
1598 IF (listb(ib) ==
list(i)) cycle loopb
1604 END SUBROUTINE combine_lists
1618 LOGICAL,
DIMENSION(:),
INTENT(IN) :: present_a, present_b
1619 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: radius_a, radius_b
1620 REAL(
dp),
DIMENSION(:, :),
INTENT(OUT) :: pair_radius
1621 REAL(
dp),
INTENT(IN),
OPTIONAL :: prmin
1623 INTEGER :: i, j, nkind
1626 nkind =
SIZE(present_a)
1631 IF (
PRESENT(prmin)) rrmin = prmin
1634 IF (.NOT. present_a(i)) cycle
1636 IF (.NOT. present_b(j)) cycle
1637 pair_radius(i, j) = radius_a(i) + radius_b(j)
1638 pair_radius(i, j) = max(pair_radius(i, j), rrmin)
1654 SUBROUTINE write_neighbor_distribution(ab, qs_kind_set, output_unit, para_env)
1655 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1657 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1658 INTEGER,
INTENT(in) :: output_unit
1659 TYPE(mp_para_env_type),
POINTER :: para_env
1661 CHARACTER(len=*),
PARAMETER :: routinen =
'write_neighbor_distribution'
1662 LOGICAL,
PARAMETER :: full_output = .false.
1664 INTEGER :: handle, ikind, inode, ipe, jkind, n, &
1666 INTEGER(int_8) :: nblock_max, nblock_sum, nelement_max, &
1667 nelement_sum, tmp(2)
1668 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nblock, nelement, nnsgf
1669 TYPE(gto_basis_set_type),
POINTER :: orb_basis_set
1670 TYPE(neighbor_list_iterator_p_type), &
1671 DIMENSION(:),
POINTER :: nl_iterator
1673 CALL timeset(routinen, handle)
1674 associate(mype => para_env%mepos + 1, npe => para_env%num_pe)
1677 ALLOCATE (nblock(npe), nelement(npe))
1680 nkind =
SIZE(qs_kind_set)
1681 ALLOCATE (nnsgf(nkind))
1684 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1685 IF (
ASSOCIATED(orb_basis_set))
THEN
1692 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, inode=inode, nnode=nnode)
1693 IF (inode == 1)
THEN
1694 n = nnsgf(ikind)*nnsgf(jkind)
1695 nblock(mype) = nblock(mype) + nnode
1696 nelement(mype) = nelement(mype) + n*nnode
1701 IF (full_output)
THEN
1703 CALL para_env%sum(nblock)
1704 CALL para_env%sum(nelement)
1706 nblock_sum = sum(int(nblock, kind=
int_8))
1707 nelement_sum = sum(int(nelement, kind=
int_8))
1709 nblock_sum = nblock(mype)
1710 nblock_max = nblock(mype)
1711 nelement_sum = nelement(mype)
1712 nelement_max = nelement(mype)
1713 tmp = (/nblock_sum, nelement_sum/)
1714 CALL para_env%sum(tmp)
1715 nblock_sum = tmp(1); nelement_sum = tmp(2)
1716 tmp = (/nblock_max, nelement_max/)
1717 CALL para_env%max(tmp)
1718 nblock_max = tmp(1); nelement_max = tmp(2)
1721 IF (output_unit > 0)
THEN
1722 IF (full_output)
THEN
1723 WRITE (unit=output_unit, &
1724 fmt=
"(/,/,T2,A,/,/,T3,A,/,/,(T4,I6,T27,I10,T55,I10))") &
1725 "DISTRIBUTION OF THE NEIGHBOR LISTS", &
1726 "Process Number of particle pairs Number of matrix elements", &
1727 (ipe - 1, nblock(ipe), nelement(ipe), ipe=1, npe)
1728 WRITE (unit=output_unit, fmt=
"(/,T7,A3,T27,I10,T55,I10)") &
1729 "Sum", sum(nblock), sum(nelement)
1731 WRITE (unit=output_unit, fmt=
"(/,T2,A)")
"DISTRIBUTION OF THE NEIGHBOR LISTS"
1732 WRITE (unit=output_unit, fmt=
"(T15,A,T68,I13)")
"Total number of particle pairs:", nblock_sum
1733 WRITE (unit=output_unit, fmt=
"(T15,A,T68,I13)")
"Total number of matrix elements:", nelement_sum
1734 WRITE (unit=output_unit, fmt=
"(T15,A,T68,I13)")
"Average number of particle pairs:", (nblock_sum + npe - 1)/npe
1735 WRITE (unit=output_unit, fmt=
"(T15,A,T68,I13)")
"Maximum number of particle pairs:", nblock_max
1736 WRITE (unit=output_unit, fmt=
"(T15,A,T68,I13)")
"Average number of matrix element:", (nelement_sum + npe - 1)/npe
1737 WRITE (unit=output_unit, fmt=
"(T15,A,T68,I13)")
"Maximum number of matrix elements:", nelement_max
1744 DEALLOCATE (nblock, nelement, nnsgf)
1746 CALL timestop(handle)
1748 END SUBROUTINE write_neighbor_distribution
1768 nl_type, middle_name, nlname)
1770 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1772 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1773 TYPE(cell_type),
POINTER :: cell
1774 TYPE(mp_para_env_type),
POINTER :: para_env
1775 TYPE(section_vals_type),
POINTER :: neighbor_list_section
1776 CHARACTER(LEN=*),
INTENT(IN) :: nl_type, middle_name, nlname
1778 CHARACTER(LEN=default_string_length) :: string, unit_str
1779 INTEGER :: iatom, inode, iw, jatom, nneighbor, nnode
1780 INTEGER,
DIMENSION(3) :: cell_b
1781 REAL(dp) :: dab, unit_conv
1782 REAL(dp),
DIMENSION(3) :: ra, rab, rb
1783 TYPE(cp_logger_type),
POINTER :: logger
1784 TYPE(neighbor_list_iterator_p_type), &
1785 DIMENSION(:),
POINTER :: nl_iterator
1788 logger => cp_get_default_logger()
1789 IF (btest(cp_print_key_should_output(logger%iter_info, neighbor_list_section, &
1792 iw = cp_print_key_unit_nr(logger=logger, &
1793 basis_section=neighbor_list_section, &
1794 print_key_path=trim(nl_type), &
1796 middle_name=trim(middle_name), &
1798 log_filename=.false., &
1799 file_position=
"REWIND")
1800 associate(mype => para_env%mepos)
1801 CALL section_vals_val_get(neighbor_list_section,
"UNIT", c_val=unit_str)
1802 unit_conv = cp_unit_from_cp2k(1.0_dp, trim(unit_str))
1806 WRITE (unit=string, fmt=
"(A,I5,A)") &
1807 trim(nlname)//
" IN "//trim(unit_str)//
" (PROCESS", mype,
")"
1808 CALL compress(string)
1809 IF (iw > 0)
WRITE (unit=iw, fmt=
"(/,/,T2,A)") trim(string)
1813 CALL neighbor_list_iterator_create(nl_iterator, ab)
1814 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
1815 CALL get_iterator_info(nl_iterator, inode=inode, nnode=nnode, &
1816 iatom=iatom, jatom=jatom, cell=cell_b, r=rab)
1817 nneighbor = nneighbor + 1
1818 ra(:) =
pbc(particle_set(iatom)%r, cell)
1819 rb(:) = ra(:) + rab(:)
1820 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
1822 IF (inode == 1)
THEN
1823 WRITE (unit=iw, fmt=
"(/,T2,I5,3X,I6,3X,3F12.6)") &
1824 iatom, nnode, ra(1:3)*unit_conv
1826 WRITE (unit=iw, fmt=
"(T10,I6,3X,3I4,3F12.6,2X,F12.6)") &
1827 jatom, cell_b(1:3), rb(1:3)*unit_conv, dab*unit_conv
1830 CALL neighbor_list_iterator_release(nl_iterator)
1833 WRITE (unit=string, fmt=
"(A,I12,A,I12)") &
1834 "Total number of neighbor interactions for process", mype,
":", &
1836 CALL compress(string)
1837 IF (iw > 0)
WRITE (unit=iw, fmt=
"(/,T2,A)") trim(string)
1838 CALL cp_print_key_finished_output(unit_nr=iw, &
1840 basis_section=neighbor_list_section, &
1841 print_key_path=trim(nl_type), &
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
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
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)
...
Handles all functions related to the CELL.
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
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).
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...
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
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.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
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 ...
Collection of simple mathematical functions and subroutines.
subroutine, public erfc_cutoff(eps, omg, r_cutoff)
compute a truncation radius for the shortrange operator
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:
real(kind=dp), parameter, public bohr
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
Definition of disperson types for DFT calculations.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
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, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, 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_r3d_rs_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, U_of_dft_plus_u, J_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr)
Get attributes of an atomic kind set.
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, 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)
...
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_ks_im_kp, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public get_iterator_task(iterator_set, task, mepos)
Captures the current state of the iterator in a neighbor_list_task_type.
subroutine, public release_neighbor_list_sets(nlists)
releases an array of neighbor_list_sets
subroutine, public add_neighbor_node(neighbor_list, neighbor, cell, r, exclusion_list, nkind)
Add a new neighbor list node to a neighbor list.
subroutine, public add_neighbor_list(neighbor_list_set, atom, neighbor_list)
Add a new neighbor list to a neighbor list set.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public allocate_neighbor_list_set(neighbor_list_set, symmetric)
Allocate and initialize a set of neighbor lists.
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
Generate the atomic neighbor lists.
subroutine, public atom2d_cleanup(atom2d)
free the internals of atom2d
subroutine, public build_qs_neighbor_lists(qs_env, para_env, molecular, force_env_section)
Build all the required neighbor lists for Quickstep.
subroutine, public pair_radius_setup(present_a, present_b, radius_a, radius_b, pair_radius, prmin)
...
subroutine, public build_neighbor_lists(ab_list, particle_set, atom, cell, pair_radius, subcells, mic, symmetric, molecular, subset_of_mol, current_subset, operator_type, nlname, atomb_to_keep)
Build simple pair neighbor lists.
subroutine, public setup_neighbor_list(ab_list, basis_set_a, basis_set_b, qs_env, mic, symmetric, molecular, operator_type)
Build a neighborlist.
subroutine, public write_neighbor_lists(ab, particle_set, cell, para_env, neighbor_list_section, nl_type, middle_name, nlname)
Write a set of neighbor lists to the output unit.
subroutine, public atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, molecule_set, molecule_only, particle_set)
Build some distribution structure of atoms, refactored from build_qs_neighbor_lists.
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
subcell types and allocation routines
subroutine, public deallocate_subcell(subcell)
Deallocate a subcell grid structure.
subroutine, public give_ijk_subcell(r, i, j, k, cell, nsubcell)
...
subroutine, public allocate_subcell(subcell, nsubcell, maxatom, cell)
Allocate and initialize a subcell grid structure for the atomic neighbor search.
All kind of helpful little routines.
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 of the xTB parameter types.
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, occupation, electronegativity, chmax)
...