The Elk Code
findsym.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2007-2008 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
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: findsym
8 ! !INTERFACE:
9 subroutine findsym(apl1,apl2,nsym,lspl,lspn,iea)
10 ! !USES:
11 use modmain
12 use moddftu
13 use modtddft
14 ! !INPUT/OUTPUT PARAMETERS:
15 ! apl1 : first set of atomic positions in lattice coordinates
16 ! (in,real(3,maxatoms,maxspecies))
17 ! apl2 : second set of atomic positions in lattice coordinates
18 ! (in,real(3,maxatoms,maxspecies))
19 ! nsym : number of symmetries (out,integer)
20 ! lspl : spatial rotation element in lattice point group for each symmetry
21 ! (out,integer(48))
22 ! lspn : spin rotation element in lattice point group for each symmetry
23 ! (out,integer(48))
24 ! iea : equivalent atom index for each symmetry
25 ! (out,integer(iea(natmmax,nspecies,48))
26 ! !DESCRIPTION:
27 ! Finds the symmetries which rotate one set of atomic positions into another.
28 ! Both sets of positions differ only by a translation vector and have the same
29 ! muffin-tin magnetic fields (stored in the global array {\tt bfcmt}). Any
30 ! symmetry element consists of a spatial rotation of the atomic position
31 ! vectors followed by a global magnetic rotation: $\{\alpha_S|\alpha_R\}$. In
32 ! the case of spin-orbit coupling $\alpha_S=\alpha_R$. The symmetries are
33 ! returned as indices of elements in the Bravais lattice point group. An
34 ! index to equivalent atoms is stored in the array {\tt iea}.
35 !
36 ! !REVISION HISTORY:
37 ! Created April 2007 (JKD)
38 ! Fixed use of proper rotations for spin, February 2008 (L. Nordstrom)
39 !EOP
40 !BOC
41 implicit none
42 ! arguments
43 real(8), intent(in) :: apl1(3,maxatoms,maxspecies)
44 real(8), intent(in) :: apl2(3,maxatoms,maxspecies)
45 integer, intent(out) :: nsym,lspl(48),lspn(48),iea(natmmax,nspecies,48)
46 ! local variables
47 integer isym,jsym,jsym0,jsym1
48 integer is,ia,ias,ja,jas,its,n
49 real(8) sl(3,3),scp(3,3)
50 real(8) c(3,3),d(3,3),v(3),t1
51 ! automatic arrays
52 integer jea(natmmax,nspecies)
53 real(8) apl3(3,natmmax)
54 complex(8) dmat(lmmaxdm,nspinor,lmmaxdm,nspinor)
55 ! external functions
56 real(8), external :: dznrm2
57 nsym=0
58 ! loop over lattice symmetries (spatial rotations)
59 do isym=1,nsymlat
60 ! make real copy of lattice rotation symmetry
61  sl(1:3,1:3)=dble(symlat(1:3,1:3,isym))
62 ! loop over species
63  do is=1,nspecies
64 ! map apl1 coordinates to [0,1) and store in apl3
65  do ia=1,natoms(is)
66  apl3(1:3,ia)=apl1(1:3,ia,is)
67  call r3frac(epslat,apl3(:,ia))
68  end do
69  do ja=1,natoms(is)
70 ! apply lattice symmetry to atomic positions
71  v(1:3)=sl(1:3,1)*apl2(1,ja,is) &
72  +sl(1:3,2)*apl2(2,ja,is) &
73  +sl(1:3,3)*apl2(3,ja,is)
74 ! map coordinates to [0,1)
75  call r3frac(epslat,v)
76 ! check if atomic positions are invariant
77  do ia=1,natoms(is)
78  t1=abs(apl3(1,ia)-v(1))+abs(apl3(2,ia)-v(2))+abs(apl3(3,ia)-v(3))
79  if (t1 < epslat) then
80 ! equivalent atom index
81  jea(ia,is)=ja
82  goto 10
83  end if
84  end do
85 ! not invariant so try new spatial rotation
86  goto 40
87 10 continue
88  end do
89  end do
90 ! all atomic positions invariant at this point
91  jsym=1
92 ! spin polarised case
93  if (spinpol) then
94 ! check invariance of magnetic fields under global spin rotation
95  if (spinorb) then
96 ! with spin-orbit coupling spin rotation equals spatial rotation
97  jsym0=isym
98  jsym1=isym
99  else
100 ! without spin-orbit coupling spin rotation independent of spatial rotation
101  jsym0=1
102  jsym1=nsymlat
103  end if
104  do jsym=jsym0,jsym1
105 ! proper part of symmetry matrix
106  scp(1:3,1:3)=dble(symlatd(jsym))*symlatc(1:3,1:3,jsym)
107 ! rotate global field and check invariance using proper part of symmetry matrix
108  v(1:3)=scp(1:3,1)*bfieldc0(1) &
109  +scp(1:3,2)*bfieldc0(2) &
110  +scp(1:3,3)*bfieldc0(3)
111  t1=abs(bfieldc0(1)-v(1))+abs(bfieldc0(2)-v(2))+abs(bfieldc0(3)-v(3))
112 ! if not invariant try a different global spin rotation
113  if (t1 > epslat) goto 20
114 ! rotate muffin-tin magnetic fields and check invariance
115  do is=1,nspecies
116  do ia=1,natoms(is)
117 ! equivalent atom
118  ja=jea(ia,is)
119  v(1:3)=scp(1:3,1)*bfcmt0(1,ja,is) &
120  +scp(1:3,2)*bfcmt0(2,ja,is) &
121  +scp(1:3,3)*bfcmt0(3,ja,is)
122  t1=abs(bfcmt0(1,ia,is)-v(1)) &
123  +abs(bfcmt0(2,ia,is)-v(2)) &
124  +abs(bfcmt0(3,ia,is)-v(3))
125 ! if not invariant try a different global spin rotation
126  if (t1 > epslat) goto 20
127  end do
128  end do
129 ! all fields invariant
130  goto 30
131 20 continue
132 ! end loop over global spin rotations
133  end do
134 ! magnetic fields not invariant so try different spatial rotation
135  goto 40
136  end if
137 30 continue
138 ! check invariance of density matrices for fixed tensor moment calculations
139  if (ftmtype /= 0) then
140  n=(lmmaxdm*nspinor)**2
141  do is=1,nspecies
142  do ia=1,natoms(is)
143  ias=idxas(ia,is)
144 ! equivalent atom
145  ja=jea(ia,is)
146  jas=idxas(ja,is)
147 ! rotate the fixed tensor moment density matrix
148  dmat(:,:,:,:)=0.d0
149  call rotdmat(symlatc(:,:,isym),symlatc(:,:,jsym),lmaxdm,nspinor, &
150  lmmaxdm,dmftm(:,:,:,:,jas),dmat)
151 ! check invariance
152  dmat(:,:,:,:)=dmat(:,:,:,:)-dmftm(:,:,:,:,ias)
153  t1=dznrm2(n,dmat,1)/dble(n)
154  if (t1 > epsdmat) goto 40
155  end do
156  end do
157  end if
158 ! check invariance of static spin-dependent vector potential
159  if (tafsp) then
160  call r3mm(symlatc(:,:,isym),afspc,c)
161  call r3mmt(c,scp,d)
162  t1=sum(abs(afspc(1:3,1:3)-d(1:3,1:3)))
163  if (t1 > epslat) goto 40
164  end if
165 ! check invariance of time- and spin-dependent vector potential
166  if (tafspt) then
167  do its=1,ntimes
168  call r3mm(symlatc(:,:,isym),afspt(:,:,its),c)
169  call r3mmt(c,scp,d)
170  t1=sum(abs(afspt(1:3,1:3,its)-d(1:3,1:3)))
171  if (t1 > epslat) goto 40
172  end do
173  end if
174 ! everything invariant so add symmetry to set
175  nsym=nsym+1
176  lspl(nsym)=isym
177  lspn(nsym)=jsym
178  do is=1,nspecies
179  do ia=1,natoms(is)
180  iea(ia,is,nsym)=jea(ia,is)
181  end do
182  end do
183 40 continue
184 ! end loop over spatial rotations
185 end do
186 end subroutine
187 !EOC
188 
pure subroutine r3mmt(a, b, c)
Definition: r3mmt.f90:10
real(8), dimension(3, maxatoms, maxspecies) bfcmt0
Definition: modmain.f90:277
real(8), dimension(3, 3) afspc
Definition: modmain.f90:333
logical spinpol
Definition: modmain.f90:230
integer, dimension(maxatoms, maxspecies) idxas
Definition: modmain.f90:42
complex(8), dimension(:,:,:,:,:), allocatable dmftm
Definition: moddftu.f90:89
integer ntimes
Definition: modtddft.f90:40
integer, dimension(3, 3, 48) symlat
Definition: modmain.f90:347
integer ftmtype
Definition: moddftu.f90:79
integer nsymlat
Definition: modmain.f90:345
real(8), dimension(3, 3, 48) symlatc
Definition: modmain.f90:353
pure subroutine r3frac(eps, v)
Definition: r3frac.f90:10
integer, dimension(48) symlatd
Definition: modmain.f90:349
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36
subroutine rotdmat(rspl, rspn, lmax, nspinor, ld, dmat1, dmat2)
Definition: rotdmat.f90:7
real(8) epslat
Definition: modmain.f90:24
subroutine findsym(apl1, apl2, nsym, lspl, lspn, iea)
Definition: findsym.f90:10
logical tafspt
Definition: modtddft.f90:58
logical spinorb
Definition: modmain.f90:232
real(8) epsdmat
Definition: moddftu.f90:19
real(8), dimension(3) bfieldc0
Definition: modmain.f90:273
logical tafsp
Definition: modmain.f90:331
integer, parameter lmaxdm
Definition: moddftu.f90:14
pure subroutine r3mm(a, b, c)
Definition: r3mm.f90:10
real(8), dimension(:,:,:), allocatable afspt
Definition: modtddft.f90:60