-
Notifications
You must be signed in to change notification settings - Fork 0
/
module-SpinAngular.jl
2746 lines (2497 loc) · 152 KB
/
module-SpinAngular.jl
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
#
# This module has mainly been contributed by Gediminas Gaigalas ([email protected])
"""
`module JAC.SpinAngular`
... a submodel of JAC that contains all methods for computing the spin-angular coefficients for one- and two-particle operators
of given rank and for symmetry-adapted CSF. At the present, these spin-angular can be obtained for all scalar (and symmetric)
one and two-particle interactions and they are sometimes refered to as 'pure angular coefficients' in order to distinguish
them from those used in GRASP (and its derivatives) where part of the `physical interaction' were included orginal
into the angular integrals. The spin-angular coefficients usally appear in the form:
<CSF_l | operator | CSF_r> = sum_{t} coeff_t (L,abcd) * X^L (abcd)
where CSF is a standard (jj-coupled) configuration state function, t a summation index, and where X^L(abcd) denotes the
effective interaction strength.
"""
module SpinAngular
using Printf, ..AngularMomentum, ..Basics, ..Defaults, ..ManyElectron, ..Radial
export Xronecker
"""
`abstract type SpinAngular.AbstractAngularType`
... defines an abstract type and a number of data types to work with one- and two-particle operators of given rank, see also:
+ struct OneParticleOperator ... to represent a single-particle operator with well-defined spherical tensor rank.
+ struct TwoParticleOperator ... to represent a two-particle operator with well-defined spherical tensor rank.
"""
abstract type AbstractAngularType end
"""
`struct SpinAngular.OneParticleOperator <: AbstractAngularType`
... a struct for defining the spherial tensor structure of a single-particle operator.
+ rank ::Int64 ... Rank of the operator.
+ parity ::Basics.Parity ... Parity of the operator (if needed ??)
+ sameOrbitalSet ::Bool ... True if orbitals for both CSF are taken from the same orbital set (if needed ??)
"""
struct OneParticleOperator <: AbstractAngularType
rank ::Int64
parity ::Basics.Parity
sameOrbitalSet ::Bool
end
"""
`SpinAngular.OneParticleOperator()` ... constructor for setting the default values.
"""
function OneParticleOperator()
OneParticleOperator( 0, Basics.plus, false)
end
# `Base.show(io::IO, op::OneParticleOperator)` ... prepares a proper printout of the op::OneParticleOperator.
function Base.show(io::IO, op::OneParticleOperator)
sa = "One-particle operator O^($(op.rank) $(op.parity))"
if op.sameOrbitalSet sa = sa * ", defined for CSF from the same orbital set."
else sa = sa * ", defined for CSF from different orbital sets."
end
println(io, sa)
end
"""
`struct SpinAngular.TwoParticleOperator`
... a struct for defining the spherial tensor structure of a two-particle operator.
+ rank ::Int64 ... Rank of the operator (if needed ??).
+ parity ::Basics.Parity ... Parity of the operator (if needed ??)
+ sameOrbitalSet ::Bool ... True if orbitals for both CSF are taken from the same orbital set (if needed ??)
"""
struct TwoParticleOperator
rank ::Int64
parity ::Basics.Parity
sameOrbitalSet ::Bool
end
"""
`SpinAngular.TwoParticleOperator()` ... constructor for setting the default values.
"""
function TwoParticleOperator()
TwoParticleOperator( 0, Basics.plus, false)
end
# `Base.show(io::IO, op::TwoParticleOperator)` ... prepares a proper printout of the op::TwoParticleOperator.
function Base.show(io::IO, op::TwoParticleOperator)
sa = "Two-particle operator O^($(op.rank) $(op.parity))"
if op.sameOrbitalSet sa = sa * ", defined for CSF from the same orbital set."
else sa = sa * ", defined for CSF from different orbital sets."
end
println(io, sa)
end
"""
`struct SpinAngular.Coefficient1p`
... a struct for defining a single spin-angular coefficient for a reduced one-particle matrix element <a || o^(L) || b>.
+ nu ::Int64 ... Rank (L or nu) of the single-particle interaction strength.
+ a ::Subshell ... Left-hand subshell (orbital).
+ b ::Subshell ... Right-hand subshell (orbital).
+ T ::Float64 ... (Value of) spin-angular coefficient.
"""
struct Coefficient1p
nu ::Int64
a ::Subshell
b ::Subshell
T ::Float64
end
# `Base.show(io::IO, coeff::Coefficient1p)` ... prepares a proper printout of the coeff::Coefficient1p.
function Base.show(io::IO, coeff::Coefficient1p)
# sa = "\n V^($(coeff.L)) [$(coeff.a), $(coeff.b)] = $(coeff.v)"
sa = " T^$(coeff.nu) [$(coeff.a), $(coeff.b)] = $(coeff.T)"
print(io, sa)
end
"""
`struct SpinAngular.Coefficient2p`
... a struct for defining a single spin-angular coefficient for a reduced two-particle matrix element <ab || o^(L) || cd>,
such as the Coulomb interaction strength.
+ nu ::Int64 ... Rank (L or nu) of the single-particle interaction strength.
+ a ::Subshell ... Left-hand subshell (orbital).
+ b ::Subshell ... Left-hand subshell (orbital).
+ c ::Subshell ... Right-hand subshell (orbital).
+ d ::Subshell ... Right-hand subshell (orbital).
+ V ::Float64 ... (Value of) spin-angular coefficient.
"""
struct Coefficient2p
nu ::Int64
a ::Subshell
b ::Subshell
c ::Subshell
d ::Subshell
V ::Float64
end
"""
`struct SpinAngular.QspaceTerm`
... a struct for defining a subshell term/state |j (nu) alpha Q J> == |j (nu) Q J Nr> for a subshell with well-defined j.
+ j ::AngularJ64 ... subshell j
+ Q ::AngularJ64 ... quasi-spin
+ J ::AngularJ64 ... total J of subshell term
+ Nr ::Int64 ... Additional quantum number Nr = 0,1,2.
+ min_odd ::Int64 ... the minimal limits of the subshell terms for odd number operators in second quantization
+ max_odd ::Int64 ... the maximal limits of the subshell terms for odd number operators in second quantization
+ min_even ::Int64 ... the minimal limits of the subshell terms for even number operators in second quantization
+ max_even ::Int64 ... the maximal limits of the subshell terms for even number operators in second quantization
"""
struct QspaceTerm
j ::AngularJ64
Q ::AngularJ64
J ::AngularJ64
Nr ::Int64
min_odd ::Int64
max_odd ::Int64
min_even ::Int64
max_even ::Int64
end
# `Base.show(io::IO, term::QspaceTerm)` ... prepares a proper printout of term::QspaceTerm.
function Base.show(io::IO, term::QspaceTerm)
if term.Nr == 0
sa = "|$(term.j) $(term.Q) $(term.J) min_odd=$(term.min_odd) max_odd=$(term.max_odd) " *
"min_even=$(term.min_even) max_even=$(term.max_even)>"
else
sa = "|$(term.j) $(term.Q) $(term.J); Nr=$(term.Nr) min_odd=$(term.min_odd) " *
"max_odd=$(term.max_odd) min_even=$(term.min_even) max_even=$(term.max_even) >"
end
println(io, sa)
end
# `Base.show(io::IO, coeff::Coefficient2p)` ... prepares a proper printout of the coeff::Coefficient2p.
function Base.show(io::IO, coeff::Coefficient2p)
sa = "\n V^($(coeff.nu)) [$(coeff.a), $(coeff.b)| $(coeff.c), $(coeff.d)] = $(coeff.V)"
print(io, sa)
end
"""
`struct SpinAngular.SchemeEta`
... to define various singleton structs in order to distinguish between different irreducible tensors
and matrix elements.
+ Eta_a ... a^(qj)_mq
+ Eta_W ... W^(k_12) = [a x a]
+ Eta_aW ... W^(k_12, k_2) = [a1 x [a2 x a3]]
+ Eta_Wa ... W^(k_12, k_2) = [[a1 x a2] x a3]
+ Eta_WW ... W^(kk0) = [[a1 x a2]^k x [a3 x a4]^k]^0
"""
struct SchemeEta_a end
struct SchemeEta_W end
struct SchemeEta_aW end
struct SchemeEta_Wa end
struct SchemeEta_WW end
"""
`struct SpinAngular.Diagram`
... to defines various singleton() structs in order to distinguish between different coupling schemes of the
matrix elements.
"""
struct DiagramC01 end
struct DiagramC02 end
struct DiagramC03 end
struct DiagramC04 end
struct DiagramC05 end
#======= This can likely be deleted soon.
"""
`struct SpinAngular.SubshellTerm`
... a struct for defining a subshell term/state |j^N (nu) alpha Q J> == |j^N (nu) Q J Nr> for a subshell with well-defined j.
+ j ::AngularJ64 ... subshell j
+ Q ::AngularJ64 ... quasi-spin
+ occupation ::Int64 ... occupation N
+ seniority ::Int64 ... seniority
+ J ::AngularJ64 ... total J of subshell term
+ Nr ::Int64 ... Additional quantum number Nr = 0,1,2.
"""
struct SubshellTerm
j ::AngularJ64
Q ::AngularJ64
occupation ::Int64
seniority ::Int64
J ::AngularJ64
Nr ::Int64
end
# `Base.show(io::IO, term::SubshellTerm)` ... prepares a proper printout of term::SubshellTerm.
function Base.show(io::IO, term::SubshellTerm)
if term.Nr == 0 sa = "|$(term.j)^($(term.occupation)) ($(term.seniority)) $(term.Q) $(term.J)>"
else sa = "|$(term.j)^($(term.occupation)) ($(term.seniority)) $(term.Q) $(term.J); Nr=$(term.Nr)>"
end
println(io, sa)
end
"""
`struct SpinAngular.Lambda`
... a struct for defining a subshell term/state |j (nu) alpha Q J> == |j (nu) Q J Nr> for a subshell with well-defined j.
+ Ji ::AngularJ64 ... J_i
+ Jj ::AngularJ64 ... J_j
+ Jip ::AngularJ64 ... J_i'
+ Jjp ::AngularJ64 ... J_j'
"""
struct Lambda
Ji ::AngularJ64
Jj ::AngularJ64
Jip ::AngularJ64
Jjp ::AngularJ64
end
# `Base.show(io::IO, lambda::Lambda)` ... prepares a proper printout of lambda::Lambda.
function Base.show(io::IO, lambda::Lambda)
sa = "Lambda($(lambda.Ji), $(lambda.Jj); lambda.Jip), $(lambda.Jjp))"
println(io, sa)
end ==================#
include("module-SpinAngular-inc-reducedcoeffs.jl")
#######################################################################################################################
#######################################################################################################################
"""
`SpinAngular.computeCoefficients(op::SpinAngular.OneParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})`
... computes the spin-angular coefficients for the reduced one-particle matrix element
<leftCsf || op^(k) || rightCsf >
if both CSF refer to the same list of subshells; a list of one-particle coefficients coeffs::Array{Coefficient1p,1} is returned.
leftCsf - is the bra confuguration state function in relativistic notation;
rightCsf - is the ket confuguration state function in relativistic notation;
subshells - is explicitly given relativistic subshell list if useStandardSubshells == false.
"""
function computeCoefficients(op::SpinAngular.OneParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})
if op.rank == 0 coeffs = computeCoefficientsScalar(op, leftCsf, rightCsf, subshells)
elseif op.rank > 0 coeffs = computeCoefficientsNonScalar(op, leftCsf, rightCsf, subshells)
else error("stop a")
end
return (coeffs)
end
"""
`SpinAngular.computeCoefficients(op::SpinAngular.TwoParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})`
... computes the spin-angular coefficients for the reduced two-particle matrix element
<leftCsf || op^(k) || rightCsf >
if both CSF refer to the same list of subshells; a Tuple of two lists with one- and two-particle coefficients tpl::Tuple{coeffs1p::Array{Coefficient1p,1}, coeffs2p::Array{Coefficient2p,1}} is returned.
leftCsf - is the bra confuguration state function in relativistic notation;
rightCsf - is the ket confuguration state function in relativistic notation;
subshells - is explicitly given relativistic subshell list if useStandardSubshells == false.
"""
function computeCoefficients(op::SpinAngular.TwoParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})
if op.rank == 0 coeffs = computeCoefficientsScalar(op, leftCsf, rightCsf, subshells)
else error("stop a")
end
return (coeffs)
end
"""
`SpinAngular.computeCoefficientsNonScalar(op::SpinAngular.OneParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})`
... computes the spin-angular coefficients for the reduced (scalar) one-particle matrix element
<leftCsf || op^(0) || rightCsf >
if both CSF refer to the same list of subshells; a list of one-particle coefficients coeffs::Array{Coefficient1p,1} is returned.
leftCsf - is the bra confuguration state function in relativistic notation;
rightCsf - is the ket confuguration state function in relativistic notation;
subshells - is explicitly given relativistic subshell list if useStandardSubshells == false.
"""
function computeCoefficientsNonScalar(op::SpinAngular.OneParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})
coeffs1p = Coefficient1p[]; kj = 2 * op.rank; kj = AngularJ64(kj//2)
if AngularMomentum.triangularDelta(leftCsf.J, kj, rightCsf.J) == 0 return( coeffs1p ) end
wa = 0.0; diff_occ = 0; count = 0; creation = 0; annihilation = 0
# Cycle through all subshells of the bra- and ket-CSF
for (i,shi) in enumerate(subshells)
diff = leftCsf.occupation[i]-rightCsf.occupation[i]
if abs(diff) > 1 return( coeffs1p )
elseif diff != 0
diff_occ = diff_occ + abs(diff); count = count + 1
end
if diff == 1
if creation == 0; creation = i; else return( coeffs1p ) end
elseif diff == -1
if annihilation == 0; annihilation = i; else return( coeffs1p ) end
end
end
if count == 0
for (i,shi) in enumerate(subshells)
Ni = leftCsf.occupation[i]; Nj = rightCsf.occupation[i]
if Nj != 0
ji = Basics.subshell_j(shi)
Ji = leftCsf.subshellJ[i]; Jj = rightCsf.subshellJ[i]
si = leftCsf.seniorityNr[i]; sj = rightCsf.seniorityNr[i]
Qi = qshellTermQ(ji,si); Qj = qshellTermQ(ji,sj)
aT = SpinAngular.getTermNumber(ji, Ni, Qi, Ji)
aTp = SpinAngular.getTermNumber(ji, Nj, Qj, Jj)
if recouplingCheck(leftCsf, rightCsf, kj, i, i, length(subshells)) != 0.0
wa = recoupling1p(leftCsf, rightCsf, kj, i, length(subshells))
if abs(wa) >= 2.0e-10
wa = wa * irreducibleTensor(SchemeEta_W(),aT, Ni, AngularM64(1//2), AngularM64(-1//2), op.rank, aTp, Nj)
if abs(wa) >= 2.0e-10
# Pure one-particle spin-angular coefficient
wa = -wa/sqrt(2. * op.rank + 1.)
# GRASP like spin-angular coefficient
wa = wa * sqrt(Basics.twice(ji) + 1.)
push!(coeffs1p, Coefficient1p(op.rank, shi, shi, wa))
end
end
end
end
end
elseif count == 2 && diff_occ == 2
if creation != annihilation
shii = subshells[creation]; ja = Basics.subshell_j(shii)
shjj = subshells[annihilation]; jb = Basics.subshell_j(shjj)
no_one = min(creation, annihilation); no_two = max(creation, annihilation)
if recouplingCheck(leftCsf, rightCsf, kj, no_one, no_two, length(subshells)) != 0.0
if creation == no_one && annihilation == no_two
j1 = ja; j2 = jb; wa = 1.0
elseif creation == no_two && annihilation == no_one
j1 = jb; j2 = ja
wa = (-1)^Int64((Basics.twice(ja)+Basics.twice(jb)-2 * op.rank + 2)/2)
else error("SpinAngular.computeCoefficientsNonScalar: stop a")
end
#
wa = wa * recoupling1p(leftCsf, rightCsf, j1, j2, kj, no_one, no_two, length(subshells))
if abs(wa) >= 2.0e-10
aN = leftCsf.occupation[creation]; aNp = rightCsf.occupation[creation]
Ji = leftCsf.subshellJ[creation]; Jj = rightCsf.subshellJ[creation]
si = leftCsf.seniorityNr[creation]; sj = rightCsf.seniorityNr[creation]
Qi = qshellTermQ(ja,si) ; Qj = qshellTermQ(ja,sj)
aT = SpinAngular.getTermNumber(ja, aN, Qi, Ji)
aTp = SpinAngular.getTermNumber(ja, aNp, Qj, Jj)
bN = leftCsf.occupation[annihilation]; bNp = rightCsf.occupation[annihilation]
Ji = leftCsf.subshellJ[annihilation]; Jj = rightCsf.subshellJ[annihilation]
si = leftCsf.seniorityNr[annihilation]; sj = rightCsf.seniorityNr[annihilation]
Qi = qshellTermQ(jb,si); Qj = qshellTermQ(jb,sj)
bT = SpinAngular.getTermNumber(jb, bN, Qi, Ji)
bTp = SpinAngular.getTermNumber(jb, bNp, Qj, Jj)
wa = wa * SpinAngular.irreducibleTensor(SchemeEta_a(),aT, aN, AngularM64(1//2), aTp, aNp) *
SpinAngular.irreducibleTensor(SchemeEta_a(),bT, bN,AngularM64(-1//2), bTp, bNp)
if abs(wa) >= 2.0e-10
occup = 0
for i = no_one:no_two-1 occup = occup + leftCsf.occupation[i] end
wa = (-1)^(occup+1) * wa
# Purer_one-particle spin-angular coefficient
wa = -wa/sqrt(2. * op.rank + 1.)
# GRASP like spin-angular coefficient
wa = wa * sqrt(Basics.twice(ja) + 1.)
push!(coeffs1p, Coefficient1p(op.rank, shii, shjj, wa))
end
end
end
end
end
return( coeffs1p )
end
"""
`SpinAngular.computeCoefficientsScalar(op::SpinAngular.OneParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})`
... computes the spin-angular coefficients for the reduced (scalar) one-particle matrix element
<leftCsf || op^(0) || rightCsf >
if both CSF refer to the same list of subshells; a list of one-particle coefficients coeffs::Array{Coefficient1p,1} is returned.
leftCsf - is the bra confuguration state function in relativistic notation;
rightCsf - is the ket confuguration state function in relativistic notation;
subshells - is explicitly given relativistic subshell list if useStandardSubshells == false.
"""
function computeCoefficientsScalar(op::SpinAngular.OneParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})
coeffs1p = Coefficient1p[]
if leftCsf.J != rightCsf.J return( coeffs1p ) end
wa = 0.0; diff_occ = 0; count = 0; creation = 0; annihilation = 0
# Cycle through all subshells of the bra- and ket-CSF
for (i,shi) in enumerate(subshells)
diff = leftCsf.occupation[i]-rightCsf.occupation[i]
if abs(diff) > 1 return( coeffs1p )
elseif diff != 0
diff_occ = diff_occ + abs(diff); count = count + 1
end
if diff == 1
if creation == 0; creation = i; else return( coeffs1p ) end
elseif diff == -1
if annihilation == 0; annihilation = i; else return( coeffs1p ) end
end
end
#
if count == 0
for (i,shi) in enumerate(subshells)
if recouplingCheck(leftCsf, rightCsf, i, i, i, i, length(subshells), 0) != 0.0
Ni = leftCsf.occupation[i]; Nj = rightCsf.occupation[i]
if Nj != 0
ji = Basics.subshell_j(shi)
Ji = leftCsf.subshellJ[i]; Jj = rightCsf.subshellJ[i]
si = leftCsf.seniorityNr[i]; sj = rightCsf.seniorityNr[i]
Qi = qshellTermQ(ji,si); Qj = qshellTermQ(ji,sj)
aT = SpinAngular.getTermNumber(ji, Ni, Qi, Ji)
aTp = SpinAngular.getTermNumber(ji, Nj, Qj, Jj)
if leftCsf == rightCsf
wa = irreducibleTensor(SchemeEta_W(),aT, Ni, AngularM64(1//2), AngularM64(-1//2), 0, aTp, Nj)
else
if recouplingCheck(leftCsf, rightCsf, i, i, i, i, length(subshells), 0) != 0.0
wa = irreducibleTensor(SchemeEta_W(),aT, Ni, AngularM64(1//2), AngularM64(-1//2), 0, aTp, Nj)
end
end
if abs(wa) >= 2.0e-11
# Pure one-particle spin-angular coefficient
wa = -wa/sqrt(Basics.twice(Ji) + 1.)
# GRASP like spin-angular coefficient
# wa = wa * sqrt(Basics.twice(ji) + 1.)
push!(coeffs1p, Coefficient1p(op.rank, shi, shi, wa))
end
end
end
end
elseif count == 2 && diff_occ == 2
if creation != annihilation
shii = subshells[creation]; ja = Basics.subshell_j(shii)
shjj = subshells[annihilation]; jb = Basics.subshell_j(shjj)
if ja == jb
no_one = min(creation, annihilation); no_two = max(creation, annihilation)
if recouplingCheck(leftCsf, rightCsf, no_one, no_two, no_two, no_two, length(subshells), 1) != 0.0
wa = recoupling1p(leftCsf, rightCsf, ja, jb, AngularJ64(0//2), no_one, no_two, length(subshells))
if abs(wa) >= 2.0e-11
aN = leftCsf.occupation[creation]; aNp = rightCsf.occupation[creation]
Ji = leftCsf.subshellJ[creation]; Jj = rightCsf.subshellJ[creation]
si = leftCsf.seniorityNr[creation]; sj = rightCsf.seniorityNr[creation]
Qi = qshellTermQ(ja,si); Qj = qshellTermQ(ja,sj)
aT = SpinAngular.getTermNumber(ja, aN, Qi, Ji)
aTp = SpinAngular.getTermNumber(ja, aNp, Qj, Jj)
bN = leftCsf.occupation[annihilation]; bNp = rightCsf.occupation[annihilation]
Ji = leftCsf.subshellJ[annihilation]; Jj = rightCsf.subshellJ[annihilation]
si = leftCsf.seniorityNr[annihilation]; sj = rightCsf.seniorityNr[annihilation]
Qi = qshellTermQ(jb,si); Qj = qshellTermQ(jb,sj)
bT = SpinAngular.getTermNumber(jb, bN, Qi, Ji)
bTp = SpinAngular.getTermNumber(jb, bNp, Qj, Jj)
wa = wa * SpinAngular.irreducibleTensor(SchemeEta_a(),aT, aN, AngularM64(1//2), aTp, aNp) *
SpinAngular.irreducibleTensor(SchemeEta_a(),bT, bN,AngularM64(-1//2), bTp, bNp)
if abs(wa) >= 2.0e-11
occup = 0
for i = no_one:no_two-1 occup = occup + leftCsf.occupation[i] end
wa = (-1)^(occup+1) * wa
# Purer_one-particle spin-angular coefficient
wa = -wa
# GRASP like spin-angular coefficient
# wa = wa * sqrt(Basics.twice(ja) + 1.)
push!(coeffs1p, Coefficient1p(op.rank, shii, shjj, wa))
end
end
end
end
end
end
return( coeffs1p )
end
"""
`SpinAngular.computeCoefficientsScalar(op::SpinAngular.TwoParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})`
... computes the spin-angular coefficients for the reduced (scalar) two-particle matrix element
<leftCsf || op^(0) || rightCsf >
a Tuple of two lists with one- and two-particle coefficients tpl::Tuple{coeffs1p::Array{Coefficient1p,1}, coeffs2p::Array{Coefficient2p,1}} is returned.
leftCsf - is the bra confuguration state function in relativistic notation;
rightCsf - is the ket confuguration state function in relativistic notation;
subshells - is explicitly given relativistic subshell list if useStandardSubshells == false.
"""
function computeCoefficientsScalar(op::SpinAngular.TwoParticleOperator, leftCsf::CsfR, rightCsf::CsfR, subshells::Array{Subshell,1})
coeffs2p = Coefficient2p[]
if leftCsf.J != rightCsf.J return( coeffs2p ) end
diff_occ = 0; count = 0
creation_one = 0; creation_two = 0
annihilation_one = 0; annihilation_two = 0
for (i,shi) in enumerate(subshells)
diff = leftCsf.occupation[i] - rightCsf.occupation[i]
if abs(diff) > 2 return( coeffs2p )
elseif diff != 0
diff_occ = diff_occ + abs(diff); count = count + 1
end
if diff == 1
if creation_one == 0; creation_one = i
elseif creation_two == 0; creation_two = i
else return( coeffs2p ) end
elseif diff == 2
if creation_one == 0; creation_one = i; creation_two = i
else return( coeffs2p ) end
elseif diff == -1
if annihilation_one == 0; annihilation_one = i
elseif annihilation_two == 0; annihilation_two = i
else return( coeffs2p ) end
elseif diff == -2
if annihilation_one == 0; annihilation_one = i; annihilation_two = i
else return( coeffs2p ) end
end
end
if count == 0
coeffs2p = twoParticleDiagonal(leftCsf, rightCsf, subshells)
elseif count == 2
if diff_occ == 2
coeffs2p = twoParticleDiffOcc2(leftCsf, rightCsf, creation_one, annihilation_one, subshells)
elseif diff_occ == 4
coeffs2p = twoParticle6(leftCsf, rightCsf, creation_one, annihilation_one, subshells)
end
elseif count == 3
coeffs2p = twoParticle15to18(leftCsf, rightCsf, creation_one,creation_two,annihilation_one,annihilation_two, subshells)
elseif count == 4
coeffs2p = twoParticle19to42(leftCsf, rightCsf, creation_one,creation_two,annihilation_one,annihilation_two, subshells)
end
return( coeffs2p )
end
"""
`SpinAngular.irreducibleTensor(eta::SchemeEta_a, aIndex::Int64, aN::Int64, mq::AngularM64, bIndex::Int64, bN::Int64)`
... computes the submatrix elements
(j^N alpha Q J || a^(qj)_{mq} || j'^N' alpha' Q' J')
as defined by Eq. (7) in Gaigalas et al. (CPC, 2001); a value::Float64 is returned.
eta - defines the irreducible tensoral form a^(qj)_mq;
aIndex - is the state number of the bra subshell in quasispin representation;
aN - is number of electrons in the bra subshell;
mq - is quasispin projection mq;
bIndex - is the state number of the ket subshell in quasispin representation;
aN - is number of electrons in the ket subshell.
"""
function irreducibleTensor(eta::SchemeEta_a, aIndex::Int64, aN::Int64, mq::AngularM64, bIndex::Int64, bN::Int64)
wa = 0.0
if aIndex < 64 && bIndex < 64
aT = qspaceTerms(aIndex); bT = qspaceTerms(bIndex)
if aT.min_odd != bT.min_even return(wa) end
if aN - bN - Basics.twice(mq) != 0 return(wa) end
if AngularMomentum.triangularDelta(aT.Q, AngularJ64(1//2), bT.Q) == 0 return(wa) end
if AngularMomentum.triangularDelta(aT.J, aT.j, bT.J) == 0 return(wa) end
aMQ = qshellTermM(aT.j, aN); bMQ = qshellTermM(bT.j, bN)
if qspacedelta(aT.Q, aMQ) == 0 return(wa) end
if qspacedelta(bT.Q, bMQ) == 0 return(wa) end
wa = - AngularMomentum.ClebschGordan_old(bT.Q, bMQ, AngularJ64(1//2), mq, aT.Q, aMQ)
wa = wa * completlyReducedCfpByIndices(aIndex, bIndex)/sqrt(Basics.twice(aT.Q)+1.)
elseif aIndex > 64 && bIndex > 64
aJ = Int64(round(mod(aIndex,1000)))
if mq.num == -1
j = Int64(round(mod(aIndex/(1000*1000),1000)))
# aQ = Int64(round(mod(aIndex/(1000),1000)))
bJ = Int64(round(mod(bIndex,1000)))
wa = (-1)^Int64((aJ-bJ-j+2*bN)/2) * sqrt(bN * (bJ + 1.0))
elseif mq.num == 1 wa = (-1)^aN * sqrt(aN * (aJ + 1.0))
end
end
return( wa )
end
"""
`SpinAngular.irreducibleTensor(eta::SchemeEta_W, aIndex::Int64, aN::Int64, mLeft::AngularM64, mRight::AngularM64, kj::Int64,
bIndex::Int64, bN::Int64)`
... computes the submatrix elements
(j^N alpha Q J || [a^(qj)_{mq1} x a^(qj)_{mq2}]^kj || j'^N' alpha' Q' J')
as defined by Eq. (8) in Gaigalas et al. (CPC, 2001); a value::Float64 is returned.
eta - defines the irreducible tensoral form [a^(qj)_{mq1} x a^(qj)_{mq2}]^kj;
aIndex - is the state number of the bra subshell in quasispin representation;
aN - is number of electrons in the bra subshell;
mLeft - is quasispin projection mq1;
mRight - is quasispin projection mq2;
bIndex - is the state number of the ket subshell in quasispin representation;
aN - is number of electrons in the ket subshell.
"""
function irreducibleTensor(eta::SchemeEta_W, aIndex::Int64, aN::Int64, mLeft::AngularM64, mRight::AngularM64, kj::Int64,
bIndex::Int64, bN::Int64)
wa = 0.0
if aIndex < 64 && bIndex < 64
aT = qspaceTerms(aIndex); bT = qspaceTerms(bIndex)
if aT.min_even != bT.min_even return( wa ) end
if AngularMomentum.triangularDelta(aT.J, AngularJ64(2*kj//2), bT.J) == 0 return(wa) end
aMQ = qshellTermM(aT.j, aN); bMQ = qshellTermM(bT.j, bN)
if qspacedelta(aT.Q, aMQ) == 0 return(wa) end
if qspacedelta(bT.Q, bMQ) == 0 return(wa) end
if aN - bN - Basics.twice(mLeft) - Basics.twice(mRight) != 0 return(wa) end
if mLeft == mRight
# cases a * a and a^+ * a^+
if (-1)^(kj) == 1
if AngularMomentum.triangularDelta(aT.Q, AngularJ64(2//2), bT.Q) == 0 return(wa) end
mtot_num = mLeft.num + mRight.num
mtot = AngularM64(mtot_num//mLeft.den)
wa = AngularMomentum.ClebschGordan_old(bT.Q, bMQ, AngularJ64(2//2), mtot, aT.Q, aMQ)
if abs(wa) < 1.0e-11 return( wa ) end
wa = wa * completelyReducedWkk(aIndex, bIndex, 1, kj)
if abs(wa) < 1.0e-11 return( wa ) end
wa = wa / sqrt(Basics.twice(aT.Q) + 1.)
end
else
# cases a * a^+ and a^+ * a
if kj == 0
if aIndex == bIndex
if mLeft == AngularM64(1//2)
wa = - aN
else
wa = Basics.twice(aT.j)+1. - aN
end
wa = wa * sqrt((Basics.twice(aT.J)+1.)/(Basics.twice(aT.j)+1.))
end
else
if (-1)^(kj) == 1 kq = 1
else kq = 0
end
if AngularMomentum.triangularDelta(aT.Q, AngularJ64((2*kq)//2), bT.Q) == 0 return(wa) end
mtot_num = mLeft.num + mRight.num
mtot = AngularM64(mtot_num//mLeft.den)
wa = AngularMomentum.ClebschGordan_old(bT.Q, bMQ, AngularJ64((2*kq)//2), mtot, aT.Q, aMQ)
if abs(wa) < 1.0e-11 return( wa ) end
wa = wa * completelyReducedWkk(aIndex, bIndex, kq, kj)
if abs(wa) < 1.0e-11 return( wa ) end
wa = wa / sqrt((Basics.twice(aT.Q) + 1.) * 2.)
if mLeft == AngularM64(-1//2) && (-1)^(kj) == -1 wa = -wa end
end
end
elseif aIndex > 64 && bIndex > 64
if aN > 2 error("SpinAngular.irreducibleTensor SchemeEta_W: stop a")
elseif bN > 2 error("SpinAngular.irreducibleTensor SchemeEta_W: stop b")
elseif mLeft.num + mRight.num + bN != aN error("SpinAngular.irreducibleTensor SchemeEta_W: stop c")
end
j = Int64(round(mod(aIndex/(1000*1000),1000)))
aJ = Int64(round(mod(aIndex,1000))); bJ = Int64(round(mod(bIndex,1000)))
rN = bN + mRight.num
if rN == 0 Q = Int64((j+1)/2); minRun = 0; maxRun = 0
elseif rN == 1 Q = Int64(((j+1)/2)-1); minRun = j; maxRun = j
elseif rN == 2 minRun = 0; maxRun = 2*j - 2
elseif error("SpinAngular.irreducibleTensor SchemeEta_W: stop d")
end
for runI = minRun:4:maxRun
rJ = AngularJ64(runI//2)
if rN == 2
if rJ == 0 Q = Int64((j+1)/2)
else Q = Int64(((j+1)/2)-2)
end
end
rIndex = ((j*1000) + Q)*1000 + runI
wa = wa + irreducibleTensor(SchemeEta_a(), aIndex, aN, mLeft, rIndex, rN) *
irreducibleTensor(SchemeEta_a(), rIndex, rN, mRight, bIndex, bN) *
AngularMomentum.Wigner_6j(AngularJ64(j//2), AngularJ64(j//2), kj, AngularJ64(bJ//2), AngularJ64(aJ//2), rJ)
end
wa = (-1)^Int64((aJ+bJ+2*kj)/2) * wa * sqrt(2.0*kj + 1.0)
end
return( wa )
end
"""
`SpinAngular.irreducibleTensor(eta::SchemeEta_WW, aIndex::Int64, aN::Int64, mLeft1::AngularM64, mRight1::AngularM64,
mLeft2::AngularM64, mRight2::AngularM64, kj::Int64, bIndex::Int64, bN::Int64)`
... computes the submatrix elements
( j^N QJ || [ W^(k_j) * W^(k_j)]^(0) || j^N' QJ)
for subshells with j = 1/2, 3/2, 5/2, 7/2, 9/2 and for j > 9/2 with N = 0, 1, 2; a value::Float64 is returned.
eta - defines the irreducible tensoral form [ W^(k_j) * W^(k_j)]^(0);
aIndex - is the state number of the bra subshell in quasispin representation;
aN - is number of electrons in the bra subshell;
mLeft1 - is quasispin projection mq1;
mRight1 - is quasispin projection mq2;
mLeft2 - is quasispin projection mq3;
mRight2 - is quasispin projection mq4;
bIndex - is the state number of the ket subshell in quasispin representation;
aN - is number of electrons in the ket subshell.
"""
function irreducibleTensor(eta::SchemeEta_WW, aIndex::Int64, aN::Int64, mLeft1::AngularM64, mRight1::AngularM64,
mLeft2::AngularM64, mRight2::AngularM64, kj::Int64, bIndex::Int64, bN::Int64)
wa = 0.0
if aIndex < 64 && bIndex < 64
aT = qspaceTerms(aIndex); bT = qspaceTerms(bIndex)
if aT.J != aT.J return( wa ) end
if aT.min_even != bT.min_even return( wa ) end
if aT.max_even != bT.max_even return( wa ) end
aMQ = qshellTermM(aT.j, aN); bMQ = qshellTermM(bT.j, bN)
if qspacedelta(aT.Q, aMQ) == 0 return( wa ) end
if qspacedelta(bT.Q, bMQ) == 0 return( wa ) end
if aN-bN-Basics.twice(mLeft1)-Basics.twice(mRight1)-Basics.twice(mLeft2)-Basics.twice(mRight2) != 0 return( wa ) end
for rIndex = aT.min_even:aT.max_even
rT = qspaceTerms(rIndex)
rN = Int64(bN+Basics.twice(mLeft2)+Basics.twice(mRight2))
rMQ = qshellTermM(rT.j, rN)
if qspacedelta(rT.Q, rMQ) != 0
wa6j = AngularMomentum.Wigner_6j(kj, kj, 0, bT.J, aT.J, rT.J)
if wa6j != 0.0
wairr = irreducibleTensor(SchemeEta_W(),aIndex, aN, mLeft1, mRight1, kj, rIndex, rN) *
irreducibleTensor(SchemeEta_W(),rIndex, rN, mLeft2, mRight2, kj, bIndex, bN)
wa = wa + (-1)^Int64((2*kj-Basics.twice(aT.J)+Basics.twice(rT.J))/2)* wairr
end
end
end
wa = wa/sqrt((2*kj + 1.)*(Basics.twice(aT.J) + 1.))
elseif aIndex > 64 && bIndex > 64
if aIndex != bIndex return( wa ) end
if aN > 2 error("SpinAngular.irreducibleTensor SchemeEta_WW: stop a")
elseif bN > 2 error("SpinAngular.irreducibleTensor SchemeEta_WW: stop b")
elseif mLeft1.num + mRight1.num + mLeft2.num + mRight2.num + bN != aN error("SpinAngular.irreducibleTensori SchemeEta_WW: stop c")
end
j = Int64(round(mod(aIndex/(1000*1000),1000)))
aJ = Int64(round(mod(aIndex,1000))); bJ = Int64(round(mod(bIndex,1000)))
rN = bN + mLeft2.num + mRight2.num
if rN == 0 Q = Int64((j+1)/2); minRun = 0; maxRun = 0
elseif rN == 1 Q = Int64(((j+1)/2)-1); minRun = j; maxRun = j
elseif rN == 2 minRun = 0; maxRun = 2*j - 2
elseif error("SpinAngular.irreducibleTensor SchemeEta_WW: stop d")
end
for runI = minRun:4:maxRun
rJ = AngularJ64(runI//2)
if rN == 2
if rJ == 0 Q = Int64((j+1)/2)
else Q = Int64(((j+1)/2)-2)
end
end
rIndex = ((j*1000) + Q)*1000 + runI
wa = wa + irreducibleTensor(SchemeEta_W(),aIndex, aN, mLeft1, mRight1, kj, rIndex, rN) *
irreducibleTensor(SchemeEta_W(),rIndex, rN, mLeft2, mRight2, kj, bIndex, bN) *
AngularMomentum.Wigner_6j(kj, kj, 0, AngularJ64(bJ//2), AngularJ64(aJ//2), rJ)
end
wa = (-1)^Int64((aJ+bJ)/2) * wa
end
return( wa )
end
"""
`SpinAngular.irreducibleTensor(eta::SchemeEta_aW,aIndex::Int64, aN::Int64, mLeft1::AngularM64, mLeft2::AngularM64,
mRight2::AngularM64, kj1::Int64, kj::AngularJ64, bIndex::Int64, bN::Int64)`
... computes the submatrix elements
( j^N QJ || [ a^(q j)_mq * W^(kj1)]^(kj) || j^N' QJ)
for subshells with j = 1/2, 3/2, 5/2, 7/2, 9/2 and for j > 9/2 with N = 0, 1, 2; a value::Float64 is returned.
eta - defines the irreducible tensoral form [ a^(q j)_mq * W^(kj1)]^(kj);
aIndex - is the state number of the bra subshell in quasispin representation;
aN - is number of electrons in the bra subshell;
mLeft1 - is quasispin projection mq;
mLeft2 - is quasispin projection mq3;
mRight2 - is quasispin projection mq4;
bIndex - is the state number of the ket subshell in quasispin representation;
aN - is number of electrons in the ket subshell.
"""
function irreducibleTensor(eta::SchemeEta_aW,aIndex::Int64, aN::Int64, mLeft1::AngularM64, mLeft2::AngularM64,
mRight2::AngularM64, kj1::Int64, kj::AngularJ64, bIndex::Int64, bN::Int64)
wa = 0.0; kkj1 = 2* kj1; kj1a =AngularJ64(kkj1//2)
if aIndex < 64 && bIndex < 64
aT = qspaceTerms(aIndex); bT = qspaceTerms(bIndex)
if AngularMomentum.triangularDelta(aT.J, kj, bT.J) == 0 return(wa) end
if aT.min_odd != bT.min_even return( wa ) end
if aT.max_odd != bT.max_even return( wa ) end
aMQ = qshellTermM(aT.j, aN); bMQ = qshellTermM(bT.j, bN)
if qspacedelta(aT.Q, aMQ) == 0 return( wa ) end
if qspacedelta(bT.Q, bMQ) == 0 return( wa ) end
if aN-bN-Basics.twice(mLeft1)-Basics.twice(mLeft2)-Basics.twice(mRight2) != 0 return( wa ) end
for rIndex=aT.min_odd:aT.max_odd
rT = qspaceTerms(rIndex)
rN = Int64(bN+Basics.twice(mLeft2)+Basics.twice(mRight2))
rMQ = qshellTermM(rT.j, rN)
if qspacedelta(rT.Q, rMQ) != 0
wa6j = AngularMomentum.Wigner_6j(aT.j, kj1a, kj, bT.J, aT.J, rT.J)
if wa6j != 0.0
wb = irreducibleTensor(SchemeEta_a(), aIndex, aN, mLeft1, rIndex, rN)
if abs(wb) >= 2.0e-10
wb = wb * wa6j * irreducibleTensor(SchemeEta_W(), rIndex, rN, mLeft2, mRight2, kj1, bIndex, bN)
wa = wa + wb
end
end
end
end
wa = wa * sqrt(Basics.twice(kj) + 1.0)
wa = (-1)^Int64((Basics.twice(kj) + Basics.twice(aT.J) + Basics.twice(bT.J))/2) * wa
elseif aIndex > 64 && bIndex > 64
if aN > 2 error("SpinAngular.irreducibleTensor SchemeEta_aW: stop a")
elseif bN > 2 error("SpinAngular.irreducibleTensor SchemeEta_aW: stop b")
elseif mLeft1.num + mLeft2.num + mRight2.num + bN != aN error("SpinAngular.irreducibleTensori SchemeEta_aW: stop c")
end
j = Int64(round(mod(aIndex/(1000*1000),1000)))
aJ = Int64(round(mod(aIndex,1000))); bJ = Int64(round(mod(bIndex,1000)))
rN = bN + mLeft2.num + mRight2.num
if rN == 0 Q = Int64((j+1)/2); minRun = 0; maxRun = 0
elseif rN == 1 Q = Int64(((j+1)/2)-1); minRun = j; maxRun = j
elseif rN == 2 minRun = 0; maxRun = 2*j - 2
elseif error("SpinAngular.irreducibleTensor SchemeEta_aW: stop d")
end
for runI = minRun:4:maxRun
rJ = AngularJ64(runI//2)
if rN == 2
if rJ == 0 Q = Int64((j+1)/2)
else Q = Int64(((j+1)/2)-2)
end
end
rIndex = ((j*1000) + Q)*1000 + runI
wa = wa + irreducibleTensor(SchemeEta_a(), aIndex, aN, mLeft1, rIndex, rN) *
irreducibleTensor(SchemeEta_W(),rIndex, rN, mLeft2, mRight2, kj1, bIndex, bN) *
AngularMomentum.Wigner_6j(AngularJ64(j//2), kj1a, kj, AngularJ64(bJ//2), AngularJ64(aJ//2), rJ)
end
wa = (-1)^Int64((aJ+bJ+Basics.twice(kj))/2) * sqrt(Basics.twice(kj) + 1.0) * wa
end
return( wa )
end
"""
`SpinAngular.irreducibleTensor(eta::SchemeEta_Wa, aIndex::Int64, aN::Int64, mLeft1::AngularM64, mRight1::AngularM64,
mLeft2::AngularM64, kj1::Int64, kj::AngularJ64, bIndex::Int64, bN::Int64)`
... computes the submatrix elements
( j^N QJ || [ W^(kj1) * a^(q j)_mq ]^(kj) || j^N' QJ)
for subshells with j = 1/2, 3/2, 5/2, 7/2, 9/2 and for j > 9/2 with N = 0, 1, 2; a value::Float64 is returned.
eta - defines the irreducible tensoral form [ W^(kj1) * a^(q j)_mq ]^(kj);
aIndex - is the state number of the bra subshell in quasispin representation;
aN - is number of electrons in the bra subshell;
mLeft1 - is quasispin projection mq1;
mRight1 - is quasispin projection mq2;
mRight2 - is quasispin projection mq;
bIndex - is the state number of the ket subshell in quasispin representation;
aN - is number of electrons in the ket subshell.
"""
function irreducibleTensor(eta::SchemeEta_Wa, aIndex::Int64, aN::Int64, mLeft1::AngularM64, mRight1::AngularM64,
mLeft2::AngularM64, kj1::Int64, kj::AngularJ64, bIndex::Int64, bN::Int64)
wa = 0.0; kkj1 = 2* kj1; kj1a =AngularJ64(kkj1//2)
if aIndex < 64 && bIndex < 64
aT = qspaceTerms(aIndex); bT = qspaceTerms(bIndex)
if AngularMomentum.triangularDelta(aT.J, kj, bT.J) == 0 return(wa) end
if aT.min_even != bT.min_odd return( wa ) end
if aT.max_even != bT.max_odd return( wa ) end
aMQ = qshellTermM(aT.j, aN); bMQ = qshellTermM(bT.j, bN)
if qspacedelta(aT.Q, aMQ) == 0 return( wa ) end
if qspacedelta(bT.Q, bMQ) == 0 return( wa ) end
if aN-bN-Basics.twice(mLeft1)-Basics.twice(mRight1)-Basics.twice(mLeft2) != 0 return( wa ) end
for rIndex = aT.min_even:aT.max_even
rT = qspaceTerms(rIndex)
rN = Int64(bN+Basics.twice(mLeft2))
rMQ = qshellTermM(rT.j, rN)
if qspacedelta(rT.Q, rMQ) != 0
wa6j = AngularMomentum.Wigner_6j(kj1a, aT.j, kj, bT.J, aT.J, rT.J)
if wa6j != 0.0
wb = irreducibleTensor(SchemeEta_a(), rIndex, rN, mLeft2, bIndex, bN)
if abs(wb) >= 2.0e-10
wb = wb * wa6j * irreducibleTensor(SchemeEta_W(), aIndex, aN, mLeft1, mRight1, kj1, rIndex, rN)
wa = wa + wb
end
end
end
end
wa = wa * sqrt(Basics.twice(kj) + 1.0)
wa = (-1)^Int64((Basics.twice(kj) + Basics.twice(aT.J) + Basics.twice(bT.J))/2) * wa
elseif aIndex > 64 && bIndex > 64
if aN > 2 error("SpinAngular.irreducibleTensor SchemeEta_Wa: stop a")
elseif bN > 2 error("SpinAngular.irreducibleTensor SchemeEta_Wa: stop b")
elseif mLeft1.num + mRight1.num + mLeft2.num + bN != aN error("SpinAngular.irreducibleTensor SchemeEta_Wa: stop c")
end
j = Int64(round(mod(aIndex/(1000*1000),1000)))
aJ = Int64(round(mod(aIndex,1000))); bJ = Int64(round(mod(bIndex,1000)))
rN = bN + mLeft2.num
if rN == 0 Q = Int64((j+1)/2); minRun = 0; maxRun = 0
elseif rN == 1 Q = Int64(((j+1)/2)-1); minRun = j; maxRun = j
elseif rN == 2 minRun = 0; maxRun = 2*j - 2
elseif error("SpinAngular.irreducibleTensor SchemeEta_Wa: stop d")
end
for runI = minRun:4:maxRun
rJ = AngularJ64(runI//2)
if rN == 2
if rJ == 0 Q = Int64((j+1)/2)
else Q = Int64(((j+1)/2)-2)
end
end
rIndex = ((j*1000) + Q)*1000 + runI
wa = wa + irreducibleTensor(SchemeEta_W(),aIndex, aN, mLeft1, mRight1, kj1, rIndex, rN) *
irreducibleTensor(SchemeEta_a(), rIndex, rN, mLeft2, bIndex, bN) *
AngularMomentum.Wigner_6j(kj1a, AngularJ64(j//2), kj, AngularJ64(bJ//2), AngularJ64(aJ//2), rJ)
end
wa = (-1)^Int64((aJ+bJ+Basics.twice(kj))/2) * sqrt(Basics.twice(kj) + 1.0) * wa
end
return( wa )
end
"""
`SpinAngular.normalForm(ia::Int64, ib::Int64, ic::Int64)`
... odering operators of second quantisation in norma form; a value::Int64 is returned.
ia, ib, ic - is the place of operators in the set of operators of second quantisatio.
"""
function normalForm(ia::Int64, ib::Int64, ic::Int64)
wa = Array{Int64}(undef,3); for i=1:3 wa[i] = (0) end
wa[1] = ia; wa[3] = ia
if wa[1] > ib wa[1] = ib end
if wa[3] < ib wa[3] = ib end
if wa[1] > ic wa[1] = ic end
if wa[3] < ic wa[3] = ic end
if ia > wa[1] && ia < wa[3] wa[2] = ia end
if ib > wa[1] && ib < wa[3] wa[2] = ib end
if ic > wa[1] && ic < wa[3] wa[2] = ic end
return( wa )
end
"""
`SpinAngular.normalPhase(ia::Int64, ib::Int64, ic::Int64, id::Int64)`
... compute the phase factor from odering operators of second quantisation in norma form; a wa::Int64 is returned.
ia, ib, ic, id - is the place of operators in the set of operators of second quantisatio.
"""
function normalPhase(ia::Int64, ib::Int64, ic::Int64, id::Int64)
wa = 1
if ia > ib wa = -wa end
if ia > ic wa = -wa end
if ia > id wa = -wa end
if ib > ic wa = -wa end
if ib > id wa = -wa end
if ic > id wa = -wa end
return( wa )
end
"""
`SpinAngular.qshellTermM(j::AngularJ64, N::Int64)`
... computes MQ quantum number; an M::Int64 is returned.
j - is angular momentum j for the subshell;
N - is number of electrons in the subshell;
"""
function qshellTermM(j::AngularJ64, N::Int64)
M = Int64(N-0.5*(Basics.twice(j)+1)); return( AngularM64(M//2) )
end
"""
`SpinAngular.qshellTermQ(j::AngularJ64, nu::Int64)`