-
Notifications
You must be signed in to change notification settings - Fork 4
/
integral_calc_quad_dipole.f90
2905 lines (2515 loc) · 147 KB
/
integral_calc_quad_dipole.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
!
! ParaGauss, a program package for high-performance computations of
! molecular systems
!
! Copyright (C) 2014 T. Belling, T. Grauschopf, S. Krüger,
! F. Nörtemann, M. Staufer, M. Mayer, V. A. Nasluzov, U. Birkenheuer,
! A. Hu, A. V. Matveev, A. V. Shor, M. S. K. Fuchs-Rohr, K. M. Neyman,
! D. I. Ganyushin, T. Kerdcharoen, A. Woiterski, A. B. Gordienko,
! S. Majumder, M. H. i Rotllant, R. Ramakrishnan, G. Dixit,
! A. Nikodem, T. Soini, M. Roderus, N. Rösch
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License version 2 as
! published by the Free Software Foundation [1].
!
! 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.
!
! [1] http://www.gnu.org/licenses/gpl-2.0.html
!
! Please see the accompanying LICENSE file for further information.
!
!===================================================================
! Public interface of module
!===================================================================
subroutine integral_calc_quad_dipole()
!-------------------------------------------------------------------
!
! Purpose: This routine is the main routine for the
! integral calculation of one quadrupel
! ( unique atom 1, l 1, unique atom 2, l 2 )
! for dipole integral calculation.
! The corresponding data (including
! the quadrupel to be calculated) are stored in
! int_data_dipole_module.
! Contraction and symmetry-adaption are directly
! done within this subroutine.
!
! Subroutine called by: main_slave integral_main_dipole
! It contains: symadapt_add_nottotalsym_gten,
! symadapt_add_nottotalsym_sporgt
! renorm_spor_gt
! and other procedures
!
! References: Publisher Document: Concepts of Integral Part
!
! Author: TB
! Date: 7/97
!
!===================================================================
! End of public interface of module
!===================================================================
!-------------------------------------------------------------------
! Modifications
!-------------------------------------------------------------------
!
! Modification
! Author: AS
! Date: 7/98
! Description: ...
!
! Modification
! Author: DG
! Date: 20/03/2001
! Description: I must not do contractions now in case if kinematic factors is on in the gtensor stuff
! I will do it late in gtensor module (dipole_module.f90?)
!
! Modification use DLB instead of master/slave for dipole integrals
! Author: AN
! Date: 4/11
! Description: use DLB for scheduling batches of dipole integrals
! remove reporting back of slaves, they get their new
! tasks via DLB
!
! Modification (Please copy before editing)
! Author: ...
! Date: ...
! Description: ...
!-------------------------------------------------------------------
!------------ Modules used ------------------------------------
# include "def.h"
use type_module ! type specification parameters
use datatype
use timer_module
use time_module
use integralpar_module
use int_data_dipole_module
use output_module
use int_send_dipole_module
use iounitadmin_module
use operations_module, only: operations_gtensor, operations_dipole, operations_hfc
use options_module, only:options_kinematic_factors
implicit none
!------------ Declaration of local variables ------------------
integer(kind=i4_kind) :: i_ea1, i_ea2 ! loop indices for equal atoms
if ( output_int_loops .or. output_int_taskdistribution) then
write(output_unit,*) "integral_calc_quad_dipole: start with quadrupel ", &
quadrupel%ua1, quadrupel%l1, quadrupel%ua2, quadrupel%l2
write(stdout_unit,*) "integral_calc_quad_dipole: start with quadrupel ", &
quadrupel%ua1, quadrupel%l1, quadrupel%ua2, quadrupel%l2
endif
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: setup")
call setup()
eqal_atom_1: do i_ea1 = 1, ua1%N_equal_atoms
eqal_atom_2: do i_ea2 = 1, ua2%N_equal_atoms
if ( output_int_loops ) then
write(output_unit,*) &
"integral_calc_quad_dipole: processing pair of equal atoms ", &
i_ea1, i_ea2
write(stdout_unit,*) &
"integral_calc_quad_dipole: processing pair of equal atoms ", &
i_ea1, i_ea2
endif
center1 = ua1%position(:,i_ea1)
center2 = ua2%position(:,i_ea2)
! calculate primitive integrals and contract them
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: calc_primitives_and_contract")
call calc_primitives_and_contract(quadrupel%ua1,i_ea1,quadrupel%l1 &
,quadrupel%ua2,i_ea2,quadrupel%l2)
! add contribution of one pair
! of equal atom to symmetry adapted integrals
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole:&
& adding results to symmetry adapted arrays")
if( operations_dipole )then
if( options_spin_orbit )then
call symadapt_add_nottotalsym_spor()
else
call symadapt_add_nottotalsym()
endif
endif
#ifdef WITH_GTENSOR
if( operations_gtensor )then
ASSERT(options_spin_orbit)
call symadapt_add_nottotalsym_sporgt()
endif
if( operations_hfc )then
if (options_spin_orbit) then
call symadapt_add_nottotalsym_sohfc()
else
call symadapt_add_nottotalsym_hfc()
endif
endif
#endif
! deallocate contracted integrals
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: deallocate_contracted")
call deallocate_contracted() ! L291 dipol and gten
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: 1 pair of equal atoms done")
end do eqal_atom_2
end do eqal_atom_1
#if 0
! write debug output
if ( output_int_data ) call symadapt_write()
#endif
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: calculation done ")
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: int_send_dipole_send")
call int_send_dipole_send()
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: shutdown")
call shutdown()
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: end")
!--------------------------------------------------------------
!------------ Private Subroutines -----------------------------
contains
!*************************************************************
subroutine setup
! Purpose: contains setup routines of various modules
!------------ Executable code ------------------------------
call stop_timer(timer_int_idle_2cob3c(integralpar_i_int_part))
call init_timer(timer_int_calc_2cob3c(integralpar_i_int_part))
call start_timer(timer_int_calc_2cob3c(integralpar_i_int_part))
call start_timer(timer_int_quadrupel_2cob3c(integralpar_i_int_part))
call int_data_dipole_setup()
end subroutine setup
!**************************************************************
subroutine shutdown
! Purpose: contains shutdown routines of various modules
!------------ Executable code ------------------------------
call int_data_dipole_shutdown()
call stop_timer(timer_int_calc_2cob3c(integralpar_i_int_part))
call stop_timer(timer_int_quadrupel_2cob3c(integralpar_i_int_part))
call start_timer(timer_int_idle_2cob3c(integralpar_i_int_part))
call timer_small_to_large( &
timer_int_calc_2cob3c(integralpar_i_int_part), &
timer_int_calcsum_2cob3c(integralpar_i_int_part) )
end subroutine shutdown
!**************************************************************
!**************************************************************
subroutine allocate_primitives()
! Purpose: allocates storage for primitive integrals
implicit none
!------------ Declaration of local variables ----------------
integer(kind=i4_kind) :: status
!------------ Executable code ------------------------------
integralpar: if ( integralpar_2cob_dipole ) then
dip: if(operations_dipole) then
allocate( prim_int_2cob_dipole(n_exp2,n_exp1,n_m2,n_m1,3), &
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: allocate_primitives: 2cob_dipole")
prim_int_2cob_dipole = 0.0_r8_kind
end if dip
#ifdef WITH_GTENSOR
gt:if (operations_gtensor) then
allocate( prim_int_2cob_dipoleg(n_exp2,n_exp1,n_m2,n_m1,13), & ! 4 + 9 DG
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: allocate_primitives: 2cob_dipoleg")
prim_int_2cob_dipoleg = 0.0_r8_kind
kf: if(options_kinematic_factors) then
allocate( cont_int_2cob_dipoleg(n_exp2,n_exp1,n_m2,n_m1,13), &
! 4 + 9 DG in case if kinematic factors I mustn`t run
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: allocate_primitives: 2cob_dipoleg")
!contract procedure, I`ll do it later in gtensor module
cont_int_2cob_dipoleg = 0.0_r8_kind
end if kf
end if gt
hfc:if (operations_hfc) then
allocate( prim_int_2cob_hfc(n_exp2,n_exp1,n_m2,n_m1,10,n_unique_atoms), & ! DG
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: allocate_primitives: 2cob_hfc")
prim_int_2cob_hfc = 0.0_r8_kind
kf_hfc: if(options_kinematic_factors) then
allocate( cont_int_2cob_hfc(n_exp2,n_exp1,n_m2,n_m1,10,n_unique_atoms), & !
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: allocate_primitives: 2cob_hfc") !
cont_int_2cob_hfc = 0.0_r8_kind
end if kf_hfc
end if hfc
#endif
endif integralpar
end subroutine allocate_primitives
!**************************************************************
!**************************************************************
subroutine deallocate_contracted()
! Purpose: deallocates storage of contracted integrals
implicit none
!------------ Declaration of local variables ----------------
integer(kind=i4_kind) :: status
!------------ Executable code -------------------------------
integralpar: if (integralpar_2cob_dipole ) then
if (operations_dipole) then
deallocate( cont_int_2cob_dipole, &
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: deallocate_contracted: 2cob_dipole")
endif
#ifdef WITH_GTENSOR
if (operations_gtensor ) then
deallocate( cont_int_2cob_dipoleg, &
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: deallocate_contracted: 2cob_dipoleg")
endif
if (operations_hfc ) then
deallocate( cont_int_2cob_hfc, &
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: deallocate_contracted: 2cob_hfc")
endif
#endif
end if integralpar
end subroutine deallocate_contracted
!**************************************************************
!**************************************************************
subroutine deallocate_primitivies()
! Purpose: deallocates storage of contracted integrals
implicit none
!------------ Declaration of local variables ----------------
integer(kind=i4_kind) :: status
!------------ Executable code -------------------------------
integralpar: if (integralpar_2cob_dipole ) then
if (operations_dipole) then
deallocate( prim_int_2cob_dipole, &
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: deallocate_primitivies: 2cob_dipole")
endif
#ifdef WITH_GTENSOR
if (operations_gtensor ) then
deallocate( prim_int_2cob_dipoleg, &
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: deallocate_primitivies: 2cob_dipoleg")
endif
if (operations_hfc ) then
deallocate( prim_int_2cob_hfc, &
stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: deallocate_primitivies: 2cob_hfc")
endif
#endif
end if integralpar
end subroutine deallocate_primitivies
!**************************************************************
!**************************************************************
subroutine contract_2center(prim,cont,n_xyz)
! Purpose: does contraction on two center integrals
! the result is in cont that is allocated by this subroutine
! prim is deallocated
!------------ Declaration of formal parameters -------------
real(kind=r8_kind), pointer, dimension(:,:,:,:,:) :: prim,cont
integer(kind=i4_kind), intent(in) :: n_xyz
!------------ Declaration of local variables ---------------
real(kind=r8_kind), allocatable :: int(:)
real(kind=r8_kind) :: coef
integer(kind=i4_kind) :: i_m1, i_m2, i_exp1, i_exp2, i_c1, &
i_c2, i_co1, i_co2, status, i_xyz
!------------ Executable code ------------------------------
allocate( int(n_c2), stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: contract_2center: allocate of int failed")
allocate( cont(n_c2,n_c1,n_m2,n_m1,n_xyz), stat=status ) !Allocate contracted integrals
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: contract_2center: allocate of cont failed")
cont(:,n_uncontr1+1:,:,:,:) = 0.0_r8_kind
xyz: do i_xyz = 1, n_xyz
m1: do i_m1 = 1, n_m1
m2: do i_m2 = 1, n_m2
exp1_uc: do i_exp1 = 1, n_uncontr1
do i_c2 =1, n_uncontr2
int(i_c2) = prim(i_c2,i_exp1,i_m2,i_m1,i_xyz)
enddo
i_co2 = 1
do i_c2 = n_uncontr2 + 1, n_c2
int(i_c2) = 0.0_r8_kind
do i_exp2 = 1, n_exp2
int(i_c2) = int(i_c2) + &
contractions2(i_exp2,i_co2) * &
prim(i_exp2,i_exp1,i_m2,i_m1,i_xyz)
enddo
i_co2 = i_co2 + 1
enddo
i_co1 = 1
do i_c1= n_uncontr1 + 1, n_c1
coef = contractions1(i_exp1,i_co1)
do i_c2 = 1, n_c2
cont(i_c2,i_c1,i_m2,i_m1,i_xyz) = &
cont(i_c2,i_c1,i_m2,i_m1,i_xyz) + &
coef * int(i_c2)
enddo
i_co1 = i_co1 + 1
enddo
do i_c2 = 1, n_c2
cont(i_c2,i_exp1,i_m2,i_m1,i_xyz) = int(i_c2)
enddo
enddo exp1_uc
exp1_c: do i_exp1 = n_uncontr1 + 1, n_exp1
do i_c2 =1, n_uncontr2
int(i_c2) = prim(i_c2,i_exp1,i_m2,i_m1,i_xyz)
enddo
i_co2 = 1
do i_c2 = n_uncontr2 + 1, n_c2
int(i_c2) = 0.0_r8_kind
do i_exp2 = 1, n_exp2
int(i_c2) = int(i_c2) + &
contractions2(i_exp2,i_co2) * &
prim(i_exp2,i_exp1,i_m2,i_m1,i_xyz)
enddo
i_co2 = i_co2 + 1
enddo
i_co1 = 1
do i_c1= n_uncontr1 + 1, n_c1
coef = contractions1(i_exp1,i_co1)
do i_c2 = 1, n_c2
cont(i_c2,i_c1,i_m2,i_m1,i_xyz) = &
cont(i_c2,i_c1,i_m2,i_m1,i_xyz) + &
coef * int(i_c2)
enddo
i_co1 = i_co1 + 1
enddo
enddo exp1_c
enddo m2
enddo m1
enddo xyz
!deallocation of primitivies removed to deallocate_primitivies() DG
deallocate( int, stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: contract_2center: deallocate of int failed")
end subroutine contract_2center
!**************************************************************
!**************************************************************
subroutine contract_2center_nua(prim,cont,n_xyz)
! Purpose: does contraction on two center integrals
! the result is in cont that is allocated by this subroutine
! prim is deallocated for n_unique_atoms
!------------ Declaration of formal parameters -------------
real(kind=r8_kind), pointer, dimension(:,:,:,:,:,:) :: prim,cont
integer(kind=i4_kind), intent(in) :: n_xyz
!------------ Declaration of local variables ---------------
real(kind=r8_kind), allocatable :: int(:)
real(kind=r8_kind) :: coef
integer(kind=i4_kind) :: i_m1, i_m2, i_exp1, i_exp2, i_c1, &
i_c2, i_co1, i_co2, status, i_xyz, i_ua
!------------ Executable code ------------------------------
allocate( int(n_c2), stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: contract_2center: allocate of int failed")
allocate( cont(n_c2,n_c1,n_m2,n_m1,n_xyz,n_unique_atoms), stat=status )
!Allocate contracted integrals
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: contract_2center: allocate of cont failed")
cont(:,n_uncontr1+1:,:,:,:,:) = 0.0_r8_kind
loopua: do i_ua = 1,n_unique_atoms
xyz: do i_xyz = 1, n_xyz
m1: do i_m1 = 1, n_m1
m2: do i_m2 = 1, n_m2
exp1_uc: do i_exp1 = 1, n_uncontr1
do i_c2 =1, n_uncontr2
int(i_c2) = prim(i_c2,i_exp1,i_m2,i_m1,i_xyz,i_ua)
enddo
i_co2 = 1
do i_c2 = n_uncontr2 + 1, n_c2
int(i_c2) = 0.0_r8_kind
do i_exp2 = 1, n_exp2
int(i_c2) = int(i_c2) + &
contractions2(i_exp2,i_co2) * &
prim(i_exp2,i_exp1,i_m2,i_m1,i_xyz,i_ua)
enddo
i_co2 = i_co2 + 1
enddo
i_co1 = 1
do i_c1= n_uncontr1 + 1, n_c1
coef = contractions1(i_exp1,i_co1)
do i_c2 = 1, n_c2
cont(i_c2,i_c1,i_m2,i_m1,i_xyz,i_ua) = &
cont(i_c2,i_c1,i_m2,i_m1,i_xyz,i_ua) + &
coef * int(i_c2)
enddo
i_co1 = i_co1 + 1
enddo
do i_c2 = 1, n_c2
cont(i_c2,i_exp1,i_m2,i_m1,i_xyz,i_ua) = int(i_c2)
enddo
enddo exp1_uc
exp1_c: do i_exp1 = n_uncontr1 + 1, n_exp1
do i_c2 =1, n_uncontr2
int(i_c2) = prim(i_c2,i_exp1,i_m2,i_m1,i_xyz,i_ua)
enddo
i_co2 = 1
do i_c2 = n_uncontr2 + 1, n_c2
int(i_c2) = 0.0_r8_kind
do i_exp2 = 1, n_exp2
int(i_c2) = int(i_c2) + &
contractions2(i_exp2,i_co2) * &
prim(i_exp2,i_exp1,i_m2,i_m1,i_xyz,i_ua)
enddo
i_co2 = i_co2 + 1
enddo
i_co1 = 1
do i_c1= n_uncontr1 + 1, n_c1
coef = contractions1(i_exp1,i_co1)
do i_c2 = 1, n_c2
cont(i_c2,i_c1,i_m2,i_m1,i_xyz,i_ua) = &
cont(i_c2,i_c1,i_m2,i_m1,i_xyz,i_ua) + &
coef * int(i_c2)
enddo
i_co1 = i_co1 + 1
enddo
enddo exp1_c
enddo m2
enddo m1
enddo xyz
end do loopua
!deallocation of primitivies removed to deallocate_primitivies() DG
deallocate( int, stat=status )
if ( status .ne. 0 ) call error_handler( &
"integral_calc_quad_dipole: contract_2center_nua: deallocate of int failed")
end subroutine contract_2center_nua
!**************************************************************
!**************************************************************
subroutine calc_primitives_and_contract(U1,E1,L1,U2,E2,L2)
! calculate primitive integrals and do contraction
use shgi_dip, only: shgi_dip_drv
implicit none
integer(i4_kind), intent(in) :: U1,E1,L1,U2,E2,L2
! *** end of interface ***
!------------ Declaration of local variables ---------------
integer(kind=i4_kind) :: i_ua
!!$ integer(kind=i4_kind) :: i_c1, i_c2, i_exp1, i_exp2
! help pointers
!------------ Executable code ------------------------------
! allocate primitive integrals
call allocate_primitives()
! calculate primitive integrals
call start_timer(timer_int_prim_2cob3c(integralpar_i_int_part))
if (operations_dipole) then
! calculate primitive integrals
call shgi_dip_drv(U1,E1,L1,U2,E2,L2,unique_atoms &
, prim_int_2cob_dipole)
endif
#ifdef WITH_GTENSOR
gt:if(operations_gtensor) then
call ll_calculate_dipoleg(U1,U2,L1,L2)
end if gt
hfc:if(operations_hfc) then
call ll_calculate_hfc(U1,U2,L1,L2)
end if hfc
#endif
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: calc_primitives_and_contract:&
&primitive integrals done")
call stop_timer(timer_int_prim_2cob3c(integralpar_i_int_part))
#if 0
if ( output_int_data ) then
! write primitive 2-center integrals
write(debug_unit,*)
write(debug_unit,*)
write(debug_unit,*) "######### primitive 2-center integrals ##########"
if (integralpar_2cob_dipole) then
write(debug_unit,*) "i_exp1, i_exp2, dipole"
do i_exp1 = 1,n_exp1
do i_exp2 = 1,n_exp2
write(debug_unit,'(2I4,100F20.8)') i_exp1, i_exp2, &
prim_int_2cob_dipole(i_exp2,i_exp1,:,:,:)
enddo
enddo
endif
write(debug_unit,*) "######### primitive 2-center integrals end ##########"
write(debug_unit,*)
write(debug_unit,*)
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: write 2 center primitives done")
endif
#endif
! do contraction
call start_timer(timer_int_cont_2cob3c(integralpar_i_int_part))
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: calc_primitives_and_contract:&
& contract 2cob_dipole")
dip: if (operations_dipole) then
call contract_2center(prim_int_2cob_dipole,cont_int_2cob_dipole,3)
end if dip
#ifdef WITH_GTENSOR
gten:if (operations_gtensor) then
kf:if(options_kinematic_factors) then
DPRINT 'don"t cotract now'
cont_int_2cob_dipoleg(:,:,:,:,:) = prim_int_2cob_dipoleg(:,:,:,:,:)
!DG I`m passing the array directly, w/o contraction
!Here I must deallocate primitives integrals because
!I don`t like to change the name of array later in all
!normaly they are deallocated in contact_2centre
!places, so I remapping it one to one directly
else
DPRINT ' cotract now'
call contract_2center(prim_int_2cob_dipoleg,cont_int_2cob_dipoleg,13) !DG
end if kf
end if gten
hfc_c:if (operations_hfc) then
hfckf:if(options_kinematic_factors) then
DPRINT 'don"t cotract now'
cont_int_2cob_hfc(:,:,:,:,:,:) = prim_int_2cob_hfc(:,:,:,:,:,:)
!DG I`m passing the array directly, w/o contraction
!Here I must deallocate primitives integrals because
!I don`t like to change the name of array later in all
!normaly they are deallocated in contact_2centre
!places, so I remapping it one to one directly
! this is not a good idea, I showld have just to change pointer
! to avoid data transfer
else
DPRINT " cotract now"
Do i_ua = 1, n_unique_atoms
call contract_2center_nua(prim_int_2cob_hfc,cont_int_2cob_hfc, 10 ) !DG
end Do
end if hfckf
end if hfc_c
#endif
!deallocation of primitivies integrals
call deallocate_primitivies()
call stop_timer(timer_int_cont_2cob3c(integralpar_i_int_part))
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_2cob3c: calc_primitives_and_contract:&
& contraction done")
#if 0
if ( output_int_data ) then
! write contracted integrals
write(debug_unit,*)
write(debug_unit,*)
write(debug_unit,*) "######### comtracted 2-center integrals ##########"
if (integralpar_2cob_dipole) then
write(debug_unit,*) "i_c1, i_c2, dipole"
do i_c1 = 1,n_c1
do i_c2 = 1,n_c2
write(debug_unit,'(2I4,100F20.8)') i_c1, i_c2, &
cont_int_2cob_dipole(i_c2,i_c1,:,:,:)
enddo
enddo
endif
write(debug_unit,*) "######### contracted 2-center integrals end ##########"
write(debug_unit,*)
write(debug_unit,*)
if ( output_int_loops ) call write_to_output_units( &
"integral_calc_quad_dipole: write done")
endif
#endif
end subroutine calc_primitives_and_contract
!**************************************************************
!**************************************************************
subroutine symadapt_add_nottotalsym()
! add contribution of one pair
! of equal atom to symmetry adapted integrals
! the case of not total symmetric integrals
!------------ Declaration of local variables ---------------
real(kind=r8_kind), pointer, dimension(:,:,:,:) :: &
saint_2cob_dipole
type(unique_atom_partner_type), pointer :: sap1, sap2
type(unique_atom_sa_int_type), pointer :: sat1, sat2
integer(kind=i4_kind) :: i_xyz, i_ir1, i_ir2, i_pa1, i_pa2, &
i_ip1, i_if1, i_if2, i_cf1, i_cf2, m1, m2
integer(kind=i4_kind) :: i_ip2
real(kind=r8_kind) :: coef1, coef
!------------ Executable code ------------------------------
if(.not.integralpar_2cob_dipole) RETURN ! FIXME: dont enter in the first line
call start_timer(timer_int_symadapt_2cob3c(integralpar_i_int_part))
! dipole: if ( integralpar_2cob_dipole ) then
xyz: do i_xyz = 1, 3
i_ip1 = 1
irrep1: do i_ir1 = 1, symmetry_data_n_irreps()
sap1 => ua1%symadapt_partner(i_ir1,quadrupel%l1)
partner1: do i_pa1 = 1, symmetry_data_n_partners(i_ir1)
i_ip2 = 1
irrep2: do i_ir2 = 1, i_ir1
sap2 => ua2%symadapt_partner(i_ir2,quadrupel%l2)
partner2: do i_pa2 = 1, symmetry_data_n_partners(i_ir2)
needed: if ( associated( &
symadapt_int_2cob_dipole(i_ip2,i_ip1,i_xyz)%int ) ) then
saint_2cob_dipole => symadapt_int_2cob_dipole(i_ip2,i_ip1,i_xyz)%int
ind_fct_1: do i_if1 = 1, sap1%N_independent_fcts
sat1 => sap1%sa_int(i_ea1,i_if1,i_pa1)
ind_fct_2: do i_if2 = 1, sap2%N_independent_fcts
sat2 => sap2%sa_int(i_ea2,i_if2,i_pa2)
m_sum_1: do i_cf1 = 1, sat1%N_fcts
m1 = sat1%m(i_cf1)
coef1 = sat1%c(i_cf1)
m_sum_2: do i_cf2 = 1, sat2%N_fcts
m2 = sat2%m(i_cf2)
coef = sat2%c(i_cf2) * coef1
saint_2cob_dipole(:,:,i_if2,i_if1) = &
saint_2cob_dipole(:,:,i_if2,i_if1) + &
coef * cont_int_2cob_dipole(:,:,m2,m1,i_xyz)
enddo m_sum_2
enddo m_sum_1
enddo ind_fct_2
enddo ind_fct_1
endif needed
i_ip2 = i_ip2 + 1
enddo partner2
enddo irrep2
i_ip1 = i_ip1 + 1
enddo partner1
enddo irrep1
enddo xyz
! endif dipole
call stop_timer(timer_int_symadapt_2cob3c(integralpar_i_int_part))
end subroutine symadapt_add_nottotalsym
!**************************************************************
#ifdef WITH_GTENSOR
!**************************************************************
subroutine symadapt_add_nottotalsym_hfc()
! add contribution of one pair
! of equal atom to symmetry adapted integrals
! the case of not total symmetric integrals
!------------ Declaration of local variables ---------------
real(kind=r8_kind), pointer, dimension(:,:,:,:) :: &
saint_2cob_hfc
type(unique_atom_partner_type), pointer :: sap1, sap2
type(unique_atom_sa_int_type), pointer :: sat1, sat2
integer(kind=i4_kind) :: i_xyz, i_ir1, i_ir2, i_pa1, i_pa2, &
i_ip1, i_if1, i_if2, i_cf1, i_cf2, m1, m2, i_ua
real(kind=r8_kind) :: coef1, coef
!------------ Executable code ------------------------------
if(.not.integralpar_2cob_dipole) RETURN ! FIXME: dont enter at all
call start_timer(timer_int_symadapt_2cob3c(integralpar_i_int_part))
! neednrhfc: if ( integralpar_2cob_dipole ) then
nua : do i_ua = 1, n_unique_atoms
xyznr: do i_xyz = 1, 7
i_ip1 = 1
do i_ir1 = 1, symmetry_data_n_irreps()
sap1 => ua1%symadapt_partner(i_ir1,quadrupel%l1)
do i_pa1 = 1, symmetry_data_n_partners(i_ir1)
i_ir2 = i_ir1
i_pa2 = i_pa1
sap2 => ua2%symadapt_partner(i_ir2,quadrupel%l2)
if ( associated( &
symadapt_int_2cob_hfc_p(1,i_ip1,i_xyz, i_ua)%int ) ) then
saint_2cob_hfc => symadapt_int_2cob_hfc_p(1,i_ip1,i_xyz, i_ua)%int
select case(i_xyz)
case(7)! Aiso 10->7
do i_if1 = 1, sap1%N_independent_fcts
sat1 => sap1%sa_int(i_ea1,i_if1,i_pa1)
do i_if2 = 1, sap2%N_independent_fcts
sat2 => sap2%sa_int(i_ea2,i_if2,i_pa2)
do i_cf1 = 1, sat1%N_fcts
m1 = sat1%m(i_cf1)
coef1 = sat1%c(i_cf1)
do i_cf2 = 1, sat2%N_fcts
m2 = sat2%m(i_cf2)
coef = sat2%c(i_cf2) * coef1
saint_2cob_hfc(:,:,i_if2,i_if1) = &
saint_2cob_hfc(:,:,i_if2,i_if1) + &
coef * cont_int_2cob_hfc(:,:,m2,m1,10, i_ua)
enddo
enddo
enddo
enddo
case(1:6)! 1->1, 2->2 etc. See description in the end of ll_calculate_hfc
do i_if1 = 1, sap1%N_independent_fcts
sat1 => sap1%sa_int(i_ea1,i_if1,i_pa1)
do i_if2 = 1, sap2%N_independent_fcts
sat2 => sap2%sa_int(i_ea2,i_if2,i_pa2)
do i_cf1 = 1, sat1%N_fcts
m1 = sat1%m(i_cf1)
coef1 = sat1%c(i_cf1)
do i_cf2 = 1, sat2%N_fcts
m2 = sat2%m(i_cf2)
coef = sat2%c(i_cf2) * coef1
saint_2cob_hfc(:,:,i_if2,i_if1) = &
saint_2cob_hfc(:,:,i_if2,i_if1) + &
coef * cont_int_2cob_hfc(:,:,m2,m1,i_xyz, i_ua)
enddo
enddo
enddo
enddo
end select
end if
i_ip1 = i_ip1 + 1
enddo
enddo
enddo xyznr
end do nua
! endif neednrhfc
call stop_timer(timer_int_symadapt_2cob3c(integralpar_i_int_part))
end subroutine symadapt_add_nottotalsym_hfc
#endif
subroutine symadapt_add_nottotalsym_spor()
! add contribution of one pair
! of equal atom to symmetry adapted integrals
! the case of not total symmetric integrals
!------------ Declaration of local variables ---------------
real(kind=r8_kind), pointer, dimension(:,:,:,:) :: &
saint_2cob_dipole_real,saint_2cob_dipole_imag
type(unique_atom_partner_type), pointer :: sap1, sap2
type(unique_atom_sa_int_type), pointer :: sat1, sat2
integer(kind=i4_kind) :: i_xyz, i_ir1, i_ir2, i_pa1, i_pa2, &
i_ip1, i_ip2, i_if1, i_if2, i_cf1, i_cf2, m1, m2,alpha
real(kind=r8_kind) :: coef1_real, coef2_real, coef_real, coef1_imag, coef2_imag, coef_imag
real(kind=r8_kind) :: coef_real_arr(9,9),coef_imag_arr(9,9)
!------------ Executable code ------------------------------
if(.not.integralpar_2cob_dipole) RETURN ! FIXME: dont enter at all
call start_timer(timer_int_symadapt_2cob3c(integralpar_i_int_part))
! dipole: if ( integralpar_2cob_dipole ) then
xyz: do i_xyz = 1, 3
i_ip1 = 1
irrep1: do i_ir1 = 1, symmetry_data_n_proj_irreps()
sap1 => ua1%symadapt_spor_partner(i_ir1,quadrupel%l1)
partner1: do i_pa1 = 1, symmetry_data_n_partners_proj(i_ir1)
i_ip2 = 1
irrep2: do i_ir2 = 1, i_ir1
sap2 => ua2%symadapt_spor_partner(i_ir2,quadrupel%l2)
partner2: do i_pa2 = 1, symmetry_data_n_partners_proj(i_ir2)
needed: if ( associated( &
symadapt_int_2cob_dipole_p(i_ip2,i_ip1,i_xyz)%int ) ) then
saint_2cob_dipole_real => symadapt_int_2cob_dipole_p(i_ip2,i_ip1,i_xyz)%int
saint_2cob_dipole_imag => symadapt_int_2cob_dipole_p(i_ip2,i_ip1,i_xyz)%int_imag
ind_fct_1: do i_if1 = 1, sap1%N_independent_fcts
ind_fct_2: do i_if2 = 1, sap2%N_independent_fcts
coef_real_arr = 0.0_r8_kind
coef_imag_arr = 0.0_r8_kind
spin_up_and_down: do alpha =1,2
sat1 => sap1%sa_spor_int(i_ea1,alpha,i_if1,i_pa1)
sat2 => sap2%sa_spor_int(i_ea2,alpha,i_if2,i_pa2)
m_sum_1: do i_cf1 = 1, sat1%N_fcts
m1 = sat1%m(i_cf1)
coef1_real = sat1%re(i_cf1)
coef1_imag = sat1%im(i_cf1)
m_sum_2: do i_cf2 = 1, sat2%N_fcts
m2 = sat2%m(i_cf2)
coef2_real = sat2%re(i_cf2)
coef2_imag = sat2%im(i_cf2)
coef_real = coef1_real * coef2_real + coef1_imag * coef2_imag
coef_imag = - coef1_real * coef2_imag + coef1_imag * coef2_real
coef_real_arr(m2,m1) = coef_real_arr(m2,m1) + coef_real
coef_imag_arr(m2,m1) = coef_imag_arr(m2,m1) + coef_imag
enddo m_sum_2
enddo m_sum_1
enddo spin_up_and_down
do m2 = 1,quadrupel%l2*2+1
do m1 = 1,quadrupel%l1*2+1
if (abs(coef_real_arr(m2,m1)).gt.0.0_r8_kind) then
saint_2cob_dipole_real(:,:,i_if2,i_if1) = &
saint_2cob_dipole_real(:,:,i_if2,i_if1) + &
coef_real_arr(m2,m1) * cont_int_2cob_dipole(:,:,m2,m1,i_xyz)
endif
if (abs(coef_imag_arr(m2,m1)).gt.0.0_r8_kind) then
saint_2cob_dipole_imag(:,:,i_if2,i_if1) = &
saint_2cob_dipole_imag(:,:,i_if2,i_if1) + &
coef_imag_arr(m2,m1) * cont_int_2cob_dipole(:,:,m2,m1,i_xyz)
endif
enddo
enddo
enddo ind_fct_2
enddo ind_fct_1
endif needed
i_ip2 = i_ip2 + 1
enddo partner2
enddo irrep2
i_ip1 = i_ip1 + 1
enddo partner1
enddo irrep1
enddo xyz
! endif dipole
call stop_timer(timer_int_symadapt_2cob3c(integralpar_i_int_part))
end subroutine symadapt_add_nottotalsym_spor
!**************************************************************
#ifdef WITH_GTENSOR
!**************************************************************
subroutine symadapt_add_nottotalsym_sporgt()
! add contribution of one pair
! of equal atom to symmetry adapted integrals
! the case of not total symmetric integrals
! calculates all associated symmetry adapted integrals
!------------ Declaration of local variables ---------------
real(kind=r8_kind), pointer, dimension(:,:,:,:) :: &
saint_2cob_dipoleg_real,saint_2cob_dipoleg_imag, &
saint_2cob_dipoleg_offdiag_real,&
saint_2cob_dipoleg_offdiag_imag
type(unique_atom_partner_type), pointer :: sap1, sap2
type(unique_atom_sa_int_type), pointer :: sat1, sat2
integer(kind=i4_kind) :: i_xyz, i_ir1, i_ir2, i_pa1, i_pa2, &
i_ip1, i_if1, i_if2, i_cf1, i_cf2, m1, m2,alpha
real(kind=r8_kind) :: coef1_real, coef2_real, coef_real, coef1_imag, coef2_imag, coef_imag
real(kind=r8_kind) :: coef_real_arr(9,9),coef_imag_arr(9,9)
integer(i4_kind) :: i
integer(i4_kind), pointer :: cc_coupling(:) ! Coupling of irreps by complex conjugation
!------------ Executable code ------------------------------
if(.not.integralpar_2cob_dipole) RETURN ! FIXME: dont enter at all
#if _DPRINT
print *,'symadapt_add_nottotalsym_sporgt runs...'
print *,'symadapt_add_nottotalsym_sporgt: symadapt_int_2cob_dipoleg_p:'
print *,'symadapt_add_nottotalsym_sporgt +shape=',shape(symadapt_int_2cob_dipoleg_p)
print *,'symadapt_add_nottotalsym_sporgt +shape(%int)',&
& shape(symadapt_int_2cob_dipoleg_p(1,1,1)%int)
#endif
call start_timer(timer_int_symadapt_2cob3c(integralpar_i_int_part))
! gten: if ( integralpar_2cob_dipole ) then
!!!!???? Diagonal matrix elements are calculated
xyzd: do i_xyz = 1, 7 ! Lx,Ly,Lz,S,sigma_x,sigma_y,sygma_z + 3 correction terms in the future
DPRINT 'symadapt_add_nottotalsym_sporgt: xyz=',i_xyz
i_ip1 = 1
irrep1_d: do i_ir1 = 1, symmetry_data_n_proj_irreps()
DPRINT 'symadapt_add_nottotalsym_sporgt: ir1=',i_ir1
sap1 => ua1%symadapt_spor_partner(i_ir1,quadrupel%l1)
partner1_d: do i_pa1 = 1, symmetry_data_n_partners_proj(i_ir1)
i_ir2 = i_ir1
i_pa2 = i_pa1
sap2 => ua2%symadapt_spor_partner(i_ir2,quadrupel%l2)
needed_d: if ( associated( &
symadapt_int_2cob_dipoleg_p(1,i_ip1,i_xyz)%int )) then
saint_2cob_dipoleg_real => &
symadapt_int_2cob_dipoleg_p(1,i_ip1,i_xyz)%int
saint_2cob_dipoleg_imag => &
symadapt_int_2cob_dipoleg_p(1,i_ip1,i_xyz)%int_imag
#if _DPRINT
print *,'symadapt_add_nottotalsym_sporgt +shape(%int)', shape(saint_2cob_dipoleg_real)
print *,'symadapt_add_nottotalsym_sporgt +shape(%int)', shape(saint_2cob_dipoleg_imag)
#endif
select case(i_xyz)
case(1:4)! Lx,Ly,Lz,S
offind_fct_1_L1_d: do i_if1 = 1, sap1%N_independent_fcts
offind_fct_2_L1_d: do i_if2 = 1, sap2%N_independent_fcts
coef_real_arr = 0.0_r8_kind
coef_imag_arr = 0.0_r8_kind
do alpha =1,2
sat1 => sap1%sa_spor_int(i_ea1,alpha,i_if1,i_pa1)
sat2 => sap2%sa_spor_int(i_ea2,alpha,i_if2,i_pa2)
do i_cf1 = 1, sat1%N_fcts