(git:08825b9)
Loading...
Searching...
No Matches
qs_ao_translations.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 Analytic translations of finite or periodized Gaussian AO functions.
10!> \author Thomas D. Kuehne, tkuehne@cp2k.org
11! **************************************************************************************************
13 USE ai_contraction, ONLY: block_add,&
15 USE ai_overlap, ONLY: overlap_ab
18 USE cell_types, ONLY: cell_type
19 USE cp_dbcsr_api, ONLY: dbcsr_create,&
26 dbcsr_type_no_symmetry
27 USE kinds, ONLY: dp
29 USE orbital_pointers, ONLY: ncoset
36#include "./base/base_uses.f90"
37
38 IMPLICIT NONE
39 PRIVATE
40 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_ao_translations'
42CONTAINS
43! **************************************************************************************************
44!> \brief Overlaps with translated ket Gaussians, U(a) psi(r) = psi(r+a).
45!> \param qs_env Quickstep environment supplying primitive AOs and their distribution
46!> \param shifts Cartesian translation vectors in internal bohr
47!> \param translations Newly allocated nonsymmetric primitive-size matrices, released by caller
48!> \param periodic_grid If present, sum images of the grid-expanded periodic cell; otherwise finite
49!> \note Arbitrary shifts use their own overlap screening, not the SCF neighbour list.
50! **************************************************************************************************
51 SUBROUTINE ao_translation_matrices(qs_env, shifts, translations, periodic_grid)
52 TYPE(qs_environment_type), POINTER :: qs_env
53 REAL(dp), INTENT(IN) :: shifts(:, :)
54 TYPE(dbcsr_p_type), POINTER :: translations(:)
55 INTEGER, INTENT(IN), OPTIONAL :: periodic_grid(3)
56
57 INTEGER :: axis, ia, ib, iset, it, jset, ka, kb, &
58 ld, lower(3), na, nb, nx, ny, nz, sa, &
59 sb, upper(3)
60 INTEGER, POINTER :: col_dist(:), pgrid(:, :), row_dist(:)
61 LOGICAL :: do_kpoints
62 REAL(dp) :: distance, h(3, 3), hinv(3, 3), &
63 offset(3), rab(3), radius, reach(3), &
64 scaled(3)
65 REAL(dp), ALLOCATABLE :: block(:, :), integrals(:, :), work(:, :)
66 TYPE(cell_type), POINTER :: cell
67 TYPE(dbcsr_distribution_type) :: distribution
68 TYPE(dbcsr_p_type), POINTER :: matrix_s(:, :)
69 TYPE(gto_basis_set_p_type), ALLOCATABLE :: bases(:)
70 TYPE(gto_basis_set_type), POINTER :: a, b
71 TYPE(mp_para_env_type), POINTER :: para_env
72 TYPE(particle_type), POINTER :: particles(:)
73 TYPE(qs_kind_type), POINTER :: kinds(:)
74
75 CALL get_qs_env(qs_env, cell=cell, do_kpoints=do_kpoints, matrix_s_kp=matrix_s, &
76 para_env=para_env, particle_set=particles, qs_kind_set=kinds)
77 h = 0.0_dp
78 hinv = 0.0_dp
79 reach = 0.0_dp
80 IF (PRESENT(periodic_grid)) THEN
81 cpassert(all(periodic_grid >= 1))
82 cpassert(all(periodic_grid == 1 .OR. cell%perd /= 0))
83 DO axis = 1, 3
84 h(:, axis) = cell%hmat(:, axis)*periodic_grid(axis)
85 hinv(axis, :) = cell%h_inv(axis, :)/periodic_grid(axis)
86 IF (cell%perd(axis) /= 0) reach(axis) = sqrt(sum(hinv(axis, :)**2))
87 END DO
88 ELSE IF (any(cell%perd /= 0) .OR. do_kpoints) THEN
89 cpabort('Finite AO translations require isolated Gamma systems.')
90 END IF
91 cpassert(SIZE(shifts, 1) == 3)
92 ALLOCATE (bases(SIZE(kinds)))
93 CALL basis_set_list_setup(bases, 'ORB', kinds)
94 ld = get_memory_usage(kinds, 'ORB')
95 ALLOCATE (integrals(ld, ld), work(ld, ld), translations(SIZE(shifts, 2)))
96 CALL dbcsr_get_info(matrix_s(1, 1)%matrix, distribution=distribution)
97 CALL dbcsr_distribution_get(distribution, pgrid=pgrid, row_dist=row_dist, col_dist=col_dist)
98 DO it = 1, SIZE(shifts, 2)
99 ALLOCATE (translations(it)%matrix)
100 CALL dbcsr_create(translations(it)%matrix, template=matrix_s(1, 1)%matrix, &
101 name='AO TRANSLATION', matrix_type=dbcsr_type_no_symmetry)
102 DO ia = 1, SIZE(particles)
103 ka = particles(ia)%atomic_kind%kind_number
104 a => bases(ka)%gto_basis_set
105 IF (.NOT. ASSOCIATED(a)) cycle
106 DO ib = 1, SIZE(particles)
107 IF (pgrid(row_dist(ia), col_dist(ib)) /= para_env%mepos) cycle
108 kb = particles(ib)%atomic_kind%kind_number
109 b => bases(kb)%gto_basis_set
110 IF (.NOT. ASSOCIATED(b)) cycle
111 offset = particles(ib)%r - particles(ia)%r - shifts(:, it)
112 lower = 0
113 upper = 0
114 IF (PRESENT(periodic_grid)) THEN
115 ! Reciprocal-plane distances bound every image, including skew cells.
116 scaled = matmul(hinv, offset)
117 radius = maxval(a%set_radius) + maxval(b%set_radius)
118 DO axis = 1, 3
119 IF (cell%perd(axis) == 0) cycle
120 lower(axis) = ceiling(-scaled(axis) - radius*reach(axis))
121 upper(axis) = floor(-scaled(axis) + radius*reach(axis))
122 END DO
123 END IF
124 ALLOCATE (block(a%nsgf, b%nsgf))
125 block = 0.0_dp
126 DO nz = lower(3), upper(3)
127 DO ny = lower(2), upper(2)
128 DO nx = lower(1), upper(1)
129 rab = offset + matmul(h, real([nx, ny, nz], dp))
130 distance = sqrt(sum(rab**2))
131 DO iset = 1, a%nset
132 sa = a%first_sgf(1, iset)
133 na = a%npgf(iset)*(ncoset(a%lmax(iset)) - ncoset(a%lmin(iset) - 1))
134 DO jset = 1, b%nset
135 IF (a%set_radius(iset) + b%set_radius(jset) < distance) cycle
136 sb = b%first_sgf(1, jset)
137 nb = b%npgf(jset)*(ncoset(b%lmax(jset)) - ncoset(b%lmin(jset) - 1))
138 CALL overlap_ab(a%lmax(iset), a%lmin(iset), a%npgf(iset), &
139 a%pgf_radius(:, iset), a%zet(:, iset), &
140 b%lmax(jset), b%lmin(jset), b%npgf(jset), &
141 b%pgf_radius(:, jset), b%zet(:, jset), rab, sab=integrals)
142 CALL contraction(integrals, work, ca=a%scon(:, sa:), na=na, ma=a%nsgf_set(iset), &
143 cb=b%scon(:, sb:), nb=nb, mb=b%nsgf_set(jset), &
144 fscale=1.0_dp, trans=.false.)
145 CALL block_add('IN', work, a%nsgf_set(iset), b%nsgf_set(jset), &
146 block, sa, sb, trans=.false.)
147 END DO
148 END DO
149 END DO
150 END DO
151 END DO
152 IF (maxval(abs(block)) > 0.0_dp) CALL dbcsr_put_block(translations(it)%matrix, ia, ib, block)
153 DEALLOCATE (block)
154 END DO
155 END DO
156 CALL dbcsr_finalize(translations(it)%matrix)
157 END DO
158 END SUBROUTINE ao_translation_matrices
159END MODULE qs_ao_translations
Set of routines to: Contract integrals over primitive Gaussians Decontract (density) matrices Trace m...
Calculation of the overlap integrals over Cartesian Gaussian-type functions.
Definition ai_overlap.F:18
subroutine, public overlap_ab(la_max, la_min, npgfa, rpgfa, zeta, lb_max, lb_min, npgfb, rpgfb, zetb, rab, sab, dab, ddab, rr_work)
Calculation of the two-center overlap integrals [a|b] over Cartesian Gaussian-type functions....
Definition ai_overlap.F:252
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_finalize(matrix)
...
subroutine, public dbcsr_put_block(matrix, row, col, block, summation)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
Define the data structure for the particle information.
Analytic translations of finite or periodized Gaussian AO functions.
subroutine, public ao_translation_matrices(qs_env, shifts, translations, periodic_grid)
Overlaps with translated ket Gaussians, U(a) psi(r) = psi(r+a).
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.
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
Define the quickstep kind type and their sub types.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.