(git:899a4fa)
Loading...
Searching...
No Matches
ai_elec_field.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 Coulomb integrals over Cartesian Gaussian-type functions
10!> (electron repulsion integrals, ERIs).
11!> \par Literature
12!> S. Obara and A. Saika, J. Chem. Phys. 84, 3963 (1986)
13!> \par History
14!> none
15!> \par Parameters
16!> - ax,ay,az : Angular momentum index numbers of orbital a.
17!> - bx,by,bz : Angular momentum index numbers of orbital b.
18!> - coset : Cartesian orbital set pointer.
19!> - dab : Distance between the atomic centers a and b.
20!> - dac : Distance between the atomic centers a and c.
21!> - dbc : Distance between the atomic centers b and c.
22!> - l{a,b,c} : Angular momentum quantum number of shell a, b or c.
23!> - l{a,b,c}_max: Maximum angular momentum quantum number of shell a, b or c.
24!> - l{a,b,c}_min: Minimum angular momentum quantum number of shell a, b or c.
25!> - ncoset : Number of orbitals in a Cartesian orbital set.
26!> - npgf{a,b} : Degree of contraction of shell a or b.
27!> - rab : Distance vector between the atomic centers a and b.
28!> - rab2 : Square of the distance between the atomic centers a and b.
29!> - rac : Distance vector between the atomic centers a and c.
30!> - rac2 : Square of the distance between the atomic centers a and c.
31!> - rbc : Distance vector between the atomic centers b and c.
32!> - rbc2 : Square of the distance between the atomic centers b and c.
33!> - rpgf{a,b,c} : Radius of the primitive Gaussian-type function a, b or c.
34!> - zet{a,b,c} : Exponents of the Gaussian-type functions a, b or c.
35!> - zetp : Reciprocal of the sum of the exponents of orbital a and b.
36!> \author VW
37! **************************************************************************************************
41 USE ai_os_rr, ONLY: os_rr_coul
42 USE kinds, ONLY: dp
43 USE mathconstants, ONLY: pi
44 USE orbital_pointers, ONLY: ncoset
45#include "../base/base_uses.f90"
46
47 IMPLICIT NONE
48 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ai_elec_field'
49 PRIVATE
50
51 ! *** Public subroutines ***
52
53 PUBLIC :: efg
54
55CONTAINS
56
57! **************************************************************************************************
58!> \brief Calculation of the primitive electric field integrals over
59!> Cartesian Gaussian-type functions.
60!> \param la_max ...
61!> \param la_min ...
62!> \param npgfa ...
63!> \param rpgfa ...
64!> \param zeta ...
65!> \param lb_max ...
66!> \param lb_min ...
67!> \param npgfb ...
68!> \param rpgfb ...
69!> \param zetb ...
70!> \param rac ...
71!> \param rbc ...
72!> \param rab ...
73!> \param vab ...
74!> \param ldrr1 ...
75!> \param ldrr2 ...
76!> \param rr ...
77!> \date 02.03.2009
78!> \author VW
79!> \version 1.0
80! **************************************************************************************************
81 SUBROUTINE efg(la_max, la_min, npgfa, rpgfa, zeta, &
82 lb_max, lb_min, npgfb, rpgfb, zetb, &
83 rac, rbc, rab, vab, ldrr1, ldrr2, rr)
84 INTEGER, INTENT(IN) :: la_max, la_min, npgfa
85 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfa, zeta
86 INTEGER, INTENT(IN) :: lb_max, lb_min, npgfb
87 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: rpgfb, zetb
88 REAL(kind=dp), DIMENSION(3), INTENT(IN) :: rac, rbc, rab
89 REAL(kind=dp), DIMENSION(:, :, :), INTENT(INOUT) :: vab
90 INTEGER, INTENT(IN) :: ldrr1, ldrr2
91 REAL(kind=dp), DIMENSION(0:ldrr1-1, ldrr2, *), &
92 INTENT(INOUT) :: rr
93
94 INTEGER, DIMENSION(2, 6), PARAMETER :: &
95 symmetric_components = reshape([1, 1, 1, 2, 1, 3, 2, 2, 2, 3, 3, 3], [2, 6])
96 INTEGER, DIMENSION(2, 9), PARAMETER :: &
97 mixed_components = reshape([1, 1, 2, 1, 3, 1, 1, 2, 2, 2, 3, 2, 1, 3, 2, 3, 3, 3], [2, 9])
98
99 INTEGER :: axis, first_a, first_b, i, icomp, idir, &
100 ipgf, j, jdir, jpgf, na, nb, ncap, &
101 ncbp, ncol, nrow
102 INTEGER, ALLOCATABLE :: map_a(:, :, :), map_ap(:, :, :), &
103 map_b(:, :, :), map_bp(:, :, :)
104 REAL(kind=dp) :: dab, f0, rab2, trace_third, xhi, za, zb, &
105 zet
106 REAL(kind=dp), ALLOCATABLE :: hessian(:, :, :), tensor(:, :, :), &
107 work(:, :)
108 REAL(kind=dp), DIMENSION(3) :: rap, rbp, rcp
109
110 first_a = ncoset(la_min - 1) + 1
111 first_b = ncoset(lb_min - 1) + 1
112 nrow = ncoset(la_max) - first_a + 1
113 ncol = ncoset(lb_max) - first_b + 1
114 ncap = ncoset(la_max + 1)
115 ncbp = ncoset(lb_max + 1)
116 ALLOCATE (map_a(4, nrow, 3), map_ap(4, ncap, 3), map_b(4, ncol, 3), map_bp(4, ncbp, 3))
117 ALLOCATE (hessian(nrow, ncol, 6), tensor(nrow, ncol, 9), work(ncap, ncbp))
118 DO axis = 1, 3
119 CALL cartesian_ladder_map(la_max, la_min, axis, map_a(:, :, axis), source_lmin=0)
120 CALL cartesian_ladder_map(la_max + 1, 0, axis, map_ap(:, :, axis))
121 CALL cartesian_ladder_map(lb_max, lb_min, axis, map_b(:, :, axis), source_lmin=0)
122 CALL cartesian_ladder_map(lb_max + 1, 0, axis, map_bp(:, :, axis))
123 END DO
124
125! *** Calculate the distance of the centers a and c ***
126
127 rab2 = rab(1)**2 + rab(2)**2 + rab(3)**2
128 dab = sqrt(rab2)
129
130 ! *** Loop over all pairs of primitive Gaussian-type functions ***
131
132 na = 0
133
134 DO ipgf = 1, npgfa
135
136 nb = 0
137
138 DO jpgf = 1, npgfb
139
140 ! *** Screening ***
141
142 IF (rpgfa(ipgf) + rpgfb(jpgf) < dab) THEN
143 DO j = nb + 1, nb + ncoset(lb_max)
144 DO i = na + 1, na + ncoset(la_max)
145 vab(i, j, 1) = 0.0_dp
146 vab(i, j, 2) = 0.0_dp
147 vab(i, j, 3) = 0.0_dp
148 vab(i, j, 4) = 0.0_dp
149 vab(i, j, 5) = 0.0_dp
150 vab(i, j, 6) = 0.0_dp
151 END DO
152 END DO
153 nb = nb + ncoset(lb_max)
154 cycle
155 END IF
156
157 ! *** Calculate some prefactors ***
158
159 za = zeta(ipgf)
160 zb = zetb(jpgf)
161 zet = za + zb
162 xhi = za*zb/zet
163 rap = zb*rab/zet
164 rbp = -za*rab/zet
165 rcp = -(za*rac + zb*rbc)/zet
166 f0 = 2.0_dp*sqrt(zet/pi)*(pi/zet)**(1.5_dp)*exp(-xhi*rab2)
167
168 ! *** Calculate the recurrence relation
169
170 CALL os_rr_coul(rap, la_max + 2, rbp, lb_max + 2, rcp, zet, ldrr1, ldrr2, rr)
171
172 ! Translational invariance gives D_C = -(D_A + D_B).
173 ! The A/B ladders differentiate the basis functions with the potential held fixed.
174 ! Form its Hessian from AA, BB and both ordered AB derivatives.
175 CALL apply_cartesian_operator_pair(rr(0, 1:ncoset(la_max + 2), first_b:ncoset(lb_max)), &
176 hessian, map_ap, map_a, symmetric_components, [.true., .true.], [za, za], &
177 [.false., .false.], work(:, 1:ncol))
178 CALL apply_cartesian_operator_pair(rr(0, first_a:ncoset(la_max), 1:ncoset(lb_max + 2)), &
179 tensor(:, :, 1:6), map_bp, map_b, symmetric_components, [.true., .true.], [zb, zb], &
180 [.true., .true.], work(1:nrow, :))
181 hessian(:, :, :) = hessian + tensor(:, :, 1:6)
182 CALL apply_cartesian_operator_pair(rr(0, 1:ncap, 1:ncbp), tensor, map_a, map_b, &
183 mixed_components, [.true., .true.], [za, zb], [.false., .true.], work(1:nrow, :))
184 DO icomp = 1, 6
185 idir = symmetric_components(1, icomp)
186 jdir = symmetric_components(2, icomp)
187 hessian(:, :, icomp) = hessian(:, :, icomp) + &
188 tensor(:, :, idir + 3*(jdir - 1)) + tensor(:, :, jdir + 3*(idir - 1))
189 END DO
190
191 ! Preserve the symmetric, traceless EFG ordering: xx, xy, xz, yy, yz, zz.
192 DO j = 1, ncol
193 DO i = 1, nrow
194 trace_third = (hessian(i, j, 1) + hessian(i, j, 4) + hessian(i, j, 6))/3.0_dp
195 hessian(i, j, 1) = hessian(i, j, 1) - trace_third
196 hessian(i, j, 4) = hessian(i, j, 4) - trace_third
197 hessian(i, j, 6) = hessian(i, j, 6) - trace_third
198 END DO
199 END DO
200 vab(na + first_a:na + ncoset(la_max), nb + first_b:nb + ncoset(lb_max), 1:6) = f0*hessian
201
202 nb = nb + ncoset(lb_max)
203
204 END DO
205
206 na = na + ncoset(la_max)
207
208 END DO
209
210 END SUBROUTINE efg
211
212END MODULE ai_elec_field
struct tensor_ tensor
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 Coulomb integrals over Cartesian Gaussian-type functions (electron repulsion integrals...
subroutine, public efg(la_max, la_min, npgfa, rpgfa, zeta, lb_max, lb_min, npgfb, rpgfb, zetb, rac, rbc, rab, vab, ldrr1, ldrr2, rr)
Calculation of the primitive electric field integrals over Cartesian Gaussian-type functions.
subroutine, public os_rr_coul(rap, la_max, rbp, lb_max, rcp, zet, ldrr1, ldrr2, rr)
Calculation of the Obara-Saika recurrence relation for 1/r_C.
Definition ai_os_rr.F:519
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
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset