The Elk Code
symrvfmt.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2018 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 subroutine symrvfmt(tspin,tnc,nrmt_,nrmti_,npmt_,ld,rvfmt)
7 use modmain
8 implicit none
9 ! arguments
10 logical, intent(in) :: tspin,tnc
11 integer, intent(in) :: nrmt_(nspecies),nrmti_(nspecies),npmt_(nspecies),ld
12 real(8), intent(inout) :: rvfmt(ld,natmtot,*)
13 ! local variables
14 integer nd,isym,lspl,lspn
15 integer is,ia,ja,ias,jas
16 integer nr,nri,np,i
17 real(8) sc(3,3),t0,t1
18 real(8) x1,x2,x3,y1,y2,y3
19 ! allocatable arrays
20 real(8), allocatable :: rvfmt1(:,:,:),rvfmt2(:,:)
21 ! dimension of the vector field
22 nd=merge(3,1,tnc)
23 allocate(rvfmt1(ld,natmmax,nd),rvfmt2(ld,nd))
24 t0=1.d0/dble(nsymcrys)
25 do is=1,nspecies
26  nr=nrmt_(is)
27  nri=nrmti_(is)
28  np=npmt_(is)
29 ! make copy of vector field for all atoms of current species
30  do i=1,nd
31  do ia=1,natoms(is)
32  ias=idxas(ia,is)
33  rvfmt1(1:np,ia,i)=rvfmt(1:np,ias,i)
34  end do
35  end do
36  do ia=1,natoms(is)
37 ! only symmetrise first equivalent atom (rotate into others)
38  if (.not.tfeqat(ia,is)) cycle
39  ias=idxas(ia,is)
40  rvfmt(1:np,ias,1:nd)=0.d0
41 ! begin loop over crystal symmetries
42  do isym=1,nsymcrys
43 ! equivalent atom
44  ja=ieqatom(ia,is,isym)
45 ! parallel transport of vector field
46  lspl=lsplsymc(isym)
47  do i=1,nd
48  call rotrfmt(symlatc(:,:,lspl),nr,nri,rvfmt1(:,ja,i),rvfmt2(:,i))
49  end do
50  if (tspin) then
51 ! global spin proper rotation matrix in Cartesian coordinates
52  lspn=lspnsymc(isym)
53  sc(1:3,1:3)=symlatd(lspn)*symlatc(1:3,1:3,lspn)
54  else
55 ! set spin rotation equal to spatial rotation
56  lspn=lspl
57  sc(1:3,1:3)=symlatc(1:3,1:3,lspl)
58  end if
59 ! global spin rotation of vector field
60  if (tnc) then
61 ! non-collinear case
62  do i=1,np
63  x1=rvfmt2(i,1); x2=rvfmt2(i,2); x3=rvfmt2(i,3)
64  y1=sc(1,1)*x1+sc(1,2)*x2+sc(1,3)*x3
65  y2=sc(2,1)*x1+sc(2,2)*x2+sc(2,3)*x3
66  y3=sc(3,1)*x1+sc(3,2)*x2+sc(3,3)*x3
67  rvfmt(i,ias,1)=rvfmt(i,ias,1)+y1
68  rvfmt(i,ias,2)=rvfmt(i,ias,2)+y2
69  rvfmt(i,ias,3)=rvfmt(i,ias,3)+y3
70  end do
71  else
72 ! collinear case
73  t1=sc(3,3)
74  rvfmt(1:np,ias,1)=rvfmt(1:np,ias,1)+t1*rvfmt2(1:np,1)
75  end if
76 ! end loop over crystal symmetries
77  end do
78 ! normalise
79  do i=1,nd
80  rvfmt(1:np,ias,i)=t0*rvfmt(1:np,ias,i)
81  end do
82 ! rotate into equivalent atoms
83  do ja=1,natoms(is)
84  if (eqatoms(ia,ja,is).and.(ia /= ja)) then
85  isym=findloc(ieqatom(ia,is,1:nsymcrys),ja,1)
86  jas=idxas(ja,is)
87 ! parallel transport of vector field (using operation inverse)
88  lspl=isymlat(lsplsymc(isym))
89  do i=1,nd
90  call rotrfmt(symlatc(:,:,lspl),nr,nri,rvfmt(:,ias,i),rvfmt(:,jas,i))
91  end do
92  if (tspin) then
93 ! inverse of global proper rotation matrix in Cartesian coordinates
94  lspn=isymlat(lspnsymc(isym))
95  sc(1:3,1:3)=symlatd(lspn)*symlatc(1:3,1:3,lspn)
96  else
97 ! set spin rotation equal to spatial rotation
98  lspn=lspl
99  sc(1:3,1:3)=symlatc(1:3,1:3,lspl)
100  end if
101 ! global spin rotation of vector field
102  if (tnc) then
103 ! non-collinear case
104  do i=1,np
105  x1=rvfmt(i,jas,1); x2=rvfmt(i,jas,2); x3=rvfmt(i,jas,3)
106  y1=sc(1,1)*x1+sc(1,2)*x2+sc(1,3)*x3
107  y2=sc(2,1)*x1+sc(2,2)*x2+sc(2,3)*x3
108  y3=sc(3,1)*x1+sc(3,2)*x2+sc(3,3)*x3
109  rvfmt(i,jas,1)=y1; rvfmt(i,jas,2)=y2; rvfmt(i,jas,3)=y3
110  end do
111  else
112 ! collinear case
113  t1=sc(3,3)
114  rvfmt(1:np,jas,1)=t1*rvfmt(1:np,jas,1)
115  end if
116  end if
117  end do
118 ! end loop over atoms and species
119  end do
120 end do
121 deallocate(rvfmt1,rvfmt2)
122 end subroutine
123 
integer, dimension(maxsymcrys) lspnsymc
Definition: modmain.f90:369
integer natmmax
Definition: modmain.f90:38
logical, dimension(:,:), allocatable tfeqat
Definition: modmain.f90:375
integer, dimension(maxatoms, maxspecies) idxas
Definition: modmain.f90:42
subroutine symrvfmt(tspin, tnc, nrmt_, nrmti_, npmt_, ld, rvfmt)
Definition: symrvfmt.f90:7
integer nsymcrys
Definition: modmain.f90:361
integer, dimension(48) isymlat
Definition: modmain.f90:351
logical, dimension(:,:,:), allocatable eqatoms
Definition: modmain.f90:373
integer, dimension(:,:,:), allocatable ieqatom
Definition: modmain.f90:371
integer, dimension(maxsymcrys) lsplsymc
Definition: modmain.f90:367
real(8), dimension(3, 3, 48) symlatc
Definition: modmain.f90:353
integer, dimension(48) symlatd
Definition: modmain.f90:349
subroutine rotrfmt(rot, nr, nri, rfmt1, rfmt2)
Definition: rotrfmt.f90:7
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36