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.
6 subroutine symdmatlu(dmat
)
10 complex(8), intent(inout
) :: dmat(lmmaxlu
,lmmaxlu
,nspinor
,nspinor
,natmtot
)
12 integer isym
,lspl
,lspn
14 integer is
,ia
,ja
,ias
,jas
20 complex(8), allocatable
:: zflm(:,:)
21 complex(8), allocatable
:: ulm(:,:,:)
22 complex(8), allocatable
:: su2(:,:,:)
23 complex(8), allocatable
:: dm1(:,:,:,:,:)
24 complex(8), allocatable
:: dm2(:,:)
25 complex(8), allocatable
:: dm3(:,:,:,:)
26 complex(8), allocatable
:: dm4(:,:)
27 complex(8), allocatable
:: dm5(:,:)
28 if (ldapu
.eq
.0) return
29 ! allocate local arrays
30 allocate(zflm(lmmaxlu
,lmmaxlu
))
31 allocate(ulm(lmmaxlu
,lmmaxlu
,nsymlat
))
32 allocate(su2(nspinor
,nspinor
,nsymlat
))
33 allocate(dm1(lmmaxlu
,lmmaxlu
,nspinor
,nspinor
,natmmax
))
34 allocate(dm2(lmmaxlu
,lmmaxlu
))
35 allocate(dm3(lmmaxlu
,lmmaxlu
,nspinor
,nspinor
))
36 allocate(dm4(nspinor
,nspinor
),dm5(nspinor
,nspinor
))
37 ! setup a complex unit matrix for (l,m) components
43 ! construct (l,m) rotation matrix for each lattice symmetry
44 call rotzflm(symlatc(1,1,isym
),lmaxlu
,lmmaxlu
,lmmaxlu
,zflm
,ulm(1,1,isym
))
45 ! construct SU(2) matrix for proper rotation of spinor components
46 ! (note that rotsu2 uses only the proper part of the rotation matrix)
48 call rotsu2(symlatc(1,1,isym
),det
,su2(1,1,isym
))
51 t1
=1.d0
/dble(nsymcrys
)
53 ! make copy of the density matrices
56 dm1(:,:,:,:,ia
)=dmat(:,:,:,:,ias
)
60 if (.not
.done(ia
)) then
62 dmat(:,:,:,:,ias
)=0.d0
66 ! equivalent atom index (symmetry rotates atom ja into atom ia)
67 ja
=ieqatom(ia
,is
,isym
)
69 ! apply (l,m) symmetry matrix as U*D*conjg(U')
72 call zgemm('N','N',lmmaxlu
,lmmaxlu
,lmmaxlu
,zone
,ulm(1,1,lspl
), &
73 lmmaxlu
,dm1(1,1,ispn
,jspn
,ja
),lmmaxlu
,zzero
,dm2
,lmmaxlu
)
74 call zgemm('N','C',lmmaxlu
,lmmaxlu
,lmmaxlu
,zone
,dm2
,lmmaxlu
, &
75 ulm(1,1,lspl
),lmmaxlu
,zzero
,dm3(1,1,ispn
,jspn
),lmmaxlu
)
78 ! apply SU(2) symmetry matrix as U*D*conjg(U') and add
82 dm4(:,:)=dm3(lm1
,lm2
,:,:)
83 call z2mm(su2(1,1,lspn
),dm4
,dm5
)
84 call z2mmct(dm5
,su2(1,1,lspn
),dm4
)
85 dmat(lm1
,lm2
,:,:,ias
)=dmat(lm1
,lm2
,:,:,ias
)+dm4(:,:)
89 dmat(:,:,1,1,ias
)=dmat(:,:,1,1,ias
)+dm3(:,:,1,1)
91 ! end loop over crystal symmetries
94 dmat(:,:,:,:,ias
)=t1
*dmat(:,:,:,:,ias
)
96 ! rotate into equivalent atoms
98 ja
=ieqatom(ia
,is
,isym
)
99 if (.not
.done(ja
)) then
103 ! apply (l,m) symmetry matrix as conjg(U')*D*U (rotates atom ia into atom ja)
106 call zgemm('C','N',lmmaxlu
,lmmaxlu
,lmmaxlu
,zone
,ulm(1,1,lspl
), &
107 lmmaxlu
,dmat(1,1,ispn
,jspn
,ias
),lmmaxlu
,zzero
,dm2
,lmmaxlu
)
108 call zgemm('N','N',lmmaxlu
,lmmaxlu
,lmmaxlu
,zone
,dm2
,lmmaxlu
, &
109 ulm(1,1,lspl
),lmmaxlu
,zzero
,dm3(1,1,ispn
,jspn
),lmmaxlu
)
112 ! apply SU(2) symmetry matrix as conjg(U')*D*U
116 dm4(:,:)=dm3(lm1
,lm2
,:,:)
117 call z2mctm(su2(1,1,lspn
),dm4
,dm5
)
118 call z2mm(dm5
,su2(1,1,lspn
),dm4
)
119 dmat(lm1
,lm2
,:,:,jas
)=dm4(:,:)
123 dmat(:,:,1,1,jas
)=dm3(:,:,1,1)
131 deallocate(zflm
,ulm
,su2
)
132 deallocate(dm1
,dm2
,dm3
,dm4
,dm5
)