-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule_auxiliary.f90
More file actions
1331 lines (1117 loc) · 40.1 KB
/
module_auxiliary.f90
File metadata and controls
1331 lines (1117 loc) · 40.1 KB
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
!===============================================================================
! module auxiliary
!===============================================================================
module auxiliary
use global
implicit none
!---------------------information for alpha string -----------------------------
integer,save :: n_string_a_fci
integer,allocatable,save :: i_string_a(:,:)
integer,allocatable,save :: i_string_a2(:,:)
!---------------------information for alpha string + beta string----------------
integer,save :: n_string_ab
integer,allocatable,save :: i_string_ab(:,:)
integer,allocatable,save :: i_string_ab2(:,:)
!---------------------space and spino ------------------------------------------
integer,allocatable,save :: space(:)
integer,allocatable,save :: spino(:)
!
integer,allocatable,save :: i_string_ab_h(:,:),i_string_ab2_h(:,:)
integer :: n_zmp1,n_zmp2
integer :: n_string_ab_h
!
integer,allocatable,save :: num_amp1(:),i_amp1(:,:,:),num_amp2(:),i_amp2(:,:,:)
integer ::n_aten,n_string_ab_hij,l_zmp1,l_zmp2
integer,allocatable,save :: i_zmp1(:,:),i_zmp2(:,:)
integer, allocatable,save :: i_string_ab_hij(:,:)
complex(kind=k2),allocatable,save :: czet1(:,:),cv_zet2(:)
!
! set the alphastring and betestring parameter
!
integer,allocatable,save :: w_vertex(:,:),n_string_ab_inv(:)
contains
!
! calculate the i_string_a, i_string_a2
! nume = numelectron/2
subroutine config1()
implicit none
integer :: ifault,idicp,jdicp,kdicp
real(kind=k1) :: resultp
call factorialcnm(system%nptot,system%numelectron/2,resultp)
n_string_a_fci =int(resultp)
!
! allocate the address
!
allocate(i_string_a(n_string_a_fci,system%numelectron/2))
allocate(i_string_a2(n_string_a_fci,system%nptot))
i_string_a = 0
i_string_a2 = 0
!
! get jout
!
call allnr(system%nptot,system%numelectron/2,n_string_a_fci,i_string_a,ifault)
if(ifault/=0) then
write(*,*) 'error happen in subroutine config1'
write(*,*) '--maybe the input parameter is something wrong--'
stop
endif
write(*,*) 'total-spatial orbitals',system%nptot
write(*,*)
write(*,*) '-----------i_string_a----------------'
write(*,*)
do idicp =1,n_string_a_fci
write(*,*) (i_string_a(idicp,jdicp),jdicp=1,system%numelectron/2)
enddo
!
! second quantuzation
! 4 spatial orbital, 4 electrons | f1:1 f2:2 f3:3
! jout 1,2 jout2 1, 1, 0, 0
! 1,3 1, 0, 1, 0
! 1,4 1, 0, 0, 1
! 2,3 0, 1, 1, 0
! 2,4 0, 1, 0, 1
! 3,4 0, 0, 1, 1
!
do idicp = 1,n_string_a_fci
do jdicp = 1,system%numelectron/2
kdicp = i_string_a(idicp,jdicp)
if(kdicp>=1.and.kdicp<=system%nptot) then
i_string_a2(idicp,kdicp) = 1
else
write(*,*) 'error happen in subroutine config1'
endif
enddo
enddo
write(*,*) '--------------i_string_a2---------------'
write(*,*)
do idicp=1,n_string_a_fci
write(*,*) (i_string_a2(idicp,jdicp),jdicp=1,system%nptot)
enddo
return
end subroutine config1
!
! definiation the spatial orbital and spin orbital
!
subroutine space_plus_spino
implicit none
integer :: idicp
!
! allocate the address
!
allocate(space(system%nptot))
allocate(spino(2*system%nptot))
space = -1
spino = 0
!
! initial space
!
do idicp = 1, system%nptot
if(idicp<=system%np0) then
space(idicp) = 0
elseif(idicp>=(system%np0+1) .and. idicp<=(system%np0+system%np1)) then
space(idicp) = 1
elseif(idicp>=(system%np1+1) .and. idicp<=(system%np1+system%np2)) then
space(idicp) = 2
else
write(*,*) 'error happen in subroutine space_plus_spino'
endif
enddo
!
! initial spino(:)
!
do idicp =1, 2*system%nptot
if(idicp<=system%nptot) then
spino(idicp) = 0
else
spino(idicp) = 1
endif
enddo
!
! ia
!
do idicp =1,10000
ia(idicp) = idicp*(idicp-1)/2
enddo
return
end subroutine space_plus_spino
!
! alpha string + beta string
!
! for this method, the N_alpha == N_beta
!
subroutine config2()
implicit none
integer(4) :: idicp,jdicp,kdicp
integer(4) :: np1p,jab,jab_old,np0p
character(len=50) :: fname
allocate(i_string_ab(n_string_a_fci**2,system%numelectron))
allocate(i_string_ab2(n_string_a_fci**2,system%nptot*2))
!
! combin a + b, the same with Haru
!
jab = 0 ! sum the combin a+b fullfill the condition !
jab_old=0
system%io_orb_eqs_p = 1
loop1: do idicp =1,n_string_a_fci
loop2: do jdicp =1,n_string_a_fci
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! np0 = 0, it means that, no orbital are frozen in the calcuations
! all the electrons are active
!
if(system%np0==0) then
if(system%np2==0) then ! np0= 0 and np2 = 0, it means that, only np1 space contains orbitals == ' MCTDHF '
fname='mctdhf' ! all configurations are included in the calcuations
if(2*system%np1==system%numelectron) fname='tdhf'
jab = jab +1
system%io_orb_eqs_p = 0
else ! np0= 0, but np2 /=0, it means that, excitation is allowed, s/d/sd are working normally, the sdtq are not debug still.
if(system%io_sdtq==0) then ! io_sdtq ==0, it means tdrasscf-d method
fname ='td-ras-scf-d without core'
call howmany(space,i_string_a(idicp,:),i_string_a(jdicp,:),system%numelectron/2,system%nptot,np1p,1)
!
!if the total numelectron are not allowed occupied in np1, then, there are two situation are allowed, first:the np1 are full with electron,
! second : there are two electron are excited to np2 space
!
if(2*system%np1<system%numelectron) then
if((np1p==2*system%np1).or.(np1p==(2*system%np1-2))) jab = jab +1
else
if((np1p==system%numelectron).or.(np1p==(system%numelectron-2))) &
jab = jab +1
endif
else ! io_sdqt/=0, 1,2,3
if(system%io_sdtq==1) fname ='td-ras-scf-s w/o core'
if(system%io_sdtq==2) fname ='td-ras-scf-sd w/o core'
if(system%io_sdtq==3) fname ='td-ras-scf-sdt w/o core'
call howmany(space,i_string_a(idicp,:),i_string_a(jdicp,:),system%numelectron/2,system%nptot,np1p,1)
if(2*system%np1<system%numelectron) then
if(np1p>=2*system%np1-system%io_sdtq) jab = jab +1
else
if(np1p>=(system%numelectron-system%io_sdtq)) &
jab = jab +1
endif
endif
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
else
! we need to figure out how many electron allocate in this np0 space, it need to be alaways full of electrons
call howmany(space,i_string_a(idicp,:),i_string_a(jdicp,:),system%numelectron/2,system%nptot,np0p,0)
if (np0p==2*system%np0) then
if(system%np2==0) then ! td-cas-scf
fname='td-cas-scf w/ core'
jab = jab+1
else
if(system%io_sdtq==0) then
fname = 'td-cas-scf w/ core'
call howmany(space,i_string_a(idicp,:),i_string_a(jdicp,:),system%numelectron/2,system%nptot,np1p,1)
if(2*(system%np0+system%np1)<system%numelectron) then
if(np1p==2*system%np1 .or. np1p==2*system%np1-2) jab = jab +1
else
if((2*system%np0+np1p)==system%numelectron .or. ((2*system%np0+np1p) == (system%numelectron-2))) &
jab = jab +1
endif
else
if(system%io_sdtq==1) fname ='td-ras-scf-s w/ core'
if(system%io_sdtq==2) fname ='td-ras-scf-sd w/ core'
if(system%io_sdtq==3) fname ='td-ras-scf-sdt w/ core'
call howmany(space,i_string_a(idicp,:),i_string_a(jdicp,:),system%numelectron/2,system%nptot,np1p,1)
if(2*(system%np0+system%np1)<system%numelectron) then
if(np1p>=(2*system%np1-system%io_sdtq)) jab = jab +1
else
if((np1p+2*system%np0)>=(system%numelectron-system%io_sdtq)) jab = jab +1
endif
endif
endif
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
endif
if(jab_old < jab) then
do kdicp=1,system%numelectron
if(kdicp<=system%numelectron/2) then
i_string_ab(jab,kdicp) = i_string_a(idicp,kdicp)
else
i_string_ab(jab,kdicp) = i_string_a(jdicp,kdicp-system%numelectron/2) + system%nptot
endif
enddo
do kdicp=1,system%nptot*2
if(kdicp<=system%nptot) then
i_string_ab2(jab,kdicp) = i_string_a2(idicp,kdicp)
else
i_string_ab2(jab,kdicp) = i_string_a2(jdicp,kdicp-system%nptot)
endif
enddo
endif
jab_old = jab
enddo loop2
enddo loop1
n_string_ab = jab
write(*,*) '--------there are total number of cofficent A---------'
write(*,*)
write(*,*) '----------n_string_ab--------- :', n_string_ab
write(*,*) '----------i_string_ab-----------'
do idicp=1,n_string_ab
write(*,*) (i_string_ab(idicp,jdicp),jdicp=1,system%numelectron)
enddo
write(*,*) '----------i_string_ab2-----------'
do idicp=1, n_string_ab
write(*,*) (i_string_ab2(idicp,jdicp),jdicp=1,2*system%nptot)
print*, idicp,n_string_ab
enddo
return
end subroutine config2
!===========================================================================
! input sp, is spatial orbital, nume = numelectron/2
! figure out howmany electron occupied in the space
!===========================================================================
subroutine howmany(space,sp1,sp2,nume,nspatial,npe,which)
implicit none
integer nume,nspatial,npe
integer space(nspatial),sp1(nume),sp2(nume)
integer idicp,jdicp,kdicp,which
!
! find how many electrons locate in np0,np1,np2 range
!
npe = 0
do idicp=1,nume
jdicp = sp1(idicp)
if(space(jdicp) == which) then
npe = npe + 1
endif
kdicp = sp2(idicp)
if(space(kdicp) == which) then
npe = npe + 1
endif
enddo
return
end subroutine howmany
!-----------------------------------------------------------------------------------------------
! FI is slater dertermin
! ____
! \
! wavefunction is expand : wavefunction = \ C_I * FI = C_1 * F1 + C_2 * F2+ .........
! /
! /___
! I=1
!
! j j
!rho1 = <wavefunction | E | wavefunciton>
! i i
! ______
! \
! \ j
! = / conjg(C_I)* <FI|E |wavefunction>
! / i
! -------
!
!
!------------------------------------------------------------------------------------------------
!
! j
! subroutine amplitude1 calculate the <FI |E | wavefunction> NB: j,i is spatial orbital
! i
!
!
subroutine amplitude1
implicit none
integer,dimension(2*system%nptot) :: iarray,iatemp
integer,dimension(system%numelectron) :: iarrayp
integer :: I_capital,m_spin,n_spin,num,method
integer :: sign_here,iresult,kk
integer :: idicp,jdicp,kdicp,spin1,ispin1,ispin2
integer :: ip,jp,ipt,jpt
allocate(num_amp1(n_string_ab))
allocate(i_amp1(n_string_ab,100000,10)) !need to revised here
! two method, one is from haru
!------------------------------------------------------------------------------------------------
! another method
!
! +
! < FI| Cm Cn | wavefunction> NB: m,n is spin orbital, Cm spin == Cn spin
! +
! for every FI, there are many combination <FI|Cm Cn|wavefunction>
! count howmany is not zero. and remember the sign and the corrsponding the right Slater dertermin
!
!------------------------------------------------------------------------------------------------
method = 3
if(method ==0) then
do I_capital = 1, n_string_ab
num = 0
!deal with the problem in second representation
do m_spin = 1, 2*system%nptot
do n_spin =1,2*system%nptot
! such as |0,1,1,0,1,1,0>
iarray = i_string_ab2(I_capital,:)
! spin of m is equal to spin of n
if(spino(m_spin) == spino(n_spin)) then
sign_here =1
if(iarray(m_spin)==1) then
sign_here = sign_here*(-1)**sum(iarray(1 : m_spin-1))
iarray(m_spin) = 0
if(iarray(n_spin)==0) then
sign_here = sign_here*(-1)**sum(iarray(1 : n_spin-1))
iarray(n_spin) = 1
call which(iarray,kk)
if(kk/=0) then
num = num +1
i_amp1(I_capital,num,1) = m_spin - spino(m_spin)*system%nptot
i_amp1(I_capital,num,2) = n_spin - spino(n_spin)*system%nptot
i_amp1(I_capital,num,3) = kk
i_amp1(I_capital,num,4) = sign_here
endif
endif
endif
endif
enddo
enddo
num_amp1(I_capital) = num
enddo
!deal with the problem in normal way
elseif(method==1) then
do idicp =1,n_string_ab
num = 0
do jdicp =1,system%numelectron
spin1 = i_string_ab(idicp,jdicp)
ispin1 = spino(spin1)
do kdicp = 1,2*system%nptot
ispin2 = spino(kdicp)
if(ispin1==ispin2) then
iarrayp = i_string_ab(idicp,:)
iarrayp(jdicp) = kdicp
call findindex(iarrayp,iresult,kk)
if(kk/=0) then
call getsign(i_string_ab(iresult,:),iarrayp,system%numelectron,sign_here)
num = num + 1
i_amp1(idicp,num,1) = spin1 - spino(spin1)*system%nptot
i_amp1(idicp,num,2) = kdicp - spino(kdicp)*system%nptot
i_amp1(idicp,num,3) = iresult
i_amp1(idicp,num,4) = sign_here
endif
endif
enddo
enddo
num_amp1(idicp) = num
enddo
else
!------------------------------------------------------------------------------
! jp
! <F_I | E | wavefunction> ! here, jp,ip is spatial orbitals
! ip
!
! + +
!= <F_I |C C + C C | wavefunction>
! ip+ jp+ ip- jp-
!------------------------------------------------------------------------------
do I_capital = 1, n_string_ab
num = 0
do ip =1,system%nptot
do jp =1,system%nptot
!
! spin + +
!
iatemp = i_string_ab2(I_capital,:)
ipt = ip
jpt = jp
sign_here = 1
if(iatemp(ipt) ==1 ) then
sign_here = sign_here*(-1)**sum(iatemp(1:ipt-1))
iatemp(ipt) = 0
if(iatemp(jpt) ==0) then
sign_here = sign_here*(-1)**sum(iatemp(1:jpt-1))
iatemp(jpt) = 1
call which(iatemp,kk)
if(kk/=0) then
num = num +1
i_amp1(I_capital,num,1) = ip
i_amp1(I_capital,num,2) = jp
i_amp1(I_capital,num,3) = kk
i_amp1(I_capital,num,4) = sign_here
endif
endif
endif
!
! spin - -
!
iatemp = i_string_ab2(I_capital,:)
ipt = ip + system%nptot
jpt = jp + system%nptot
sign_here = 1
if(iatemp(ipt) ==1 ) then
sign_here = sign_here*(-1)**sum(iatemp(1:ipt-1))
iatemp(ipt) = 0
if(iatemp(jpt) ==0) then
sign_here = sign_here*(-1)**sum(iatemp(1:jpt-1))
iatemp(jpt) = 1
call which(iatemp,kk)
if(kk/=0) then
num = num +1
i_amp1(I_capital,num,1) = ip
i_amp1(I_capital,num,2) = jp
i_amp1(I_capital,num,3) = kk
i_amp1(I_capital,num,4) = sign_here
endif
endif
endif
enddo
enddo
num_amp1(I_capital) = num
enddo
endif
!--------------------------------------------------------------------
! output the debug information
!--------------------------------------------------------------------
! write(*,*) 'information about the <F_I | Eji | wavefunction> '
! write(*,*) 'number of the slater configuration is : ', n_string_ab
! write(*,*)
! do idicp =1,n_string_ab
! write(*,*) 'there are ', num_amp1(idicp), ' term /= 0, for the--', idicp,'-- slater term'
! write(*,*)'------------------------------------------------------------------------------'
! write(*,*) ' Eji-i', ' Eji-j', ' postion ', ' sign '
! do jdicp =1,num_amp1(idicp)
! write(*,*)
! write(*,*) i_amp1(idicp,jdicp,1),i_amp1(idicp,jdicp,2),i_amp1(idicp,jdicp,3),i_amp1(idicp,jdicp,4)
! write(*,*)
!
! enddo
! write(*,*)
! write(*,*)
! enddo
return
end subroutine amplitude1
!------------------------------------------------------------------------------------------------------
!find the value :
!
!
!
! from haru
!------------------------------------------------------------------------------------------------------
subroutine amplitude2
implicit none
integer(4) :: iab,ipqrs,ire,ipe,iir,iip,is,iq,iis,iiq,ii,jj,ir,ip,ipm,kk
integer(4),dimension(system%numelectron) :: ibox
integer(4) :: idicp,iresult
! from haru
allocate(num_amp2(n_string_ab))
allocate(i_amp2(n_string_ab,100000,10)) !need to revised here
do iab=1,n_string_ab
ipqrs=0 ! counter reset
do ire=2,system%numelectron
do ipe=1,ire-1
ir=i_string_ab(iab,ire)
ip=i_string_ab(iab,ipe) ! ip < ir
iir=spino(ir) !(ir-1)/ras1%nptot
iip=spino(ip) !(ip-1)/ras1%nptot
do is=2,system%nptot*2
do iq=1,is-1 ! iq < is
iis=spino(is) !(is-1)/ras1%nptot
iiq=spino(iq) !(iq-1)/ras1%nptot
!----judge-------------------
if (iip+iir.eq.iis+iiq) then
do ii=1,system%numelectron
jj=i_string_ab(iab,ii)
if (jj.eq.ip) then
jj=iq
elseif (jj.eq.ir) then
jj=is
endif
ibox(ii)=jj
enddo
call findindex(ibox,iresult,kk)
if(kk/=0) then
call getsign(i_string_ab(iresult,:),ibox,system%numelectron,ipm)
!=================================================================
ipqrs=ipqrs+1 ! counter increment
i_amp2(iab,ipqrs,1)=ip-system%nptot*iip
i_amp2(iab,ipqrs,2)=iq-system%nptot*iiq ! iq <- ip
i_amp2(iab,ipqrs,3)=ir-system%nptot*iir
i_amp2(iab,ipqrs,4)=is-system%nptot*iis ! is <- ir
! i_amp2(iab,ipqrs,5)=ipm*iresult
i_amp2(iab,ipqrs,5)=iresult
i_amp2(iab,ipqrs,6)=iip
i_amp2(iab,ipqrs,7)=iiq
i_amp2(iab,ipqrs,8)=iir
i_amp2(iab,ipqrs,9)=iis
i_amp2(iab,ipqrs,10) = ipm
!=================================================================
endif
endif
enddo
enddo
enddo
enddo
num_amp2(iab)=ipqrs
enddo
!
! for debug output
!
!
! write(*,*) '______________two electron replacement term______________________ '
! do iab = 1,n_string_ab
! write(*,*)
! write(*,*)
! write(*,*) 'for slater ',iab,' number of term is ', num_amp2(iab)
! write(*,*)' -ip-', ' -iq-', ' -ir-', ' -is-', ' ipm*iresult'
! do idicp =1, num_amp2(iab)
! ip = i_amp2(iab,idicp,1)
! iq = i_amp2(iab,idicp,2)
! ir = i_amp2(iab,idicp,3)
! is = i_amp2(iab,idicp,4)
! ipm = i_amp2(iab,idicp,5)
! write(*,*) idicp,' ', ip,iq,ir,is,ipm
! enddo
! enddo
return
end subroutine amplitude2
!
! find the position of iarray in jout
! haru
!
subroutine findindex(iarray,iresult,kk)
implicit none
integer,intent(out) :: iresult
integer :: idicp,jdicp,numdiffer
integer,intent(in),dimension(system%numelectron) :: iarray
integer,dimension(system%numelectron):: itemp
integer :: kk,judge0
kk = 1
judge0 = 0
do idicp = 1,system%numelectron-1
do jdicp =idicp+1,system%numelectron
if(iarray(idicp) == iarray(jdicp)) then
judge0 = 1
kk =0
endif
enddo
enddo
if(judge0==0) then
do idicp=1,n_string_ab
itemp = i_string_ab(idicp,:)
call get(iarray,itemp,system%numelectron,numdiffer)
iresult=-1
if(numdiffer==0) then
iresult=idicp
exit
endif
enddo
if(iresult==-1) then
kk = 0
endif
endif
return
end subroutine findindex
!====================================================================================
! set alphastring and betastring
! set the weigth of vertex , the details can be found in the paper of Jeppe, Olsen
! j.chem.phys. 89, 1988, or the book of W. Duch, GRMS or Graphical represnetation of
! model spaces, Lecture notes in Chemistry, Section 1.1, introducing graphical repres-
! entation
!===================================================================================
subroutine set_alphastring()
implicit none
integer :: ie,io
integer :: iab,ii_add
integer :: ibox(system%numelectron)
allocate(w_vertex(0:system%nptot,0:system%numelectron/2))
allocate(n_string_ab_inv(n_string_a_fci**2))
!
! initialization of the array
! this array store the weight of every vertex, have important relation with the single occupied src
!
w_vertex = 0
!
! this array store the index of the path (every path is corrsponding to one configuration)
!
n_string_ab_inv = 0
!
! set the value of the first column
!
do io=0,system%nptot-system%numelectron/2
w_vertex(io,0)=1
enddo
!
!set the value of the rightmost position
!
do ie=0,system%numelectron/2
w_vertex(ie,ie)=1
enddo
w_vertex(1,0)=1
!
! the relation between (e,o) with (e-1,o-1) and (e,o-1)
!
do ie=1,system%numelectron/2
do io=1,system%nptot
w_vertex(io,ie)=w_vertex(io-1,ie)+w_vertex(io-1,ie-1)
enddo
enddo
!
!find the index of the path and store
!
do iab=1,n_string_ab
ibox = i_string_ab(iab,:)
!
! input : ibox store the spin orbital (configuration)
!
call address(ii_add,ibox)
!
! output: ii_add, is the index of the path(configuration)
!
n_string_ab_inv(ii_add)=iab
enddo
return
end subroutine set_alphastring
!==================================================================
subroutine amp_alg()
!==================================================================
use global
implicit none
integer :: iab,jab,ipq,ipqrs,ip,iq,ir,is,iip,iiq,iir,iis
integer :: ipe,ire,ii,jj,kk,ipm,ibox(system%numelectron)
integer :: l_amp1,l_amp2, ispin_ip, ispin_iq
l_amp1 = system%numelectron/2*(system%nptot-system%numelectron/2+1)*2
allocate(num_amp1(n_string_ab))
allocate(i_amp1(n_string_ab,l_amp1,4)) !need to revised here
l_amp2 = system%numelectron/2*(system%numelectron/2-1)*(system%nptot-system%numelectron/2+2)*&
(system%nptot-system%numelectron/2+1)/4*2+system%numelectron/2*system%numelectron/2*&
(system%nptot-system%numelectron/2+1)*(system%nptot-system%numelectron/2+1)
allocate(num_amp2(n_string_ab))
allocate(i_amp2(n_string_ab,l_amp2,10))
do iab=1,n_string_ab
ipq=0
do ipe=1,system%numelectron
ip=i_string_ab(iab,ipe)
!
!wenliang, ip is the serial number of spin orbital, ipp is the spin of this spin orbital
! for example, if ipp =0, positive, ipp =1, nagative
!
ispin_ip = spino(ip) ! remember the spin of the orbital ip 0, or 1
do iq=1,system%nptot*2
ispin_iq = spino(iq)
!
!----judge-----------------------
if (ispin_ip.eq.ispin_iq) then !wenliang spin = spin, in the same spin space
do ii=1,system%numelectron
jj=i_string_ab(iab,ii)
if (jj.eq.ip) jj=iq
ibox(ii)=jj
enddo !wenliang 2 1 5 6 ! np_tot = 3, nel =4, nel/2 = 2
!
call asc_order(ibox,ipm,kk) !
! 1 2 5 6 ipm is coefficient,
if (kk.ne.0) then !wenliang kk=0, there are two electron in the same spin orbital, not allowed
!=================================================================
ipq=ipq+1 ! counter increment
i_amp1(iab,ipq,1)=ip-system%nptot*ispin_ip !记录哪一个空间轨道
i_amp1(iab,ipq,2)=iq-system%nptot*ispin_iq ! iq <- ip
i_amp1(iab,ipq,3)=kk
i_amp1(iab,ipq,4)=ipm
!=================================================================
endif
endif
enddo
enddo
if (l_amp1.lt.ipq) stop '***** ERROR IN AMP_ALG 1 *****'
num_amp1(iab)=ipq
enddo
!! !$omp end do nowait
!----two-electron replacement------------------------------------------
!! !$omp do
do iab=1,n_string_ab
ipqrs=0 ! counter reset
do ire=2,system%numelectron
do ipe=1,ire-1
ir=i_string_ab(iab,ire)
ip=i_string_ab(iab,ipe) ! ip < ir
iir= spino(ir)
iip= spino(ip)
do is=2,system%nptot*2
do iq=1,is-1 ! iq < is
iis=spino(is)
iiq=spino(iq)
!----judge-------------------
if (iip+iir.eq.iis+iiq) then
do ii=1,system%numelectron
jj=i_string_ab(iab,ii)
if (jj.eq.ip) then
jj=iq
elseif (jj.eq.ir) then
jj=is
endif
ibox(ii)=jj
enddo
call asc_order(ibox,ipm,kk)
if (kk.ne.0) then
!=================================================================
ipqrs=ipqrs+1 ! counter increment
i_amp2(iab,ipqrs,1) = ip-system%nptot*iip
i_amp2(iab,ipqrs,2) = iq-system%nptot*iiq ! iq <- ip
i_amp2(iab,ipqrs,3) = ir-system%nptot*iir
i_amp2(iab,ipqrs,4) = is-system%nptot*iis ! is <- ir
i_amp2(iab,ipqrs,5) = kk
i_amp2(iab,ipqrs,6) = iip
i_amp2(iab,ipqrs,7) = iiq
i_amp2(iab,ipqrs,8) = iir
i_amp2(iab,ipqrs,9) = iis
i_amp2(iab,ipqrs,10) = ipm
!=================================================================
endif
endif
enddo
enddo
enddo
enddo
if (l_amp2.lt.ipqrs) stop '***** ERROR IN AMP_ALG 2 *****'
num_amp2(iab)=ipqrs
enddo
return
end subroutine amp_alg
!
! construct the zet_alg1 parameter
!
!=================================================================
subroutine zet_alg1
!=================================================================
implicit none
integer :: jab,jab_h,judge,judge1,judge2,jab_ij,ipm,iab_ij,iz,iab
integer :: iel,jel,i,ii,iii,j,jj,jjj,ie,ibox(system%numelectron),NNA1,NNA2
allocate(i_string_ab_h(n_string_a_fci**2,system%numelectron+1))
allocate(i_string_ab2_h(n_string_a_fci**2,2*system%nptot+1))
NNA1=system%np0
NNA2=system%np0+system%np1
jab_h=0
do jab=1,n_string_ab
judge=0
do jel=1,system%numelectron
j=i_string_ab(jab,jel)
jj=(j-1)/system%nptot
jjj=j-jj*system%nptot
if (jjj.gt.NNA2) judge=judge+1
enddo
if (judge.eq.system%io_sdtq) then
jab_h=jab_h+1
do ii=1,system%numelectron
i_string_ab_h(jab_h,ii)=i_string_ab(jab,ii)
enddo
i_string_ab_h(jab_h,system%numelectron+1)=jab
do ii=1,system%nptot*2
i_string_ab2_H(jab_h,ii)=i_string_ab2(jab,ii)
enddo
i_string_ab2_h(jab_h,system%nptot*2+1)=jab
endif
enddo
n_string_ab_h=jab_h
jab_ij=0
do jab_h=1,n_string_ab_H
do ie=1,system%numelectron
i =i_string_ab_H(jab_h,ie)
ii =(i-1)/system%nptot
iii=i-ii*system%nptot
if ((ii.eq.0).and.(NNA1.lt.iii).and.(iii.le.NNA2)) then !Only spin UP state
do jjj=NNA2+1,system%nptot
!--- there should be iii but not jjj ---
judge1=0
judge2=0
do iel=1,system%numelectron/2
jel=i_string_ab_H(jab_h,iel)
if (jjj.ne.jel) judge2=judge2+1
enddo
if (judge2.eq.system%numelectron/2) then
!---- one-electron replacement (jjj <-- iii) ----
do iel=1,system%numelectron
jel=i_string_ab_H(jab_h,iel)
if (jel.eq.iii) jel=jjj
ibox(iel)=jel
enddo
call asc_order(ibox,ipm,jab)
if (jab.eq.0) then
!=================================================================
jab_ij=jab_ij+1 ! counter increment
do iel=1,system%numelectron
i_string_ab_Hij(jab_ij,iel)=ibox(iel)
enddo
i_string_ab_Hij(jab_ij,system%numelectron+1)=iii
i_string_ab_Hij(jab_ij,system%numelectron+2)=jjj
i_string_ab_Hij(jab_ij,system%numelectron+3)=ipm*i_string_ab_H(jab_h,system%numelectron+1)
!=================================================================
endif
endif
enddo
endif