/
tensor_matrix_elements.jl
982 lines (808 loc) · 31.8 KB
/
tensor_matrix_elements.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
# * Tensor acts on entire system
# ** Wigner–Eckart
@doc raw"""
matrix_element((γj′, m′), Tᵏq::TensorComponent, (γj, m))
Calculate the matrix element `⟨γ′j′m′|Tᵏq|γjm⟩` via Wigner–Eckart's
theorem:
```math
\begin{equation}
\begin{aligned}
\matrixel{\gamma'j'm'}{\tensor{T}^{(k)}_q}{\gamma jm}
&\defd
(-)^{2k} \frac{1}{\angroot{j'}}
C_{jm;kq}^{j'm'}
\redmatrixel{\gamma' j'}{\tensor{T}^{(k)}}{\gamma j} \\
&=
(-)^{j'-m'}
\begin{pmatrix}
j'&k&j\\
-m'&q&m
\end{pmatrix}
\redmatrixel{\gamma'j'}{\tensor{T}^{(k)}}{\gamma j},
\end{aligned}
\label{eqn:wigner-eckart}
\tag{V13.1.2}
\end{equation}
```
where the _reduced matrix element_
$\redmatrixel{n'j'}{\tensor{T}^{(k)}}{nj}$ does not depend on
$m,m'$. `j′` and `j` are the total angular momenta with `m′` and `m`
being their respective projections. `γ′` and `γ` are all other quantum
numbers needed to fully specify the quantum system; their presence
depend on the quantum system.
# Examples
```jldoctest
julia> matrix_element((2, 1), TensorComponent(OrbitalAngularMomentum(), 1), (2, 0))
-1.7320508075688774
julia> matrix_element((0, 0), TensorComponent(SphericalTensor(1), 0), (1, 0))
0.5773502691896256
julia> matrix_element(((1,half(1),half(1)), -half(1)),
TensorComponent(TotalAngularMomentum(), -1),
((1,half(1),half(1)), half(1)))
0.7071067811865475
```
"""
function matrix_element((γj′, m′)::Tuple{<:Any, <:Number},
Tᵏq::TensorComponent,
(γj, m)::Tuple{<:Any, <:Number})
Tᵏ = parent(Tᵏq)
r = rme(γj′, Tᵏ, γj)
iszero(r) && return 0
j′,j = last(γj′), last(γj)
c = powneg1(Int(j′-m′))*wigner3j(j′, rank(Tᵏ), j,
-m′, component(Tᵏq), m)
iszero(c) && return 0
c*r
end
matrix_element(γj′m′::Tuple{<:Any, <:Number},
lct::LinearCombinationTensor,
γjm::Tuple{<:Any, <:Number}) =
sum(filter!(!iszero, [c*matrix_element(γj′m′, Tᵏq, γjm) for (Tᵏq,c) in lct]))
# ** Product tensors
@doc raw"""
matrix_element((γj′, m′), X::TensorScalarProduct, (γj, m))
Calculate the matrix element of a scalar product tensor according to:
```math
\begin{equation}
\begin{aligned}
\matrixel{n'j'm'}{[\tensor{P}^{(k)}\cdot\tensor{Q}^{(k)}]}{njm}
=&
\delta_{jj'}\delta_{mm'}
\frac{1}{\angroot{j}^2}\\
&\times\sum_{n_1j_1}
(-)^{-j+j_1}
\redmatrixel{n'j}{\tensor{P}^{(k)}}{n_1j_1}
\redmatrixel{n_1j_1}{\tensor{Q}^{(k)}}{nj}
\end{aligned}
\label{eqn:scalar-product-tensor-matrix-element}
\tag{V13.1.11}
\end{equation}
```
The permissible values of ``n_1j_1`` in the summation are found using
[`AngularMomentumAlgebra.couplings`](@ref); it is assumed that the
summation only consists of a finite amount of terms and that
```math
\redmatrixel{n'j}{\tensor{P}^{(k)}}{n_1j_1}\neq0
\iff
\redmatrixel{n_1j_1}{\tensor{P}^{(k)}}{n'j}\neq0,
```
i.e. that ``\tensor{P}^{(k)}`` is (skew)symmetric.
# Examples
```jldoctest
julia> 𝐒 = SpinAngularMomentum()
𝐒̂⁽¹⁾
julia> 𝐒² = 𝐒⋅𝐒
(𝐒̂⁽¹⁾⋅𝐒̂⁽¹⁾)
julia> matrix_element((half(1), half(1)),
𝐒², (half(1), half(1)))
0.7499999999999998
julia> half(1)*(half(1)+1) # S(S+1)
0.75
julia> 𝐉 = TotalAngularMomentum()
𝐉̂⁽¹⁾
julia> 𝐉² = 𝐉⋅𝐉
(𝐉̂⁽¹⁾⋅𝐉̂⁽¹⁾)
julia> matrix_element(((1, half(1), half(3)), half(3)),
𝐉², ((1, half(1), half(3)), half(3)))
3.7500000000000004
julia> half(3)*(half(3)+1) # J(J+1)
3.75
```
"""
function matrix_element((γj′, m′), X::TensorScalarProduct, (γj, m))
j′, j = last(γj′), last(γj)
@δ j′,j m′,m
T,U = X.T,X.U
c = 0.0
# We assume that iszero(⟨n′j′||𝐓̂⁽ᵏ⁾||n₁j₁⟩) ⇔
# iszero(⟨n₁j₁||𝐓̂⁽ᵏ⁾||n′j′⟩).
Tγj₁ = couplings(T, γj′)
Uγj₁ = couplings(U, γj)
γj₁s = map(((Tγj₁, Uγj₁),) -> ∩(Tγj₁, Uγj₁), zip(Tγj₁, Uγj₁))
for γj₁ ∈ Iterators.product(γj₁s...)
length(γj₁) == 1 && (γj₁ = first(γj₁))
j₁ = last(γj₁)
c += powneg1(Int(-j+j₁))*rme(γj′,T,γj₁)*rme(γj₁,U,γj)
end
c/∏(j)^2
end
# ** Uncoupled basis functions
@doc raw"""
matrix_element((γj₁′, m₁′), (γj₂′, m₂′), 𝐓ᵏq, (γj₁, m₁), (γj₂, m₂))
Compute the matrix element of the irreducible tensor `𝐓ᵏq` acting on
coordinates `1` and `2`, by first coupling `γj₁′m₁′γj₂′m₂′` and
`γj₁m₁γj₂m₂` to all permissible `j′m′` and `jm`, respectively,
according to
```math
\begin{equation}
\begin{aligned}
&\matrixel{γ_1'j_1'm_1';γ_2'j_2'm_2'}{\tensor{P}^{(k)}_q(1,2)}{γ_1j_1m_1;γ_2j_2m_2} \\
=& (-)^{2k}
\frac{1}{\angroot{j'}}
\sum_{jmj'm'}
C_{j_1m_1;j_2m_2}^{jm}
C_{j_1'm_1';j_2'm_2'}^{j'm'}
C_{jm;kq}^{j'm'}\\
&\times
\redmatrixel{γ_1'j_1'γ_2'j_2'j'}{\tensor{P}^{(k)}(1,2)}{γ_1j_1γ_2j_2j} \\
\equiv&
\sum_{jmj'm'}
C_{j_1m_1;j_2m_2}^{jm}
C_{j_1'm_1';j_2'm_2'}^{j'm'}
\matrixel{γ_1'j_1'γ_2'j_2'j'm'}{\tensor{P}^{(k)}(1,2)}{γ_1j_1γ_2j_2jm}
\end{aligned}
\tag{V13.1.23}
\label{eqn:coupling}
\end{equation}
```
The non-vanishing terms of the sum are found using
[`AngularMomentumAlgebra.couplings`](@ref).
# Examples
```jldoctest
julia> 𝐉 = TotalAngularMomentum()
𝐉̂⁽¹⁾
julia> 𝐉₀ = TensorComponent(𝐉, 0)
𝐉̂⁽¹⁾₀
julia> matrix_element((1,1), (half(1),half(1)),
𝐉₀, (1,1), (half(1), half(1)))
1.5
julia> matrix_element((1,-1), (half(1),half(1)),
𝐉₀, (1,-1), (half(1), half(1)))
-0.4999999999999999
julia> 𝐉₁ = TensorComponent(𝐉, 1)
𝐉̂⁽¹⁾₁
julia> matrix_element((1,1), (half(1),half(1)),
𝐉₁, (1,0), (half(1), half(1)))
-1.0
julia> 𝐉² = 𝐉⋅𝐉
(𝐉̂⁽¹⁾⋅𝐉̂⁽¹⁾)
julia> matrix_element((1,1), (half(1),half(1)),
𝐉², (1,1), (half(1), half(1)))
3.7500000000000004
julia> half(3)*(half(3)+1) # J(J+1)
3.75
```
"""
function matrix_element((γj₁′, m₁′), (γj₂′, m₂′), 𝐓ᵏq, (γj₁, m₁), (γj₂, m₂))
j₁′,j₂′,j₁,j₂ = last(γj₁′), last(γj₂′), last(γj₁), last(γj₂)
j′s,m′ = couplings(j₁′, m₁′, j₂′, m₂′)
js,m = couplings(j₁, m₁, j₂, m₂)
γj′ = (γj₁′..., γj₂′...)
γj = (γj₁..., γj₂...)
v = 0.0
for j′ ∈ j′s
c′ = clebschgordan(j₁′, m₁′, j₂′, m₂′, j′, m′)
for j ∈ js
me = matrix_element(((γj′...,j′), m′), 𝐓ᵏq, ((γj...,j), m))
iszero(me) && continue
c = c′*clebschgordan(j₁, m₁, j₂, m₂, j, m)
v += c*me
end
end
v
end
# * Tensor acts on subsystems
# ** Uncoupling of coupled basis states
@doc raw"""
matrix_element((γj₁′, γj₂′, j′, m′), 𝐓ᵏq, (γj₁, γj₂, j, m))
Compute the matrix element of the tensor `𝐓ᵏq` which acts on
coordinate `1` only in the coupled basis, by employing the uncoupling
formula
```math
\begin{equation}
\begin{aligned}
&\matrixel{γ_1'j_1'γ_2'j_2'j'm'}{\tensor{T}^{(k)}_q(1)}{γ_1j_1γ_2j_2jm}\\
=& \delta_{j_2'j_2}\delta_{γ_2'γ_2}
(-)^{j+j_1'+j_2-k}
\angroot{j}
C_{jm;kq}^{j'm'}\\
&\times
\wignersixj{j_1&j_2&j\\j'&k&j_1'}
\redmatrixel{γ_1'j_1'}{\tensor{T}^{(k)}(1)}{γ_1j_1}
\end{aligned}
\tag{V13.1.40}
\label{eqn:uncoupling}
\end{equation}
```
# Examples
```jldoctest
julia> 𝐋₀ = TensorComponent(OrbitalAngularMomentum(), 0)
𝐋̂⁽¹⁾₀
julia> matrix_element((1, half(1), half(3), half(3)),
𝐋₀, (1, half(1), half(3), half(3)))
0.9999999999999999
julia> matrix_element((1, 1), 𝐋₀, (1, 1)) # For comparison
0.9999999999999999
julia> 𝐒₀ = TensorComponent(SpinAngularMomentum(), 0)
𝐒̂⁽¹⁾₀
julia> matrix_element((half(1), 1, half(3), half(3)),
𝐒₀, (half(1), 1, half(3), half(3)))
0.49999999999999994
julia> matrix_element((half(1),half(1)), 𝐒₀, (half(1),half(1)))
0.49999999999999994
```
"""
function matrix_element((γj₁′, γj₂′, j′, m′)::Tuple{<:Any, <:Any, <:Number, <:Number},
𝐓ᵏq::TensorComponent,
(γj₁, γj₂, j, m)::Tuple{<:Any, <:Any, <:Number, <:Number})
@δ γj₂′,γj₂
𝐓ᵏ = parent(𝐓ᵏq)
r = rme(γj₁′, 𝐓ᵏ, γj₁)
iszero(r) && return 0
j₁′,j₂′,j₁,j₂ = last(γj₁′), last(γj₂′), last(γj₁), last(γj₂)
k = rank(𝐓ᵏ)
q = component(𝐓ᵏq)
c = clebschgordan(j,m,k,q,j′,m′)
iszero(c) && return 0
w6j = wigner6j(j₁, j₂, j,
j′, k, j₁′)
iszero(w6j) && return 0
powneg1(Int(j+j₁′+j₂-k))*∏(j)*c*w6j*r
end
@doc raw"""
matrix_element((γj₁′, ::Tuple{}, j′, m′), 𝐓ᵏq, (γj₁, ::Tuple{}, j, m))
Compute the matrix element of the tensor `𝐓ᵏq` which acts on
coordinate `1`, in the special case that the second coordinate is
immaterial for the tensor `𝐓ᵏ` (an example is the principal quantum
number ``n``, which does not affect the matrix elements of `𝐉`).
# Examples
```jldoctest
julia> 𝐉₀ = TensorComponent(TotalAngularMomentum(), 0)
𝐉̂⁽¹⁾₀
julia> a = ((0, half(1), half(1)), (), half(1), half(1))
((0, 1/2, 1/2), (), 1/2, 1/2)
julia> matrix_element(a, 𝐉₀, a)
0.49999999999999994
```
"""
function matrix_element((γj₁′, γj₂′, j′, m′)::Tuple{<:Any, Tuple{}, <:Number, <:Number},
𝐓ᵏq::TensorComponent,
(γj₁, γj₂, j, m)::Tuple{<:Any, Tuple{}, <:Number, <:Number})
last(γj₁′) == j′ && last(γj₁) == j ||
throw(ArgumentError("Angular momentum mismatch"))
matrix_element((γj₁′, m′), 𝐓ᵏq, (γj₁, m))
end
# ** Uncoupled basis states
@doc raw"""
matrix_element2(γjm₁′, γjm₂′, X::TensorScalarProduct, γjm₁, γjm₂)
The matrix element of a scalar product of two tensors acting on
different coordinates is given by (in the uncoupled basis)
```math
\begin{equation}
\begin{aligned}
&\matrixel{\gamma_1'j_1'm_1';\gamma_2'j_2'm_2'}{[\tensor{P}^{(k)}(1)\cdot\tensor{Q}^{(k)}(2)]}{\gamma_1j_1m_1;\gamma_2j_2m_2}\\
=&
\frac{1}{\angroot{j_1'j_2'}}
\sum_\alpha(-)^{-\alpha}
C_{j_1m_1;k,\alpha}^{j_1'm_1'}
C_{j_2m_2;k,-\alpha}^{j_2'm_2'}\\
&\times
\redmatrixel{\gamma_1'j_1'}{\tensor{P}^{(k)}(1)}{\gamma_1j_1}
\redmatrixel{\gamma_2'j_2'}{\tensor{Q}^{(k)}(2)}{\gamma_2j_2} \\
\equiv&
\sum_\alpha
(-)^{-\alpha}
\matrixel{\gamma_1'j_1'm_1'}{\tensor{P}^{(k)}_{\alpha}(1)}{\gamma_1j_1m_1}
\matrixel{\gamma_2'j_2'm_2'}{\tensor{Q}^{(k)}_{-\alpha}(2)}{\gamma_2j_2m_2}
\end{aligned}
\tag{V13.1.26}
\label{eqn:scalar-product-tensor-matrix-element-diff-coords-uncoupled}
\end{equation}
```
Since the [Clebsch–Gordan coefficients](@ref) can be rewritten using 3j
symbols and the 3j symbols vanish unless $m_1 + \alpha - m_1' = m_2 -
\alpha - m_2' = 0$, we have
```math
\alpha = m_1' - m_1 = m_2-m_2'
```
This case occurs in two-body interactions, such as the [Coulomb
interaction](@ref), where ``1',1`` and ``2',2`` are pairs of orbitals
and the scalar product tensor is a term in the multipole expansion in
terms of [Spherical tensors](@ref tensors_spherical_tensors):
```jldoctest
julia> 𝐂⁰ = SphericalTensor(0)
𝐂̂⁽⁰⁾
julia> matrix_element2((0, 0), (0, 0), 𝐂⁰⋅𝐂⁰, (0,0), (0, 0)) # ⟨1s₀,1s₀|𝐂⁰⋅𝐂⁰|1s₀,1s₀⟩
1.0
julia> 𝐂¹ = SphericalTensor(1)
𝐂̂⁽¹⁾
julia> matrix_element2((0, 0), (1, 0), 𝐂¹⋅𝐂¹, (1,0), (2, 0)) # ⟨1s₀,2p₀|𝐂¹⋅𝐂¹|2p₀,3d₀⟩
0.29814239699997186
julia> matrix_element2((0, 0), (1, 1), 𝐂¹⋅𝐂¹, (1,0), (2, 1)) # ⟨1s₀,2p₁|𝐂¹⋅𝐂¹|2p₀,3d₁⟩
0.25819888974716104
```
but also in the case of the operator ``\tensor{L}\cdot\tensor{S}`` and
coordinates ``1`` and ``2`` correspond to orbital and spin angular
momenta, respectively. We can verify this using the classical result
known from spin–orbit splitting:
```math
\begin{aligned}
J^2 &= (\tensor{L}+\tensor{S})^2 = L^2 + 2\tensor{L}\cdot\tensor{S} + S^2\\
\implies
\expect{\tensor{L}\cdot\tensor{S}} &=
\frac{1}{2}(\expect{J^2} - \expect{L^2} - \expect{S^2}) =
\frac{1}{2}[J(J+1) - L(L+1) - S(S+1)]
\end{aligned}
```
In the uncoupled basis, ``J`` is not a good quantum number (it is not
a constant of motion), except for _pure states_, i.e. those with
maximal ``\abs{m_\ell + m_s}``:
```jldoctest
julia> X = OrbitalAngularMomentum()⋅SpinAngularMomentum()
(𝐋̂⁽¹⁾⋅𝐒̂⁽¹⁾)
julia> matrix_element2((1, 1), (half(1), half(1)),
X, (1,1), (half(1), half(1)))
0.4999999999999999
julia> 1/2*(half(3)*(half(3)+1)-1*(1+1)-half(1)*(half(1)+1)) # 1/2(J(J+1)-L(L+1)-S(S+1))
0.5
```
"""
function matrix_element2(γjm₁′, γjm₂′, X::TensorScalarProduct, γjm₁, γjm₂)
T,U = X.T,X.U
k = rank(T)
α = Int(last(γjm₁′)-last(γjm₁))
(α != last(γjm₂)-last(γjm₂′) || abs(α) > k) && return 0
powneg1(-α)*
matrix_element(γjm₁′, TensorComponent(T,α), γjm₁)*
matrix_element(γjm₂′, TensorComponent(U,-α), γjm₂)
end
@doc raw"""
matrix_element2((γj₁′, γj₂′, j′, m′), X::TensorScalarProduct, (γj₁, γj₂, j, m))
The matrix element of a scalar product of two tensors acting on
different coordinates is given by (in the coupled basis)
```math
\begin{equation}
\begin{aligned}
&\matrixel{n_1'j_1'n_2'j_2'j'm'}{[\tensor{P}^{(k)}(1)\cdot\tensor{Q}^{(k)}(2)]}{n_1j_1n_2j_2jm}\\
=& \delta_{j'j}\delta_{m'm}
(-)^{j+j_1+j_2'}
\wignersixj{j_1'&j_1&k\\j_2&j_2'&j}\\
&\times
\redmatrixel{n_1'j_1'}{\tensor{P}^{(k)}(1)}{n_1j_1}
\redmatrixel{n_2'j_2'}{\tensor{Q}^{(k)}(2)}{n_2j_2}.
\end{aligned}
\tag{V13.1.29}
\label{eqn:scalar-product-tensor-matrix-element-diff-coords-coupled}
\end{equation}
```
```jldoctest
julia> X = OrbitalAngularMomentum()⋅SpinAngularMomentum()
(𝐋̂⁽¹⁾⋅𝐒̂⁽¹⁾)
julia> matrix_element2((1, half(1), half(3), half(3)),
X, (1, half(1), half(3), half(3)))
0.4999999999999999
```
"""
function matrix_element2((γj₁′, γj₂′, j′, m′), X::TensorScalarProduct, (γj₁, γj₂, j, m))
@δ j′,j m′,m
j₁′,j₂′,j₁,j₂ = last(γj₁′), last(γj₂′), last(γj₁), last(γj₂)
T,U = X.T,X.U
Tr = rme(γj₁′, T, γj₁)
iszero(Tr) && return 0
Ur = rme(γj₂′, U, γj₂)
iszero(Ur) && return 0
powneg1(Int(j+j₁+j₂′))*Tr*Ur*wigner6j(j₁′, j₁, rank(T),
j₂, j₂′, j)
end
# * Tensor matrix elements in orbital basis
"""
dot(a::SpinOrbital,
𝐓ᵏq::Union{TensorComponent,TensorScalarProduct},
b::SpinOrbital)
Compute the matrix element `⟨a|𝐓ᵏq|b⟩` in the basis of spin-orbitals,
dispatching to the correct low-level function `matrix_element`,
depending on the value of `system(𝐓ᵏq)`.
# Examples with coupled orbitals
```jldoctest
julia> a,b,c,d = (SpinOrbital(ro"2p", half(3)),
SpinOrbital(ro"2p", half(1)),
SpinOrbital(ro"2s", half(1)),
SpinOrbital(ro"3d", half(3)))
(2p(3/2), 2p(1/2), 2s(1/2), 3d(3/2))
julia> 𝐋, 𝐒, 𝐉 = OrbitalAngularMomentum(), SpinAngularMomentum(), TotalAngularMomentum()
(𝐋̂⁽¹⁾, 𝐒̂⁽¹⁾, 𝐉̂⁽¹⁾)
julia> 𝐋², 𝐒², 𝐉² = 𝐋⋅𝐋, 𝐒⋅𝐒, 𝐉⋅𝐉
((𝐋̂⁽¹⁾⋅𝐋̂⁽¹⁾), (𝐒̂⁽¹⁾⋅𝐒̂⁽¹⁾), (𝐉̂⁽¹⁾⋅𝐉̂⁽¹⁾))
julia> dot(a, cartesian_tensor_component(𝐉, :x), b),
1/2*√((3/2+1/2+1)*(3/2-1/2)) # 1/2√((J+M+1)*(J-M))
(0.8660254037844386, 0.8660254037844386)
julia> dot(a, cartesian_tensor_component(𝐉, :z), a), a.m[1]
(1.5, 3/2)
julia> dot(a, TensorComponent(𝐋, 0), a)
0.9999999999999999
julia> dot(c, cartesian_tensor_component(Gradient(), :x), a)
- 0.408248(∂ᵣ + 2/r)
julia> dot(c, cartesian_tensor_component(SphericalTensor(1), :x), a)
-0.40824829046386296
julia> orbitals = rsos"2[p]"
6-element Array{SpinOrbital{RelativisticOrbital{Int64},Tuple{Half{Int64}}},1}:
2p-(-1/2)
2p-(1/2)
2p(-3/2)
2p(-1/2)
2p(1/2)
2p(3/2)
julia> map(o -> dot(o, 𝐉², o), orbitals)
6-element Array{Float64,1}:
0.7499999999999998
0.7499999999999998
3.7500000000000004
3.7500000000000004
3.7500000000000004
3.7500000000000004
julia> 1/2*(1/2+1),3/2*(3/2+1) # J(J+1)
(0.75, 3.75)
julia> dot(a, 𝐋², a), 1*(1+1)
(2.0, 2)
julia> dot(d, 𝐋², d), 2*(2+1)
(5.999999999999999, 6)
julia> dot(a, 𝐒², a), 1/2*(1/2+1)
(0.7499999999999998, 0.75)
julia> dot(a, 𝐋⋅𝐒, a)
0.4999999999999999
```
# Examples with uncoupled orbitals
```jldoctest
julia> a,b,c,d = (SpinOrbital(o"2p", 1, half(1)),
SpinOrbital(o"2p", -1, half(1)),
SpinOrbital(o"2s", 0, half(1)),
SpinOrbital(o"3d", 2, -half(1)))
(2p₁α, 2p₋₁α, 2s₀α, 3d₂β)
julia> 𝐋,𝐒,𝐉 = OrbitalAngularMomentum(),SpinAngularMomentum(),TotalAngularMomentum()
(𝐋̂⁽¹⁾, 𝐒̂⁽¹⁾, 𝐉̂⁽¹⁾)
julia> 𝐋²,𝐒²,𝐉² = 𝐋⋅𝐋,𝐒⋅𝐒,𝐉⋅𝐉
((𝐋̂⁽¹⁾⋅𝐋̂⁽¹⁾), (𝐒̂⁽¹⁾⋅𝐒̂⁽¹⁾), (𝐉̂⁽¹⁾⋅𝐉̂⁽¹⁾))
julia> dot(a, cartesian_tensor_component(𝐉, :z), a), sum(a.m)
(1.5, 3/2)
julia> dot(a, TensorComponent(𝐋, 0), a)
0.9999999999999999
julia> # Same as previous, but with spin down
dot(a, TensorComponent(𝐋, 0), SpinOrbital(o"2p", 1, -half(1)))
0
julia> dot(d, TensorComponent(𝐋, 0), d)
1.9999999999999998
julia> dot(d, TensorComponent(𝐒, 0), d)
-0.49999999999999994
julia> dot(c, cartesian_tensor_component(Gradient(), :x), a)
- 0.408248(∂ᵣ + 2/r)
julia> dot(c, cartesian_tensor_component(SphericalTensor(1), :x), a)
-0.40824829046386285
julia> orbitals = sos"2[p]"
6-element Array{SpinOrbital{Orbital{Int64},Tuple{Int64,Half{Int64}}},1}:
2p₋₁α
2p₋₁β
2p₀α
2p₀β
2p₁α
2p₁β
julia> # Only 2p₋₁β and 2p₁α are pure states, with J = 3/2 => J(J + 1) = 3.75
map(o -> dot(o, 𝐉², o), orbitals)
6-element Array{Float64,1}:
1.7499999999999998
3.7500000000000004
2.75
2.75
3.7500000000000004
1.7499999999999998
julia> dot(a, 𝐋², a), 1*(1+1)
(2.0, 2)
julia> dot(d, 𝐋², d), 2*(2+1)
(5.999999999999999, 6)
julia> dot(a, 𝐒², a), half(1)*(half(1)+1)
(0.7499999999999998, 0.75)
julia> dot(a, 𝐋⋅𝐒, a)
0.4999999999999999
```
"""
LinearAlgebra.dot(a::SpinOrbital,
𝐓ᵏq::Union{TensorComponent,TensorScalarProduct},
b::SpinOrbital) =
matrix_element(system(𝐓ᵏq), a, 𝐓ᵏq, b)
"""
dot((a,b)::Tuple, X::TensorScalarProduct, (c,d)::Tuple)
Compute the matrix element `⟨a(1)b(2)|𝐓(1)⋅𝐔(2)|c(1)d(2)⟩` in the
basis of spin-orbitals, dispatching the correct low-level function
`matrix_element` depending on the value of `system(X)`, where `X` is
the scalar product tensor.
# Examples
```jldoctest
julia> 𝐊⁰,𝐊² = CoulombTensor(0),CoulombTensor(2)
(𝐊̂⁽⁰⁾, 𝐊̂⁽²⁾)
julia> a,b = SpinOrbital(o"1s", 0, half(1)),SpinOrbital(o"3d", 0, half(1))
(1s₀α, 3d₀α)
julia> dot((a,b), 𝐊⁰⋅𝐊⁰, (a,b))
1.0
julia> dot((a,b), 𝐊²⋅𝐊², (b,a))
0.19999999999999998
julia> a,b = SpinOrbital(ro"1s", half(1)),SpinOrbital(ro"3d", half(1))
(1s(1/2), 3d(1/2))
julia> dot((a,b), 𝐊⁰⋅𝐊⁰, (a,b))
1.0
julia> dot((a,b), 𝐊²⋅𝐊², (b,a))
0.12
```
"""
LinearAlgebra.dot((a,b)::Tuple, X::TensorScalarProduct, (c,d)::Tuple) =
matrix_element(system(X), (a,b), X, (c,d))
LinearAlgebra.dot(o′, lct::LinearCombinationTensor, o) =
sum(filter!(!iszero, [c*dot(o′, Tᵏq, o) for (Tᵏq,c) in lct]))
# ** Coupled orbitals
"""
matrix_element(::Union{FullSystem,TotalAngularMomentumSubSystem},
a::SpinOrbital{<:RelativisticOrbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:RelativisticOrbital})
The matrix element of a tensor acting on the full system or the total
angular momentum, evaluated in the basis of coupled spin-orbitals, is
simply computed using the Wigner–Eckart theorem
``\\eqref{eqn:wigner-eckart}``.
"""
matrix_element(system::Union{FullSystem,TotalAngularMomentumSubSystem},
a::SpinOrbital{<:RelativisticOrbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:RelativisticOrbital}) =
matrix_element(quantum_numbers(system, a),
𝐓ᵏq, quantum_numbers(system, b))
"""
matrix_element(system,
a::SpinOrbital{<:RelativisticOrbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:RelativisticOrbital})
The matrix element of a tensor acting on `system`, which is a
subsystem, evaluated in the basis coupled spin-orbitals, needs to be
computed via the uncoupling formula ``\\eqref{eqn:uncoupling}``.
"""
function matrix_element(system,
a::SpinOrbital{<:RelativisticOrbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:RelativisticOrbital})
j′, m′ = a.orb.j, a.m[1]
j, m = b.orb.j, b.m[1]
γj₁′, γj₁ = first.(quantum_numbers(system, a, b))
γj₂′, γj₂ = first.(other_quantum_numbers(system, a, b))
matrix_element((γj₁′, γj₂′, j′, m′), 𝐓ᵏq, (γj₁, γj₂, j, m))
end
"""
matrix_element(::Tuple{S,S},
a::SpinOrbital{<:RelativisticOrbital},
X::TensorScalarProduct,
b::SpinOrbital{<:RelativisticOrbital}) where {S<:Union{FullSystem,TotalAngularMomentumSubSystem}}
The matrix element of a tensor scalar product, where both factors act
on the full system or the total angular momentum, evaluated in the
basis of coupled spin-orbitals, is computed using
``\\eqref{eqn:scalar-product-tensor-matrix-element}``.
"""
matrix_element(systems::Tuple{S,S},
a::SpinOrbital{<:RelativisticOrbital},
X::TensorScalarProduct,
b::SpinOrbital{<:RelativisticOrbital}) where {S<:Union{FullSystem,TotalAngularMomentumSubSystem}} =
matrix_element(quantum_numbers(systems[1], a),
X, quantum_numbers(systems[1], b))
@doc raw"""
matrix_element(systems::Tuple{S,S},
a::SpinOrbital{<:RelativisticOrbital},
X::TensorScalarProduct,
b::SpinOrbital{<:RelativisticOrbital}) where {S<:SubSystem}
The matrix element of a tensor scalar product, where both factors act
on the same subsystem, evaluated in the
basis of coupled spin-orbitals, is computed using
```math
\begin{equation}
\begin{aligned}
&\matrixel{n_1'j_1'n_2'j_2'j'm'}{[\tensor{P}^{(k)}(1)\cdot\tensor{Q}^{(k)}(1)]}{n_1j_1n_2j_2jm}\\
=&\delta_{n_2'n_2}\delta_{j_2'j_2}\delta_{j_1'j_1}\delta_{j'j}\delta_{m'm}
\frac{1}{\angroot{j_1}^2}
(-)^{-j_1}\\
&\times
\sum_{JN}(-)^J
\redmatrixel{n_1'j_1}{\tensor{P}^{(k)}(1)}{NJ}
\redmatrixel{NJ}{\tensor{Q}^{(k)}(1)}{n_1j_1}.
\end{aligned}
\tag{V13.1.43}
\end{equation}
```
Apart from the additional factor ``\delta_{n_2'n_2}\delta_{j_2'j_2}``,
this expression is equivalent to
``\eqref{eqn:scalar-product-tensor-matrix-element}``.
"""
function matrix_element((s,_)::Tuple{S,S},
a::SpinOrbital{<:RelativisticOrbital},
X::TensorScalarProduct,
b::SpinOrbital{<:RelativisticOrbital}) where {S<:SubSystem}
γj₁′, γj₁ = first.(quantum_numbers(s, a, b))
γj₂′, γj₂ = first.(other_quantum_numbers(s, a, b))
@δ γj₂′,γj₂ a.orb.j,b.orb.j
matrix_element((γj₁′, a.m[1]), X, (γj₁, b.m[1]))
end
"""
matrix_element((s₁,s₂)::Tuple{<:SubSystem,<:SubSystem},
a::SpinOrbital{<:RelativisticOrbital},
X::TensorScalarProduct,
b::SpinOrbital{<:RelativisticOrbital})
The matrix element of a tensor scalar product, where the factors act
on different subsystems, evaluated in the basis of coupled
spin-orbitals, is computed using
``\\eqref{eqn:scalar-product-tensor-matrix-element-diff-coords-coupled}``.
"""
function matrix_element((s₁,s₂)::Tuple{<:SubSystem,<:SubSystem},
a::SpinOrbital{<:RelativisticOrbital},
X::TensorScalarProduct,
b::SpinOrbital{<:RelativisticOrbital})
γj₁′, γj₁ = first.(quantum_numbers(s₁, a, b))
γj₂′, γj₂ = first.(quantum_numbers(s₂, a, b))
matrix_element2((γj₁′, γj₂′, a.orb.j, a.m[1]), X, (γj₁, γj₂, b.orb.j, b.m[1]))
end
"""
matrix_element((s₁,s₂)::Tuple{<:System,<:System},
(a,b)::Tuple{<:SpinOrbital{<:RelativisticOrbital},
<:SpinOrbital{<:RelativisticOrbital}},
X::TensorScalarProduct,
(c,d)::Tuple{<:SpinOrbital{<:RelativisticOrbital},
<:SpinOrbital{<:RelativisticOrbital}})
The matrix element of a tensor scalar product, where the factors act
on the orbital pairs `a`,`c` and `b`,`d`, respectively, evaluated in
the basis of coupled spin-orbitals, is computed using
``\\eqref{eqn:scalar-product-tensor-matrix-element-diff-coords-uncoupled}``
together with ``\\eqref{eqn:uncoupling}`` applied to each matrix
element between single orbitals; the individual spin-orbitals couple
``\\ell`` and ``s`` to form a total ``j``, but they are not further
coupled to e.g. a term.
"""
function matrix_element((s₁,s₂)::Tuple{<:System,<:System},
(a,b)::Tuple{<:SpinOrbital{<:RelativisticOrbital},
<:SpinOrbital{<:RelativisticOrbital}},
X::TensorScalarProduct,
(c,d)::Tuple{<:SpinOrbital{<:RelativisticOrbital},
<:SpinOrbital{<:RelativisticOrbital}})
γjm₁′ = (first(quantum_numbers(s₁, a)), first(other_quantum_numbers(s₁, a)),
a.orb.j, a.m[1])
γjm₂′ = (first(quantum_numbers(s₂, b)), first(other_quantum_numbers(s₂, b)),
b.orb.j, b.m[1])
γjm₁ = (first(quantum_numbers(s₁, c)), first(other_quantum_numbers(s₁, c)),
c.orb.j, c.m[1])
γjm₂ = (first(quantum_numbers(s₂, d)), first(other_quantum_numbers(s₂, d)),
d.orb.j, d.m[1])
matrix_element2(γjm₁′, γjm₂′, X, γjm₁, γjm₂)
end
# ** Uncoupled orbitals
"""
matrix_element(::Union{FullSystem,TotalAngularMomentumSubSystem},
a::SpinOrbital{<:Orbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:Orbital})
The matrix element of a tensor acting on the full system or the total
angular momentum, evaluated in the basis of uncoupled spin-orbitals,
is computed by transforming to the coupled system via
``\\eqref{eqn:coupling}``.
"""
matrix_element(system::Union{FullSystem,TotalAngularMomentumSubSystem},
a::SpinOrbital{<:Orbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:Orbital}) =
matrix_element(quantum_numbers(system, a)..., 𝐓ᵏq, quantum_numbers(system, b)...)
@doc raw"""
matrix_element(system,
a::SpinOrbital{<:Orbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:Orbital})
The matrix element of a tensor acting on `system`, which is a
subsystem, evaluated in the basis uncoupled spin-orbitals, is given by
```math
\begin{equation}
\begin{aligned}
&\matrixel{n_1'j_1'm_1';n_2'j_2'm_2'}{\tensor{T}^{(k)}_q(1)}{n_1j_1m_1;n_2j_2m_2} \\
=&
\delta_{n_2'n_2}\delta_{j_2'j_2}\delta_{m_2'm_2} \\
&\matrixel{n_1'j_1'm_1'}{\tensor{T}^{(k)}_q(1)}{n_1j_1m_1}.
\end{aligned}
\label{eqn:tensor-matrix-element-subsystem-uncoupled}
\tag{V13.1.39}
\end{equation}
```
"""
function matrix_element(system,
a::SpinOrbital{<:Orbital},
𝐓ᵏq::TensorComponent,
b::SpinOrbital{<:Orbital})
γjm₂′,γjm₂ = other_quantum_numbers(system, a, b)
@δ γjm₂′,γjm₂
matrix_element(quantum_numbers(system, a), 𝐓ᵏq, quantum_numbers(system, b))
end
"""
matrix_element(::Tuple{S,S},
a::SpinOrbital{<:Orbital},
X::TensorScalarProduct,
b::SpinOrbital{<:Orbital}) where {S<:Union{FullSystem,TotalAngularMomentumSubSystem}}
The matrix element of a tensor scalar product, where both factors act
on the full system or the total angular momentum, evaluated in the
basis of uncoupled spin-orbitals, is computed by transforming to the
coupled system via ``\\eqref{eqn:coupling}``, which then dispatches to
``\\eqref{eqn:scalar-product-tensor-matrix-element}``.
"""
matrix_element(systems::Tuple{S,S},
a::SpinOrbital{<:Orbital},
X::TensorScalarProduct,
b::SpinOrbital{<:Orbital}) where {S<:Union{FullSystem,TotalAngularMomentumSubSystem}} =
matrix_element(quantum_numbers(systems[1], a)...,
X, quantum_numbers(systems[1], b)...)
"""
matrix_element(systems::Tuple{S,S},
a::SpinOrbital{<:Orbital},
X::TensorScalarProduct,
b::SpinOrbital{<:Orbital}) where {S<:SubSystem}
The matrix element of a tensor scalar product, where both factors act
on the same subsystem, evaluated in the basis of uncoupled
spin-orbitals, is just a special case of
``\\eqref{eqn:tensor-matrix-element-subsystem-uncoupled}`` combined
with ``\\eqref{eqn:scalar-product-tensor-matrix-element}``.
"""
function matrix_element((s,_)::Tuple{S,S},
a::SpinOrbital{<:Orbital},
X::TensorScalarProduct,
b::SpinOrbital{<:Orbital}) where {S<:SubSystem}
@δ other_quantum_numbers(s, a, b)
matrix_element(quantum_numbers(s, a),
X, quantum_numbers(s, b))
end
"""
matrix_element((s₁,s₂)::Tuple{<:SubSystem,<:SubSystem},
a::SpinOrbital{<:Orbital},
X::TensorScalarProduct,
b::SpinOrbital{<:Orbital})
The matrix element of a tensor scalar product, where the factors act
on different subsystems, evaluated in the basis of uncoupled
spin-orbitals, is computed using
``\\eqref{eqn:scalar-product-tensor-matrix-element-diff-coords-uncoupled}``.
"""
function matrix_element((s₁,s₂)::Tuple{<:SubSystem,<:SubSystem},
a::SpinOrbital{<:Orbital},
X::TensorScalarProduct,
b::SpinOrbital{<:Orbital})
γjm₁′, γjm₁ = quantum_numbers(s₁, a, b)
γjm₂′, γjm₂ = quantum_numbers(s₂, a, b)
matrix_element2(γjm₁′, γjm₂′, X, γjm₁, γjm₂)
end
"""
matrix_element((s₁,s₂)::Tuple{<:System,<:System},
(a,b)::Tuple{<:SpinOrbital{<:Orbital},
<:SpinOrbital{<:Orbital}},
X::TensorScalarProduct,
(c,d)::Tuple{<:SpinOrbital{<:Orbital},
<:SpinOrbital{<:Orbital}})
The matrix element of a tensor scalar product, where the factors act
on the orbital pairs `a`,`c` and `b`,`d`, respectively, evaluated in
the basis of uncoupled spin-orbitals, is computed using
``\\eqref{eqn:scalar-product-tensor-matrix-element-diff-coords-uncoupled}``.
"""
function matrix_element((s₁,s₂)::Tuple{<:System,<:System},
(a,b)::Tuple{<:SpinOrbital{<:Orbital},
<:SpinOrbital{<:Orbital}},
X::TensorScalarProduct,
(c,d)::Tuple{<:SpinOrbital{<:Orbital},
<:SpinOrbital{<:Orbital}})
@δ other_quantum_numbers(s₁, a, c) other_quantum_numbers(s₂, b, d)
γjm₁′, γjm₁ = quantum_numbers(s₁, a, c)
γjm₂′, γjm₂ = quantum_numbers(s₂, b, d)
matrix_element2(γjm₁′, γjm₂′, X, γjm₁, γjm₂)
end
export matrix_element, matrix_element2