Line data Source code
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 Calculation of contracted, spherical Gaussian integrals using the solid harmonic
10 : !> Gaussian (SHG) integral scheme. Routines for the following two-center integrals:
11 : !> i) (a|O(r12)|b) where O(r12) is the overlap, coulomb operator etc.
12 : !> ii) (aba) and (abb) s-overlaps
13 : !> \par Literature
14 : !> T.J. Giese and D. M. York, J. Chem. Phys, 128, 064104 (2008)
15 : !> T. Helgaker, P Joergensen, J. Olsen, Molecular Electronic-Structure
16 : !> Theory, Wiley
17 : !> \par History
18 : !> created [05.2016]
19 : !> \author Dorothea Golze
20 : ! **************************************************************************************************
21 : MODULE generic_shg_integrals
22 : USE basis_set_types, ONLY: gto_basis_set_type
23 : USE constants_operator, ONLY: operator_coulomb,&
24 : operator_gauss,&
25 : operator_verf,&
26 : operator_verfc,&
27 : operator_vgauss
28 : USE construct_shg, ONLY: &
29 : construct_dev_shg_ab, construct_int_shg_ab, construct_overlap_shg_aba, &
30 : construct_overlap_shg_abb, dev_overlap_shg_aba, dev_overlap_shg_abb, get_W_matrix, &
31 : get_dW_matrix, get_real_scaled_solid_harmonic
32 : USE kinds, ONLY: dp
33 : USE orbital_pointers, ONLY: nsoset
34 : USE s_contract_shg, ONLY: &
35 : contract_s_overlap_aba, contract_s_overlap_abb, contract_s_ra2m_ab, &
36 : contract_sint_ab_chigh, contract_sint_ab_clow, s_coulomb_ab, s_gauss_ab, s_overlap_ab, &
37 : s_overlap_abb, s_ra2m_ab, s_verf_ab, s_verfc_ab, s_vgauss_ab
38 : #include "../base/base_uses.f90"
39 :
40 : IMPLICIT NONE
41 :
42 : PRIVATE
43 :
44 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'generic_shg_integrals'
45 :
46 : PUBLIC :: int_operators_r12_ab_shg, int_overlap_ab_shg, &
47 : int_ra2m_ab_shg, int_overlap_aba_shg, int_overlap_abb_shg, &
48 : get_abb_same_kind, lri_precalc_angular_shg_part, &
49 : int_overlap_ab_shg_low, int_ra2m_ab_shg_low, int_overlap_aba_shg_low, &
50 : int_overlap_abb_shg_low
51 :
52 : ABSTRACT INTERFACE
53 : ! **************************************************************************************************
54 : !> \brief Interface for the calculation of integrals over s-functions and their scalar derivatives
55 : !> with respect to rab2
56 : !> \param la_max ...
57 : !> \param npgfa ...
58 : !> \param zeta ...
59 : !> \param lb_max ...
60 : !> \param npgfb ...
61 : !> \param zetb ...
62 : !> \param omega ...
63 : !> \param rab ...
64 : !> \param v matrix storing the integrals and scalar derivatives
65 : !> \param calculate_forces ...
66 : ! **************************************************************************************************
67 : SUBROUTINE ab_sint_shg(la_max, npgfa, zeta, lb_max, npgfb, zetb, omega, rab, v, calculate_forces)
68 : USE kinds, ONLY: dp
69 : INTEGER, INTENT(IN) :: la_max, npgfa
70 : REAL(KIND=dp), DIMENSION(:), INTENT(IN) :: zeta
71 : INTEGER, INTENT(IN) :: lb_max, npgfb
72 : REAL(KIND=dp), DIMENSION(:), INTENT(IN) :: zetb
73 : REAL(KIND=dp), INTENT(IN) :: omega
74 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
75 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(INOUT) :: v
76 : LOGICAL, INTENT(IN) :: calculate_forces
77 :
78 : END SUBROUTINE ab_sint_shg
79 : END INTERFACE
80 :
81 : ! **************************************************************************************************
82 :
83 : CONTAINS
84 :
85 : ! **************************************************************************************************
86 : !> \brief Calcululates the two-center integrals of the type (a|O(r12)|b) using the SHG scheme
87 : !> \param r12_operator the integral operator, which depends on r12=|r1-r2|
88 : !> \param vab integral matrix of spherical contracted Gaussian functions
89 : !> \param dvab derivative of the integrals
90 : !> \param rab distance vector between center A and B
91 : !> \param fba basis at center A
92 : !> \param fbb basis at center B
93 : !> \param scona_shg SHG contraction matrix for A
94 : !> \param sconb_shg SHG contraction matrix for B
95 : !> \param omega parameter in the operator
96 : !> \param calculate_forces ...
97 : ! **************************************************************************************************
98 7854618 : SUBROUTINE int_operators_r12_ab_shg(r12_operator, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
99 : omega, calculate_forces)
100 :
101 : INTEGER, INTENT(IN) :: r12_operator
102 : REAL(KIND=dp), DIMENSION(:, :), INTENT(INOUT) :: vab
103 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(INOUT), &
104 : OPTIONAL :: dvab
105 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
106 : TYPE(gto_basis_set_type), POINTER :: fba, fbb
107 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: scona_shg, sconb_shg
108 : REAL(KIND=dp), INTENT(IN), OPTIONAL :: omega
109 : LOGICAL, INTENT(IN) :: calculate_forces
110 :
111 : INTEGER :: la_max, lb_max
112 : REAL(KIND=dp) :: my_omega
113 7854618 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: Waux_mat
114 7854618 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :, :) :: dWaux_mat
115 :
116 19846510 : la_max = MAXVAL(fba%lmax)
117 19847310 : lb_max = MAXVAL(fbb%lmax)
118 :
119 7854618 : CALL precalc_angular_shg_part(la_max, lb_max, rab, Waux_mat, dWaux_mat, calculate_forces)
120 7854618 : my_omega = 1.0_dp
121 :
122 15709108 : SELECT CASE (r12_operator)
123 : CASE (operator_coulomb)
124 : CALL int_operator_ab_shg_low(s_coulomb_ab, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
125 15708948 : my_omega, Waux_mat, dWaux_mat, calculate_forces)
126 : CASE (operator_verf)
127 32 : IF (PRESENT(omega)) my_omega = omega
128 : CALL int_operator_ab_shg_low(s_verf_ab, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
129 32 : my_omega, Waux_mat, dWaux_mat, calculate_forces)
130 : CASE (operator_verfc)
131 32 : IF (PRESENT(omega)) my_omega = omega
132 : CALL int_operator_ab_shg_low(s_verfc_ab, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
133 32 : my_omega, Waux_mat, dWaux_mat, calculate_forces)
134 : CASE (operator_vgauss)
135 32 : IF (PRESENT(omega)) my_omega = omega
136 : CALL int_operator_ab_shg_low(s_vgauss_ab, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
137 32 : my_omega, Waux_mat, dWaux_mat, calculate_forces)
138 : CASE (operator_gauss)
139 32 : IF (PRESENT(omega)) my_omega = omega
140 : CALL int_operator_ab_shg_low(s_gauss_ab, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
141 32 : my_omega, Waux_mat, dWaux_mat, calculate_forces)
142 : CASE DEFAULT
143 7854618 : CPABORT("Operator not available")
144 : END SELECT
145 :
146 7854618 : DEALLOCATE (Waux_mat, dWaux_mat)
147 :
148 7854618 : END SUBROUTINE int_operators_r12_ab_shg
149 :
150 : ! **************************************************************************************************
151 : !> \brief calculate overlap integrals (a,b)
152 : !> \param vab integral (a,b)
153 : !> \param dvab derivative of sab
154 : !> \param rab distance vector
155 : !> \param fba basis at center A
156 : !> \param fbb basis at center B
157 : !> \param scona_shg contraction matrix A
158 : !> \param sconb_shg contraxtion matrix B
159 : !> \param calculate_forces ...
160 : ! **************************************************************************************************
161 32 : SUBROUTINE int_overlap_ab_shg(vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
162 : calculate_forces)
163 :
164 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :), &
165 : INTENT(INOUT) :: vab
166 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
167 : INTENT(INOUT) :: dvab
168 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
169 : TYPE(gto_basis_set_type), POINTER :: fba, fbb
170 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: scona_shg, sconb_shg
171 : LOGICAL, INTENT(IN) :: calculate_forces
172 :
173 : INTEGER :: la_max, lb_max
174 32 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: Waux_mat
175 32 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :, :) :: dWaux_mat
176 :
177 352 : la_max = MAXVAL(fba%lmax)
178 512 : lb_max = MAXVAL(fbb%lmax)
179 :
180 32 : CALL precalc_angular_shg_part(la_max, lb_max, rab, Waux_mat, dWaux_mat, calculate_forces)
181 :
182 : CALL int_overlap_ab_shg_low(vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
183 32 : Waux_mat, dWaux_mat, .TRUE., calculate_forces, contraction_high=.TRUE.)
184 :
185 32 : DEALLOCATE (Waux_mat, dWaux_mat)
186 :
187 32 : END SUBROUTINE int_overlap_ab_shg
188 :
189 : ! **************************************************************************************************
190 : !> \brief Calcululates the two-center integrals of the type (a|(r-Ra)^(2m)|b) using the SHG scheme
191 : !> \param vab integral matrix of spherical contracted Gaussian functions
192 : !> \param dvab derivative of the integrals
193 : !> \param rab distance vector between center A and B
194 : !> \param fba basis at center A
195 : !> \param fbb basis at center B
196 : !> \param scon_ra2m contraction matrix for A including the combinatorial factors
197 : !> \param sconb_shg SHG contraction matrix for B
198 : !> \param m exponent in (r-Ra)^(2m) operator
199 : !> \param calculate_forces ...
200 : ! **************************************************************************************************
201 32 : SUBROUTINE int_ra2m_ab_shg(vab, dvab, rab, fba, fbb, scon_ra2m, sconb_shg, &
202 : m, calculate_forces)
203 :
204 : REAL(KIND=dp), DIMENSION(:, :), INTENT(INOUT) :: vab
205 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(INOUT) :: dvab
206 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
207 : TYPE(gto_basis_set_type), POINTER :: fba, fbb
208 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: scon_ra2m
209 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: sconb_shg
210 : INTEGER, INTENT(IN) :: m
211 : LOGICAL, INTENT(IN) :: calculate_forces
212 :
213 : INTEGER :: la_max, lb_max
214 32 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: Waux_mat
215 32 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :, :) :: dWaux_mat
216 :
217 352 : la_max = MAXVAL(fba%lmax)
218 512 : lb_max = MAXVAL(fbb%lmax)
219 :
220 32 : CALL precalc_angular_shg_part(la_max, lb_max, rab, Waux_mat, dWaux_mat, calculate_forces)
221 : CALL int_ra2m_ab_shg_low(vab, dvab, rab, fba, fbb, sconb_shg, scon_ra2m, &
222 32 : m, Waux_mat, dWaux_mat, calculate_forces)
223 :
224 32 : DEALLOCATE (Waux_mat, dWaux_mat)
225 :
226 32 : END SUBROUTINE int_ra2m_ab_shg
227 :
228 : ! **************************************************************************************************
229 : !> \brief calculate integrals (a,b,fa)
230 : !> \param saba integral [aba]
231 : !> \param dsaba derivative of [aba]
232 : !> \param rab distance vector between A and B
233 : !> \param oba orbital basis at center A
234 : !> \param obb orbital basis at center B
235 : !> \param fba auxiliary basis set at center A
236 : !> \param scon_obb contraction matrix for orb bas on B
237 : !> \param scona_mix mixed contraction matrix orb + ri basis on A
238 : !> \param oba_index orbital basis index for scona_mix
239 : !> \param fba_index ri basis index for scona_mix
240 : !> \param cg_coeff Clebsch-Gordon coefficients
241 : !> \param cg_none0_list list of none-zero Clebsch-Gordon coefficients
242 : !> \param ncg_none0 number of non-zero Clebsch-Gordon coefficients
243 : !> \param calculate_forces ...
244 : ! **************************************************************************************************
245 162 : SUBROUTINE int_overlap_aba_shg(saba, dsaba, rab, oba, obb, fba, scon_obb, &
246 162 : scona_mix, oba_index, fba_index, &
247 162 : cg_coeff, cg_none0_list, ncg_none0, &
248 : calculate_forces)
249 :
250 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
251 : INTENT(INOUT) :: saba
252 : REAL(KIND=dp), ALLOCATABLE, &
253 : DIMENSION(:, :, :, :), INTENT(INOUT) :: dsaba
254 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
255 : TYPE(gto_basis_set_type), POINTER :: oba, obb, fba
256 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: scon_obb
257 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: scona_mix
258 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: oba_index, fba_index
259 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: cg_coeff
260 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: cg_none0_list
261 : INTEGER, DIMENSION(:, :), INTENT(IN) :: ncg_none0
262 : LOGICAL, INTENT(IN) :: calculate_forces
263 :
264 : INTEGER :: laa_max, lb_max
265 162 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: Waux_mat
266 162 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :, :) :: dWaux_mat
267 :
268 2290 : laa_max = MAXVAL(oba%lmax) + MAXVAL(fba%lmax)
269 368 : lb_max = MAXVAL(obb%lmax)
270 :
271 162 : saba = 0.0_dp
272 162 : IF (calculate_forces) dsaba = 0.0_dp
273 : CALL precalc_angular_shg_part(laa_max, lb_max, rab, Waux_mat, dWaux_mat, &
274 162 : calculate_forces)
275 : CALL int_overlap_aba_shg_low(saba, dsaba, rab, oba, obb, fba, &
276 : scon_obb, scona_mix, oba_index, fba_index, &
277 : cg_coeff, cg_none0_list, ncg_none0, &
278 162 : Waux_mat, dWaux_mat, .TRUE., calculate_forces)
279 :
280 162 : DEALLOCATE (Waux_mat, dWaux_mat)
281 :
282 162 : END SUBROUTINE int_overlap_aba_shg
283 :
284 : ! **************************************************************************************************
285 : !> \brief calculate integrals (a,b,fb)
286 : !> \param sabb integral [abb]
287 : !> \param dsabb derivative of [abb]
288 : !> \param rab distance vector between A and B
289 : !> \param oba orbital basis at center A
290 : !> \param obb orbital basis at center B
291 : !> \param fbb auxiliary basis set at center B
292 : !> \param scon_oba contraction matrix for orb bas on A
293 : !> \param sconb_mix mixed contraction matrix orb + ri basis on B
294 : !> \param obb_index orbital basis index for sconb_mix
295 : !> \param fbb_index ri basis index for sconb_mix
296 : !> \param cg_coeff Clebsch-Gordon coefficients
297 : !> \param cg_none0_list list of none-zero Clebsch-Gordon coefficients
298 : !> \param ncg_none0 number of non-zero Clebsch-Gordon coefficients
299 : !> \param calculate_forces ...
300 : ! **************************************************************************************************
301 16 : SUBROUTINE int_overlap_abb_shg(sabb, dsabb, rab, oba, obb, fbb, scon_oba, &
302 16 : sconb_mix, obb_index, fbb_index, &
303 16 : cg_coeff, cg_none0_list, ncg_none0, &
304 : calculate_forces)
305 :
306 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
307 : INTENT(INOUT) :: sabb
308 : REAL(KIND=dp), ALLOCATABLE, &
309 : DIMENSION(:, :, :, :), INTENT(INOUT) :: dsabb
310 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
311 : TYPE(gto_basis_set_type), POINTER :: oba, obb, fbb
312 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: scon_oba
313 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: sconb_mix
314 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: obb_index, fbb_index
315 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: cg_coeff
316 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: cg_none0_list
317 : INTEGER, DIMENSION(:, :), INTENT(IN) :: ncg_none0
318 : LOGICAL, INTENT(IN) :: calculate_forces
319 :
320 : INTEGER :: la_max, lbb_max
321 16 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: Waux_mat
322 16 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :, :) :: dWaux_mat
323 :
324 32 : la_max = MAXVAL(oba%lmax)
325 272 : lbb_max = MAXVAL(obb%lmax) + MAXVAL(fbb%lmax)
326 :
327 16 : sabb = 0.0_dp
328 16 : IF (calculate_forces) dsabb = 0.0_dp
329 : CALL precalc_angular_shg_part(lbb_max, la_max, rab, Waux_mat, dWaux_mat, &
330 16 : calculate_forces)
331 : CALL int_overlap_abb_shg_low(sabb, dsabb, rab, oba, obb, fbb, &
332 : scon_oba, sconb_mix, obb_index, fbb_index, &
333 : cg_coeff, cg_none0_list, ncg_none0, &
334 16 : Waux_mat, dWaux_mat, .TRUE., calculate_forces)
335 :
336 16 : DEALLOCATE (Waux_mat, dWaux_mat)
337 :
338 16 : END SUBROUTINE int_overlap_abb_shg
339 :
340 : ! **************************************************************************************************
341 : !> \brief precalculates the angular part of the SHG integrals
342 : !> \param la_max ...
343 : !> \param lb_max ...
344 : !> \param rab distance vector between a and b
345 : !> \param Waux_mat W matrix that contains the angular-dependent part
346 : !> \param dWaux_mat derivative of the W matrix
347 : !> \param calculate_forces ...
348 : ! **************************************************************************************************
349 7854860 : SUBROUTINE precalc_angular_shg_part(la_max, lb_max, rab, Waux_mat, dWaux_mat, calculate_forces)
350 :
351 : INTEGER, INTENT(IN) :: la_max, lb_max
352 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
353 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
354 : INTENT(OUT) :: Waux_mat
355 : REAL(KIND=dp), ALLOCATABLE, &
356 : DIMENSION(:, :, :, :), INTENT(OUT) :: dWaux_mat
357 : LOGICAL, INTENT(IN) :: calculate_forces
358 :
359 : INTEGER :: lmax, mdim(3)
360 : INTEGER, DIMENSION(:), POINTER :: la_max_all
361 : REAL(KIND=dp) :: rab2
362 7854860 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: Rc, Rs
363 :
364 7854860 : NULLIFY (la_max_all)
365 7854860 : rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
366 7854860 : lmax = MAX(la_max, lb_max)
367 :
368 23564580 : ALLOCATE (la_max_all(0:lb_max))
369 47129160 : ALLOCATE (Rc(0:lmax, -2*lmax:2*lmax), Rs(0:lmax, -2*lmax:2*lmax))
370 7854860 : Rc = 0._dp
371 7854860 : Rs = 0._dp
372 7854860 : mdim(1) = MIN(la_max, lb_max) + 1
373 7854860 : mdim(2) = nsoset(la_max) + 1
374 7854860 : mdim(3) = nsoset(lb_max) + 1
375 39274300 : ALLOCATE (Waux_mat(mdim(1), mdim(2), mdim(3)))
376 39274300 : ALLOCATE (dWaux_mat(3, mdim(1), mdim(2), mdim(3)))
377 :
378 19055685 : la_max_all(0:lb_max) = la_max
379 : !*** -rab, since Eq. in Ref. use Ra-Rb, not Rb-Ra
380 31419440 : CALL get_real_scaled_solid_harmonic(Rc, Rs, lmax, -rab, rab2)
381 7854860 : CALL get_W_matrix(la_max_all, lb_max, lmax, Rc, Rs, Waux_mat)
382 7854860 : IF (calculate_forces) THEN
383 256 : CALL get_dW_matrix(la_max_all, lb_max, Waux_mat, dWaux_mat)
384 : END IF
385 :
386 7854860 : DEALLOCATE (Rc, Rs, la_max_all)
387 :
388 7854860 : END SUBROUTINE precalc_angular_shg_part
389 :
390 : ! **************************************************************************************************
391 : !> \brief calculate integrals (a|O(r12)|b)
392 : !> \param s_operator_ab procedure for the respective operator. The integral evaluation
393 : !> differs only in the calculation of the [s|O(r12)|s] integrals and their scalar
394 : !> derivatives.
395 : !> \param vab integral matrix of spherical contracted Gaussian functions
396 : !> \param dvab derivative of the integrals
397 : !> \param rab distance vector between center A and B
398 : !> \param fba basis at center A
399 : !> \param fbb basis at center B
400 : !> \param scona_shg SHG contraction matrix for A
401 : !> \param sconb_shg SHG contraction matrix for B
402 : !> \param omega parameter in the operator
403 : !> \param Waux_mat W matrix that contains the angular-dependent part
404 : !> \param dWaux_mat derivative of the W matrix
405 : !> \param calculate_forces ...
406 : ! **************************************************************************************************
407 7854618 : SUBROUTINE int_operator_ab_shg_low(s_operator_ab, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, &
408 7854618 : omega, Waux_mat, dWaux_mat, calculate_forces)
409 :
410 : PROCEDURE(ab_sint_shg) :: s_operator_ab
411 : REAL(KIND=dp), DIMENSION(:, :), INTENT(INOUT) :: vab
412 : REAL(KIND=dp), DIMENSION(:, :, :), OPTIONAL, INTENT(INOUT) :: dvab
413 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
414 : TYPE(gto_basis_set_type), POINTER :: fba, fbb
415 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(INOUT) :: scona_shg, sconb_shg
416 : REAL(KIND=dp), INTENT(IN) :: omega
417 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: Waux_mat
418 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: dWaux_mat
419 : LOGICAL, INTENT(IN) :: calculate_forces
420 :
421 : INTEGER :: iset, jset, la_max_set, lb_max_set, ndev, nds, nds_max, npgfa_set, &
422 : npgfb_set, nseta, nsetb, nsgfa_set, nsgfb_set, nshella_set, nshellb_set
423 7854618 : INTEGER, DIMENSION(:), POINTER :: la_max, lb_max, npgfa, npgfb, nsgfa, &
424 7854618 : nsgfb, nshella, nshellb
425 7854618 : INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfb, la, lb
426 : REAL(KIND=dp) :: dab
427 7854618 : REAL(KIND=dp), DIMENSION(:), POINTER :: set_radius_a, set_radius_b
428 7854618 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: zeta, zetb
429 : REAL(KIND=dp), DIMENSION(:, :, :), ALLOCATABLE :: swork, swork_cont
430 :
431 7854618 : NULLIFY (la_max, lb_max, npgfa, npgfb, first_sgfa, first_sgfb, set_radius_a, &
432 7854618 : set_radius_b, zeta, zetb)
433 :
434 : ! basis ikind
435 7854618 : first_sgfa => fba%first_sgf
436 7854618 : la_max => fba%lmax
437 7854618 : la => fba%l
438 7854618 : npgfa => fba%npgf
439 7854618 : nsgfa => fba%nsgf_set
440 7854618 : nseta = fba%nset
441 7854618 : set_radius_a => fba%set_radius
442 7854618 : zeta => fba%zet
443 7854618 : nshella => fba%nshell
444 : ! basis jkind
445 7854618 : first_sgfb => fbb%first_sgf
446 7854618 : lb_max => fbb%lmax
447 7854618 : lb => fbb%l
448 7854618 : npgfb => fbb%npgf
449 7854618 : nsgfb => fbb%nsgf_set
450 7854618 : nsetb = fbb%nset
451 7854618 : set_radius_b => fbb%set_radius
452 7854618 : zetb => fbb%zet
453 7854618 : nshellb => fbb%nshell
454 :
455 31418472 : dab = SQRT(SUM(rab**2))
456 :
457 19846510 : la_max_set = MAXVAL(la_max)
458 19847310 : lb_max_set = MAXVAL(lb_max)
459 :
460 : ! allocate some work matrices
461 19846510 : npgfa_set = MAXVAL(npgfa)
462 19847310 : npgfb_set = MAXVAL(npgfb)
463 19846510 : nshella_set = MAXVAL(nshella)
464 19847310 : nshellb_set = MAXVAL(nshellb)
465 19846510 : nsgfa_set = MAXVAL(nsgfa)
466 19847310 : nsgfb_set = MAXVAL(nsgfb)
467 7854618 : ndev = 0
468 7854618 : IF (calculate_forces) ndev = 1
469 7854618 : nds_max = la_max_set + lb_max_set + ndev + 1
470 39273090 : ALLOCATE (swork(npgfa_set, npgfb_set, nds_max))
471 39273090 : ALLOCATE (swork_cont(nds_max, nshella_set, nshellb_set))
472 :
473 199318484 : vab = 0.0_dp
474 22312858 : IF (calculate_forces) dvab = 0.0_dp
475 :
476 19846510 : DO iset = 1, nseta
477 :
478 49761828 : DO jset = 1, nsetb
479 :
480 29915318 : nds = la_max(iset) + lb_max(jset) + ndev + 1
481 233242292 : swork(1:npgfa(iset), 1:npgfb(jset), 1:nds) = 0.0_dp
482 : CALL s_operator_ab(la_max(iset), npgfa(iset), zeta(:, iset), &
483 : lb_max(jset), npgfb(jset), zetb(:, jset), &
484 29915318 : omega, rab, swork, calculate_forces)
485 : CALL contract_sint_ab_chigh(npgfa(iset), nshella(iset), &
486 : scona_shg(1:npgfa(iset), 1:nshella(iset), iset), &
487 : npgfb(jset), nshellb(jset), &
488 : sconb_shg(1:npgfb(jset), 1:nshellb(jset), jset), &
489 : nds, swork(1:npgfa(iset), 1:npgfb(jset), 1:nds), &
490 29915318 : swork_cont(1:nds, 1:nshella(iset), 1:nshellb(jset)))
491 : CALL construct_int_shg_ab(la(:, iset), first_sgfa(:, iset), nshella(iset), &
492 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
493 29915318 : swork_cont, Waux_mat, vab)
494 41907210 : IF (calculate_forces) THEN
495 : !*** -rab, since Eq. in Ref. use Ra-Rb, not Rb-Ra
496 : CALL construct_dev_shg_ab(la(:, iset), first_sgfa(:, iset), nshella(iset), &
497 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
498 96000 : -rab, swork_cont, Waux_mat, dWaux_mat, dvab)
499 : END IF
500 : END DO
501 : END DO
502 :
503 7854618 : DEALLOCATE (swork, swork_cont)
504 :
505 7854618 : END SUBROUTINE int_operator_ab_shg_low
506 :
507 : ! **************************************************************************************************
508 : !> \brief calculate overlap integrals (a,b); requires angular-dependent part as input
509 : !> \param sab integral (a,b)
510 : !> \param dsab derivative of sab
511 : !> \param rab distance vector
512 : !> \param fba basis at center A
513 : !> \param fbb basis at center B
514 : !> \param scona_shg contraction matrix A
515 : !> \param sconb_shg contraxtion matrix B
516 : !> \param Waux_mat W matrix that contains the angular-dependent part
517 : !> \param dWaux_mat derivative of the W matrix
518 : !> \param calculate_ints ...
519 : !> \param calculate_forces ...
520 : !> \param contraction_high ...
521 : ! **************************************************************************************************
522 30546 : SUBROUTINE int_overlap_ab_shg_low(sab, dsab, rab, fba, fbb, scona_shg, sconb_shg, Waux_mat, dWaux_mat, &
523 : calculate_ints, calculate_forces, contraction_high)
524 :
525 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :), &
526 : INTENT(INOUT) :: sab
527 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
528 : INTENT(INOUT) :: dsab
529 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
530 : TYPE(gto_basis_set_type), POINTER :: fba, fbb
531 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: scona_shg, sconb_shg, Waux_mat
532 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: dWaux_mat
533 : LOGICAL, INTENT(IN) :: calculate_ints, calculate_forces
534 : LOGICAL, INTENT(IN), OPTIONAL :: contraction_high
535 :
536 : INTEGER :: iset, jset, la_max_set, lb_max_set, &
537 : ndev, nds, nds_max, npgfa_set, &
538 : npgfb_set, nseta, nsetb, nshella_set, &
539 : nshellb_set
540 30546 : INTEGER, DIMENSION(:), POINTER :: la_max, lb_max, npgfa, npgfb, nshella, &
541 30546 : nshellb
542 30546 : INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfb, la, lb
543 : LOGICAL :: my_contraction_high
544 : REAL(KIND=dp) :: dab
545 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: swork, swork_cont
546 30546 : REAL(KIND=dp), DIMENSION(:), POINTER :: set_radius_a, set_radius_b
547 30546 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: zeta, zetb
548 :
549 30546 : NULLIFY (la_max, lb_max, npgfa, npgfb, first_sgfa, first_sgfb, set_radius_a, &
550 30546 : set_radius_b, zeta, zetb)
551 :
552 : ! basis ikind
553 30546 : first_sgfa => fba%first_sgf
554 30546 : la_max => fba%lmax
555 30546 : la => fba%l
556 30546 : npgfa => fba%npgf
557 30546 : nseta = fba%nset
558 30546 : set_radius_a => fba%set_radius
559 30546 : zeta => fba%zet
560 30546 : nshella => fba%nshell
561 : ! basis jkind
562 30546 : first_sgfb => fbb%first_sgf
563 30546 : lb_max => fbb%lmax
564 30546 : lb => fbb%l
565 30546 : npgfb => fbb%npgf
566 30546 : nsetb = fbb%nset
567 30546 : set_radius_b => fbb%set_radius
568 30546 : zetb => fbb%zet
569 30546 : nshellb => fbb%nshell
570 :
571 122184 : dab = SQRT(SUM(rab**2))
572 :
573 82065 : la_max_set = MAXVAL(la_max)
574 82225 : lb_max_set = MAXVAL(lb_max)
575 :
576 : ! allocate some work matrices
577 82065 : npgfa_set = MAXVAL(npgfa)
578 82225 : npgfb_set = MAXVAL(npgfb)
579 82065 : nshella_set = MAXVAL(nshella)
580 82225 : nshellb_set = MAXVAL(nshellb)
581 30546 : ndev = 0
582 30546 : IF (calculate_forces) ndev = 1
583 30546 : nds_max = la_max_set + lb_max_set + ndev + 1
584 152730 : ALLOCATE (swork(npgfa_set, npgfb_set, nds_max))
585 152730 : ALLOCATE (swork_cont(nds_max, nshella_set, nshellb_set))
586 :
587 30546 : IF (calculate_ints) sab = 0.0_dp
588 30546 : IF (calculate_forces) dsab = 0.0_dp
589 :
590 30546 : my_contraction_high = .TRUE.
591 30546 : IF (PRESENT(contraction_high)) my_contraction_high = contraction_high
592 :
593 82065 : DO iset = 1, nseta
594 :
595 327168 : DO jset = 1, nsetb
596 :
597 245103 : IF (set_radius_a(iset) + set_radius_b(jset) < dab) CYCLE
598 :
599 203782 : nds = la_max(iset) + lb_max(jset) + ndev + 1
600 7862356 : swork(1:npgfa(iset), 1:npgfb(jset), 1:nds) = 0.0_dp
601 : CALL s_overlap_ab(la_max(iset), npgfa(iset), zeta(:, iset), &
602 : lb_max(jset), npgfb(jset), zetb(:, jset), &
603 203782 : rab, swork, calculate_forces)
604 203782 : IF (my_contraction_high) THEN
605 : CALL contract_sint_ab_chigh(npgfa(iset), nshella(iset), &
606 : scona_shg(1:npgfa(iset), 1:nshella(iset), iset), &
607 : npgfb(jset), nshellb(jset), &
608 : sconb_shg(1:npgfb(jset), 1:nshellb(jset), jset), &
609 : nds, swork(1:npgfa(iset), 1:npgfb(jset), 1:nds), &
610 32539 : swork_cont(1:nds, 1:nshella(iset), 1:nshellb(jset)))
611 : ELSE
612 : CALL contract_sint_ab_clow(la(:, iset), npgfa(iset), nshella(iset), &
613 : scona_shg(:, :, iset), &
614 : lb(:, jset), npgfb(jset), nshellb(jset), &
615 : sconb_shg(:, :, jset), &
616 171243 : swork, swork_cont, calculate_forces)
617 : END IF
618 203782 : IF (calculate_ints) THEN
619 : CALL construct_int_shg_ab(la(:, iset), first_sgfa(:, iset), nshella(iset), &
620 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
621 123600 : swork_cont, Waux_mat, sab)
622 : END IF
623 255301 : IF (calculate_forces) THEN
624 : !*** -rab, since Eq. in Ref. use Ra-Rb, not Rb-Ra
625 : CALL construct_dev_shg_ab(la(:, iset), first_sgfa(:, iset), nshella(iset), &
626 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
627 339928 : -rab, swork_cont, Waux_mat, dWaux_mat, dsab)
628 : END IF
629 : END DO
630 : END DO
631 :
632 30546 : DEALLOCATE (swork, swork_cont)
633 :
634 30546 : END SUBROUTINE int_overlap_ab_shg_low
635 :
636 : ! **************************************************************************************************
637 : !> \brief calculate integrals (a|ra^2m)|b); requires angular-dependent part as input
638 : !> \param vab integral matrix of spherical contracted Gaussian functions
639 : !> \param dvab derivative of the integrals
640 : !> \param rab distance vector between center A and B
641 : !> \param fba basis at center A
642 : !> \param fbb basis at center B
643 : !> \param sconb_shg SHG contraction matrix for B
644 : !> \param scon_ra2m contraction matrix for A including the combinatorial factors
645 : !> \param m exponent in (r-Ra)^(2m) operator
646 : !> \param Waux_mat W matrix that contains the angular-dependent part
647 : !> \param dWaux_mat derivative of the W matrix
648 : !> \param calculate_forces ...
649 : ! **************************************************************************************************
650 32 : SUBROUTINE int_ra2m_ab_shg_low(vab, dvab, rab, fba, fbb, sconb_shg, scon_ra2m, m, Waux_mat, dWaux_mat, &
651 : calculate_forces)
652 :
653 : REAL(KIND=dp), DIMENSION(:, :), INTENT(INOUT) :: vab
654 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(INOUT) :: dvab
655 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
656 : TYPE(gto_basis_set_type), POINTER :: fba, fbb
657 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: sconb_shg
658 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: scon_ra2m
659 : INTEGER, INTENT(IN) :: m
660 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: Waux_mat
661 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: dWaux_mat
662 : LOGICAL, INTENT(IN) :: calculate_forces
663 :
664 : INTEGER :: iset, jset, la_max_set, lb_max_set, &
665 : ndev, nds, nds_max, npgfa_set, &
666 : npgfb_set, nseta, nsetb, nshella_set, &
667 : nshellb_set
668 32 : INTEGER, DIMENSION(:), POINTER :: la_max, lb_max, npgfa, npgfb, nsgfa, &
669 32 : nsgfb, nshella, nshellb
670 32 : INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfb, la, lb
671 : REAL(KIND=dp) :: dab
672 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: swork_cont
673 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :, :) :: swork
674 32 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: zeta, zetb
675 :
676 32 : NULLIFY (la_max, lb_max, npgfa, npgfb, first_sgfa, first_sgfb, zeta, zetb)
677 :
678 : ! basis ikind
679 32 : first_sgfa => fba%first_sgf
680 32 : la_max => fba%lmax
681 32 : la => fba%l
682 32 : npgfa => fba%npgf
683 32 : nsgfa => fba%nsgf_set
684 32 : nseta = fba%nset
685 32 : zeta => fba%zet
686 32 : nshella => fba%nshell
687 : ! basis jkind
688 32 : first_sgfb => fbb%first_sgf
689 32 : lb_max => fbb%lmax
690 32 : lb => fbb%l
691 32 : npgfb => fbb%npgf
692 32 : nsgfb => fbb%nsgf_set
693 32 : nsetb = fbb%nset
694 32 : zetb => fbb%zet
695 32 : nshellb => fbb%nshell
696 :
697 128 : dab = SQRT(SUM(rab**2))
698 :
699 352 : la_max_set = MAXVAL(la_max)
700 512 : lb_max_set = MAXVAL(lb_max)
701 :
702 : ! allocate some work matrices
703 352 : npgfa_set = MAXVAL(npgfa)
704 512 : npgfb_set = MAXVAL(npgfb)
705 352 : nshella_set = MAXVAL(nshella)
706 512 : nshellb_set = MAXVAL(nshellb)
707 32 : ndev = 0
708 32 : IF (calculate_forces) ndev = 1
709 32 : nds_max = la_max_set + lb_max_set + ndev + 1
710 192 : ALLOCATE (swork(npgfa_set, npgfb_set, 1:m + 1, nds_max))
711 160 : ALLOCATE (swork_cont(nds_max, nshella_set, nshellb_set))
712 :
713 963872 : vab = 0.0_dp
714 2891680 : IF (calculate_forces) dvab = 0.0_dp
715 :
716 352 : DO iset = 1, nseta
717 :
718 5152 : DO jset = 1, nsetb
719 :
720 4800 : nds = la_max(iset) + lb_max(jset) + ndev + 1
721 447840 : swork(1:npgfa(iset), 1:npgfb(jset), 1:m + 1, 1:nds) = 0.0_dp
722 : CALL s_ra2m_ab(la_max(iset), npgfa(iset), zeta(:, iset), &
723 : lb_max(jset), npgfb(jset), zetb(:, jset), &
724 4800 : m, rab, swork, calculate_forces)
725 : CALL contract_s_ra2m_ab(npgfa(iset), nshella(iset), &
726 : scon_ra2m(1:npgfa(iset), 1:m + 1, 1:nshella(iset), iset), &
727 : npgfb(jset), nshellb(jset), &
728 : sconb_shg(1:npgfb(jset), 1:nshellb(jset), jset), &
729 : swork(1:npgfa(iset), 1:npgfb(jset), 1:m + 1, 1:nds), &
730 : swork_cont(1:nds, 1:nshella(iset), 1:nshellb(jset)), &
731 4800 : m, nds)
732 : CALL construct_int_shg_ab(la(:, iset), first_sgfa(:, iset), nshella(iset), &
733 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
734 4800 : swork_cont, Waux_mat, vab)
735 5120 : IF (calculate_forces) THEN
736 : !*** -rab, since Eq. in Ref. use Ra-Rb, not Rb-Ra
737 : CALL construct_dev_shg_ab(la(:, iset), first_sgfa(:, iset), nshella(iset), &
738 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
739 19200 : -rab, swork_cont, Waux_mat, dWaux_mat, dvab)
740 : END IF
741 : END DO
742 : END DO
743 :
744 32 : DEALLOCATE (swork, swork_cont)
745 :
746 32 : END SUBROUTINE int_ra2m_ab_shg_low
747 : ! **************************************************************************************************
748 : !> \brief calculate integrals (a,b,fb); requires angular-dependent part as input
749 : !> \param abbint integral (a,b,fb)
750 : !> \param dabbint derivative of abbint
751 : !> \param rab distance vector between A and B
752 : !> \param oba orbital basis at center A
753 : !> \param obb orbital basis at center B
754 : !> \param fbb auxiliary basis set at center B
755 : !> \param scon_oba contraction matrix for orb bas on A
756 : !> \param sconb_mix mixed contraction matrix orb + ri basis on B
757 : !> \param obb_index orbital basis index for sconb_mix
758 : !> \param fbb_index ri basis index for sconb_mix
759 : !> \param cg_coeff Clebsch-Gordon coefficients
760 : !> \param cg_none0_list list of none-zero Clebsch-Gordon coefficients
761 : !> \param ncg_none0 number of non-zero Clebsch-Gordon coefficients
762 : !> \param Waux_mat W matrix that contains the angular-dependent part
763 : !> \param dWaux_mat derivative of the W matrix
764 : !> \param calculate_ints ...
765 : !> \param calculate_forces ...
766 : ! **************************************************************************************************
767 752 : SUBROUTINE int_overlap_abb_shg_low(abbint, dabbint, rab, oba, obb, fbb, scon_oba, sconb_mix, &
768 752 : obb_index, fbb_index, cg_coeff, cg_none0_list, &
769 752 : ncg_none0, Waux_mat, dWaux_mat, calculate_ints, calculate_forces)
770 :
771 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
772 : INTENT(INOUT) :: abbint
773 : REAL(KIND=dp), ALLOCATABLE, &
774 : DIMENSION(:, :, :, :), INTENT(INOUT) :: dabbint
775 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
776 : TYPE(gto_basis_set_type), POINTER :: oba, obb, fbb
777 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: scon_oba
778 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: sconb_mix
779 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: obb_index, fbb_index
780 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: cg_coeff
781 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: cg_none0_list
782 : INTEGER, DIMENSION(:, :), INTENT(IN) :: ncg_none0
783 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: Waux_mat
784 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: dWaux_mat
785 : LOGICAL, INTENT(IN) :: calculate_ints, calculate_forces
786 :
787 : INTEGER :: iset, jset, kset, la_max_set, lb_max_set, lbb_max, lbb_max_set, lcb_max_set, na, &
788 : nb, ncb, ndev, nds, nds_max, nl, nl_set, npgfa_set, npgfb_set, npgfcb_set, nseta, nsetb, &
789 : nsetcb, nshella_set, nshellb_set, nshellcb_set, sgfa, sgfb, sgfcb
790 752 : INTEGER, DIMENSION(:), POINTER :: la_max, lb_max, lcb_max, npgfa, npgfb, &
791 752 : npgfcb, nsgfa, nsgfb, nsgfcb, nshella, &
792 752 : nshellb, nshellcb
793 752 : INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfb, first_sgfcb, la, &
794 752 : lb, lcb
795 : REAL(KIND=dp) :: dab, rab2
796 : REAL(KIND=dp), ALLOCATABLE, &
797 : DIMENSION(:, :, :, :, :) :: swork, swork_cont
798 752 : REAL(KIND=dp), DIMENSION(:), POINTER :: set_radius_a, set_radius_b, set_radius_cb
799 752 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: zeta, zetb, zetcb
800 :
801 752 : NULLIFY (la_max, lb_max, lcb_max, npgfa, npgfb, npgfcb)
802 752 : NULLIFY (first_sgfa, first_sgfb, first_sgfcb, set_radius_a, set_radius_b, &
803 752 : set_radius_cb, zeta, zetb, zetcb)
804 :
805 : ! basis ikind
806 752 : first_sgfa => oba%first_sgf
807 752 : la_max => oba%lmax
808 752 : la => oba%l
809 752 : nsgfa => oba%nsgf_set
810 752 : npgfa => oba%npgf
811 752 : nshella => oba%nshell
812 752 : nseta = oba%nset
813 752 : set_radius_a => oba%set_radius
814 752 : zeta => oba%zet
815 : ! basis jkind
816 752 : first_sgfb => obb%first_sgf
817 752 : lb_max => obb%lmax
818 752 : lb => obb%l
819 752 : nsgfb => obb%nsgf_set
820 752 : npgfb => obb%npgf
821 752 : nshellb => obb%nshell
822 752 : nsetb = obb%nset
823 752 : set_radius_b => obb%set_radius
824 752 : zetb => obb%zet
825 :
826 : ! basis RI on B
827 752 : first_sgfcb => fbb%first_sgf
828 752 : lcb_max => fbb%lmax
829 752 : lcb => fbb%l
830 752 : nsgfcb => fbb%nsgf_set
831 752 : npgfcb => fbb%npgf
832 752 : nshellcb => fbb%nshell
833 752 : nsetcb = fbb%nset
834 752 : set_radius_cb => fbb%set_radius
835 752 : zetcb => fbb%zet
836 :
837 3008 : dab = SQRT(SUM(rab**2))
838 752 : rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
839 :
840 1732 : la_max_set = MAXVAL(la_max)
841 1732 : lb_max_set = MAXVAL(lb_max)
842 7394 : lcb_max_set = MAXVAL(lcb_max)
843 1732 : npgfa_set = MAXVAL(npgfa)
844 1732 : npgfb_set = MAXVAL(npgfb)
845 7394 : npgfcb_set = MAXVAL(npgfcb)
846 1732 : nshella_set = MAXVAL(nshella)
847 1732 : nshellb_set = MAXVAL(nshellb)
848 7394 : nshellcb_set = MAXVAL(nshellcb)
849 : !*** for forces: derivative+1 in auxiliary vector required
850 752 : ndev = 0
851 752 : IF (calculate_forces) ndev = 1
852 :
853 752 : lbb_max_set = lb_max_set + lcb_max_set
854 :
855 : ! allocate some work storage....
856 752 : nds_max = la_max_set + lbb_max_set + ndev + 1
857 752 : nl_set = INT((lbb_max_set)/2)
858 5264 : ALLOCATE (swork(npgfa_set, npgfb_set, npgfcb_set, nl_set + 1, nds_max))
859 5264 : ALLOCATE (swork_cont(nds_max, 0:nl_set, nshella_set, nshellb_set, nshellcb_set))
860 :
861 1732 : DO iset = 1, nseta
862 :
863 3168 : DO jset = 1, nsetb
864 :
865 1436 : IF (set_radius_a(iset) + set_radius_b(jset) < dab) CYCLE
866 :
867 8824 : DO kset = 1, nsetcb
868 :
869 6960 : IF (set_radius_a(iset) + set_radius_cb(kset) < dab) CYCLE
870 :
871 4148 : lbb_max = lb_max(jset) + lcb_max(kset)
872 4148 : nds = la_max(iset) + lbb_max + ndev + 1
873 4148 : nl = INT((lbb_max)/2) + 1
874 4860860 : swork(1:npgfa(iset), 1:npgfb(jset), 1:npgfcb(kset), 1:nl, 1:nds) = 0.0_dp
875 : CALL s_overlap_abb(la_max(iset), npgfa(iset), zeta(:, iset), &
876 : lb_max(jset), npgfb(jset), zetb(:, jset), &
877 : lcb_max(kset), npgfcb(kset), zetcb(:, kset), &
878 4148 : rab, swork, calculate_forces)
879 :
880 : CALL contract_s_overlap_abb(la(:, iset), npgfa(iset), nshella(iset), &
881 : scon_oba(1:npgfa(iset), 1:nshella(iset), iset), &
882 : lb(:, jset), npgfb(jset), nshellb(jset), &
883 : lcb(:, kset), npgfcb(kset), nshellcb(kset), &
884 : obb_index(:, :, jset), fbb_index(:, :, kset), sconb_mix, nl, nds, &
885 : swork(1:npgfa(iset), 1:npgfb(jset), 1:npgfcb(kset), 1:nl, 1:nds), &
886 4148 : swork_cont, calculate_forces)
887 :
888 4148 : IF (calculate_ints) THEN
889 : CALL construct_overlap_shg_abb(la(:, iset), first_sgfa(:, iset), nshella(iset), &
890 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
891 : lcb(:, kset), first_sgfcb(:, kset), nshellcb(kset), &
892 : cg_coeff, cg_none0_list, &
893 3349 : ncg_none0, swork_cont, Waux_mat, abbint)
894 : END IF
895 4148 : IF (calculate_forces) THEN
896 : !*** -rab, since Eq. in Ref. use Ra-Rb, not Rb-Ra
897 : CALL dev_overlap_shg_abb(la(:, iset), first_sgfa(:, iset), nshella(iset), &
898 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
899 : lcb(:, kset), first_sgfcb(:, kset), nshellcb(kset), &
900 : cg_coeff, cg_none0_list, ncg_none0, -rab, swork_cont, &
901 4156 : Waux_mat, dWaux_mat, dabbint)
902 : END IF
903 : ! max value of integrals in this set triple
904 4148 : sgfa = first_sgfa(1, iset)
905 4148 : na = sgfa + nsgfa(iset) - 1
906 4148 : sgfb = first_sgfb(1, jset)
907 4148 : nb = sgfb + nsgfb(jset) - 1
908 4148 : sgfcb = first_sgfcb(1, kset)
909 8396 : ncb = sgfcb + nsgfcb(kset) - 1
910 : END DO
911 : END DO
912 : END DO
913 :
914 752 : DEALLOCATE (swork_cont)
915 752 : DEALLOCATE (swork)
916 :
917 752 : END SUBROUTINE int_overlap_abb_shg_low
918 : ! **************************************************************************************************
919 : !> \brief obtain integrals (a,b,fb) by symmetry relations from (a,b,fa) if basis sets at a and
920 : !> b are of the same kind, i.e. a and b are same atom type
921 : !> \param abbint integral (a,b,fb)
922 : !> \param dabbint derivative of abbint
923 : !> \param abaint integral (a,b,fa)
924 : !> \param dabdaint derivative of abaint
925 : !> \param rab distance vector between A and B
926 : !> \param oba orbital basis at center A
927 : !> \param fba auxiliary basis set at center A
928 : !> \param calculate_ints ...
929 : !> \param calculate_forces ...
930 : ! **************************************************************************************************
931 26717 : SUBROUTINE get_abb_same_kind(abbint, dabbint, abaint, dabdaint, rab, oba, fba, &
932 : calculate_ints, calculate_forces)
933 :
934 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
935 : INTENT(INOUT) :: abbint
936 : REAL(KIND=dp), ALLOCATABLE, &
937 : DIMENSION(:, :, :, :), INTENT(INOUT) :: dabbint
938 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
939 : INTENT(INOUT) :: abaint
940 : REAL(KIND=dp), ALLOCATABLE, &
941 : DIMENSION(:, :, :, :), INTENT(INOUT) :: dabdaint
942 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
943 : TYPE(gto_basis_set_type), POINTER :: oba, fba
944 : LOGICAL, INTENT(IN) :: calculate_ints, calculate_forces
945 :
946 : INTEGER :: i, iend, iset, isgfa, ishella, istart, jend, jset, jsgfa, jshella, jstart, kend, &
947 : kset, ksgfa, kshella, kstart, lai, laj, lak, nseta, nsetca, nsgfa, nsgfca, sgfa_end, &
948 : sgfa_start
949 26717 : INTEGER, ALLOCATABLE, DIMENSION(:) :: lai_set, laj_set, lak_set
950 26717 : INTEGER, DIMENSION(:), POINTER :: nsgfa_set, nsgfca_set, nshella, nshellca
951 26717 : INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfca, la, lca
952 : REAL(KIND=dp) :: dab
953 26717 : REAL(KIND=dp), DIMENSION(:), POINTER :: set_radius_a, set_radius_ca
954 :
955 26717 : NULLIFY (nshellca, first_sgfa, first_sgfca, lca, set_radius_a, &
956 26717 : set_radius_ca)
957 :
958 : ! basis ikind
959 26717 : first_sgfa => oba%first_sgf
960 26717 : set_radius_a => oba%set_radius
961 26717 : nseta = oba%nset
962 26717 : nsgfa = oba%nsgf
963 26717 : nsgfa_set => oba%nsgf_set
964 26717 : nshella => oba%nshell
965 26717 : la => oba%l
966 :
967 : ! basis RI
968 26717 : first_sgfca => fba%first_sgf
969 26717 : set_radius_ca => fba%set_radius
970 26717 : nsetca = fba%nset
971 26717 : nshellca => fba%nshell
972 26717 : nsgfca = fba%nsgf
973 26717 : nsgfca_set => fba%nsgf_set
974 26717 : lca => fba%l
975 :
976 80151 : ALLOCATE (lai_set(nsgfa))
977 53434 : ALLOCATE (laj_set(nsgfa))
978 80151 : ALLOCATE (lak_set(nsgfca))
979 :
980 106868 : dab = SQRT(SUM(rab**2))
981 53950 : DO iset = 1, nseta
982 :
983 158716 : DO ishella = 1, nshella(iset)
984 131483 : sgfa_start = first_sgfa(ishella, iset)
985 131483 : sgfa_end = sgfa_start + 2*la(ishella, iset)
986 500723 : lai_set(sgfa_start:sgfa_end) = la(ishella, iset)
987 : END DO
988 27233 : istart = first_sgfa(1, iset)
989 27233 : iend = istart + nsgfa_set(iset) - 1
990 :
991 82215 : DO jset = 1, nseta
992 :
993 28265 : IF (set_radius_a(iset) + set_radius_a(jset) < dab) CYCLE
994 157592 : DO jshella = 1, nshella(jset)
995 130721 : sgfa_start = first_sgfa(jshella, jset)
996 130721 : sgfa_end = sgfa_start + 2*la(jshella, jset)
997 494173 : laj_set(sgfa_start:sgfa_end) = la(jshella, jset)
998 : END DO
999 26871 : jstart = first_sgfa(1, jset)
1000 26871 : jend = jstart + nsgfa_set(jset) - 1
1001 :
1002 292452 : DO kset = 1, nsetca
1003 :
1004 238348 : IF (set_radius_a(iset) + set_radius_ca(kset) < dab) CYCLE
1005 :
1006 403256 : DO kshella = 1, nshellca(kset)
1007 288284 : sgfa_start = first_sgfca(kshella, kset)
1008 288284 : sgfa_end = sgfa_start + 2*lca(kshella, kset)
1009 1395162 : lak_set(sgfa_start:sgfa_end) = lca(kshella, kset)
1010 : END DO
1011 114972 : kstart = first_sgfca(1, kset)
1012 114972 : kend = kstart + nsgfca_set(kset) - 1
1013 1135143 : DO ksgfa = kstart, kend
1014 991906 : lak = lak_set(ksgfa)
1015 13739136 : DO jsgfa = jstart, jend
1016 12508882 : laj = laj_set(jsgfa)
1017 174134118 : DO isgfa = istart, iend
1018 160633330 : lai = lai_set(isgfa)
1019 173142212 : IF (MODULO((lai + laj + lak), 2) /= 0) THEN
1020 80295721 : IF (calculate_ints) THEN
1021 : abbint(isgfa, jsgfa, ksgfa) = &
1022 43125635 : -abaint(jsgfa, isgfa, ksgfa)
1023 : END IF
1024 80295721 : IF (calculate_forces) THEN
1025 148680344 : DO i = 1, 3
1026 : dabbint(isgfa, jsgfa, ksgfa, i) = &
1027 148680344 : -dabdaint(jsgfa, isgfa, ksgfa, i)
1028 : END DO
1029 : END IF
1030 : ELSE
1031 80337609 : IF (calculate_ints) THEN
1032 : abbint(isgfa, jsgfa, ksgfa) = &
1033 43144617 : abaint(jsgfa, isgfa, ksgfa)
1034 : END IF
1035 80337609 : IF (calculate_forces) THEN
1036 148771968 : DO i = 1, 3
1037 : dabbint(isgfa, jsgfa, ksgfa, i) = &
1038 148771968 : dabdaint(jsgfa, isgfa, ksgfa, i)
1039 : END DO
1040 : END IF
1041 : END IF
1042 : END DO
1043 : END DO
1044 : END DO
1045 : END DO
1046 : END DO
1047 : END DO
1048 :
1049 26717 : DEALLOCATE (lai_set, laj_set, lak_set)
1050 :
1051 26717 : END SUBROUTINE get_abb_same_kind
1052 :
1053 : ! **************************************************************************************************
1054 : !> \brief calculate integrals (a,b,fa); requires angular-dependent part as input
1055 : !> \param abaint integral (a,b,fa)
1056 : !> \param dabdaint ...
1057 : !> \param rab distance vector between A and B
1058 : !> \param oba orbital basis at center A
1059 : !> \param obb orbital basis at center B
1060 : !> \param fba auxiliary basis set at center A
1061 : !> \param scon_obb contraction matrix for orb bas on B
1062 : !> \param scona_mix mixed contraction matrix orb + ri basis on A
1063 : !> \param oba_index orbital basis index for scona_mix
1064 : !> \param fba_index ri basis index for scona_mix
1065 : !> \param cg_coeff Clebsch-Gordon coefficients
1066 : !> \param cg_none0_list list of none-zero Clebsch-Gordon coefficients
1067 : !> \param ncg_none0 number of non-zero Clebsch-Gordon coefficients
1068 : !> \param Waux_mat W matrix that contains the angular-dependent part
1069 : !> \param dWaux_mat derivative of the W matrix
1070 : !> \param calculate_ints ...
1071 : !> \param calculate_forces ...
1072 : ! **************************************************************************************************
1073 27615 : SUBROUTINE int_overlap_aba_shg_low(abaint, dabdaint, rab, oba, obb, fba, scon_obb, scona_mix, &
1074 27615 : oba_index, fba_index, cg_coeff, cg_none0_list, &
1075 27615 : ncg_none0, Waux_mat, dWaux_mat, calculate_ints, calculate_forces)
1076 :
1077 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
1078 : INTENT(INOUT) :: abaint
1079 : REAL(KIND=dp), ALLOCATABLE, &
1080 : DIMENSION(:, :, :, :), INTENT(INOUT) :: dabdaint
1081 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
1082 : TYPE(gto_basis_set_type), POINTER :: oba, obb, fba
1083 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: scon_obb
1084 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: scona_mix
1085 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: oba_index, fba_index
1086 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: cg_coeff
1087 : INTEGER, DIMENSION(:, :, :), INTENT(IN) :: cg_none0_list
1088 : INTEGER, DIMENSION(:, :), INTENT(IN) :: ncg_none0
1089 : REAL(KIND=dp), DIMENSION(:, :, :), INTENT(IN) :: Waux_mat
1090 : REAL(KIND=dp), DIMENSION(:, :, :, :), INTENT(IN) :: dWaux_mat
1091 : LOGICAL, INTENT(IN) :: calculate_ints, calculate_forces
1092 :
1093 : INTEGER :: iset, jset, kset, la_max_set, laa_max, laa_max_set, lb_max_set, lca_max_set, na, &
1094 : nb, nca, ndev, nds, nds_max, nl, nl_set, npgfa_set, npgfb_set, npgfca_set, nseta, nsetb, &
1095 : nsetca, nshella_set, nshellb_set, nshellca_set, sgfa, sgfb, sgfca
1096 27615 : INTEGER, DIMENSION(:), POINTER :: la_max, lb_max, lca_max, npgfa, npgfb, &
1097 27615 : npgfca, nsgfa, nsgfb, nsgfca, nshella, &
1098 27615 : nshellb, nshellca
1099 27615 : INTEGER, DIMENSION(:, :), POINTER :: first_sgfa, first_sgfb, first_sgfca, la, &
1100 27615 : lb, lca
1101 : REAL(KIND=dp) :: dab, rab2
1102 : REAL(KIND=dp), ALLOCATABLE, &
1103 : DIMENSION(:, :, :, :, :) :: swork, swork_cont
1104 27615 : REAL(KIND=dp), DIMENSION(:), POINTER :: set_radius_a, set_radius_b, set_radius_ca
1105 27615 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: zeta, zetb, zetca
1106 :
1107 27615 : NULLIFY (la_max, lb_max, lca_max, npgfa, npgfb, npgfca)
1108 27615 : NULLIFY (first_sgfa, first_sgfb, first_sgfca, set_radius_a, set_radius_b, &
1109 27615 : set_radius_ca, zeta, zetb, zetca)
1110 :
1111 : ! basis ikind
1112 27615 : first_sgfa => oba%first_sgf
1113 27615 : la_max => oba%lmax
1114 27615 : la => oba%l
1115 27615 : nsgfa => oba%nsgf_set
1116 27615 : npgfa => oba%npgf
1117 27615 : nshella => oba%nshell
1118 27615 : nseta = oba%nset
1119 27615 : set_radius_a => oba%set_radius
1120 27615 : zeta => oba%zet
1121 : ! basis jkind
1122 27615 : first_sgfb => obb%first_sgf
1123 27615 : lb_max => obb%lmax
1124 27615 : lb => obb%l
1125 27615 : nsgfb => obb%nsgf_set
1126 27615 : npgfb => obb%npgf
1127 27615 : nshellb => obb%nshell
1128 27615 : nsetb = obb%nset
1129 27615 : set_radius_b => obb%set_radius
1130 27615 : zetb => obb%zet
1131 :
1132 : ! basis RI A
1133 27615 : first_sgfca => fba%first_sgf
1134 27615 : lca_max => fba%lmax
1135 27615 : lca => fba%l
1136 27615 : nsgfca => fba%nsgf_set
1137 27615 : npgfca => fba%npgf
1138 27615 : nshellca => fba%nshell
1139 27615 : nsetca = fba%nset
1140 27615 : set_radius_ca => fba%set_radius
1141 27615 : zetca => fba%zet
1142 :
1143 110460 : dab = SQRT(SUM(rab**2))
1144 27615 : rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
1145 :
1146 56018 : la_max_set = MAXVAL(la_max)
1147 56018 : lb_max_set = MAXVAL(lb_max)
1148 273943 : lca_max_set = MAXVAL(lca_max)
1149 56018 : npgfa_set = MAXVAL(npgfa)
1150 56018 : npgfb_set = MAXVAL(npgfb)
1151 273943 : npgfca_set = MAXVAL(npgfca)
1152 56018 : nshella_set = MAXVAL(nshella)
1153 56018 : nshellb_set = MAXVAL(nshellb)
1154 273943 : nshellca_set = MAXVAL(nshellca)
1155 : !*** for forces: derivative+1 in auxiliary vector required
1156 27615 : ndev = 0
1157 27615 : IF (calculate_forces) ndev = 1
1158 :
1159 27615 : laa_max_set = la_max_set + lca_max_set
1160 :
1161 : ! allocate some work storage....
1162 27615 : nds_max = laa_max_set + lb_max_set + ndev + 1
1163 27615 : nl_set = INT((laa_max_set)/2)
1164 193305 : ALLOCATE (swork(npgfb_set, npgfa_set, npgfca_set, nl_set + 1, nds_max))
1165 193305 : ALLOCATE (swork_cont(nds_max, 0:nl_set, nshella_set, nshellb_set, nshellca_set))
1166 :
1167 56018 : DO iset = 1, nseta
1168 :
1169 86093 : DO jset = 1, nsetb
1170 :
1171 30075 : IF (set_radius_a(iset) + set_radius_b(jset) < dab) CYCLE
1172 :
1173 305862 : DO kset = 1, nsetca
1174 :
1175 249330 : IF (set_radius_b(jset) + set_radius_ca(kset) < dab) CYCLE
1176 :
1177 : !*** calculate s_baa here
1178 123142 : laa_max = la_max(iset) + lca_max(kset)
1179 123142 : nds = laa_max + lb_max(jset) + ndev + 1
1180 123142 : nl = INT(laa_max/2) + 1
1181 97118295 : swork(1:npgfb(jset), 1:npgfa(iset), 1:npgfca(kset), 1:nl, 1:nds) = 0.0_dp
1182 : CALL s_overlap_abb(lb_max(jset), npgfb(jset), zetb(:, jset), &
1183 : la_max(iset), npgfa(iset), zeta(:, iset), &
1184 : lca_max(kset), npgfca(kset), zetca(:, kset), &
1185 123142 : rab, swork, calculate_forces)
1186 :
1187 : CALL contract_s_overlap_aba(la(:, iset), npgfa(iset), nshella(iset), &
1188 : lb(:, jset), npgfb(jset), nshellb(jset), &
1189 : scon_obb(1:npgfb(jset), 1:nshellb(jset), jset), &
1190 : lca(:, kset), npgfca(kset), nshellca(kset), &
1191 : oba_index(:, :, iset), fba_index(:, :, kset), scona_mix, nl, nds, &
1192 : swork(1:npgfb(jset), 1:npgfa(iset), 1:npgfca(kset), 1:nl, 1:nds), &
1193 123142 : swork_cont, calculate_forces)
1194 123142 : IF (calculate_ints) THEN
1195 : CALL construct_overlap_shg_aba(la(:, iset), first_sgfa(:, iset), nshella(iset), &
1196 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
1197 : lca(:, kset), first_sgfca(:, kset), nshellca(kset), &
1198 : cg_coeff, cg_none0_list, ncg_none0, &
1199 69930 : swork_cont, Waux_mat, abaint)
1200 : END IF
1201 123142 : IF (calculate_forces) THEN
1202 : !*** -rab, since Eq. in Ref. use Ra-Rb, not Rb-Ra
1203 : CALL dev_overlap_shg_aba(la(:, iset), first_sgfa(:, iset), nshella(iset), &
1204 : lb(:, jset), first_sgfb(:, jset), nshellb(jset), &
1205 : lca(:, kset), first_sgfca(:, kset), nshellca(kset), &
1206 : cg_coeff, cg_none0_list, ncg_none0, &
1207 213808 : -rab, swork_cont, Waux_mat, dWaux_mat, dabdaint)
1208 : END IF
1209 : ! max value of integrals in this set triple
1210 123142 : sgfa = first_sgfa(1, iset)
1211 123142 : na = sgfa + nsgfa(iset) - 1
1212 123142 : sgfb = first_sgfb(1, jset)
1213 123142 : nb = sgfb + nsgfb(jset) - 1
1214 123142 : sgfca = first_sgfca(1, kset)
1215 279405 : nca = sgfca + nsgfca(kset) - 1
1216 :
1217 : END DO
1218 : END DO
1219 : END DO
1220 :
1221 27615 : DEALLOCATE (swork_cont)
1222 27615 : DEALLOCATE (swork)
1223 :
1224 27615 : END SUBROUTINE int_overlap_aba_shg_low
1225 :
1226 : ! **************************************************************************************************
1227 : !> \brief precalculates the angular part of the SHG integrals for the matrices
1228 : !> (fa,fb), (a,b), (a,b,fa) and (b,fb,a); the same Waux_mat can then be used for all
1229 : !> for integrals; specific for LRIGPW
1230 : !> \param oba orbital basis on a
1231 : !> \param obb orbital basis on b
1232 : !> \param fba aux basis on a
1233 : !> \param fbb aux basis on b
1234 : !> \param rab distance vector between a and b
1235 : !> \param Waux_mat W matrix that contains the angular-dependent part
1236 : !> \param dWaux_mat derivative of the W matrix
1237 : !> \param calculate_forces ...
1238 : ! **************************************************************************************************
1239 27453 : SUBROUTINE lri_precalc_angular_shg_part(oba, obb, fba, fbb, rab, Waux_mat, dWaux_mat, calculate_forces)
1240 :
1241 : TYPE(gto_basis_set_type), POINTER :: oba, obb, fba, fbb
1242 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rab
1243 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :), &
1244 : INTENT(OUT) :: Waux_mat
1245 : REAL(KIND=dp), ALLOCATABLE, &
1246 : DIMENSION(:, :, :, :), INTENT(OUT) :: dWaux_mat
1247 : LOGICAL, INTENT(IN) :: calculate_forces
1248 :
1249 : INTEGER :: i, isize, j, k, la_max, laa_max, lb_max, &
1250 : lbb_max, lca_max, lcb_max, li_max, &
1251 : lj_max, lmax, mdim(3), size_int(4, 2), &
1252 : temp
1253 27453 : INTEGER, DIMENSION(:), POINTER :: li_max_all
1254 : REAL(KIND=dp) :: rab2
1255 27453 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: Rc, Rs
1256 :
1257 27453 : rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
1258 :
1259 : !*** 1 Waux_mat of size (li_max,lj_max) for elements
1260 : ! i j
1261 : ! [aab] --> (laa_max, lb_max)
1262 : ! [bba] --> (lbb_max, la_max) --> use for [abb]
1263 : ! [ab] ri --> (lca_max, lcb_max)
1264 : ! [ab] orb --> (la_max , lb_max)
1265 :
1266 55650 : la_max = MAXVAL(oba%lmax)
1267 55650 : lb_max = MAXVAL(obb%lmax)
1268 271859 : lca_max = MAXVAL(fba%lmax)
1269 271859 : lcb_max = MAXVAL(fbb%lmax)
1270 :
1271 27453 : laa_max = la_max + lca_max
1272 27453 : lbb_max = lb_max + lcb_max
1273 27453 : li_max = MAX(laa_max, lbb_max)
1274 27453 : lj_max = MAX(la_max, lb_max, lcb_max)
1275 27453 : lmax = li_max
1276 :
1277 82359 : ALLOCATE (li_max_all(0:lj_max))
1278 164718 : ALLOCATE (Rc(0:lmax, -2*lmax:2*lmax), Rs(0:lmax, -2*lmax:2*lmax))
1279 27453 : Rc = 0._dp
1280 27453 : Rs = 0._dp
1281 27453 : mdim(1) = li_max + lj_max + 1
1282 27453 : mdim(2) = nsoset(li_max) + 1
1283 27453 : mdim(3) = nsoset(lj_max) + 1
1284 137265 : ALLOCATE (Waux_mat(mdim(1), mdim(2), mdim(3)))
1285 137265 : ALLOCATE (dWaux_mat(3, mdim(1), mdim(2), mdim(3)))
1286 : !Waux_mat = 0._dp !.. takes time
1287 : !dWaux_mat =0._dp !.. takes time
1288 :
1289 : !*** Waux_mat (li_max,lj_max) contains elements not needed,
1290 : !*** make indixing so that only required ones are computed
1291 : !*** li_max_all(j) --> li_max dependent on j
1292 82359 : size_int(1, :) = [laa_max, lb_max]
1293 82359 : size_int(2, :) = [lbb_max, la_max]
1294 82359 : size_int(3, :) = [lca_max, lcb_max]
1295 82359 : size_int(4, :) = [la_max, lb_max]
1296 :
1297 139059 : li_max_all(:) = 0
1298 137265 : DO isize = 1, 4
1299 109812 : i = size_int(isize, 1)
1300 109812 : j = size_int(isize, 2)
1301 109812 : k = li_max_all(j)
1302 137265 : IF (k < i) li_max_all(j) = i
1303 : END DO
1304 27453 : temp = li_max_all(lj_max)
1305 139059 : DO j = lj_max, 0, -1
1306 139059 : IF (li_max_all(j) < temp) THEN
1307 56024 : li_max_all(j) = temp
1308 : ELSE
1309 : temp = li_max_all(j)
1310 : END IF
1311 : END DO
1312 :
1313 : !*** -rab, since Eq. in Ref. use Ra-Rb, not Rb-Ra
1314 109812 : CALL get_real_scaled_solid_harmonic(Rc, Rs, lmax, -rab, rab2)
1315 27453 : CALL get_W_matrix(li_max_all, lj_max, lmax, Rc, Rs, Waux_mat)
1316 27453 : IF (calculate_forces) THEN
1317 11940 : CALL get_dW_matrix(li_max_all, lj_max, Waux_mat, dWaux_mat)
1318 : END IF
1319 :
1320 27453 : DEALLOCATE (Rc, Rs, li_max_all)
1321 :
1322 27453 : END SUBROUTINE lri_precalc_angular_shg_part
1323 :
1324 : END MODULE generic_shg_integrals
|