forked from ferchault/APHF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrals.py
908 lines (755 loc) · 27.3 KB
/
integrals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
"""
Copyright (C) 2015 Rocco Meli, 2021 Guido Falk von Rudorff
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import numpy as np
import scipy.misc as misc
import scipy.special as spec
import scipy.integrate as quad
import mpmath
import multiprocessing as mp
import os
import functools
import tqdm
import itertools as it
from basis import *
@functools.lru_cache(maxsize=1000)
def cached_factorial(n, exact=True):
return spec.factorial(n, exact)
@functools.lru_cache(maxsize=1000)
def cached_factorial2(n, exact=True):
return spec.factorial2(n, exact)
misc.factorial2 = cached_factorial2
misc.comb = spec.comb
misc.factorial = cached_factorial
def gaussian_product(aa, bb, Ra, Rb):
"""
Gaussian produc theorem.
INPUT:
AA: Exponential coefficient of Gaussian 1
BB: Exponential coefficient of Gaussian 2
RA: Center of Gaussian 1
RB: Center of Gaussian 2
OUTPUT:
R: Gaussian product center
C: Gaussian product coefficient
Source:
Modern Quantum Chemistry
Szabo and Ostlund
Dover
1989
"""
# Transform centers in Numpy arrays
Ra = np.asarray(Ra)
Rb = np.asarray(Rb)
# Compute Gaussian product center
q = aa + bb
R = (aa * Ra + bb * Rb) / q
# Compute Gaussian product coefficient
d = Ra - Rb
c = np.dot(d, d)
c *= -aa * bb / q
c = np.vectorize(mpmath.mp.exp)(c)
return R, c
@functools.lru_cache(maxsize=1000)
def norm(ax, ay, az, aa):
"""
General cartesian Gaussian normalization factor.
INPUT:
AX: Angular momentum lx
AY: Angular momentum ly
AZ: Angular momentum lz
AA: Gaussian exponential coefficient
OUTPUT:
N: Normalization coefficient (to be multiplied with the Gaussian)
Source:
Handbook of Computational Chemistry
David Cook
Oxford University Press
1998
"""
# Compute normalization coefficient
N = (2 * aa / mpmath.mp.pi) ** (mpmath.mp.mpf("3.0") / mpmath.mp.mpf("4.0"))
N *= (4 * aa) ** ((ax + ay + az) / mpmath.mp.mpf("2.0"))
N /= mpmath.mp.sqrt(
misc.factorial2(2 * ax - 1)
* misc.factorial2(2 * ay - 1)
* misc.factorial2(2 * az - 1)
)
return N
def Sxyz(a, b, aa, bb, Ra, Rb, R):
"""
Compute overlap integral between two unnormalized Cartesian gaussian functions along one direction.
INPUT:
A: Angular momentum along the chosen direction for Gaussian 1
B: Angular momentum along the chosen direction for Gaussian 2
AA: Exponential coefficient for Gaussian 1
BB: Exponential coefficient for Gaussian 2
RA: Coordinate (along chosen direction) of the center of Gaussian 1
RB: Coordinate (along chosen direction) of the center of Gaussian 2
R: Coordinate (along chosen direction) of the center of the product of the two gaussians
OUTPUT:
S: Overlap of the two gaussians along the chosen direction
Source:
The Mathematica Journal
Evaluation of Gaussian Molecular Integrals
I. Overlap Integrals
Minhhuy Hô and Julio Manuel Hernández-Pérez
"""
S = mpmath.mp.mpf("0.0")
for i in range(a + 1):
for j in range(b + 1):
if (i + j) % 2 == 0:
tmp = misc.comb(a, i, exact=True)
tmp *= misc.comb(b, j, exact=True)
tmp *= misc.factorial2(i + j - 1, exact=True)
tmp /= (mpmath.mp.mpf("2.0") * (aa + bb)) ** (
(i + j) / mpmath.mp.mpf("2.0")
)
tmp *= (R - Ra) ** (a - i)
tmp *= (R - Rb) ** (b - j)
S += tmp
return S
def overlap(ax, ay, az, bx, by, bz, aa, bb, Ra, Rb):
"""
Compute overlap integral between two Cartesian gaussian functions.
INPUT:
AX: Angular momentum lx for Gaussian 1
AY: Angular momentum ly for Gaussian 1
AZ: Angular momentum lz for Gaussian 1
AA: Exponential coefficient for Gaussian 1
BX: Angular momentum lx for Gaussian 2
BY: Angular momentum ly for Gaussian 2
BZ: Angular momentum lz for Gaussian 2
BB: Exponential coefficient for Gaussian 2
RA: Center of Gaussian 1
RB: Center of Gaussian 2
OUTPUT:
S: Overlap of the two gaussians
Source:
The Mathematica Journal
Evaluation of Gaussian Molecular Integrals
I. Overlap Integrals
Minhhuy Hô and Julio Manuel Hernández-Pérez
"""
# Compute gaussian product center and coefficient
R, c = gaussian_product(aa, bb, Ra, Rb)
# Compute normalization factors for the two gaussians
Na = norm(ax, ay, az, aa)
Nb = norm(bx, by, bz, bb)
S = 1
S *= Sxyz(ax, bx, aa, bb, Ra[0], Rb[0], R[0]) # Overlap along x
S *= Sxyz(ay, by, aa, bb, Ra[1], Rb[1], R[1]) # Overlap along y
S *= Sxyz(az, bz, aa, bb, Ra[2], Rb[2], R[2]) # Overlap along z
S *= Na * Nb * c # Product coefficient and normalization
S *= (mpmath.mp.pi / (aa + bb)) ** (
mpmath.mp.mpf("3.0") / mpmath.mp.mpf("2.0")
) # Normalization
return S
def kinetic(ax, ay, az, bx, by, bz, aa, bb, Ra, Rb):
"""
Compute kinetic integral between two Cartesian gaussian functions.
INPUT:
AX: Angular momentum lx for Gaussian 1
AY: Angular momentum ly for Gaussian 1
AZ: Angular momentum lz for Gaussian 1
AA: Exponential coefficient for Gaussian 1
BX: Angular momentum lx for Gaussian 2
BY: Angular momentum ly for Gaussian 2
BZ: Angular momentum lz for Gaussian 2
BB: Exponential coefficient for Gaussian 2
RA: Center of Gaussian 1
RB: Center of Gaussian 2
OUTPUT:
K: Kinetic integral between the two gaussians
Source:
The Mathematica Journal
Evaluation of Gaussian Molecular Integrals
II. Kinetic-Energy Integrals
Minhhuy Hô and Julio Manuel Hernández-Pérez
"""
R, c = gaussian_product(aa, bb, Ra, Rb)
def Kxyz(ac, a1, a2, bc, b1, b2, aa, bb, Ra, Rb, Ra1, Rb1, Ra2, Rb2, Rc, R1, R2):
"""
Compute kinetic integral between two Cartesian gaussian functions along one direction.
INPUT:
AC: Component of angular momentum for Gaussian 1 along direction of interest
A1: Component of angular momentum for Gaussian 1 along second direction
A2: Component of angular momentum for Gaussian 1 along third direction
BC: Component of angular momentum for Gaussian 2 along direction of interest
B1: Component of angular momentum for Gaussian 2 along second direction
B2: Component of angular momentum for Gaussian 2 along third direction
AA: Exponential coefficient for Gaussian 1
BB: Exponential coefficient for Gaussian 2
RA: Component of the center of Gaussian 1 along direction of interest
RB: Component of the center of Gaussian 2 along direction of interest
RA1: Component of the center of Gaussian 1 along second direction
RA2: Component of the center of Gaussian 1 along third direction
RB1: Component of the center of Gaussian 2 along second direction
RB2: Component of the center of Gaussian 2 along third direction
OUTPUT:
KC: Kinetic integral between two gaussians along chosen direction
Source:
The Mathematica Journal
Evaluation of Gaussian Molecular Integrals
II. Kinetic-Energy Integrals
Minhhuy Hô and Julio Manuel Hernández-Pérez
"""
kc = mpmath.mp.mpf("0.0")
kc += ac * bc * Sxyz(ac - 1, bc - 1, aa, bb, Ra, Rb, Rc)
kc += -2 * aa * bc * Sxyz(ac + 1, bc - 1, aa, bb, Ra, Rb, Rc)
kc += -2 * ac * bb * Sxyz(ac - 1, bc + 1, aa, bb, Ra, Rb, Rc)
kc += 4 * aa * bb * Sxyz(ac + 1, bc + 1, aa, bb, Ra, Rb, Rc)
kc *= mpmath.mp.mpf("0.5")
Kc = 1
Kc *= (
c
* (mpmath.mp.pi / (aa + bb))
** (mpmath.mp.mpf("3.0") / mpmath.mp.mpf("2.0"))
* kc
)
Kc *= Sxyz(a1, b1, aa, bb, Ra1, Rb1, R1)
Kc *= Sxyz(a2, b2, aa, bb, Ra2, Rb2, R2)
return Kc
# Cyclic permutation of the entries
Kx = Kxyz(
ax,
ay,
az,
bx,
by,
bz,
aa,
bb,
Ra[0],
Rb[0],
Ra[1],
Rb[1],
Ra[2],
Rb[2],
R[0],
R[1],
R[2],
) # Kinetic integral along x
Ky = Kxyz(
ay,
az,
ax,
by,
bz,
bx,
aa,
bb,
Ra[1],
Rb[1],
Ra[2],
Rb[2],
Ra[0],
Rb[0],
R[1],
R[2],
R[0],
) # Kinetic integral along y
Kz = Kxyz(
az,
ax,
ay,
bz,
bx,
by,
aa,
bb,
Ra[2],
Rb[2],
Ra[0],
Rb[0],
Ra[1],
Rb[1],
R[2],
R[0],
R[1],
) # Kinetic integral along z
Na = norm(ax, ay, az, aa) # Normalization factor for Gaussian 1
Nb = norm(bx, by, bz, bb) # Normalization factor for Gaussian 2
K = (Kx + Ky + Kz) * Na * Nb # Normalization of total kinetic energy integral
return K
def f(j, l, m, a, b):
"""
Expansion coefficient f.
Source:
Handbook of Computational Chemistry
David Cook
Oxford University Press
1998
"""
f = 0
for k in range(max(0, j - m), min(j, l) + 1):
tmp = 1
tmp *= spec.comb(l, k, exact=True)
tmp *= spec.comb(m, j - k, exact=True)
tmp *= a ** (l - k)
tmp *= b ** (m + k - j)
f += tmp
return f
ONEHALF = mpmath.mp.mpf("0.5")
ZERO = mpmath.mp.mpf("0.0")
ONE = mpmath.mp.mpf("1.0")
def F(nu, x):
"""
Boys function.
INPUT:
NU: Boys function index
X: Boys function variable
OUTPUT:
FF: Value of the Boys function for index NU evaluated at X
Source:
Evaluation of the Boys Function using Analytical Relations
I. I. Guseinov and B. A. Mamedov
Journal of Mathematical Chemistry
2006
"""
if x == ZERO: # x < 1e-8:
# Taylor expansion for argument close or equal to zero (avoid division by zero)
ff = ONE / (2 * nu + 1)
else:
# Evaluate Boys function with incomplete and complete Gamma functions
ff = (
ONEHALF
/ x ** (nu + ONEHALF)
* mpmath.gamma(nu + 0.5)
* mpmath.gammainc(nu + 0.5, 0, x, regularized=True)
)
return ff
def nuclear(ax, ay, az, bx, by, bz, aa, bb, Ra, Rb, Rn, Zn):
"""
Compute nuclear-electron interaction integrals.
INPUT:
AX,AY,AZ: Angular momentum components for the first Gaussian.
BX,BY,BZ: Angular momentum components for the second Gaussian.
AA: Exponential coefficient for the first Gaussian.
BB: Exponential coefficient for the second Gaussian.
RA: Center of the first Gaussian.
RB: Center of the second Gaussian.
RN: Nuclear coordinates.
ZN: Nuclear charge.
Source:
Handbook of Computational Chemistry
David Cook
Oxford University Press
1998
"""
Vn = ZERO
# Intermediate variable
g = aa + bb
eps = ONE / (4 * g)
Rp, c = gaussian_product(aa, bb, Ra, Rb) # Gaussian product
def A(l, r, i, l1, l2, Ra, Rb, Rc, Rp):
"""
Expansion coefficient A.
Source:
Handbook of Computational Chemistry
David Cook
Oxford University Press
1998
"""
A = 1
A *= (-1) ** (l)
A *= f(l, l1, l2, Rp - Ra, Rp - Rb)
A *= (-1) ** i
A *= misc.factorial(l, exact=True)
A *= (Rp - Rc) ** (l - 2 * r - 2 * i)
A *= eps ** (r + i)
A /= misc.factorial(r, exact=True)
A /= misc.factorial(i, exact=True)
A /= misc.factorial(l - 2 * r - 2 * i, exact=True)
return A
for l in range(0, ax + bx + 1):
for r in range(0, int(l / 2) + 1):
for i in range(0, int((l - 2 * r) / 2) + 1):
Ax = A(l, r, i, ax, bx, Ra[0], Rb[0], Rn[0], Rp[0])
for m in range(0, ay + by + 1):
for s in range(0, int(m / 2) + 1):
for j in range(0, int((m - 2 * s) / 2) + 1):
Ay = A(m, s, j, ay, by, Ra[1], Rb[1], Rn[1], Rp[1])
for n in range(0, az + bz + 1):
for t in range(0, int(n / 2) + 1):
for k in range(0, int((n - 2 * t) / 2) + 1):
Az = A(
n, t, k, az, bz, Ra[2], Rb[2], Rn[2], Rp[2]
)
nu = (
l + m + n - 2 * (r + s + t) - (i + j + k)
) # Index of Boys function
ff = F(
nu, g * np.dot(Rp - Rn, Rp - Rn)
) # Boys function
Vn += Ax * Ay * Az * ff
# Compute normalization
Na = norm(ax, ay, az, aa)
Nb = norm(bx, by, bz, bb)
Vn *= -Zn * Na * Nb * c * 2 * mpmath.mp.pi / g
return Vn
def electronic(
ax,
ay,
az,
bx,
by,
bz,
cx,
cy,
cz,
dx,
dy,
dz,
aa,
bb,
cc,
dd,
Ra,
Rb,
Rc,
Rd,
Rp,
c1,
Rq,
c2,
):
"""
Compute electron-electron interaction integrals.
INPUT:
AX,AY,AZ: Angular momentum components for the first Gaussian.
BX,BY,BZ: Angular momentum components for the second Gaussian.
CX,CY,CZ: Angular momentum components for the third Gaussian.
DX,DY,DZ: Angular momentum components for the fourth Gaussian.
AA: Exponential coefficient for the first Gaussian.
BB: Exponential coefficient for the second Gaussian.
CC: Exponential coefficient for the third Gaussian.
DD: Exponential coefficient for the fourth Gaussian.
RA: Center of the first Gaussian.
RB: Center of the second Gaussian.
RC: Center of the third Gaussian.
RD: Center of the fourth Gaussian.
OUTPUT:
G: Electron-electron integral
Source:
Handbook of Computational Chemistry
David Cook
Oxford University Press
1998
ERRATA (the original formula is WRONG)!
http://spider.shef.ac.uk/
"""
G = ZERO
# Intermediate variable
g1 = aa + bb
g2 = cc + dd
# Compute gaussian products
delta = ONE / (4 * g1) + ONE / (4 * g2)
_q = np.dot(Rp - Rq, Rp - Rq) / (4 * delta)
def theta(l, l1, l2, a, b, r, g):
"""
Expansion coefficient theta.
Source:
Handbook of Computational Chemistry
David Cook
Oxford University Press
1998
"""
t = f(l, l1, l2, a, b)
t *= misc.factorial(l, exact=True)
t *= g ** (r - l)
t /= misc.factorial(r, exact=True) * misc.factorial(l - 2 * r, exact=True)
return t
def B(l, ll, r, rr, i, l1, l2, Ra, Rb, Rp, g1, l3, l4, Rc, Rd, Rq, g2):
"""
Expansion coefficient B.
Source:
Handbook of Computational Chemistry
David Cook
Oxford University Press
1998
"""
b = (-1) ** (l) * theta(l, l1, l2, Rp - Ra, Rp - Rb, r, g1)
b *= theta(ll, l3, l4, Rq - Rc, Rq - Rd, rr, g2)
b *= (-1) ** i * (2 * delta) ** (2 * (r + rr))
b *= misc.factorial(l + ll - 2 * r - 2 * rr, exact=True)
b *= delta ** i * (Rp - Rq) ** (l + ll - 2 * (r + rr + i))
tmp = 1
tmp *= (4 * delta) ** (l + ll) * misc.factorial(i, exact=True)
tmp *= misc.factorial(l + ll - 2 * (r + rr + i), exact=True)
b /= tmp
return b
@functools.lru_cache(maxsize=10000)
def _ff(nu):
return F(
nu,
_q,
)
for l in range(0, ax + bx + 1):
for r in range(0, int(l / 2) + 1):
for ll in range(0, cx + dx + 1):
for rr in range(0, int(ll / 2) + 1):
for i in range(0, int((l + ll - 2 * r - 2 * rr) / 2) + 1):
Bx = B(
l,
ll,
r,
rr,
i,
ax,
bx,
Ra[0],
Rb[0],
Rp[0],
g1,
cx,
dx,
Rc[0],
Rd[0],
Rq[0],
g2,
)
for m in range(0, ay + by + 1):
for s in range(0, int(m / 2) + 1):
for mm in range(0, cy + dy + 1):
for ss in range(0, int(mm / 2) + 1):
for j in range(
0, int((m + mm - 2 * s - 2 * ss) / 2) + 1
):
By = B(
m,
mm,
s,
ss,
j,
ay,
by,
Ra[1],
Rb[1],
Rp[1],
g1,
cy,
dy,
Rc[1],
Rd[1],
Rq[1],
g2,
)
for n in range(0, az + bz + 1):
for t in range(0, int(n / 2) + 1):
for nn in range(0, cz + dz + 1):
for tt in range(
0, int(nn / 2) + 1
):
for k in range(
0,
int(
(
n
+ nn
- 2 * t
- 2 * tt
)
/ 2
)
+ 1,
):
Bz = B(
n,
nn,
t,
tt,
k,
az,
bz,
Ra[2],
Rb[2],
Rp[2],
g1,
cz,
dz,
Rc[2],
Rd[2],
Rq[2],
g2,
)
nu = (
l
+ ll
+ m
+ mm
+ n
+ nn
- 2
* (
r
+ rr
+ s
+ ss
+ t
+ tt
)
- (i + j + k)
)
ff = _ff(nu)
G += Bx * By * Bz * ff
# Compute normalization
Na = norm(ax, ay, az, aa)
Nb = norm(bx, by, bz, bb)
Nc = norm(cx, cy, cz, cc)
Nd = norm(dx, dy, dz, dd)
G *= (
Na
* Nb
* Nc
* Nd
* c1
* c2
* 2
* mpmath.mp.pi ** 2
/ (g1 * g2)
* mpmath.mp.sqrt(mpmath.mp.pi / (g1 + g2))
)
return G
def EE_list(basis, single_core):
"""
Multidimensional array of two-electron integrals.
INPUT:
BASIS: Basis set
OUTPUT:
EE: list of two-electron integrals, with indices (i,j,k,l)
"""
# List of basis functions
B = basis.basis()
combos = [_ for _ in enumerate(B)]
if single_core:
results = [
do_one((mpmath.mp.dps, *_))
for _ in tqdm.tqdm(it.product(combos, repeat=4), total=len(combos) ** 4)
]
else:
with mp.Pool(os.cpu_count()) as pool:
results = list(
tqdm.tqdm(
pool.imap(
do_one,
[(mpmath.mp.dps, *_) for _ in it.product(combos, repeat=4)],
),
total=len(combos) ** 4,
desc="2e integrals",
)
)
return results
def do_one(parts):
"""
Multidimensional array of two-electron integrals.
INPUT:
BASIS: Basis set
OUTPUT:
EE: list of two-electron integrals, with indices (i,j,k,l)
"""
dps, p, q, r, s = parts
mpmath.mp.dps = dps
i, b1 = p
j, b2 = q
k, b3 = r
l, b4 = s
ret = ZERO
# Basis functions centers
R1 = b1["R"]
R2 = b2["R"]
R3 = b3["R"]
R4 = b4["R"]
# Basis functions angular momenta
ax = b1["lx"]
ay = b1["ly"]
az = b1["lz"]
bx = b2["lx"]
by = b2["ly"]
bz = b2["lz"]
cx = b3["lx"]
cy = b3["ly"]
cz = b3["lz"]
dx = b4["lx"]
dy = b4["ly"]
dz = b4["lz"]
for a1, d1 in zip(b1["a"], b1["d"]):
for a2, d2 in zip(b2["a"], b2["d"]):
Rp, c1 = gaussian_product(a1, a2, R1, R2)
qq = d1.conjugate() * d2.conjugate()
for a3, d3 in zip(b3["a"], b3["d"]):
qqq = qq * d3
for a4, d4 in zip(b4["a"], b4["d"]):
tmp = qqq * d4
Rq, c2 = gaussian_product(a3, a4, R3, R4)
tmp *= electronic(
ax,
ay,
az,
bx,
by,
bz,
cx,
cy,
cz,
dx,
dy,
dz,
a1,
a2,
a3,
a4,
R1,
R2,
R3,
R4,
Rp,
c1,
Rq,
c2,
)
ret += tmp
return i, j, k, l, ret
def print_EE_list(ee):
"""
Print list of electron-electron integrals.
INPUT:
EE: list of electron-electron integrals (computed by EE_LIST function)
"""
K = ee.shape[0]
for i in range(K):
for j in range(K):
for k in range(K):
for l in range(K):
print(
"({0},{1},{2},{3}) {4}".format(
i + 1, j + 1, k + 1, l + 1, ee[i, j, k, l]
)
)
if __name__ == "__main__":
"""
Results compared with
Modern Quantum Chemistry
Szabo and Ostlund
Dover
1989
"""
# System: HeH+
HeH = [Atom("He", (0, 0, 1.4632), 2, ["1s"]), Atom("H", (0, 0, 0), 1, ["1s"])]
sto3g_HeH = STO3G(HeH) # Create basis set
ee_HeH = EE_list(sto3g_HeH) # Compute electron-electron integrals for HeH+
print("######################")
print("Two electron integrals")
print("######################")
print("\n HeH")
print_EE_list(ee_HeH) # Print electron-electron integrals