(git:899a4fa)
Loading...
Searching...
No Matches
ai_overlap.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 Calculation of the overlap integrals over Cartesian Gaussian-type
10!> functions.
11!> \par Literature
12!> S. Obara and A. Saika, J. Chem. Phys. 84, 3963 (1986)
13!> \par History
14!> - Derivatives added (02.05.2002,MK)
15!> - New OS routine with simpler logic (11.07.2014, JGH)
16!> \author Matthias Krack (08.10.1999)
17! **************************************************************************************************
23 USE ai_os_rr, ONLY: os_rr_ovlp
24 USE kinds, ONLY: dp
25 USE mathconstants, ONLY: pi,&
26 twopi,&
27 z_one
28 USE orbital_pointers, ONLY: coset,&
29 indco,&
30 nco,&
31 ncoset,&
32 nso
34#include "../base/base_uses.f90"
35
36 IMPLICIT NONE
37
38 PRIVATE
39
40 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ai_overlap'
41
42! *** Public subroutines ***
45
46CONTAINS
47
48! **************************************************************************************************
49!> \brief Purpose: Calculation of the two-center overlap integrals [a|b] over
50!> Cartesian Gaussian-type functions.
51!> \param la_max_set Max L on center A
52!> \param la_min_set Min L on center A
53!> \param npgfa Number of primitives on center A
54!> \param rpgfa Range of functions on A, used for screening
55!> \param zeta Exponents on center A
56!> \param lb_max_set Max L on center B
57!> \param lb_min_set Min L on center B
58!> \param npgfb Number of primitives on center B
59!> \param rpgfb Range of functions on B, used for screening
60!> \param zetb Exponents on center B
61!> \param rab Distance vector A-B
62!> \param dab Distance A-B
63!> \param sab Final Integrals, basic and derivatives
64!> \param da_max_set Some additional derivative information
65!> \param return_derivatives Return integral derivatives
66!> \param s Work space
67!> \param lds Leading dimension of s
68!> \date 19.09.2000
69!> \author MK
70!> \version 1.0
71! **************************************************************************************************
72 SUBROUTINE overlap(la_max_set, la_min_set, npgfa, rpgfa, zeta, &
73 lb_max_set, lb_min_set, npgfb, rpgfb, zetb, &
74 rab, dab, sab, da_max_set, return_derivatives, s, lds)
75 INTEGER, INTENT(IN) :: la_max_set, la_min_set, npgfa
76 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfa, zeta
77 INTEGER, INTENT(IN) :: lb_max_set, lb_min_set, npgfb
78 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfb, zetb
79 REAL(kind=dp), DIMENSION(3), INTENT(IN) :: rab
80 REAL(kind=dp), INTENT(IN) :: dab
81 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: sab
82 INTEGER, INTENT(IN) :: da_max_set
83 LOGICAL, INTENT(IN) :: return_derivatives
84 INTEGER, INTENT(IN) :: lds
85 REAL(kind=dp), DIMENSION(lds, lds, *), &
86 INTENT(INOUT) :: s
87
88 INTEGER :: ax, axis, ay, az, bx, by, bz, cda, coa, cob, da, da_max, first, first_b, i, ipgf, &
89 j, jk, jpgf, jstart, k, la_max, la_start, last, last_b, lb_max, lb_start, ldrr, na, nb, &
90 parent, power(3)
91 INTEGER, ALLOCATABLE :: derivative_map(:, :, :)
92 REAL(kind=dp) :: f0, zetp
93 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: rr
94 REAL(kind=dp), DIMENSION(3) :: rap, rbp
95
96 da_max = da_max_set
97 la_max = la_max_set + da_max_set
98
99 lb_max = lb_max_set
100 ldrr = max(la_max, lb_max) + 1
101 ALLOCATE (rr(0:ldrr - 1, 0:ldrr - 1, 3))
102 IF (da_max > 0) THEN
103 ALLOCATE (derivative_map(4, ncoset(la_max - 1), 3))
104 DO axis = 1, 3
105 CALL cartesian_ladder_map(la_max - 1, 0, axis, derivative_map(:, :, axis))
106 END DO
107 END IF
108
109! *** Loop over all pairs of primitive Gaussian-type functions ***
110
111 na = 0
112 DO ipgf = 1, npgfa
113
114 nb = 0
115
116 DO jpgf = 1, npgfb
117
118! *** Screening ***
119
120 IF (rpgfa(ipgf) + rpgfb(jpgf) < dab) THEN
121 DO j = nb + 1, nb + ncoset(lb_max_set)
122 DO i = na + 1, na + ncoset(la_max_set)
123 sab(i, j) = 0.0_dp
124 END DO
125 END DO
126 IF (return_derivatives) THEN
127 DO k = 2, ncoset(da_max_set)
128 jstart = (k - 1)*SIZE(sab, 1)
129 DO j = jstart + nb + 1, jstart + nb + ncoset(lb_max_set)
130 DO i = na + 1, na + ncoset(la_max_set)
131 sab(i, j) = 0.0_dp
132 END DO
133 END DO
134 END DO
135 END IF
136 nb = nb + ncoset(lb_max_set)
137 cycle
138 END IF
139
140! *** Calculate some prefactors ***
141
142 zetp = 1.0_dp/(zeta(ipgf) + zetb(jpgf))
143
144 f0 = sqrt((pi*zetp)**3)*exp(-zeta(ipgf)*zetb(jpgf)*zetp*dab*dab)
145 rap(:) = zetb(jpgf)*zetp*rab(:)
146 rbp(:) = -zeta(ipgf)*zetp*rab(:)
147
148 CALL os_rr_ovlp(rap, la_max, rbp, lb_max, 1.0_dp/zetp, ldrr, rr)
149
150 DO cob = 1, ncoset(lb_max)
151 bx = indco(1, cob)
152 by = indco(2, cob)
153 bz = indco(3, cob)
154 DO coa = 1, ncoset(la_max)
155 ax = indco(1, coa)
156 ay = indco(2, coa)
157 az = indco(3, coa)
158 s(coa, cob, 1) = f0*rr(ax, bx, 1)*rr(ay, by, 2)*rr(az, bz, 3)
159 END DO
160 END DO
161
162! *** Store the primitive overlap integrals ***
163
164 DO j = 1, ncoset(lb_max_set)
165 DO i = 1, ncoset(la_max_set)
166 sab(na + i, nb + j) = s(i, j, 1)
167 END DO
168 END DO
169
170! *** Calculate the requested derivatives with respect ***
171! *** to the nuclear coordinates of the atomic center a ***
172
173 IF (return_derivatives) THEN
174 la_start = 0
175 lb_start = 0
176 ELSE
177 la_start = la_min_set
178 lb_start = lb_min_set
179 END IF
180
181 first_b = ncoset(lb_start - 1) + 1
182 last_b = ncoset(lb_max_set)
183 DO da = 1, da_max
184 ! Intermediate shells must cover lowering in the remaining derivative steps.
185 first = ncoset(max(0, la_start - da_max + da) - 1) + 1
186 last = ncoset(la_max - da)
187 DO cda = ncoset(da - 1) + 1, ncoset(da)
188 power = indco(:, cda)
189 axis = 3
190 IF (power(3) == 0) axis = 2
191 IF (power(axis) == 0) axis = 1
192 power(axis) = power(axis) - 1
193 parent = coset(power(1), power(2), power(3))
194 CALL cartesian_ladder(s(:, first_b:last_b, parent), s(first:last, first_b:last_b, cda), &
195 derivative_map(:, first:last, axis), .true., zeta(ipgf), 0.0_dp, .false.)
196 END DO
197 END DO
198
199! *** Return all the calculated derivatives of the ***
200! *** primitive overlap integrals, if requested ***
201
202 IF (return_derivatives) THEN
203 DO k = 2, ncoset(da_max_set)
204 jstart = (k - 1)*SIZE(sab, 1)
205 DO j = 1, ncoset(lb_max_set)
206 jk = jstart + j
207 DO i = 1, ncoset(la_max_set)
208 sab(na + i, nb + jk) = s(i, j, k)
209 END DO
210 END DO
211 END DO
212 END IF
213
214 nb = nb + ncoset(lb_max_set)
215
216 END DO
217
218 na = na + ncoset(la_max_set)
219 END DO
220
221 DEALLOCATE (rr)
222
223 END SUBROUTINE overlap
224
225! **************************************************************************************************
226!> \brief Calculation of the two-center overlap integrals [a|b] over
227!> Cartesian Gaussian-type functions. First and second derivatives
228!> \param la_max Max L on center A
229!> \param la_min Min L on center A
230!> \param npgfa Number of primitives on center A
231!> \param rpgfa Range of functions on A, used for screening
232!> \param zeta Exponents on center A
233!> \param lb_max Max L on center B
234!> \param lb_min Min L on center B
235!> \param npgfb Number of primitives on center B
236!> \param rpgfb Range of functions on B, used for screening
237!> \param zetb Exponents on center B
238!> \param rab Distance vector A-B
239!> \param sab Final overlap integrals
240!> \param dab First derivative overlap integrals
241!> \param ddab Second derivative overlap integrals ordered xx, xy, xz, yy, yz, zz
242!> \param rr_work Optional caller-provided one-dimensional overlap recurrence workspace
243!> \date 01.07.2014
244!> \author JGH
245! **************************************************************************************************
246 SUBROUTINE overlap_ab(la_max, la_min, npgfa, rpgfa, zeta, &
247 lb_max, lb_min, npgfb, rpgfb, zetb, &
248 rab, sab, dab, ddab, rr_work)
249 INTEGER, INTENT(IN) :: la_max, la_min, npgfa
250 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfa, zeta
251 INTEGER, INTENT(IN) :: lb_max, lb_min, npgfb
252 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfb, zetb
253 REAL(kind=dp), DIMENSION(3), INTENT(IN) :: rab
254 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT), &
255 OPTIONAL :: sab
256 REAL(kind=dp), DIMENSION(:, :, :), INTENT(INOUT), &
257 OPTIONAL :: dab, ddab
258 REAL(kind=dp), DIMENSION(:), INTENT(INOUT), &
259 OPTIONAL, TARGET :: rr_work
260
261 INTEGER, PARAMETER :: component(2, 1) = reshape([1, 1], [2, 1]), &
262 pairs(2, 6) = reshape([1, 1, 1, 2, 1, 3, 2, 2, 2, 3, 3, 3], [2, 6])
263
264 INTEGER :: avec(3), bvec(3), coa, cob, ia, ib, icomp, idir, ipgf, jdir, jpgf, kdir, ldrr, &
265 lma, lmb, ma, mb, na, nb, ofa, ofb, map_b(4, lb_max + 1, 1), map_a(4, la_max + 1, 1)
266 REAL(kind=dp) :: a, b, f0, factor(3), rab2, sval(3), tab, &
267 xhi, zet
268 REAL(kind=dp), ALLOCATABLE :: drr_a(:, :, :), drr_ab(:, :, :)
269 REAL(kind=dp), DIMENSION(3) :: rap, rbp
270 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: rr
271
272 ! Distance of the centers a and b
273
274 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
275 tab = sqrt(rab2)
276
277 ! Maximum l for auxiliary integrals
278 cpassert(PRESENT(sab) .OR. PRESENT(dab) .OR. PRESENT(ddab))
279 IF (PRESENT(sab)) THEN
280 lma = la_max
281 lmb = lb_max
282 END IF
283 IF (PRESENT(dab)) THEN
284 lma = la_max + 1
285 lmb = lb_max
286 END IF
287 IF (PRESENT(ddab)) THEN
288 lma = la_max + 1
289 lmb = lb_max + 1
290 END IF
291 ldrr = max(lma, lmb) + 1
292
293 ! Allocate or attach the workspace for auxiliary integrals
294 NULLIFY (rr)
295 IF (PRESENT(rr_work)) THEN
296 cpassert(SIZE(rr_work) >= ldrr*ldrr*3)
297 rr(0:ldrr - 1, 0:ldrr - 1, 1:3) => rr_work(1:ldrr*ldrr*3)
298 ELSE
299 ALLOCATE (rr(0:ldrr - 1, 0:ldrr - 1, 3))
300 END IF
301
302 IF (PRESENT(dab) .OR. PRESENT(ddab)) ALLOCATE (drr_a(0:ldrr - 1, 0:ldrr - 1, 3))
303 IF (PRESENT(ddab)) THEN
304 ALLOCATE (drr_ab(0:ldrr - 1, 0:ldrr - 1, 3))
305 CALL cartesian_ladder_map(la_max, 0, 0, map_a(:, :, 1))
306 CALL cartesian_ladder_map(lb_max, 0, 0, map_b(:, :, 1))
307 END IF
308
309 ! Number of integrals, check size of arrays
310 ofa = ncoset(la_min - 1)
311 ofb = ncoset(lb_min - 1)
312 na = ncoset(la_max) - ofa
313 nb = ncoset(lb_max) - ofb
314 IF (PRESENT(sab)) THEN
315 cpassert((SIZE(sab, 1) >= na*npgfa))
316 cpassert((SIZE(sab, 2) >= nb*npgfb))
317 END IF
318 IF (PRESENT(dab)) THEN
319 cpassert((SIZE(dab, 1) >= na*npgfa))
320 cpassert((SIZE(dab, 2) >= nb*npgfb))
321 cpassert((SIZE(dab, 3) >= 3))
322 END IF
323 IF (PRESENT(ddab)) THEN
324 cpassert((SIZE(ddab, 1) >= na*npgfa))
325 cpassert((SIZE(ddab, 2) >= nb*npgfb))
326 cpassert((SIZE(ddab, 3) >= 6))
327 END IF
328
329 ! Loops over all pairs of primitive Gaussian-type functions
330 ma = 0
331 DO ipgf = 1, npgfa
332 mb = 0
333 DO jpgf = 1, npgfb
334 ! Distance Screening
335 IF (rpgfa(ipgf) + rpgfb(jpgf) < tab) THEN
336 IF (PRESENT(sab)) sab(ma + 1:ma + na, mb + 1:mb + nb) = 0.0_dp
337 IF (PRESENT(dab)) dab(ma + 1:ma + na, mb + 1:mb + nb, 1:3) = 0.0_dp
338 IF (PRESENT(ddab)) ddab(ma + 1:ma + na, mb + 1:mb + nb, 1:6) = 0.0_dp
339 mb = mb + nb
340 cycle
341 END IF
342
343 ! Calculate some prefactors
344 a = zeta(ipgf)
345 b = zetb(jpgf)
346 zet = a + b
347 xhi = a*b/zet
348 rap = b*rab/zet
349 rbp = -a*rab/zet
350
351 ! [s|s] integral
352 f0 = (pi/zet)**(1.5_dp)*exp(-xhi*rab2)
353
354 ! Calculate the recurrence relation
355 CALL os_rr_ovlp(rap, lma, rbp, lmb, zet, ldrr, rr)
356 IF (PRESENT(ddab)) THEN
357 DO idir = 1, 3
358 CALL apply_cartesian_operator_pair(rr(:, :, idir), drr_ab(0:la_max, 0:lb_max, idir:idir), &
359 map_a, map_b, component, [.true., .true.], [a, b], &
360 [.false., .true.], drr_a(0:la_max, 0:lmb, idir))
361 END DO
362 ELSE IF (PRESENT(dab)) THEN
363 CALL apply_cartesian_1d(rr, drr_a, la_max, lmb, .false., .true., a, [0.0_dp, 0.0_dp, 0.0_dp])
364 END IF
365
366 DO cob = ofb + 1, ncoset(lb_max)
367 bvec = indco(:, cob)
368 ib = mb + cob - ofb
369 DO coa = ofa + 1, ncoset(la_max)
370 avec = indco(:, coa)
371 ia = ma + coa - ofa
372 sval = [(rr(avec(idir), bvec(idir), idir), idir=1, 3)]
373 ! integrals
374 IF (PRESENT(sab)) THEN
375 sab(ia, ib) = f0*sval(1)*sval(2)*sval(3)
376 END IF
377 ! first derivatives
378 IF (PRESENT(dab)) THEN
379 DO idir = 1, 3
380 jdir = mod(idir, 3) + 1
381 kdir = mod(idir + 1, 3) + 1
382 dab(ia, ib, idir) = f0*drr_a(avec(idir), bvec(idir), idir)*sval(jdir)*sval(kdir)
383 END DO
384 END IF
385 ! Translational invariance gives D_B S = -D_A S and D_A D_A S = -D_A D_B S.
386 IF (PRESENT(ddab)) THEN
387 DO icomp = 1, 6
388 idir = pairs(1, icomp)
389 jdir = pairs(2, icomp)
390 factor = sval
391 IF (idir == jdir) THEN
392 factor(idir) = -drr_ab(avec(idir), bvec(idir), idir)
393 ELSE
394 factor(idir) = drr_a(avec(idir), bvec(idir), idir)
395 factor(jdir) = drr_a(avec(jdir), bvec(jdir), jdir)
396 END IF
397 ddab(ia, ib, icomp) = f0*factor(1)*factor(2)*factor(3)
398 END DO
399 END IF
400 !
401 END DO
402 END DO
403
404 mb = mb + nb
405 END DO
406 ma = ma + na
407 END DO
408
409 IF (.NOT. PRESENT(rr_work)) DEALLOCATE (rr)
410 NULLIFY (rr)
411
412 END SUBROUTINE overlap_ab
413
414! **************************************************************************************************
415!> \brief Calculation of the two-center overlap integrals [aa|b] over
416!> Cartesian Gaussian-type functions.
417!> \param la1_max Max L on center A (basis 1)
418!> \param la1_min Min L on center A (basis 1)
419!> \param npgfa1 Number of primitives on center A (basis 1)
420!> \param rpgfa1 Range of functions on A, used for screening (basis 1)
421!> \param zeta1 Exponents on center A (basis 1)
422!> \param la2_max Max L on center A (basis 2)
423!> \param la2_min Min L on center A (basis 2)
424!> \param npgfa2 Number of primitives on center A (basis 2)
425!> \param rpgfa2 Range of functions on A, used for screening (basis 2)
426!> \param zeta2 Exponents on center A (basis 2)
427!> \param lb_max Max L on center B
428!> \param lb_min Min L on center B
429!> \param npgfb Number of primitives on center B
430!> \param rpgfb Range of functions on B, used for screening
431!> \param zetb Exponents on center B
432!> \param rab Distance vector A-B
433!> \param saab Final overlap integrals
434!> \param daab First derivatives with respect to the shared center of both A functions
435!> \param saba Final overlap integrals; different order
436!> \param daba Same shared-center derivatives as daab, with A-B-A output ordering
437!> \date 01.07.2014
438!> \author JGH
439! **************************************************************************************************
440 SUBROUTINE overlap_aab(la1_max, la1_min, npgfa1, rpgfa1, zeta1, &
441 la2_max, la2_min, npgfa2, rpgfa2, zeta2, &
442 lb_max, lb_min, npgfb, rpgfb, zetb, &
443 rab, saab, daab, saba, daba)
444 INTEGER, INTENT(IN) :: la1_max, la1_min, npgfa1
445 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfa1, zeta1
446 INTEGER, INTENT(IN) :: la2_max, la2_min, npgfa2
447 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfa2, zeta2
448 INTEGER, INTENT(IN) :: lb_max, lb_min, npgfb
449 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfb, zetb
450 REAL(kind=dp), DIMENSION(3), INTENT(IN) :: rab
451 REAL(kind=dp), DIMENSION(:, :, :), INTENT(INOUT), &
452 OPTIONAL :: saab
453 REAL(kind=dp), DIMENSION(:, :, :, :), &
454 INTENT(INOUT), OPTIONAL :: daab
455 REAL(kind=dp), DIMENSION(:, :, :), INTENT(INOUT), &
456 OPTIONAL :: saba
457 REAL(kind=dp), DIMENSION(:, :, :, :), &
458 INTENT(INOUT), OPTIONAL :: daba
459
460 INTEGER :: coa1, coa2, cob, i1pgf, i2pgf, ia1, ia2, &
461 ib, jpgf, ldrr, lma, lmb, ma1, ma2, &
462 mb, na1, na2, nb, ofa1, ofa2, ofb
463 INTEGER, DIMENSION(3) :: a2vec, avec, bvec
464 REAL(kind=dp) :: a, b, dum(3), f0, rab2, rpgfa, tab, &
465 value, xhi, zet
466 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: drr, rr
467 REAL(kind=dp), DIMENSION(3) :: rap, rbp
468
469 ! Distance of the centers a and b
470
471 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
472 tab = sqrt(rab2)
473
474 ! Maximum l for auxiliary integrals
475 cpassert(PRESENT(saab) .OR. PRESENT(daab) .OR. PRESENT(saba) .OR. PRESENT(daba))
476 IF (PRESENT(saab) .OR. PRESENT(saba)) THEN
477 lma = la1_max + la2_max
478 lmb = lb_max
479 END IF
480 IF (PRESENT(daab) .OR. PRESENT(daba)) THEN
481 lma = la1_max + la2_max + 1
482 lmb = lb_max
483 END IF
484 ldrr = max(lma, lmb) + 1
485
486 ! Allocate space for auxiliary integrals
487 ALLOCATE (rr(0:ldrr - 1, 0:ldrr - 1, 3))
488 IF (PRESENT(daab) .OR. PRESENT(daba)) ALLOCATE (drr(0:lma - 1, 0:lmb, 3))
489
490 ! Number of integrals, check size of arrays
491 ofa1 = ncoset(la1_min - 1)
492 ofa2 = ncoset(la2_min - 1)
493 ofb = ncoset(lb_min - 1)
494 na1 = ncoset(la1_max) - ofa1
495 na2 = ncoset(la2_max) - ofa2
496 nb = ncoset(lb_max) - ofb
497 IF (PRESENT(saab)) THEN
498 cpassert((SIZE(saab, 1) >= na1*npgfa1))
499 cpassert((SIZE(saab, 2) >= na2*npgfa2))
500 cpassert((SIZE(saab, 3) >= nb*npgfb))
501 END IF
502 IF (PRESENT(daab)) THEN
503 cpassert((SIZE(daab, 1) >= na1*npgfa1))
504 cpassert((SIZE(daab, 2) >= na2*npgfa2))
505 cpassert((SIZE(daab, 3) >= nb*npgfb))
506 cpassert((SIZE(daab, 4) >= 3))
507 END IF
508 IF (PRESENT(saba)) THEN
509 cpassert((SIZE(saba, 1) >= na1*npgfa1))
510 cpassert((SIZE(saba, 2) >= nb*npgfb))
511 cpassert((SIZE(saba, 3) >= na2*npgfa2))
512 END IF
513 IF (PRESENT(daba)) THEN
514 cpassert((SIZE(daba, 1) >= na1*npgfa1))
515 cpassert((SIZE(daba, 2) >= nb*npgfb))
516 cpassert((SIZE(daba, 3) >= na2*npgfa2))
517 cpassert((SIZE(daba, 4) >= 3))
518 END IF
519
520 ! Loops over all primitive Gaussian-type functions
521 ma1 = 0
522 DO i1pgf = 1, npgfa1
523 ma2 = 0
524 DO i2pgf = 1, npgfa2
525 rpgfa = min(rpgfa1(i1pgf), rpgfa2(i2pgf))
526 mb = 0
527 DO jpgf = 1, npgfb
528 ! Distance Screening
529 IF (rpgfa + rpgfb(jpgf) < tab) THEN
530 IF (PRESENT(saab)) saab(ma1 + 1:ma1 + na1, ma2 + 1:ma2 + na2, mb + 1:mb + nb) = 0.0_dp
531 IF (PRESENT(daab)) daab(ma1 + 1:ma1 + na1, ma2 + 1:ma2 + na2, mb + 1:mb + nb, 1:3) = 0.0_dp
532 IF (PRESENT(saba)) saba(ma1 + 1:ma1 + na1, mb + 1:mb + nb, ma2 + 1:ma2 + na2) = 0.0_dp
533 IF (PRESENT(daba)) daba(ma1 + 1:ma1 + na1, mb + 1:mb + nb, ma2 + 1:ma2 + na2, 1:3) = 0.0_dp
534 mb = mb + nb
535 cycle
536 END IF
537
538 ! Calculate some prefactors
539 a = zeta1(i1pgf) + zeta2(i2pgf)
540 b = zetb(jpgf)
541 zet = a + b
542 xhi = a*b/zet
543 rap = b*rab/zet
544 rbp = -a*rab/zet
545
546 ! [ss|s] integral
547 f0 = (pi/zet)**(1.5_dp)*exp(-xhi*rab2)
548
549 ! Calculate the recurrence relation
550 CALL os_rr_ovlp(rap, lma, rbp, lmb, zet, ldrr, rr)
551 IF (PRESENT(daab) .OR. PRESENT(daba)) THEN
552 CALL apply_cartesian_1d(rr, drr, la1_max + la2_max, lmb, .false., .true., a, &
553 [0.0_dp, 0.0_dp, 0.0_dp])
554 END IF
555
556 DO cob = ofb + 1, ncoset(lb_max)
557 bvec = indco(:, cob)
558 ib = mb + cob - ofb
559 DO coa2 = ofa2 + 1, ncoset(la2_max)
560 a2vec = indco(:, coa2)
561 ia2 = ma2 + coa2 - ofa2
562 DO coa1 = ofa1 + 1, ncoset(la1_max)
563 avec = indco(:, coa1) + a2vec
564 ia1 = ma1 + coa1 - ofa1
565 ! integrals
566 IF (PRESENT(saab) .OR. PRESENT(saba)) THEN
567 value = f0*rr(avec(1), bvec(1), 1)*rr(avec(2), bvec(2), 2)*rr(avec(3), bvec(3), 3)
568 IF (PRESENT(saab)) saab(ia1, ia2, ib) = value
569 IF (PRESENT(saba)) saba(ia1, ib, ia2) = value
570 END IF
571 ! first derivatives
572 IF (PRESENT(daab) .OR. PRESENT(daba)) THEN
573 dum(1) = f0*drr(avec(1), bvec(1), 1)*rr(avec(2), bvec(2), 2)*rr(avec(3), bvec(3), 3)
574 dum(2) = f0*rr(avec(1), bvec(1), 1)*drr(avec(2), bvec(2), 2)*rr(avec(3), bvec(3), 3)
575 dum(3) = f0*rr(avec(1), bvec(1), 1)*rr(avec(2), bvec(2), 2)*drr(avec(3), bvec(3), 3)
576 IF (PRESENT(daab)) daab(ia1, ia2, ib, 1:3) = dum
577 IF (PRESENT(daba)) daba(ia1, ib, ia2, 1:3) = dum
578 END IF
579 END DO
580 END DO
581 END DO
582
583 mb = mb + nb
584 END DO
585 ma2 = ma2 + na2
586 END DO
587 ma1 = ma1 + na1
588 END DO
589
590 DEALLOCATE (rr)
591
592 END SUBROUTINE overlap_aab
593
594! **************************************************************************************************
595!> \brief Calculation of the two-center overlap integrals [a|bb] over
596!> Cartesian Gaussian-type functions.
597!> \param la_max Max L on center A
598!> \param la_min Min L on center A
599!> \param npgfa Number of primitives on center A
600!> \param rpgfa Range of functions on A, used for screening
601!> \param zeta Exponents on center A
602!> \param lb1_max Max L on center B (basis 1)
603!> \param lb1_min Min L on center B (basis 1)
604!> \param npgfb1 Number of primitives on center B (basis 1)
605!> \param rpgfb1 Range of functions on B, used for screening (basis 1)
606!> \param zetb1 Exponents on center B (basis 1)
607!> \param lb2_max Max L on center B (basis 2)
608!> \param lb2_min Min L on center B (basis 2)
609!> \param npgfb2 Number of primitives on center B (basis 2)
610!> \param rpgfb2 Range of functions on B, used for screening (basis 2)
611!> \param zetb2 Exponents on center B (basis 2)
612!> \param rab Distance vector A-B
613!> \param sabb Final overlap integrals
614!> \param dabb First derivatives with respect to center A
615!> \date 01.07.2014
616!> \author JGH
617! **************************************************************************************************
618 SUBROUTINE overlap_abb(la_max, la_min, npgfa, rpgfa, zeta, &
619 lb1_max, lb1_min, npgfb1, rpgfb1, zetb1, &
620 lb2_max, lb2_min, npgfb2, rpgfb2, zetb2, &
621 rab, sabb, dabb)
622 INTEGER, INTENT(IN) :: la_max, la_min, npgfa
623 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfa, zeta
624 INTEGER, INTENT(IN) :: lb1_max, lb1_min, npgfb1
625 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfb1, zetb1
626 INTEGER, INTENT(IN) :: lb2_max, lb2_min, npgfb2
627 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfb2, zetb2
628 REAL(kind=dp), DIMENSION(3), INTENT(IN) :: rab
629 REAL(kind=dp), DIMENSION(:, :, :), INTENT(INOUT), &
630 OPTIONAL :: sabb
631 REAL(kind=dp), DIMENSION(:, :, :, :), &
632 INTENT(INOUT), OPTIONAL :: dabb
633
634 INTEGER :: coa, cob1, cob2, ia, ib1, ib2, ipgf, &
635 j1pgf, j2pgf, ldrr, lma, lmb, ma, mb1, &
636 mb2, na, nb1, nb2, ofa, ofb1, ofb2
637 INTEGER, DIMENSION(3) :: avec, b2vec, bvec
638 REAL(kind=dp) :: a, b, f0, rab2, rpgfb, tab, xhi, zet
639 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: drr, rr
640 REAL(kind=dp), DIMENSION(3) :: rap, rbp
641
642 ! Distance of the centers a and b
643
644 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
645 tab = sqrt(rab2)
646
647 ! Maximum l for auxiliary integrals
648 cpassert(PRESENT(sabb) .OR. PRESENT(dabb))
649 IF (PRESENT(sabb)) THEN
650 lma = la_max
651 lmb = lb1_max + lb2_max
652 END IF
653 IF (PRESENT(dabb)) THEN
654 lma = la_max + 1
655 lmb = lb1_max + lb2_max
656 END IF
657 ldrr = max(lma, lmb) + 1
658
659 ! Allocate space for auxiliary integrals
660 ALLOCATE (rr(0:ldrr - 1, 0:ldrr - 1, 3))
661 IF (PRESENT(dabb)) ALLOCATE (drr(0:lma - 1, 0:lmb, 3))
662
663 ! Number of integrals, check size of arrays
664 ofa = ncoset(la_min - 1)
665 ofb1 = ncoset(lb1_min - 1)
666 ofb2 = ncoset(lb2_min - 1)
667 na = ncoset(la_max) - ofa
668 nb1 = ncoset(lb1_max) - ofb1
669 nb2 = ncoset(lb2_max) - ofb2
670 IF (PRESENT(sabb)) THEN
671 cpassert((SIZE(sabb, 1) >= na*npgfa))
672 cpassert((SIZE(sabb, 2) >= nb1*npgfb1))
673 cpassert((SIZE(sabb, 3) >= nb2*npgfb2))
674 END IF
675 IF (PRESENT(dabb)) THEN
676 cpassert((SIZE(dabb, 1) >= na*npgfa))
677 cpassert((SIZE(dabb, 2) >= nb1*npgfb1))
678 cpassert((SIZE(dabb, 3) >= nb2*npgfb2))
679 cpassert((SIZE(dabb, 4) >= 3))
680 END IF
681
682 ! Loops over all pairs of primitive Gaussian-type functions
683 ma = 0
684 DO ipgf = 1, npgfa
685 mb1 = 0
686 DO j1pgf = 1, npgfb1
687 mb2 = 0
688 DO j2pgf = 1, npgfb2
689 ! Distance Screening
690 rpgfb = min(rpgfb1(j1pgf), rpgfb2(j2pgf))
691 IF (rpgfa(ipgf) + rpgfb < tab) THEN
692 IF (PRESENT(sabb)) sabb(ma + 1:ma + na, mb1 + 1:mb1 + nb1, mb2 + 1:mb2 + nb2) = 0.0_dp
693 IF (PRESENT(dabb)) dabb(ma + 1:ma + na, mb1 + 1:mb1 + nb1, mb2 + 1:mb2 + nb2, 1:3) = 0.0_dp
694 mb2 = mb2 + nb2
695 cycle
696 END IF
697
698 ! Calculate some prefactors
699 a = zeta(ipgf)
700 b = zetb1(j1pgf) + zetb2(j2pgf)
701 zet = a + b
702 xhi = a*b/zet
703 rap = b*rab/zet
704 rbp = -a*rab/zet
705
706 ! [s|s] integral
707 f0 = (pi/zet)**(1.5_dp)*exp(-xhi*rab2)
708
709 ! Calculate the recurrence relation
710 CALL os_rr_ovlp(rap, lma, rbp, lmb, zet, ldrr, rr)
711 IF (PRESENT(dabb)) THEN
712 CALL apply_cartesian_1d(rr, drr, la_max, lmb, .false., .true., a, &
713 [0.0_dp, 0.0_dp, 0.0_dp])
714 END IF
715
716 DO cob2 = ofb2 + 1, ncoset(lb2_max)
717 b2vec = indco(:, cob2)
718 ib2 = mb2 + cob2 - ofb2
719 DO cob1 = ofb1 + 1, ncoset(lb1_max)
720 bvec = indco(:, cob1) + b2vec
721 ib1 = mb1 + cob1 - ofb1
722 DO coa = ofa + 1, ncoset(la_max)
723 avec = indco(:, coa)
724 ia = ma + coa - ofa
725 ! integrals
726 IF (PRESENT(sabb)) THEN
727 sabb(ia, ib1, ib2) = f0*rr(avec(1), bvec(1), 1)*rr(avec(2), bvec(2), 2)*rr(avec(3), bvec(3), 3)
728 END IF
729 ! first derivatives
730 IF (PRESENT(dabb)) THEN
731 dabb(ia, ib1, ib2, 1) = f0*drr(avec(1), bvec(1), 1)*rr(avec(2), bvec(2), 2)*rr(avec(3), bvec(3), 3)
732 dabb(ia, ib1, ib2, 2) = f0*rr(avec(1), bvec(1), 1)*drr(avec(2), bvec(2), 2)*rr(avec(3), bvec(3), 3)
733 dabb(ia, ib1, ib2, 3) = f0*rr(avec(1), bvec(1), 1)*rr(avec(2), bvec(2), 2)*drr(avec(3), bvec(3), 3)
734 END IF
735 END DO
736 END DO
737 END DO
738
739 mb2 = mb2 + nb2
740 END DO
741 mb1 = mb1 + nb1
742 END DO
743 ma = ma + na
744 END DO
745
746 DEALLOCATE (rr)
747
748 END SUBROUTINE overlap_abb
749
750! **************************************************************************************************
751
752! **************************************************************************************************
753!> \brief Calculation of the two-center overlap integrals [a|b] over
754!> Spherical Gaussian-type functions.
755!> \param la Max L on center A
756!> \param zeta Exponents on center A
757!> \param lb Max L on center B
758!> \param zetb Exponents on center B
759!> \param rab Distance vector A-B
760!> \param sab Final overlap integrals
761!> \date 01.03.2016
762!> \author JGH
763! **************************************************************************************************
764 SUBROUTINE overlap_ab_s(la, zeta, lb, zetb, rab, sab)
765 INTEGER, INTENT(IN) :: la
766 REAL(kind=dp), INTENT(IN) :: zeta
767 INTEGER, INTENT(IN) :: lb
768 REAL(kind=dp), INTENT(IN) :: zetb
769 REAL(kind=dp), DIMENSION(3), INTENT(IN) :: rab
770 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: sab
771
772 REAL(kind=dp), PARAMETER :: huge4 = huge(1._dp)/4._dp
773
774 INTEGER :: nca, ncb, nsa, nsb
775 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: cab
776 REAL(kind=dp), DIMENSION(1) :: rpgf, za, zb
777 REAL(kind=dp), DIMENSION(:, :), POINTER :: c2sa, c2sb
778
779 rpgf(1) = huge4
780 za(1) = zeta
781 zb(1) = zetb
782
783 nca = nco(la)
784 ncb = nco(lb)
785 ALLOCATE (cab(nca, ncb))
786 nsa = nso(la)
787 nsb = nso(lb)
788
789 CALL overlap_ab(la, la, 1, rpgf, za, lb, lb, 1, rpgf, zb, rab, cab)
790
791 c2sa => orbtramat(la)%c2s
792 c2sb => orbtramat(lb)%c2s
793 sab(1:nsa, 1:nsb) = matmul(c2sa(1:nsa, 1:nca), &
794 matmul(cab(1:nca, 1:ncb), transpose(c2sb(1:nsb, 1:ncb))))
795
796 DEALLOCATE (cab)
797
798 END SUBROUTINE overlap_ab_s
799
800! **************************************************************************************************
801!> \brief Calculation of the overlap integrals [a|b] over
802!> cubic periodic Spherical Gaussian-type functions.
803!> \param la Max L on center A
804!> \param zeta Exponents on center A
805!> \param lb Max L on center B
806!> \param zetb Exponents on center B
807!> \param alat Lattice constant
808!> \param sab Final overlap integrals
809!> \date 01.03.2016
810!> \author JGH
811! **************************************************************************************************
812 SUBROUTINE overlap_ab_sp(la, zeta, lb, zetb, alat, sab)
813 INTEGER, INTENT(IN) :: la
814 REAL(kind=dp), INTENT(IN) :: zeta
815 INTEGER, INTENT(IN) :: lb
816 REAL(kind=dp), INTENT(IN) :: zetb, alat
817 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: sab
818
819 COMPLEX(KIND=dp) :: zfg
820 COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: fun, gun
821 INTEGER :: ax, ay, az, bx, by, bz, i, ia, ib, l, &
822 l1, l2, na, nb, nca, ncb, nmax, nsa, &
823 nsb
824 REAL(kind=dp) :: oa, ob, ovol, zm
825 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: fexp, gexp, gval
826 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: cab
827 REAL(kind=dp), DIMENSION(0:3, 0:3) :: fgsum
828 REAL(kind=dp), DIMENSION(:, :), POINTER :: c2sa, c2sb
829
830 nca = nco(la)
831 ncb = nco(lb)
832 ALLOCATE (cab(nca, ncb))
833 cab = 0.0_dp
834 nsa = nso(la)
835 nsb = nso(lb)
836
837 zm = min(zeta, zetb)
838 nmax = nint(1.81_dp*alat*sqrt(zm) + 1.0_dp)
839 ALLOCATE (fun(-nmax:nmax, 0:la), gun(-nmax:nmax, 0:lb), &
840 fexp(-nmax:nmax), gexp(-nmax:nmax), gval(-nmax:nmax))
841
842 oa = 1._dp/zeta
843 ob = 1._dp/zetb
844 DO i = -nmax, nmax
845 gval(i) = twopi/alat*real(i, kind=dp)
846 fexp(i) = sqrt(oa*pi)*exp(-0.25_dp*oa*gval(i)**2)
847 gexp(i) = sqrt(ob*pi)*exp(-0.25_dp*ob*gval(i)**2)
848 END DO
849 DO l = 0, la
850 IF (l == 0) THEN
851 fun(:, l) = z_one
852 ELSE IF (l == 1) THEN
853 fun(:, l) = cmplx(0.0_dp, 0.5_dp*oa*gval(:), kind=dp)
854 ELSE IF (l == 2) THEN
855 fun(:, l) = cmplx(-(0.5_dp*oa*gval(:))**2, 0.0_dp, kind=dp)
856 fun(:, l) = fun(:, l) + cmplx(0.5_dp*oa, 0.0_dp, kind=dp)
857 ELSE IF (l == 3) THEN
858 fun(:, l) = cmplx(0.0_dp, -(0.5_dp*oa*gval(:))**3, kind=dp)
859 fun(:, l) = fun(:, l) + cmplx(0.0_dp, 0.75_dp*oa*oa*gval(:), kind=dp)
860 ELSE
861 cpabort("l value too high")
862 END IF
863 END DO
864 DO l = 0, lb
865 IF (l == 0) THEN
866 gun(:, l) = z_one
867 ELSE IF (l == 1) THEN
868 gun(:, l) = cmplx(0.0_dp, 0.5_dp*ob*gval(:), kind=dp)
869 ELSE IF (l == 2) THEN
870 gun(:, l) = cmplx(-(0.5_dp*ob*gval(:))**2, 0.0_dp, kind=dp)
871 gun(:, l) = gun(:, l) + cmplx(0.5_dp*ob, 0.0_dp, kind=dp)
872 ELSE IF (l == 3) THEN
873 gun(:, l) = cmplx(0.0_dp, -(0.5_dp*ob*gval(:))**3, kind=dp)
874 gun(:, l) = gun(:, l) + cmplx(0.0_dp, 0.75_dp*ob*ob*gval(:), kind=dp)
875 ELSE
876 cpabort("l value too high")
877 END IF
878 END DO
879
880 fgsum = 0.0_dp
881 DO l1 = 0, la
882 DO l2 = 0, lb
883 zfg = sum(conjg(fun(:, l1))*fexp(:)*gun(:, l2)*gexp(:))
884 fgsum(l1, l2) = real(zfg, kind=dp)
885 END DO
886 END DO
887
888 na = ncoset(la - 1)
889 nb = ncoset(lb - 1)
890 DO ax = 0, la
891 DO ay = 0, la - ax
892 az = la - ax - ay
893 ia = coset(ax, ay, az) - na
894 DO bx = 0, lb
895 DO by = 0, lb - bx
896 bz = lb - bx - by
897 ib = coset(bx, by, bz) - nb
898 cab(ia, ib) = fgsum(ax, bx)*fgsum(ay, by)*fgsum(az, bz)
899 END DO
900 END DO
901 END DO
902 END DO
903
904 c2sa => orbtramat(la)%c2s
905 c2sb => orbtramat(lb)%c2s
906 sab(1:nsa, 1:nsb) = matmul(c2sa(1:nsa, 1:nca), &
907 matmul(cab(1:nca, 1:ncb), transpose(c2sb(1:nsb, 1:ncb))))
908 ovol = 1._dp/(alat**3)
909 sab(1:nsa, 1:nsb) = ovol*sab(1:nsa, 1:nsb)
910
911 DEALLOCATE (cab, fun, gun, fexp, gexp, gval)
912
913 END SUBROUTINE overlap_ab_sp
914
915END MODULE ai_overlap
Coordinate and basis-center derivative ladders for Cartesian Gaussian integrals. Derivatives act on a...
subroutine, public cartesian_ladder_map(lmax, lmin, axis, map, source_lmin)
Construct base, raised, lowered and degree indices for a Cartesian ladder.
Calculation of the overlap integrals over Cartesian Gaussian-type functions.
Definition ai_overlap.F:18
subroutine, public overlap(la_max_set, la_min_set, npgfa, rpgfa, zeta, lb_max_set, lb_min_set, npgfb, rpgfb, zetb, rab, dab, sab, da_max_set, return_derivatives, s, lds)
Purpose: Calculation of the two-center overlap integrals [a|b] over Cartesian Gaussian-type functions...
Definition ai_overlap.F:75
subroutine, public overlap_ab_s(la, zeta, lb, zetb, rab, sab)
Calculation of the two-center overlap integrals [a|b] over Spherical Gaussian-type functions.
Definition ai_overlap.F:765
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:249
subroutine, public overlap_ab_sp(la, zeta, lb, zetb, alat, sab)
Calculation of the overlap integrals [a|b] over cubic periodic Spherical Gaussian-type functions.
Definition ai_overlap.F:813
subroutine, public overlap_aab(la1_max, la1_min, npgfa1, rpgfa1, zeta1, la2_max, la2_min, npgfa2, rpgfa2, zeta2, lb_max, lb_min, npgfb, rpgfb, zetb, rab, saab, daab, saba, daba)
Calculation of the two-center overlap integrals [aa|b] over Cartesian Gaussian-type functions.
Definition ai_overlap.F:444
subroutine, public overlap_abb(la_max, la_min, npgfa, rpgfa, zeta, lb1_max, lb1_min, npgfb1, rpgfb1, zetb1, lb2_max, lb2_min, npgfb2, rpgfb2, zetb2, rab, sabb, dabb)
Calculation of the two-center overlap integrals [a|bb] over Cartesian Gaussian-type functions.
Definition ai_overlap.F:622
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
complex(kind=dp), parameter, public z_one
real(kind=dp), parameter, public twopi
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :, :), allocatable, public coset
integer, dimension(:, :), allocatable, public indco
integer, dimension(:), allocatable, public nso
Calculation of the spherical harmonics and the corresponding orbital transformation matrices.
type(orbtramat_type), dimension(:), pointer, public orbtramat