-
Notifications
You must be signed in to change notification settings - Fork 1
/
semi_empirical_int_utils.F
2471 lines (2387 loc) · 118 KB
/
semi_empirical_int_utils.F
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
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Utilities for Integrals for semi-empiric methods
!> \author Teodoro Laino (03.2008) [tlaino] - University of Zurich
! **************************************************************************************************
MODULE semi_empirical_int_utils
USE input_constants, ONLY: do_method_pchg, &
do_se_IS_kdso_d
USE kinds, ONLY: dp
USE semi_empirical_int3_utils, ONLY: charg_int_3, &
dcharg_int_3, &
ijkl_low_3
USE semi_empirical_int_arrays, ONLY: &
CLMp, CLMxx, CLMxy, CLMyy, CLMz, CLMzp, CLMzz, clm_d, clm_sp, ijkl_ind, indexa, indexb, &
int2c_type
USE semi_empirical_types, ONLY: rotmat_type, &
se_int_control_type, &
se_int_screen_type, &
se_taper_type, &
semi_empirical_type
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
#:include 'semi_empirical_int_debug.fypp'
LOGICAL, PARAMETER, PRIVATE :: debug_this_module = .FALSE.
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'semi_empirical_int_utils'
PUBLIC :: ijkl_sp, ijkl_d, rotmat, rot_2el_2c_first, store_2el_2c_diag, &
d_ijkl_sp, d_ijkl_d
ABSTRACT INTERFACE
! **************************************************************************************************
!> \brief ...
!> \param r ...
!> \param l1_i ...
!> \param l2_i ...
!> \param m1_i ...
!> \param m2_i ...
!> \param da_i ...
!> \param db_i ...
!> \param add0 ...
!> \param fact_screen ...
!> \return ...
! **************************************************************************************************
FUNCTION eval_func_sp(r, l1_i, l2_i, m1_i, m2_i, da_i, db_i, add0, fact_screen) RESULT(charg)
USE kinds, ONLY: dp
REAL(KIND=dp), INTENT(IN) :: r
INTEGER, INTENT(IN) :: l1_i, l2_i, m1_i, m2_i
REAL(KIND=dp), INTENT(IN) :: da_i, db_i, add0, fact_screen
REAL(KIND=dp) :: charg
END FUNCTION eval_func_sp
END INTERFACE
ABSTRACT INTERFACE
! **************************************************************************************************
!> \brief ...
!> \param r ...
!> \param l1_i ...
!> \param l2_i ...
!> \param m ...
!> \param da_i ...
!> \param db_i ...
!> \param add0 ...
!> \param fact_screen ...
!> \return ...
! **************************************************************************************************
FUNCTION eval_func_d(r, l1_i, l2_i, m, da_i, db_i, add0, fact_screen) RESULT(charg)
USE kinds, ONLY: dp
REAL(KIND=dp), INTENT(IN) :: r
INTEGER, INTENT(IN) :: l1_i, l2_i, m
REAL(KIND=dp), INTENT(IN) :: da_i, db_i, add0, fact_screen
REAL(KIND=dp) :: charg
END FUNCTION eval_func_d
END INTERFACE
CONTAINS
! **************************************************************************************************
!> \brief General driver for computing semi-empirical integrals <ij|kl> with
!> sp basis set. This code uses the old definitions of quadrupoles and
!> therefore cannot be used for integrals involving d-orbitals (which
!> require a definition of quadrupoles based on the rotational invariant
!> property)
!>
!> \param sepi ...
!> \param sepj ...
!> \param ij ...
!> \param kl ...
!> \param li ...
!> \param lj ...
!> \param lk ...
!> \param ll ...
!> \param ic ...
!> \param r ...
!> \param se_int_control ...
!> \param se_int_screen ...
!> \param itype ...
!> \return ...
!> \date 04.2008 [tlaino]
!> \author Teodoro Laino [tlaino] - University of Zurich
! **************************************************************************************************
FUNCTION ijkl_sp(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_control, &
se_int_screen, itype) RESULT(res)
TYPE(semi_empirical_type), POINTER :: sepi, sepj
INTEGER, INTENT(IN) :: ij, kl, li, lj, lk, ll, ic
REAL(KIND=dp), INTENT(IN) :: r
TYPE(se_int_control_type), INTENT(IN) :: se_int_control
TYPE(se_int_screen_type), INTENT(IN) :: se_int_screen
INTEGER, INTENT(IN) :: itype
REAL(KIND=dp) :: res
res = ijkl_sp_low(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_screen, &
se_int_control%integral_screening, se_int_control%shortrange, &
se_int_control%pc_coulomb_int, se_int_control%max_multipole, &
itype, charg_int_nri)
! If only the shortrange component is requested we can skip the rest
IF ((.NOT. se_int_control%pc_coulomb_int) .AND. (itype /= do_method_pchg)) THEN
! Handle the 1/r^3 term, this term is ALWAYS false for KDSO-D integrals
IF (se_int_control%shortrange .AND. se_int_control%do_ewald_r3) THEN
res = res - ijkl_low_3(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, &
itype, charg_int_3)
END IF
END IF
END FUNCTION ijkl_sp
! **************************************************************************************************
!> \brief General driver for computing derivatives of semi-empirical integrals
!> <ij|kl> with sp basis set.
!> This code uses the old definitions of quadrupoles and therefore
!> cannot be used for integrals involving d-orbitals (which requires a
!> definition of quadrupoles based on the rotational invariant property)
!>
!> \param sepi ...
!> \param sepj ...
!> \param ij ...
!> \param kl ...
!> \param li ...
!> \param lj ...
!> \param lk ...
!> \param ll ...
!> \param ic ...
!> \param r ...
!> \param se_int_control ...
!> \param se_int_screen ...
!> \param itype ...
!> \return ...
!> \date 05.2008 [tlaino]
!> \author Teodoro Laino [tlaino] - University of Zurich
! **************************************************************************************************
FUNCTION d_ijkl_sp(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_control, &
se_int_screen, itype) RESULT(res)
TYPE(semi_empirical_type), POINTER :: sepi, sepj
INTEGER, INTENT(IN) :: ij, kl, li, lj, lk, ll, ic
REAL(KIND=dp), INTENT(IN) :: r
TYPE(se_int_control_type), INTENT(IN) :: se_int_control
TYPE(se_int_screen_type), INTENT(IN) :: se_int_screen
INTEGER, INTENT(IN) :: itype
REAL(KIND=dp) :: res
REAL(KIND=dp) :: dfs, srd
IF (se_int_control%integral_screening == do_se_IS_kdso_d) THEN
res = ijkl_sp_low(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_screen, &
se_int_control%integral_screening, .FALSE., &
se_int_control%pc_coulomb_int, se_int_control%max_multipole, &
itype, dcharg_int_nri)
IF (.NOT. se_int_control%pc_coulomb_int) THEN
dfs = ijkl_sp_low(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_screen, &
se_int_control%integral_screening, .FALSE., .FALSE., &
se_int_control%max_multipole, itype, dcharg_int_nri_fs)
res = res + dfs*se_int_screen%dft
! In case we need the shortrange part we have to evaluate an additional derivative
! to handle the derivative of the Tapering term
IF (se_int_control%shortrange) THEN
srd = ijkl_sp_low(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_screen, &
se_int_control%integral_screening, .FALSE., .TRUE., &
se_int_control%max_multipole, itype, dcharg_int_nri)
res = res - srd
END IF
END IF
ELSE
res = ijkl_sp_low(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_screen, &
se_int_control%integral_screening, se_int_control%shortrange, &
se_int_control%pc_coulomb_int, se_int_control%max_multipole, &
itype, dcharg_int_nri)
END IF
! If only the shortrange component is requested we can skip the rest
IF ((.NOT. se_int_control%pc_coulomb_int) .AND. (itype /= do_method_pchg)) THEN
! Handle the 1/r^3 term, this term is ALWAYS false for KDSO-D integrals
IF (se_int_control%shortrange .AND. se_int_control%do_ewald_r3) THEN
res = res - ijkl_low_3(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, &
itype, dcharg_int_3)
END IF
END IF
END FUNCTION d_ijkl_sp
! **************************************************************************************************
!> \brief Low level general driver for computing semi-empirical integrals
!> <ij|kl> and their derivatives with sp basis set only.
!> This code uses the old definitions of quadrupoles and
!> therefore cannot be used for integrals involving d-orbitals (which
!> require a definition of quadrupoles based on the rotational invariant
!> property)
!>
!> \param sepi ...
!> \param sepj ...
!> \param ij ...
!> \param kl ...
!> \param li ...
!> \param lj ...
!> \param lk ...
!> \param ll ...
!> \param ic ...
!> \param r ...
!> \param se_int_screen ...
!> \param iscreen ...
!> \param shortrange ...
!> \param pc_coulomb_int ...
!> \param max_multipole ...
!> \param itype ...
!> \param eval a function without explicit interface
!> \return ...
!> \date 05.2008 [tlaino]
!> \author Teodoro Laino [tlaino] - University of Zurich
! **************************************************************************************************
FUNCTION ijkl_sp_low(sepi, sepj, ij, kl, li, lj, lk, ll, ic, r, se_int_screen, &
iscreen, shortrange, pc_coulomb_int, max_multipole, itype, eval) RESULT(res)
TYPE(semi_empirical_type), POINTER :: sepi, sepj
INTEGER, INTENT(IN) :: ij, kl, li, lj, lk, ll, ic
REAL(KIND=dp), INTENT(IN) :: r
TYPE(se_int_screen_type), INTENT(IN) :: se_int_screen
INTEGER, INTENT(IN) :: iscreen
LOGICAL, INTENT(IN) :: shortrange, pc_coulomb_int
INTEGER, INTENT(IN) :: max_multipole, itype
PROCEDURE(eval_func_sp) :: eval
REAL(KIND=dp) :: res
INTEGER :: ccc, l1, l1max, l1min, l2, l2max, l2min, &
lij, lkl, lmin, m
REAL(KIND=dp) :: add, chrg, dij, dkl, fact_ij, fact_kl, &
fact_screen, pij, pkl, s1, sum
l1min = ABS(li - lj)
l1max = li + lj
lij = indexb(li + 1, lj + 1)
l2min = ABS(lk - ll)
l2max = lk + ll
lkl = indexb(lk + 1, ll + 1)
l1max = MIN(l1max, 2)
l1min = MIN(l1min, 2)
l2max = MIN(l2max, 2)
l2min = MIN(l2min, 2)
sum = 0.0_dp
dij = 0.0_dp
dkl = 0.0_dp
fact_ij = 1.0_dp
fact_kl = 1.0_dp
fact_screen = 1.0_dp
IF (lij == 3) fact_ij = SQRT(2.0_dp)
IF (lkl == 3) fact_kl = SQRT(2.0_dp)
IF (.NOT. pc_coulomb_int) THEN
IF (iscreen == do_se_IS_kdso_d) fact_screen = se_int_screen%ft
! Standard value of the integral
DO l1 = l1min, l1max
IF (l1 == 0) THEN
IF (lij == 1) THEN
pij = sepi%ko(1)
IF (ic == -1 .OR. ic == 1) THEN
pij = sepi%ko(9)
END IF
ELSE IF (lij == 3) THEN
pij = sepi%ko(7)
END IF
ELSE
dij = sepi%cs(lij)*fact_ij
pij = sepi%ko(lij)
END IF
!
DO l2 = l2min, l2max
IF (l2 == 0) THEN
IF (lkl == 1) THEN
pkl = sepj%ko(1)
IF (ic == -1 .OR. ic == 2) THEN
pkl = sepj%ko(9)
END IF
ELSE IF (lkl == 3) THEN
pkl = sepj%ko(7)
END IF
ELSE
dkl = sepj%cs(lkl)*fact_kl
pkl = sepj%ko(lkl)
END IF
IF (itype == do_method_pchg) THEN
add = 0.0_dp
ELSE
add = (pij + pkl)**2
END IF
lmin = MAX(l1, l2)
s1 = 0.0_dp
DO m = -lmin, lmin
ccc = clm_sp(ij, l1, m)*clm_sp(kl, l2, m)
IF (ABS(ccc) > EPSILON(0.0_dp)) THEN
chrg = eval(r, l1, l2, clm_sp(ij, l1, m), clm_sp(kl, l2, m), dij, dkl, add, fact_screen)
s1 = s1 + chrg
END IF
END DO
sum = sum + s1
END DO
END DO
res = sum
END IF
! Shortrange: Possibly computes pure Coulomb and subtract from the original integral value
IF (shortrange .OR. pc_coulomb_int) THEN
sum = 0.0_dp
dij = 0.0_dp
dkl = 0.0_dp
add = 0.0_dp
fact_screen = 0.0_dp
DO l1 = l1min, l1max
IF (l1 > max_multipole) CYCLE
IF (l1 /= 0) THEN
dij = sepi%cs(lij)*fact_ij
END IF
!
DO l2 = l2min, l2max
IF (l2 > max_multipole) CYCLE
IF (l2 /= 0) THEN
dkl = sepj%cs(lkl)*fact_kl
END IF
lmin = MAX(l1, l2)
s1 = 0.0_dp
DO m = -lmin, lmin
ccc = clm_sp(ij, l1, m)*clm_sp(kl, l2, m)
IF (ABS(ccc) > EPSILON(0.0_dp)) THEN
chrg = eval(r, l1, l2, clm_sp(ij, l1, m), clm_sp(kl, l2, m), dij, dkl, add, fact_screen)
s1 = s1 + chrg
END IF
END DO
sum = sum + s1
END DO
END DO
IF (pc_coulomb_int) res = sum
IF (shortrange) res = res - sum
END IF
END FUNCTION ijkl_sp_low
! **************************************************************************************************
!> \brief Interaction function between two point-charge configurations NDDO sp-code
!> Non-Rotational Invariant definition of quadrupoles
!> r - Distance r12
!> l1,m - Quantum numbers for multipole of configuration 1
!> l2,m - Quantum numbers for multipole of configuration 2
!> da - charge separation of configuration 1
!> db - charge separation of configuration 2
!> add - additive term
!>
!> \param r ...
!> \param l1_i ...
!> \param l2_i ...
!> \param m1_i ...
!> \param m2_i ...
!> \param da_i ...
!> \param db_i ...
!> \param add0 ...
!> \param fact_screen ...
!> \return ...
!> \date 04.2008 [tlaino]
!> \author Teodoro Laino [tlaino] - University of Zurich
! **************************************************************************************************
FUNCTION charg_int_nri(r, l1_i, l2_i, m1_i, m2_i, da_i, db_i, add0, fact_screen) RESULT(charg)
REAL(KIND=dp), INTENT(in) :: r
INTEGER, INTENT(in) :: l1_i, l2_i, m1_i, m2_i
REAL(KIND=dp), INTENT(in) :: da_i, db_i, add0, fact_screen
REAL(KIND=dp) :: charg
INTEGER :: l1, l2, m1, m2
REAL(KIND=dp) :: add, da, db, dxdx, dxqxz, dzdz, dzqxx, &
dzqzz, fact, qqxx, qqzz, qxxqxx, &
qxxqyy, qxzqxz, xyxy, zzzz
! Computing only Integral Values
IF (l1_i < l2_i) THEN
l1 = l1_i
l2 = l2_i
m1 = m1_i
m2 = m2_i
da = da_i
db = db_i
fact = 1.0_dp
ELSE IF (l1_i > l2_i) THEN
l1 = l2_i
l2 = l1_i
m1 = m2_i
m2 = m1_i
da = db_i
db = da_i
fact = (-1.0_dp)**(l1 + l2)
ELSE IF (l1_i == l2_i) THEN
l1 = l1_i
l2 = l2_i
IF (m1_i <= m2_i) THEN
m1 = m1_i
m2 = m2_i
da = da_i
db = db_i
ELSE
m1 = m2_i
m2 = m1_i
da = db_i
db = da_i
END IF
fact = 1.0_dp
END IF
add = add0*fact_screen
charg = 0.0_dp
! Q - Q.
IF (l1 == 0 .AND. l2 == 0) THEN
charg = fact/SQRT(r**2 + add)
RETURN
END IF
! Q - Z.
IF (l1 == 0 .AND. l2 == 1 .AND. m2 == CLMz) THEN
charg = 1.0_dp/SQRT((r + db)**2 + add) - 1.0_dp/SQRT((r - db)**2 + add)
charg = charg*0.5_dp*fact
RETURN
END IF
! Z - Z.
IF (l1 == 1 .AND. l2 == 1 .AND. m1 == CLMz .AND. m2 == CLMz) THEN
dzdz = &
+1.0_dp/SQRT((r + da - db)**2 + add) + 1.0_dp/SQRT((r - da + db)**2 + add) &
- 1.0_dp/SQRT((r - da - db)**2 + add) - 1.0_dp/SQRT((r + da + db)**2 + add)
charg = dzdz*0.25_dp*fact
RETURN
END IF
! X - X
IF (l1 == 1 .AND. l2 == 1 .AND. m1 == CLMp .AND. m2 == CLMp) THEN
dxdx = 2.0_dp/SQRT(r**2 + (da - db)**2 + add) - 2.0_dp/SQRT(r**2 + (da + db)**2 + add)
charg = dxdx*0.25_dp*fact
RETURN
END IF
! Q - ZZ
IF (l1 == 0 .AND. l2 == 2 .AND. m2 == CLMzz) THEN
qqzz = 1.0_dp/SQRT((r - db)**2 + add) - 2.0_dp/SQRT(r**2 + add) + 1.0_dp/SQRT((r + db)**2 + add)
charg = qqzz*0.25_dp*fact
RETURN
END IF
! Q - XX
IF (l1 == 0 .AND. l2 == 2 .AND. (m2 == CLMyy .OR. m2 == CLMxx)) THEN
qqxx = -1.0_dp/SQRT(r**2 + add) + 1.0_dp/SQRT(r**2 + add + db**2)
charg = qqxx*0.5_dp*fact
RETURN
END IF
! Z - ZZ
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMz .AND. m2 == CLMzz) THEN
dzqzz = &
+1.0_dp/SQRT((r - da - db)**2 + add) - 2.0_dp/SQRT((r - da)**2 + add) &
+ 1.0_dp/SQRT((r - da + db)**2 + add) - 1.0_dp/SQRT((r + da - db)**2 + add) &
+ 2.0_dp/SQRT((r + da)**2 + add) - 1.0_dp/SQRT((r + da + db)**2 + add)
charg = dzqzz*0.125_dp*fact
RETURN
END IF
! Z - XX
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMz .AND. (m2 == CLMyy .OR. m2 == CLMxx)) THEN
dzqxx = &
+1.0_dp/SQRT((r + da)**2 + add) - 1.0_dp/SQRT((r + da)**2 + add + db**2) &
- 1.0_dp/SQRT((r - da)**2 + add) + 1.0_dp/SQRT((r - da)**2 + add + db**2)
charg = dzqxx*0.25_dp*fact
RETURN
END IF
! ZZ - ZZ
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzz .AND. m2 == CLMzz) THEN
zzzz = &
+1.0_dp/SQRT((r - da - db)**2 + add) + 1.0_dp/SQRT((r + da + db)**2 + add) &
+ 1.0_dp/SQRT((r - da + db)**2 + add) + 1.0_dp/SQRT((r + da - db)**2 + add)
xyxy = &
+1.0_dp/SQRT((r - da)**2 + add) + 1.0_dp/SQRT((r + da)**2 + add) &
+ 1.0_dp/SQRT((r - db)**2 + add) + 1.0_dp/SQRT((r + db)**2 + add) &
- 2.0_dp/SQRT(r**2 + add)
charg = (zzzz*0.0625_dp - xyxy*0.125_dp)*fact
RETURN
END IF
! ZZ - XX
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzz .AND. (m2 == CLMxx .OR. m2 == CLMyy)) THEN
zzzz = &
-1.0_dp/SQRT((r + da)**2 + add) + 1.0_dp/SQRT((r + da)**2 + db**2 + add) &
- 1.0_dp/SQRT((r - da)**2 + add) + 1.0_dp/SQRT((r - da)**2 + db**2 + add)
xyxy = &
+1.0_dp/SQRT(r**2 + db**2 + add) - 1.0_dp/SQRT(r**2 + add)
charg = (zzzz*0.125_dp - xyxy*0.25_dp)*fact
RETURN
END IF
! X - ZX
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMp .AND. m2 == CLMzp) THEN
db = db/2.0_dp
dxqxz = &
-1.0_dp/SQRT((r - db)**2 + (da - db)**2 + add) + 1.0_dp/SQRT((r + db)**2 + (da - db)**2 + add) &
+ 1.0_dp/SQRT((r - db)**2 + (da + db)**2 + add) - 1.0_dp/SQRT((r + db)**2 + (da + db)**2 + add)
charg = dxqxz*0.25_dp*fact
RETURN
END IF
! ZX - ZX
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzp .AND. m2 == CLMzp) THEN
da = da/2.0_dp
db = db/2.0_dp
qxzqxz = &
+1.0_dp/SQRT((r + da - db)**2 + (da - db)**2 + add) - 1.0_dp/SQRT((r + da + db)**2 + (da - db)**2 + add) &
- 1.0_dp/SQRT((r - da - db)**2 + (da - db)**2 + add) + 1.0_dp/SQRT((r - da + db)**2 + (da - db)**2 + add) &
- 1.0_dp/SQRT((r + da - db)**2 + (da + db)**2 + add) + 1.0_dp/SQRT((r + da + db)**2 + (da + db)**2 + add) &
+ 1.0_dp/SQRT((r - da - db)**2 + (da + db)**2 + add) - 1.0_dp/SQRT((r - da + db)**2 + (da + db)**2 + add)
charg = qxzqxz*0.125_dp*fact
RETURN
END IF
! XX - XX
IF (l1 == 2 .AND. l2 == 2 .AND. (((m1 == CLMyy) .AND. (m2 == CLMyy)) .OR. ((m1 == CLMxx) .AND. (m2 == CLMxx)))) THEN
qxxqxx = &
+2.0_dp/SQRT(r**2 + add) + 1.0_dp/SQRT(r**2 + (da - db)**2 + add) &
+ 1.0_dp/SQRT(r**2 + (da + db)**2 + add) - 2.0_dp/SQRT(r**2 + da**2 + add) &
- 2.0_dp/SQRT(r**2 + db**2 + add)
charg = qxxqxx*0.125_dp*fact
RETURN
END IF
! XX - YY
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMyy .AND. m2 == CLMxx) THEN
qxxqyy = &
+1.0_dp/SQRT(r**2 + add) - 1.0_dp/SQRT(r**2 + da**2 + add) &
- 1.0_dp/SQRT(r**2 + db**2 + add) + 1.0_dp/SQRT(r**2 + da**2 + db**2 + add)
charg = qxxqyy*0.25_dp*fact
RETURN
END IF
! XY - XY
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMxy .AND. m2 == CLMxy) THEN
qxxqxx = &
+2.0_dp/SQRT(r**2 + add) + 1.0_dp/SQRT(r**2 + (da - db)**2 + add) &
+ 1.0_dp/SQRT(r**2 + (da + db)**2 + add) - 2.0_dp/SQRT(r**2 + da**2 + add) &
- 2.0_dp/SQRT(r**2 + db**2 + add)
qxxqyy = &
+1.0_dp/SQRT(r**2 + add) - 1.0_dp/SQRT(r**2 + da**2 + add) &
- 1.0_dp/SQRT(r**2 + db**2 + add) + 1.0_dp/SQRT(r**2 + da**2 + db**2 + add)
charg = 0.5_dp*(qxxqxx*0.125_dp - qxxqyy*0.25_dp)*fact
RETURN
END IF
! We should NEVER reach this point
CPABORT("")
END FUNCTION charg_int_nri
! **************************************************************************************************
!> \brief Derivatives of interaction function between two point-charge
!> configurations NDDO sp-code.
!> Non-Rotational Invariant definition of quadrupoles
!>
!> r - Distance r12
!> l1,m - Quantum numbers for multipole of configuration 1
!> l2,m - Quantum numbers for multipole of configuration 2
!> da - charge separation of configuration 1
!> db - charge separation of configuration 2
!> add - additive term
!>
!> \param r ...
!> \param l1_i ...
!> \param l2_i ...
!> \param m1_i ...
!> \param m2_i ...
!> \param da_i ...
!> \param db_i ...
!> \param add0 ...
!> \param fact_screen ...
!> \return ...
!> \date 04.2008 [tlaino]
!> \author Teodoro Laino [tlaino] - University of Zurich
! **************************************************************************************************
FUNCTION dcharg_int_nri(r, l1_i, l2_i, m1_i, m2_i, da_i, db_i, add0, fact_screen) RESULT(charg)
REAL(KIND=dp), INTENT(in) :: r
INTEGER, INTENT(in) :: l1_i, l2_i, m1_i, m2_i
REAL(KIND=dp), INTENT(in) :: da_i, db_i, add0, fact_screen
REAL(KIND=dp) :: charg
INTEGER :: l1, l2, m1, m2
REAL(KIND=dp) :: add, da, db, dxdx, dxqxz, dzdz, dzqxx, &
dzqzz, fact, qqxx, qqzz, qxxqxx, &
qxxqyy, qxzqxz, xyxy, zzzz
! Computing only Integral Derivatives
IF (l1_i < l2_i) THEN
l1 = l1_i
l2 = l2_i
m1 = m1_i
m2 = m2_i
da = da_i
db = db_i
fact = 1.0_dp
ELSE IF (l1_i > l2_i) THEN
l1 = l2_i
l2 = l1_i
m1 = m2_i
m2 = m1_i
da = db_i
db = da_i
fact = (-1.0_dp)**(l1 + l2)
ELSE IF (l1_i == l2_i) THEN
l1 = l1_i
l2 = l2_i
IF (m1_i <= m2_i) THEN
m1 = m1_i
m2 = m2_i
da = da_i
db = db_i
ELSE
m1 = m2_i
m2 = m1_i
da = db_i
db = da_i
END IF
fact = 1.0_dp
END IF
charg = 0.0_dp
add = add0*fact_screen
! Q - Q.
IF (l1 == 0 .AND. l2 == 0) THEN
charg = r/SQRT(r**2 + add)**3
charg = -charg*fact
RETURN
END IF
! Q - Z.
IF (l1 == 0 .AND. l2 == 1 .AND. m2 == CLMz) THEN
charg = (r + db)/SQRT((r + db)**2 + add)**3 - (r - db)/SQRT((r - db)**2 + add)**3
charg = -charg*0.5_dp*fact
RETURN
END IF
! Z - Z.
IF (l1 == 1 .AND. l2 == 1 .AND. m1 == CLMz .AND. m2 == CLMz) THEN
dzdz = &
+(r + da - db)/SQRT((r + da - db)**2 + add)**3 + (r - da + db)/SQRT((r - da + db)**2 + add)**3 &
- (r - da - db)/SQRT((r - da - db)**2 + add)**3 - (r + da + db)/SQRT((r + da + db)**2 + add)**3
charg = -dzdz*0.25_dp*fact
RETURN
END IF
! X - X
IF (l1 == 1 .AND. l2 == 1 .AND. m1 == CLMp .AND. m2 == CLMp) THEN
dxdx = 2.0_dp*r/SQRT(r**2 + (da - db)**2 + add)**3 - 2.0_dp*r/SQRT(r**2 + (da + db)**2 + add)**3
charg = -dxdx*0.25_dp*fact
RETURN
END IF
! Q - ZZ
IF (l1 == 0 .AND. l2 == 2 .AND. m2 == CLMzz) THEN
qqzz = (r - db)/SQRT((r - db)**2 + add)**3 - 2.0_dp*r/SQRT(r**2 + add)**3 + (r + db)/SQRT((r + db)**2 + add)**3
charg = -qqzz*0.25_dp*fact
RETURN
END IF
! Q - XX
IF (l1 == 0 .AND. l2 == 2 .AND. (m2 == CLMyy .OR. m2 == CLMxx)) THEN
qqxx = -r/SQRT(r**2 + add)**3 + r/SQRT(r**2 + add + db**2)**3
charg = -qqxx*0.5_dp*fact
RETURN
END IF
! Z - ZZ
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMz .AND. m2 == CLMzz) THEN
dzqzz = &
+(r - da - db)/SQRT((r - da - db)**2 + add)**3 - 2.0_dp*(r - da)/SQRT((r - da)**2 + add)**3 &
+ (r - da + db)/SQRT((r - da + db)**2 + add)**3 - (r + da - db)/SQRT((r + da - db)**2 + add)**3 &
+ 2.0_dp*(r + da)/SQRT((r + da)**2 + add)**3 - (r + da + db)/SQRT((r + da + db)**2 + add)**3
charg = -dzqzz*0.125_dp*fact
RETURN
END IF
! Z - XX
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMz .AND. (m2 == CLMyy .OR. m2 == CLMxx)) THEN
dzqxx = &
+(r + da)/SQRT((r + da)**2 + add)**3 - (r + da)/SQRT((r + da)**2 + add + db**2)**3 &
- (r - da)/SQRT((r - da)**2 + add)**3 + (r - da)/SQRT((r - da)**2 + add + db**2)**3
charg = -dzqxx*0.25_dp*fact
RETURN
END IF
! ZZ - ZZ
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzz .AND. m2 == CLMzz) THEN
zzzz = &
+(r - da - db)/SQRT((r - da - db)**2 + add)**3 + (r + da + db)/SQRT((r + da + db)**2 + add)**3 &
+ (r - da + db)/SQRT((r - da + db)**2 + add)**3 + (r + da - db)/SQRT((r + da - db)**2 + add)**3
xyxy = &
+(r - da)/SQRT((r - da)**2 + add)**3 + (r + da)/SQRT((r + da)**2 + add)**3 &
+ (r - db)/SQRT((r - db)**2 + add)**3 + (r + db)/SQRT((r + db)**2 + add)**3 &
- 2.0_dp*r/SQRT(r**2 + add)**3
charg = -(zzzz*0.0625_dp - xyxy*0.125_dp)*fact
RETURN
END IF
! ZZ - XX
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzz .AND. (m2 == CLMxx .OR. m2 == CLMyy)) THEN
zzzz = &
-(r + da)/SQRT((r + da)**2 + add)**3 + (r + da)/SQRT((r + da)**2 + db**2 + add)**3 &
- (r - da)/SQRT((r - da)**2 + add)**3 + (r - da)/SQRT((r - da)**2 + db**2 + add)**3
xyxy = r/SQRT(r**2 + db**2 + add)**3 - r/SQRT(r**2 + add)**3
charg = -(zzzz*0.125_dp - xyxy*0.25_dp)*fact
RETURN
END IF
! X - ZX
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMp .AND. m2 == CLMzp) THEN
db = db/2.0_dp
dxqxz = &
-(r - db)/SQRT((r - db)**2 + (da - db)**2 + add)**3 + (r + db)/SQRT((r + db)**2 + (da - db)**2 + add)**3 &
+ (r - db)/SQRT((r - db)**2 + (da + db)**2 + add)**3 - (r + db)/SQRT((r + db)**2 + (da + db)**2 + add)**3
charg = -dxqxz*0.25_dp*fact
RETURN
END IF
! ZX - ZX
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzp .AND. m2 == CLMzp) THEN
da = da/2.0_dp
db = db/2.0_dp
qxzqxz = &
+(r + da - db)/SQRT((r + da - db)**2 + (da - db)**2 + add)**3 - (r + da + db)/SQRT((r + da + db)**2 + (da - db)**2 + add)**3 &
- (r - da - db)/SQRT((r - da - db)**2 + (da - db)**2 + add)**3 + (r - da + db)/SQRT((r - da + db)**2 + (da - db)**2 + add)**3 &
- (r + da - db)/SQRT((r + da - db)**2 + (da + db)**2 + add)**3 + (r + da + db)/SQRT((r + da + db)**2 + (da + db)**2 + add)**3 &
+ (r - da - db)/SQRT((r - da - db)**2 + (da + db)**2 + add)**3 - (r - da + db)/SQRT((r - da + db)**2 + (da + db)**2 + add)**3
charg = -qxzqxz*0.125_dp*fact
RETURN
END IF
! XX - XX
IF (l1 == 2 .AND. l2 == 2 .AND. (((m1 == CLMyy) .AND. (m2 == CLMyy)) .OR. ((m1 == CLMxx) .AND. (m2 == CLMxx)))) THEN
qxxqxx = &
+2.0_dp*r/SQRT(r**2 + add)**3 + r/SQRT(r**2 + (da - db)**2 + add)**3 &
+ r/SQRT(r**2 + (da + db)**2 + add)**3 - 2.0_dp*r/SQRT(r**2 + da**2 + add)**3 &
- 2.0_dp*r/SQRT(r**2 + db**2 + add)**3
charg = -qxxqxx*0.125_dp*fact
RETURN
END IF
! XX - YY
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMyy .AND. m2 == CLMxx) THEN
qxxqyy = &
+r/SQRT(r**2 + add)**3 - r/SQRT(r**2 + da**2 + add)**3 &
- r/SQRT(r**2 + db**2 + add)**3 + r/SQRT(r**2 + da**2 + db**2 + add)**3
charg = -qxxqyy*0.25_dp*fact
RETURN
END IF
! XY - XY
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMxy .AND. m2 == CLMxy) THEN
qxxqxx = &
+2.0_dp*r/SQRT(r**2 + add)**3 + r/SQRT(r**2 + (da - db)**2 + add)**3 &
+ r/SQRT(r**2 + (da + db)**2 + add)**3 - 2.0_dp*r/SQRT(r**2 + da**2 + add)**3 &
- 2.0_dp*r/SQRT(r**2 + db**2 + add)**3
qxxqyy = &
+r/SQRT(r**2 + add)**3 - r/SQRT(r**2 + da**2 + add)**3 &
- r/SQRT(r**2 + db**2 + add)**3 + r/SQRT(r**2 + da**2 + db**2 + add)**3
charg = -0.5_dp*(qxxqxx*0.125_dp - qxxqyy*0.25_dp)*fact
RETURN
END IF
! We should NEVER reach this point
CPABORT("")
END FUNCTION dcharg_int_nri
! **************************************************************************************************
!> \brief Derivatives of interaction function between two point-charge
!> configurations NDDO sp-code. The derivative takes care of the screening
!> term only.
!> Non-Rotational Invariant definition of quadrupoles
!>
!> r - Distance r12
!> l1,m - Quantum numbers for multipole of configuration 1
!> l2,m - Quantum numbers for multipole of configuration 2
!> da - charge separation of configuration 1
!> db - charge separation of configuration 2
!> add - additive term
!>
!> \param r ...
!> \param l1_i ...
!> \param l2_i ...
!> \param m1_i ...
!> \param m2_i ...
!> \param da_i ...
!> \param db_i ...
!> \param add0 ...
!> \param fact_screen ...
!> \return ...
!> \date 04.2008 [tlaino]
!> \author Teodoro Laino [tlaino] - University of Zurich
! **************************************************************************************************
FUNCTION dcharg_int_nri_fs(r, l1_i, l2_i, m1_i, m2_i, da_i, db_i, add0, fact_screen) RESULT(charg)
REAL(KIND=dp), INTENT(in) :: r
INTEGER, INTENT(in) :: l1_i, l2_i, m1_i, m2_i
REAL(KIND=dp), INTENT(in) :: da_i, db_i, add0, fact_screen
REAL(KIND=dp) :: charg
INTEGER :: l1, l2, m1, m2
REAL(KIND=dp) :: add, da, db, dxdx, dxqxz, dzdz, dzqxx, &
dzqzz, fact, qqxx, qqzz, qxxqxx, &
qxxqyy, qxzqxz, xyxy, zzzz
! Computing only Integral Derivatives
IF (l1_i < l2_i) THEN
l1 = l1_i
l2 = l2_i
m1 = m1_i
m2 = m2_i
da = da_i
db = db_i
fact = 1.0_dp
ELSE IF (l1_i > l2_i) THEN
l1 = l2_i
l2 = l1_i
m1 = m2_i
m2 = m1_i
da = db_i
db = da_i
fact = (-1.0_dp)**(l1 + l2)
ELSE IF (l1_i == l2_i) THEN
l1 = l1_i
l2 = l2_i
IF (m1_i <= m2_i) THEN
m1 = m1_i
m2 = m2_i
da = da_i
db = db_i
ELSE
m1 = m2_i
m2 = m1_i
da = db_i
db = da_i
END IF
fact = 1.0_dp
END IF
charg = 0.0_dp
add = add0*fact_screen
! The 0.5 factor handles the derivative of the SQRT
fact = fact*0.5_dp
! Q - Q.
IF (l1 == 0 .AND. l2 == 0) THEN
charg = add0/SQRT(r**2 + add)**3
charg = -charg*fact
RETURN
END IF
! Q - Z.
IF (l1 == 0 .AND. l2 == 1 .AND. m2 == CLMz) THEN
charg = add0/SQRT((r + db)**2 + add)**3 - add0/SQRT((r - db)**2 + add)**3
charg = -charg*0.5_dp*fact
RETURN
END IF
! Z - Z.
IF (l1 == 1 .AND. l2 == 1 .AND. m1 == CLMz .AND. m2 == CLMz) THEN
dzdz = &
+add0/SQRT((r + da - db)**2 + add)**3 + add0/SQRT((r - da + db)**2 + add)**3 &
- add0/SQRT((r - da - db)**2 + add)**3 - add0/SQRT((r + da + db)**2 + add)**3
charg = -dzdz*0.25_dp*fact
RETURN
END IF
! X - X
IF (l1 == 1 .AND. l2 == 1 .AND. m1 == CLMp .AND. m2 == CLMp) THEN
dxdx = 2.0_dp*add0/SQRT(r**2 + (da - db)**2 + add)**3 - 2.0_dp*add0/SQRT(r**2 + (da + db)**2 + add)**3
charg = -dxdx*0.25_dp*fact
RETURN
END IF
! Q - ZZ
IF (l1 == 0 .AND. l2 == 2 .AND. m2 == CLMzz) THEN
qqzz = add0/SQRT((r - db)**2 + add)**3 - 2.0_dp*add0/SQRT(r**2 + add)**3 + add0/SQRT((r + db)**2 + add)**3
charg = -qqzz*0.25_dp*fact
RETURN
END IF
! Q - XX
IF (l1 == 0 .AND. l2 == 2 .AND. (m2 == CLMyy .OR. m2 == CLMxx)) THEN
qqxx = -add0/SQRT(r**2 + add)**3 + add0/SQRT(r**2 + add + db**2)**3
charg = -qqxx*0.5_dp*fact
RETURN
END IF
! Z - ZZ
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMz .AND. m2 == CLMzz) THEN
dzqzz = &
+add0/SQRT((r - da - db)**2 + add)**3 - 2.0_dp*add0/SQRT((r - da)**2 + add)**3 &
+ add0/SQRT((r - da + db)**2 + add)**3 - add0/SQRT((r + da - db)**2 + add)**3 &
+ 2.0_dp*add0/SQRT((r + da)**2 + add)**3 - add0/SQRT((r + da + db)**2 + add)**3
charg = -dzqzz*0.125_dp*fact
RETURN
END IF
! Z - XX
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMz .AND. (m2 == CLMyy .OR. m2 == CLMxx)) THEN
dzqxx = &
+add0/SQRT((r + da)**2 + add)**3 - add0/SQRT((r + da)**2 + add + db**2)**3 &
- add0/SQRT((r - da)**2 + add)**3 + add0/SQRT((r - da)**2 + add + db**2)**3
charg = -dzqxx*0.25_dp*fact
RETURN
END IF
! ZZ - ZZ
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzz .AND. m2 == CLMzz) THEN
zzzz = &
+add0/SQRT((r - da - db)**2 + add)**3 + add0/SQRT((r + da + db)**2 + add)**3 &
+ add0/SQRT((r - da + db)**2 + add)**3 + add0/SQRT((r + da - db)**2 + add)**3
xyxy = &
+add0/SQRT((r - da)**2 + add)**3 + add0/SQRT((r + da)**2 + add)**3 &
+ add0/SQRT((r - db)**2 + add)**3 + add0/SQRT((r + db)**2 + add)**3 &
- 2.0_dp*add0/SQRT(r**2 + add)**3
charg = -(zzzz*0.0625_dp - xyxy*0.125_dp)*fact
RETURN
END IF
! ZZ - XX
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzz .AND. (m2 == CLMxx .OR. m2 == CLMyy)) THEN
zzzz = &
-add0/SQRT((r + da)**2 + add)**3 + add0/SQRT((r + da)**2 + db**2 + add)**3 &
- add0/SQRT((r - da)**2 + add)**3 + add0/SQRT((r - da)**2 + db**2 + add)**3
xyxy = add0/SQRT(r**2 + db**2 + add)**3 - add0/SQRT(r**2 + add)**3
charg = -(zzzz*0.125_dp - xyxy*0.25_dp)*fact
RETURN
END IF
! X - ZX
IF (l1 == 1 .AND. l2 == 2 .AND. m1 == CLMp .AND. m2 == CLMzp) THEN
db = db/2.0_dp
dxqxz = &
-add0/SQRT((r - db)**2 + (da - db)**2 + add)**3 + add0/SQRT((r + db)**2 + (da - db)**2 + add)**3 &
+ add0/SQRT((r - db)**2 + (da + db)**2 + add)**3 - add0/SQRT((r + db)**2 + (da + db)**2 + add)**3
charg = -dxqxz*0.25_dp*fact
RETURN
END IF
! ZX - ZX
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMzp .AND. m2 == CLMzp) THEN
da = da/2.0_dp
db = db/2.0_dp
qxzqxz = &
+add0/SQRT((r + da - db)**2 + (da - db)**2 + add)**3 - add0/SQRT((r + da + db)**2 + (da - db)**2 + add)**3 &
- add0/SQRT((r - da - db)**2 + (da - db)**2 + add)**3 + add0/SQRT((r - da + db)**2 + (da - db)**2 + add)**3 &
- add0/SQRT((r + da - db)**2 + (da + db)**2 + add)**3 + add0/SQRT((r + da + db)**2 + (da + db)**2 + add)**3 &
+ add0/SQRT((r - da - db)**2 + (da + db)**2 + add)**3 - add0/SQRT((r - da + db)**2 + (da + db)**2 + add)**3
charg = -qxzqxz*0.125_dp*fact
RETURN
END IF
! XX - XX
IF (l1 == 2 .AND. l2 == 2 .AND. (((m1 == CLMyy) .AND. (m2 == CLMyy)) .OR. ((m1 == CLMxx) .AND. (m2 == CLMxx)))) THEN
qxxqxx = &
+2.0_dp*add0/SQRT(r**2 + add)**3 + add0/SQRT(r**2 + (da - db)**2 + add)**3 &
+ add0/SQRT(r**2 + (da + db)**2 + add)**3 - 2.0_dp*add0/SQRT(r**2 + da**2 + add)**3 &
- 2.0_dp*add0/SQRT(r**2 + db**2 + add)**3
charg = -qxxqxx*0.125_dp*fact
RETURN
END IF
! XX - YY
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMyy .AND. m2 == CLMxx) THEN
qxxqyy = &
+add0/SQRT(r**2 + add)**3 - add0/SQRT(r**2 + da**2 + add)**3 &
- add0/SQRT(r**2 + db**2 + add)**3 + add0/SQRT(r**2 + da**2 + db**2 + add)**3
charg = -qxxqyy*0.25_dp*fact
RETURN
END IF
! XY - XY
IF (l1 == 2 .AND. l2 == 2 .AND. m1 == CLMxy .AND. m2 == CLMxy) THEN
qxxqxx = &
+2.0_dp*add0/SQRT(r**2 + add)**3 + add0/SQRT(r**2 + (da - db)**2 + add)**3 &
+ add0/SQRT(r**2 + (da + db)**2 + add)**3 - 2.0_dp*add0/SQRT(r**2 + da**2 + add)**3 &
- 2.0_dp*add0/SQRT(r**2 + db**2 + add)**3
qxxqyy = &
+add0/SQRT(r**2 + add)**3 - add0/SQRT(r**2 + da**2 + add)**3 &
- add0/SQRT(r**2 + db**2 + add)**3 + add0/SQRT(r**2 + da**2 + db**2 + add)**3
charg = -0.5_dp*(qxxqxx*0.125_dp - qxxqyy*0.25_dp)*fact
RETURN
END IF
! We should NEVER reach this point
CPABORT("")
END FUNCTION dcharg_int_nri_fs
! **************************************************************************************************
!> \brief General driver for computing semi-empirical integrals <ij|kl>
!> involving d-orbitals.
!> The choice of the linear quadrupole was REALLY unhappy
!> in the first development of the NDDO codes. That choice makes
!> impossible the merging of the integral code with or without d-orbitals
!> unless a reparametrization of all NDDO codes for s and p orbitals will
!> be performed.. more over the choice of the linear quadrupole does not make
!> calculations rotational invariants (of course the rotational invariant
!> can be forced). The definitions of quadrupoles for d-orbitals is the
!> correct one in order to have the rotational invariant property by
!> construction..
!>
!> \param sepi ...
!> \param sepj ...
!> \param ij ...
!> \param kl ...
!> \param li ...
!> \param lj ...
!> \param lk ...
!> \param ll ...
!> \param ic ...
!> \param r ...
!> \param se_int_control ...
!> \param se_int_screen ...
!> \param itype ...
!> \return ...
!> \date 03.2008 [tlaino]