-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInt2e.f90
1895 lines (1887 loc) · 87.5 KB
/
Int2e.f90
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
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! int2e.f90 !!!!
!!!! This file calculats the general two electron intgral. !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!1. ERINT
!description: subroutine
! Calculat the general overlap intgral, Kinetic intgral and Nuclear
! attraction intgral of shell.
! input: (1) katom integer(natom)
! Z of atoms
! (2)coor double precision(natom,3)
! (coordinates of atom )
! (3) ntype integer(nshell)
! (ntype is type of gauss function for all shells)
! (S=1,P=2,D=3,F=4,G=5,H=6,I=7)
! (4) ngf integer(nshell)
! (The gauss function number of all shells)
! (5) gfc double precision(ngfsum)
! (gfc is coefficient of primitive gauss functions)
! ngfsum=SUM(ngf(:))
! (6) gfe double precision(ngfsum)
! (gfc is orbital exponent of primitive gauss functions)
! output: (1) S double precision
! (2) T double precision
! (3) V double precision
!2. recERI1(m,nax,nay,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,
! ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,Px,Qx,Ay,By,Cy,Dy,Py,
! Qy,Az,Bz,Cz,Dz,Pz,Qz,T) result(tem)
!description: recursive function
! Calculat the ERI <ac|1/r12|bd>(m).
! use DPK method
! ref:F W.Chen,Computational Methods in Quantum Chemistry
! input: (1) m integer
! (m=0,<ac|1/r12|bd>)
! (2) nax,nay,naz integer
! (3) nbx,nby,nbz integer
! (4) ncx,ncy,ncz integer
! (5) ndx,ndy,ndz integer
! (2),(3),(4),(5) gauss function parameter
! (6) ep double precision
! (7) eq double precision
! (8) ABK double precision
! ABK=K_{AB}
! (9) CDK double precision
! CDK=K_{CD}
! (10) Ax,Ay,Az double precision
! (11) Bx,By,Bz double precision
! (12) Cx,Cy,Cz double precision
! (13) Dx,Dy,Dz double precision
! (10),(11),(12),(13) Coordinates of center a,b,c,d
! (14) Px,Py,Pz double precision
! P is the new center after combining A,B.
! (15) Qx,Qy,Qz double precision
! Q is the new center after combining C,D.
! (16) T double precision
! T=(ea*eb)/(ea+eb)*((Px-Qx)^2+(Py-Qy)^2+(Pz-Qz)^2)
! output: (1) result double precision
!3. recERI2(m,nax,nay,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,
! ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,Px,Qx,Ay,By,Cy,Dy,Py,
! Qy,Az,Bz,Cz,Dz,Pz,Qz,T) result(tem)
!description: recursive function
! Calculat the ERI <ac|1/r12|bd>(m).
! use S.Obara;A.saika method
! ref:F W.Chen,Computational Methods in Quantum Chemistry
! input: (1) m integer
! (m=0,<ac|1/r12|bd>)
! (2) nax,nay,naz integer
! (3) nbx,nby,nbz integer
! (4) ncx,ncy,ncz integer
! (5) ndx,ndy,ndz integer
! (2),(3),(4),(5) gauss function parameter
! (6) ep double precision
! (7) eq double precision
! (8) ABK double precision
! ABK=K_{AB}
! (9) CDK double precision
! CDK=K_{CD}
! (10) Ax,Ay,Az double precision
! (11) Bx,By,Bz double precision
! (12) Cx,Cy,Cz double precision
! (13) Dx,Dy,Dz double precision
! (10),(11),(12),(13) Coordinates of center a,b,c,d
! (14) Px,Py,Pz double precision
! P is the new center after combining A,B.
! (15) Qx,Qy,Qz double precision
! Q is the new center after combining C,D.
! (16) T double precision
! T=(ea*eb)/(ea+eb)*((Px-Qx)^2+(Py-Qy)^2+(Pz-Qz)^2)
! output: (1) result double precision
!4. anaERI1(nax,nay,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,
! ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,Px,Qx,Ay,By,Cy,Dy,Py,
! Qy,Az,Bz,Cz,Dz,Pz,Qz,T) result(tem)
!description: function
! Calculat the ERI <ac|1/r12|bd>(m).
! use (Analytical method) O.Ohata method
! ref:F W.Chen,Computational Methods in Quantum Chemistry
! input:
! (1) nax,nay,naz integer
! (2) nbx,nby,nbz integer
! (3) ncx,ncy,ncz integer
! (4) ndx,ndy,ndz integer
! (1),(2),(3),(4) gauss function parameter
! (5) ep double precision
! (6) eq double precision
! (7) ABK double precision
! ABK=K_{AB}
! (8) CDK double precision
! CDK=K_{CD}
! (9) Ax,Ay,Az double precision
! (10) Bx,By,Bz double precision
! (11) Cx,Cy,Cz double precision
! (12) Dx,Dy,Dz double precision
! (9),(10),(11),(12) Coordinates of center a,b,c,d
! (13) Px,Py,Pz double precision
! P is the new center after combining A,B.
! (14) Qx,Qy,Qz double precision
! Q is the new center after combining C,D.
! (15) T double precision
! T=(ea*eb)/(ea+eb)*((Px-Qx)^2+(Py-Qy)^2+(Pz-Qz)^2)
! output: (1) result double precision
!5. BFanaERI1
!description: function
! BFanaERI1 is a part of anaERI1.
!6. recERIfast
!description: function
! recERIfast is the efficient version of recERI1.
!7. recERI1xyz
!description: function
! recERI1xyz is a part of recERIfast.
!======================================================================!
Module Int2e
contains
subroutine ERINT(nshell,nbasis,natom,coor,neri,&
kcenter,gfc,gfe,ntype,ngf,ngfall,&
kbasst,kbased,knbas,kpgfst,&
kpgfed,naxyz,ERIall,methodERI)
use Global
implicit double precision (A-H,O-Z)
Integer*16 neri
dimension::kbasst(nshell),kbased(nshell),knbas(nshell),&
kpgfst(nshell),kpgfed(nshell),naxyz(3*nbasis),&
ERIall(neri),coor(natom,3)
dimension::kcenter(nshell),gfc(ngfall),gfe(ngfall),ntype(nshell),ngf(nshell)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!=================================================================!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!! SHELL !!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
write(*,*)'*** Computing two electron intgral ***'
write(*,*)'neri=',neri !! number of stored ERI
nsize=neri*8
write(*,*)'The storage space of storing ERI requires approximately '
write(*,*) 'size',nsize,'B',nsize/1024**1d0,'Kb',nsize/1024**2d0,'Mb',nsize/1024**3d0,'Gb'
keri=1
do Ish=1,nshell ! I shell
Iatom=kcenter(Ish)
cix=coor(Iatom,1)
ciy=coor(Iatom,2)
ciz=coor(Iatom,3)
do Jsh=1,Ish ! J shell
! do Jsh=1,nshell ! J shell
Jatom=kcenter(Jsh)
cJx=coor(Jatom,1)
cJy=coor(Jatom,2)
cJz=coor(Jatom,3)
Rij=(cix-cjx)**2+(ciy-cjy)**2+(ciz-cjz)**2
do ksh=1,Ish ! K shell
kkatom=kcenter(Ksh)
ckx=coor(Kkatom,1)
cky=coor(Kkatom,2)
ckz=coor(Kkatom,3)
do Lsh=1,ksh ! L shell
latom=kcenter(lsh)
clx=coor(latom,1)
cly=coor(latom,2)
clz=coor(latom,3)
Rkl=(ckx-clx)**2+(cky-cly)**2+(ckz-clz)**2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!! BASIS FUNCTION !!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do ibas=kbasst(ish),kbased(ish)
nax=naxyz(ibas)
nay=naxyz(ibas+nbasis)
naz=naxyz(ibas+2*nbasis)
jbased=kbased(jsh)
ipgfst=kpgfst(ish)
ipgfed=kpgfed(ish)
!!!!! only for sp shell
if(ntype(ish)==12)then
if(nax+nay+naz==0) then
ipgfed=kpgfed(ish)-ngf(ish)/2
else
ipgfst=kpgfst(ish)+ngf(ish)/2
end if
end if
do jbas=kbasst(jsh),jbased
if(ibas<jbas) cycle
nbx=naxyz(jbas)
nby=naxyz(jbas+nbasis)
nbz=naxyz(jbas+2*nbasis)
jpgfst=kpgfst(jsh)
jpgfed=kpgfed(jsh)
!!!!! only for sp shell
if(ntype(jsh)==12)then
if(nbx+nby+nbz==0)then
jpgfed=kpgfed(jsh)-ngf(jsh)/2
else
jpgfst=kpgfst(jsh)+ngf(jsh)/2
end if
end if
do kbas=kbasst(ksh),kbased(ksh)
ncx=naxyz(kbas)
ncy=naxyz(kbas+nbasis)
ncz=naxyz(kbas+2*nbasis)
lbased=kbased(lsh)
kkpgfst=kpgfst(ksh)
kkpgfed=kpgfed(ksh)
!!!!! only for sp shell
if(ntype(ksh)==12)then
if(ncx+ncy+ncz==0) then
kkpgfed=kpgfed(ksh)-ngf(ksh)/2
else
kkpgfst=kpgfst(ksh)+ngf(ksh)/2
end if
end if
do lbas=kbasst(lsh),lbased
ndx=naxyz(lbas)
ndy=naxyz(lbas+nbasis)
ndz=naxyz(lbas+2*nbasis)
lpgfst=kpgfst(lsh)
lpgfed=kpgfed(lsh)
!!!!! only for sp shell
if(ntype(lsh)==12)then
if(ndx+ndy+ndz==0) then
lpgfed=kpgfed(lsh)-ngf(lsh)/2
else
lpgfst=kpgfst(lsh)+ngf(lsh)/2
end if
end if
ij=ibas*(ibas+1)/2+Jbas
kl=kbas*(kbas+1)/2+lbas
if(ibas<jbas .or.kbas<lbas .or.ij<kl) cycle
eri=0d0
eri1=0d0
eri2=0d0
eri3=0d0
eri4=0d0
!!!!!!!!!!!!!!! <ac|bd>=(ab|cd)
!!! primitive gauss functions (a|
do ipgf=ipgfst,ipgfed
ea=gfe(ipgf)
ca=gfc(ipgf)
dNa=(2*ea/pi)**0.75*((4*ea)**(nax+nay+naz)&
/(Dfact(2*nax-1)*Dfact(2*nay-1)*Dfact(2*naz-1)))**0.5
!!! primitive gauss functions (b|
do jpgf=jpgfst,jpgfed
eb=gfe(jpgf)
cb=gfc(jpgf)
ep=ea+eb
ep1=1d0/ep
ABK=exp(-ea*eb*ep1*Rij)
PX=ep1*(ea*cix+eb*cjx)
PY=ep1*(ea*ciy+eb*cjy)
PZ=ep1*(ea*ciz+eb*cjz)
if(abs(Rij)<1D-15) then
ABK=1d0
PX=cix
PY=ciy
PZ=ciz
end if
dNb=(2*eb/pi)**0.75*((4*eb)**(nbx+nby+nbz)&
/(Dfact(2*nbx-1)*Dfact(2*nby-1)*Dfact(2*nbz-1)))**0.5
!!! primitive gauss funct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,Qzz,TT)
else if(methodERI==2)then
!!!!!!!!!!!!! Recursive method 2
!!!!!!! S.Obara;A.saika The Journal of Chemical Physics 84, 3963 (1986);
!!!!! doi: 10.1063/1.450106
methodERI=2
eri=eri+ca*cb*cc*cd*dNa*dNb*dNc*dNd*recERI2(0,naxx,nayy,nazz,&
nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Pxx,Qxx,Ayy,Byy,Cyy,Dyy,Pyy,&
Qyy,Azz,Bzz,Czz,Dzz,Pzz,Qzz,TT)
else if(methodERI==3)then
!!!!!!! 3.(Analytical method) O.Ohata method (1966)
!!!! https://doi.org/10.1143/JPSJ.21.2313
methodERI=3
eri=eri+ca*cb*cc*cd*dNa*dNb*dNc*dNd&
*anaERI1(naxx,nayy,nazz,nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Pxx,Qxx,Ayy,Byy,Cyy,Dyy,Pyy,&
Qyy,Azz,Bzz,Czz,Dzz,Pzz,Qzz,TT)
else if(methodERI==4)then
!!!!! fast method
methodERI=4
eri=eri+ca*cb*cc*cd*dNa*dNb*dNc*dNd&
*recERIfast(naxx,nayy,nazz,nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Pxx,Qxx,Ayy,Byy,Cyy,Dyy,Pyy,&
Qyy,Azz,Bzz,Czz,Dzz,Pzz,Qzz,TT)
!!!!
else if(methodERI==-1)then
!!!! for test
eri1=eri1+ca*cb*cc*cd*dNa*dNb*dNc*dNd*recERI1(0,naxx,nayy,nazz,&
nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Pxx,Qxx,Ayy,Byy,Cyy,Dyy,Pyy,&
Qyy,Azz,Bzz,Czz,Dzz,Pzz,Qzz,TT)
!!!! for test
eri2=eri2+ca*cb*cc*cd*dNa*dNb*dNc*dNd*recERI2(0,naxx,nayy,nazz,&
nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Pxx,Qxx,Ayy,Byy,Cyy,Dyy,Pyy,&
Qyy,Azz,Bzz,Czz,Dzz,Pzz,Qzz,TT)
!!!! for test
eri3=eri3+ca*cb*cc*cd*dNa*dNb*dNc*dNd&
*anaERI1(naxx,nayy,nazz,nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Pxx,Qxx,Ayy,Byy,Cyy,Dyy,Pyy,&
Qyy,Azz,Bzz,Czz,Dzz,Pzz,Qzz,TT)
!!!! for test
eri4=eri4+ca*cb*cc*cd*dNa*dNb*dNc*dNd&
*recERIfast(naxx,nayy,nazz,nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Pxx,Qxx,Ayy,Byy,Cyy,Dyy,Pyy,&
Qyy,Azz,Bzz,Czz,Dzz,Pzz,Qzz,TT)
else
stop "bad ERI method"
end if
end do !!! d gf
end do !!! c gf
end do !!! b gf
end do !!! a gf
! if(abs(eri)>=1d-9)write(99,*)'I=',ibas,'J=',Jbas,'K=',Kbas,'L=',Lbas,'ERI=',eri
! if(kprinteri==2)then
! write(99,*)'I=',ibas,'J=',Jbas,'K=',Kbas,'L=',Lbas,'ERI=',eri
! end if
ijkl=indexeri(ibas,jbas,kbas,lbas)
if(abs(eri)<1d-16)eri=0d0
ERIall(ijkl)=eri
!!! test
if (methodERI==-1)then
msum=nax+nay+naz+nbx+nby+nbz+ncx+ncy+ncz+ndx+ndy+ndz
if (abs(eri1-eri2)>1d-16 .or.abs(eri1-eri3)>1d-16 .or.abs(eri2-eri3)>1d-16&
.OR. abs(eri1-eri4)>1d-16)then
write(99,*)'I=',ibas,'J=',Jbas,'K=',Kbas,'L=',Lbas,'delt ERI12=',eri1-eri2,&
'delt ERI13=',eri1-eri3,'delt ERI23=',eri2-eri3,'delt ERI14=',eri1-eri4,&
'TT=',TT,'m=',msum,'ERI1=',eri1,'ERI2=',eri2,'ERI3=',eri3,'ERI4=',eri4,&
'nx1=',nax+nbx,'nx2=',ncx+ndx,'ny1=',nay+nby,'ny2=',ncy+ndy,'nz1=',naz+nbz,&
'nz2=',ncz+ndz,nax,nbx,ncx,ndx,nay,nby,ncy,ndy,naz,nbz,ncz,ndz
end if
end if
!!!!!!
keri=keri+1
if(mod(keri,10000)==0)write(*,*)keri,'ERI done,',real(keri)/neri*100d0,'% done'
end do !!! d basis
end do !!! c basis
end do !!! b basis
end do !!! a basis
!!!!!!!!!!!!!!!
end do !!! L shell
end do !!! K shell
end do !!! J shell
end do !!! I shell
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! now in IO.f90
! if(methodERI==1)then
! write(99,'(23x,A40)')'ERI: Dupuis-Rys-King method '
! else if(methodERI==2) then
! write(99,'(23x,A40)')'ERI: S.Obara Recursive Method '
! else if(methodERI==3) then
! write(99,'(23x,A40)')'ERI: (Analytical) O.Ohata method '
! else
! write(99,'(23x,A40)')'ERI: Something wrong !!! '
! end if
!!!!!!!
write(*,*)'*** Two electron intgral Done ***'
!!!!
end subroutine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
recursive function recERI1(m,nax,nay,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) result(tem)
!!!!!
use Global,only:PI,F,F_pade,F_ser
implicit double precision (A-H,O-Z)
tem=0d0
if(nax<0.or.nbx<0.or.nay<0.or.nby<0.or.naz<0.or.nbz<0.or.&
ncx<0.or.ndx<0.or.ncy<0.or.ndy<0.or.ncz<0.or.ndz<0)then
tem=0d0
return
end if
epq1=1d0/(ep+eq)
!!!!!!!!! recursive method 1
!!!!!!! Dupuis-Rys-King method
!!!! F W.Chen,Computational Methods in Quantum Chemistry
if (nax==0.and.nbx==0.and.ncx==0.and.ndx==0)then
if (nay==0.and.nby==0.and.ncy==0.and.ndy==0)then
if (naz==0.and.nbz==0.and.ncz==0.and.ndz==0)then
tem=2d0*ABK*CDK*pi**2.5d0/(ep*eq)/sqrt(ep+eq)*F(m,TT)
! tem=2*ABK*CDK/(ep*eq)*pi**2.5/sqrt(ep+eq)*F_pade(m,TT)
! tem=2d0*ABK*CDK/(ep*eq)*pi**2.5/sqrt(ep+eq)*F_ser(m,TT)
return
!!!! z
else if(ndz==0) then !!!! (ab|c0)z
if(nbz==0) then !!!! (a0|c0)z
if(ncz==0) then !!!! (a0|00)z
tem=0.5d0*(naz-1)/ep*(&
recERI1(m,nax,nay,naz-2,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
-eq*epq1*&
recERI1(m+1,nax,nay,naz-2,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) )&
+(Ppz-Az)*recERI1(m,nax,nay,naz-1,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
+eq*(QQz-PPz)*epq1*recERI1(m+1,nax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DK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT)
return
end if
else !!!! ndx /= 0 (ab|cd)x
tem=recERI1(m,nax,nay,naz,nbx,nby,nbz,ncx+1,ncy,ncz,ndx-1,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
+(Cx-Dx)*recERI1(m,nax,nay,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx-1,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT)
return
end if
end function recERI1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
recursive function recERI2(m,naxx,nayy,nazz,nbxx,nbyy,nbzz,ncxx,ncyy,nczz,ndxx,ndyy,ndzz,&
epp,eqq,ABK,CDK,Axx,Bxx,Cxx,Dxx,Px,Qx,Ayy,Byy,Cyy,Dyy,Py,&
Qy,Azz,Bzz,Czz,Dzz,Pz,Qz,TT) result(tem)
!!!!!
use Global,only:PI,F,F_pade,F_ser,dexchange,iexchange
implicit double precision (A-H,O-Z)
logical amax
!!!! copy values for exchange
nax=naxx
nay=nayy
naz=nazz
nbx=nbxx
nby=nbyy
nbz=nbzz
ncx=ncxx
ncy=ncyy
ncz=nczz
ndx=ndxx
ndy=ndyy
ndz=ndzz
!!!!
ep=epp
eq=eqq
!!!!
ax=Axx
bx=Bxx
cx=Cxx
dx=Dxx
ppx=Px
QQx=qx
ay=Ayy
by=Byy
cy=Cyy
dy=Dyy
ppy=Py
QQy=qy
az=Azz
bz=Bzz
cz=Czz
dz=Dzz
ppz=Pz
QQz=qz
!!!!!!!!!!!!!!!!!
if(nax<0.or.nbx<0.or.nay<0.or.nby<0.or.naz<0.or.nbz<0.or.&
ncx<0.or.ndx<0.or.ncy<0.or.ndy<0.or.ncz<0.or.ndz<0)then
tem=0d0
return
end if
!!!!
tem=0d0
amax=.true.
epq1=1d0/(ep+eq)
Wx=(ep*PPx+eq*QQx)*epq1
Wy=(ep*Ppy+eq*Qqy)*epq1
Wz=(ep*Ppz+eq*Qqz)*epq1
!!!!!!!!!!!!! Recursive method 2
!!!!!!! S.Obara;A.saika The Journal of Chemical Physics 84, 3963 (1986); doi: 10.1063/1.450106
if (nax==0.and.nbx==0.and.ncx==0.and.ndx==0)then
if (nay==0.and.nby==0.and.ncy==0.and.ndy==0)then
if (naz==0.and.nbz==0.and.ncz==0.and.ndz==0)then
tem=2d0*ABK*CDK*pi**2.5d0/(ep*eq)/sqrt(ep+eq)*F(m,TT)
! tem=2*ABK*CDK/(ep*eq)*pi**2.5/sqrt(ep+eq)*F_pade(m,TT)
! tem=2d0*ABK*CDK/(ep*eq)*pi**2.5/sqrt(ep+eq)*F_ser(m,TT)
return
else !!!!z
!!!! make sure naz is max
if(naz>=nbz) then
amax=naz<ncz .or. naz<ndz
else
amax=nbz<ncz .or. nbz<ndz
end if
if(amax)then !!! exchange ac,bd a-><-c b-><-d
!!!!!!! Direct exchange
! chtem=ep
! ep=eq
! eq=chtem
!!!!!!! Use function Iexchange/Dexchange
call dexchange(ep,eq)
!!!! exchange z
!!!!!!!! Direct exchange
! nchtem=naz
! naz=ncz
! ncz=nchtem
! chtem=Az
! Az=Cz
! Cz=chtem
! nchtem=nbz
! nbz=ndz
! ndz=nchtem
! chtem=Bz
! Bz=Dz
! Dz=chtem
! chtem=Ppz
! Ppz=QQz
! Qqz=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(naz,ncz)
call dexchange(Az,Cz)
call Iexchange(nbz,ndz)
call dexchange(Bz,Dz)
call dexchange(PPz,QQz)
end if
!!!! make sure nax>=nbx
if(naz<nbz)then !!!! exchange a,b
!!!!!!!!! Direct exchange
! nchtem=naz
! naz=nbz
! nbz=nchtem
! cht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,QQz,TT) )&
+0.5d0*ncz*epq1 *recERI2(m+1,nax,nay,naz-1,nbx,nby,nbz,ncx,ncy,ncz-1,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
+0.5d0*ndz*epq1 *recERI2(m+1,nax,nay,naz-1,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz-1,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT)
return
end if
else !!!! y
!!!! make sure nay is max
if(nay>=nby) then
amax=nay<ncy .or. nay<ndy
else
amax=nby<ncy .or. nby<ndy
end if
if(amax)then !!! exchange ac,bd a-><-c b-><-d
!!!!!!!! Direct exchange
! chtem=ep
! ep=eq
! eq=chtem
!!!!!!!! Use function Iexchange/Dexchange
call dexchange(ep,eq)
!!!! change y
!!!!!!!! Direct exchange
! nchtem=nay
! nay=ncy
! ncy=nchtem
! chtem=Ay
! Ay=Cy
! Cy=chtem
! nchtem=nby
! nby=ndy
! ndy=nchtem
! chtem=By
! By=Dy
! Dy=chtem
! chtem=PPy
! PPy=Qqy
! Qqy=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(nay,ncy)
call dexchange(Ay,Cy)
call Iexchange(nby,ndy)
call dexchange(By,Dy)
call dexchange(PPy,QQy)
!!!! change z
! nchtem=naz
! naz=ncz
! ncz=nchtem
! chtem=Az
! Az=Cz
! Cz=chtem
! nchtem=nbz
! nbz=ndz
! ndz=nchtem
! chtem=Bz
! Bz=Dz
! Dz=chtem
! chtem=Ppz
! Ppz=QQz
! QQz=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(naz,ncz)
call dexchange(Az,Cz)
call Iexchange(nbz,ndz)
call dexchange(Bz,Dz)
call dexchange(PPz,QQz)
end if
!!!! make sure nay>=nby
if(nay<nby)then
!!!!! exchange ab y
!!!!!!!! Direct exchange
! nchtem=nay
! nay=nby
! nby=nchtem
! chtem=Ay
! Ay=By
! By=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(nay,nBy)
call dexchange(Ay,By)
!!!!! exchange ab z
!!!!!!!! Direct exchange
! nchtem=naz
! naz=nbz
! nbz=nchtem
! chtem=Az
! Az=Bz
! Bz=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(naz,nBz)
call dexchange(Az,Bz)
end if
tem=(Ppy-Ay)*recERI2(m,nax,nay-1,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
+(Wy-Ppy)*recERI2(m+1,nax,nay-1,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
! +eq*epq1*(QQy-Ppy)*recERI2(m+1,nax,nay,naz-1,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
+0.5d0/ep*(nay-1)*(recERI2(m,nax,nay-2,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
-eq*epq1*recERI2(m+1,nax,nay-2,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) )&
+ 0.5d0/ep*nby*(recERI2(m,nax,nay-1,naz,nbx,nby-1,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
-eq*epq1*recERI2(m+1,nax,nay-1,naz,nbx,nby-1,nbz,ncx,ncy,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) )&
+0.5d0*ncy*epq1 *recERI2(m+1,nax,nay-1,naz,nbx,nby,nbz,ncx,ncy-1,ncz,ndx,ndy,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT) &
+0.5d0*ndy*epq1 *recERI2(m+1,nax,nay-1,naz,nbx,nby,nbz,ncx,ncy,ncz,ndx,ndy-1,ndz,&
ep,eq,ABK,CDK,Ax,Bx,Cx,Dx,PPx,QQx,Ay,By,Cy,Dy,PPy,&
QQy,Az,Bz,Cz,Dz,PPz,QQz,TT)
return
end if
else !!!!x
!!!! make sure nax is max
if(nax>=nbx) then
amax=nax<ncx .or. nax<ndx
else
amax=nbx<ncx .or. nbx<ndx
end if
if(amax)then !!! exchange ab,cd a-><-c b-><-d
!!!!!!!! Direct exchange
! chtem=ep
! ep=eq
! eq=chtem
!!!!!!!! Use function Iexchange/Dexchange
call dexchange(ep,eq)
!!!! change x
!!!!!!!! Direct exchange
! nchtem=nax
! nax=ncx
! ncx=nchtem
! chtem=Ax
! Ax=Cx
! Cx=chtem
! nchtem=nbx
! nbx=ndx
! ndx=nchtem
! chtem=Bx
! Bx=Dx
! Dx=chtem
! chtem=Ppx
! Ppx=QQx
! QQx=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(nax,ncx)
call dexchange(Ax,Cx)
call Iexchange(nbx,ndx)
call dexchange(Bx,Dx)
call dexchange(ppx,qqx)
!!!! change y
!!!!!!!! Direct exchange
! nchtem=nay
! nay=ncy
! ncy=nchtem
! chtem=Ay
! Ay=Cy
! Cy=chtem
! nchtem=nby
! nby=ndy
! ndy=nchtem
! chtem=By
! By=Dy
! Dy=chtem
! chtem=Ppy
! Ppy=QQy
! QQy=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(nay,ncy)
call dexchange(Ay,Cy)
call Iexchange(nby,ndy)
call dexchange(By,Dy)
!!!! change z
!!!!!!!! Direct exchange
! nchtem=naz
! naz=ncz
! ncz=nchtem
! chtem=Az
! Az=Cz
! Cz=chtem
! nchtem=nbz
! nbz=ndz
! ndz=nchtem
! chtem=Bz
! Bz=Dz
! Dz=chtem
! chtem=Ppz
! Ppz=QQz
! QQz=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(naz,ncz)
call dexchange(Az,Cz)
call Iexchange(nbz,ndz)
call dexchange(Bz,Dz)
call dexchange(PPz,QQz)
end if
!!!! make sure nax>=nbx
if(nax<nbx)then
!!!! exchange ab
!!!!!!!! Direct exchange
! nchtem=nax
! nax=nbx
! nbx=nchtem
! chtem=Ax
! Ax=Bx
! Bx=chtem
!!!!!!!! Use function Iexchange/Dexchange
call Iexchange(nax,nBx)
call dexchange(Ax,Bx)
!!!! change y
!!!!!!!! Direct exchange
! nchtem=nay