The Elk Code
tm2todm.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2007 F. Bultmark, F. Cricchio, L. Nordstrom and J. K. Dewhurst.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 !BOP
7 ! !ROUTINE: tm2todm
8 ! !INTERFACE:
9 subroutine tm2todm(l,k,p,ld,wkp,dm)
10 ! !INPUT/OUTPUT PARAMETERS:
11 ! l : angular momentum quantum number (in,integer)
12 ! k : angular momentum tensor moment label (in,integer)
13 ! p : spin tensor moment label (in,integer)
14 ! ld : leading dimension (in,integer)
15 ! wkp : 2-index tensor moment components (in,real(-ld:ld,-1:1))
16 ! dm : real density matrix (out,real(ld,2,ld,2))
17 ! !DESCRIPTION:
18 ! Calculates the real density matrix
19 ! $$ D=\sum_{y=-p}^p\sum_{x=-k}^k w_{xy}^{kp}\,\Gamma_{xy}^{kp} $$
20 ! from the real 2-index coefficients $w_{xy}^{kp}$ and the uncoupled tensor
21 ! moment matrices given by
22 ! $$ \Gamma_{xy}^{kp}(m_1\sigma_1,m_2\sigma_2)=
23 ! (-1)^{l-m_2+s-\sigma_2}\sqrt{(2k+1)(2p+1)}
24 ! \begin{pmatrix} l & k & l \\ -m_2 & x & m_1 \end{pmatrix}
25 ! \begin{pmatrix} s & p & s \\ -\sigma_2 & y & \sigma_1 \end{pmatrix}, $$
26 ! where $l$ is the angular momentum quantum number, $s=\frac{1}{2}$ and the
27 ! irreducible representations are labeled by $k\in\{0,\ldots,2l\}$ and
28 ! $p\in\{0,1\}$. The variables $x\in\{-k,\ldots, k\}$ and $y\in\{-1,0,1\}$
29 ! index the components in the array {\tt wkp}. These matrices are real and
30 ! orthonormal in the sense
31 ! $$ \tr\big(\Gamma_{xy}^{kp}\Gamma_{x'y'}^{k'p'}\big)=
32 ! \delta_{kk'}\delta_{pp'}\delta_{xx'}\delta_{yy'}. $$
33 ! For a detailed derivation see {\it Phys. Rev. B} {\bf 80}, 035121 (2009) and
34 ! {\it J. Phys.: Condens. Matter} {\bf 7}, 9947 (1995). See also the routine
35 ! {\tt tm3todm}.
36 !
37 ! !REVISION HISTORY:
38 ! Created 2007 (Francesco Cricchio and Lars Nordstrom)
39 ! Changed normalisation and decoupled loops, January 2022 (JKD)
40 !EOP
41 !BOC
42 implicit none
43 ! arguments
44 integer, intent(in) :: l,k,p,ld
45 real(8), intent(in) :: wkp(-ld:ld,-1:1)
46 real(8), intent(out) :: dm(ld,2,ld,2)
47 ! local variables
48 integer ispn,jspn
49 integer m1,m2,n,x,y
50 integer lm0,lm1,lm2
51 real(8) t0,t1
52 ! automatic arrays
53 real(8) dlm(2*l+1,2*l+1,-k:k),dsp(2,2,-p:p)
54 ! external functions
55 real(8), external :: wigner3j,wigner3jf
56 if (l < 0) then
57  write(*,*)
58  write(*,'("Error(tm2todm): l < 0 : ",I8)') l
59  write(*,*)
60  stop
61 end if
62 if (k < 0) then
63  write(*,*)
64  write(*,'("Error(tm2todm): k < 0 : ",I8)') k
65  write(*,*)
66  stop
67 end if
68 if (k > 2*l) then
69  write(*,*)
70  write(*,'("Error(tm2todm): k > 2*l : ",2I8)') k,2*l
71  write(*,*)
72  stop
73 end if
74 if ((p < 0).or.(p > 1)) then
75  write(*,*)
76  write(*,'("Error(tm2todm): p should be 0 or 1 : ",I8)') p
77  write(*,*)
78  stop
79 end if
80 ! calculate the angular momentum matrices
81 t0=sqrt(dble(2*k+1))
82 do x=-k,k
83  dlm(:,:,x)=0.d0
84  lm2=0
85  do m2=-l,l
86  lm2=lm2+1
87  if (mod(l-m2,2) == 0) then
88  t1=t0
89  else
90  t1=-t0
91  end if
92  lm1=0
93  do m1=-l,l
94  lm1=lm1+1
95  dlm(lm1,lm2,x)=t1*wigner3j(l,k,l,-m2,x,m1)
96  end do
97  end do
98 end do
99 ! calculate the spin matrices
100 t0=sqrt(dble(2*p+1))
101 do y=-p,p
102  dsp(:,:,y)=0.d0
103  do jspn=1,2
104  if (jspn == 1) then
105  t1=t0
106  else
107  t1=-t0
108  end if
109  do ispn=1,2
110  dsp(ispn,jspn,y)=t1*wigner3jf(1,2*p,1,2*jspn-3,2*y,3-2*ispn)
111  end do
112  end do
113 end do
114 ! determine the full matrix from the Kronecker product of dlm and dsp
115 dm(:,:,:,:)=0.d0
116 lm0=l**2
117 n=2*l+1
118 do y=-p,p
119  do x=-k,k
120  t1=wkp(x,y)
121  if (abs(t1) < 1.d-8) cycle
122  do jspn=1,2
123  do lm2=1,n
124  do ispn=1,2
125  do lm1=1,n
126  dm(lm0+lm1,ispn,lm0+lm2,jspn)=dm(lm0+lm1,ispn,lm0+lm2,jspn) &
127  +t1*dlm(lm1,lm2,x)*dsp(ispn,jspn,y)
128  end do
129  end do
130  end do
131  end do
132  end do
133 end do
134 end subroutine
135 !EOC
136 
subroutine tm2todm(l, k, p, ld, wkp, dm)
Definition: tm2todm.f90:10