The Elk Code
symrvfir.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2007 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: symrvfir
8 ! !INTERFACE:
9 subroutine symrvfir(tspin,tnc,ngridg_,ngtot_,ngvec_,nfgrz_,igfft_,igrzf_,ld, &
10  rvfir)
11 ! !USES:
12 use modmain
13 ! !INPUT/OUTPUT PARAMETERS:
14 ! tspin : .true. if spin rotations should be used (in,logical)
15 ! tnc : .true. if the vector field is non-collinear, otherwise it is
16 ! collinear along the z-axis (in,logical)
17 ! ngridg_ : G-vector grid sizes (in,integer(3))
18 ! ngtot_ : total number of G-vectors (in,integer)
19 ! ngvec_ : number of G-vectors within cut-off (in,integer)
20 ! nfgrz_ : number of FFT elements for real-complex transforms (in,integer)
21 ! igfft_ : map from G-vector index to FFT array (in,integer(ngvec_))
22 ! igrzf_ : map from real-complex FFT index to G-point index
23 ! (in,integer(nfgrz_))
24 ! ld : leading dimension (in,integer)
25 ! rvfir : real interstitial vector function (inout,real(ld,*))
26 ! !DESCRIPTION:
27 ! Symmetrises a real interstitial vector function. See routines {\tt symrvf}
28 ! and {\tt symrfir} for details.
29 !
30 ! !REVISION HISTORY:
31 ! Created July 2007 (JKD)
32 !EOP
33 !BOC
34 implicit none
35 ! arguments
36 logical, intent(in) :: tspin,tnc
37 integer, intent(in) :: ngridg_(3),ngtot_,ngvec_,nfgrz_
38 integer, intent(in) :: igfft_(ngvec_),igrzf_(nfgrz_),ld
39 real(8), intent(inout) :: rvfir(ld,*)
40 ! local variables
41 logical tv0
42 integer isym,lspl,lspn,sym(3,3)
43 integer nd,ig,jg,ifg,jfg
44 integer i1,i2,i3,j1,j2,j3,i
45 real(8) sc(3,3),v1,v2,v3,t1
46 complex(8) z0,z1,z2,z3
47 ! allocatable arrays
48 complex(8), allocatable :: zfft1(:,:),zfft2(:,:)
49 ! dimension of the vector field
50 nd=merge(3,1,tnc)
51 allocate(zfft1(ngtot_,nd),zfft2(nfgrz_,nd))
52 ! Fourier transform vector function to G-space
53 do i=1,nd
54  zfft1(1:ngtot_,i)=rvfir(1:ngtot_,i)
55  call zfftifc(3,ngridg_,-1,zfft1(:,i))
56 end do
57 zfft2(1:nfgrz_,1:nd)=0.d0
58 ! loop over crystal symmetries
59 do isym=1,nsymcrys
60 ! zero translation vector flag
61  tv0=tv0symc(isym)
62 ! translation vector in Cartesian coordinates
63  if (.not.tv0) then
64  v1=vtcsymc(1,isym)
65  v2=vtcsymc(2,isym)
66  v3=vtcsymc(3,isym)
67  end if
68 ! index to spatial rotation lattice symmetry
69  lspl=lsplsymc(isym)
70  sym(1:3,1:3)=symlat(1:3,1:3,lspl)
71  if (tspin) then
72 ! global spin proper rotation in Cartesian coordinates
73  lspn=lspnsymc(isym)
74  sc(1:3,1:3)=symlatd(lspn)*symlatc(1:3,1:3,lspn)
75  else
76 ! set spin rotation equal to spatial rotation
77  lspn=lspl
78  sc(1:3,1:3)=symlatc(1:3,1:3,lspl)
79  end if
80  do ifg=1,nfgrz_
81  ig=igrzf_(ifg)
82  if (ig > ngvec_) cycle
83 ! multiply the transpose of the inverse symmetry matrix with the G-vector
84  if (lspl == 1) then
85  jg=ig
86  else
87  i1=ivg(1,ig); i2=ivg(2,ig); i3=ivg(3,ig)
88  j1=sym(1,1)*i1+sym(2,1)*i2+sym(3,1)*i3
89  j2=sym(1,2)*i1+sym(2,2)*i2+sym(3,2)*i3
90  j3=sym(1,3)*i1+sym(2,3)*i2+sym(3,3)*i3
91  jg=ivgig(j1,j2,j3)
92  end if
93  jfg=igfft_(jg)
94 ! translation, spatial rotation and global spin rotation
95  if (tv0) then
96 ! zero translation vector
97  if (lspn == 1) then
98 ! global spin symmetry is the identity
99  zfft2(ifg,1:nd)=zfft2(ifg,1:nd)+zfft1(jfg,1:nd)
100  else
101  if (tnc) then
102 ! non-collinear case
103  z1=zfft1(jfg,1); z2=zfft1(jfg,2); z3=zfft1(jfg,3)
104  zfft2(ifg,1)=zfft2(ifg,1)+sc(1,1)*z1+sc(1,2)*z2+sc(1,3)*z3
105  zfft2(ifg,2)=zfft2(ifg,2)+sc(2,1)*z1+sc(2,2)*z2+sc(2,3)*z3
106  zfft2(ifg,3)=zfft2(ifg,3)+sc(3,1)*z1+sc(3,2)*z2+sc(3,3)*z3
107  else
108 ! collinear case
109  zfft2(ifg,1)=zfft2(ifg,1)+sc(3,3)*zfft1(jfg,1)
110  end if
111  end if
112  else
113 ! complex phase factor for translation
114  t1=vgc(1,jg)*v1+vgc(2,jg)*v2+vgc(3,jg)*v3
115  z0=cmplx(cos(t1),-sin(t1),8)
116  if (lspn == 1) then
117  zfft2(ifg,1:nd)=zfft2(ifg,1:nd)+z0*zfft1(jfg,1:nd)
118  else
119  if (tnc) then
120  z1=zfft1(jfg,1); z2=zfft1(jfg,2); z3=zfft1(jfg,3)
121  zfft2(ifg,1)=zfft2(ifg,1)+z0*(sc(1,1)*z1+sc(1,2)*z2+sc(1,3)*z3)
122  zfft2(ifg,2)=zfft2(ifg,2)+z0*(sc(2,1)*z1+sc(2,2)*z2+sc(2,3)*z3)
123  zfft2(ifg,3)=zfft2(ifg,3)+z0*(sc(3,1)*z1+sc(3,2)*z2+sc(3,3)*z3)
124  else
125  zfft2(ifg,1)=zfft2(ifg,1)+sc(3,3)*z0*zfft1(jfg,1)
126  end if
127  end if
128  end if
129  end do
130 end do
131 ! Fourier transform to real-space and normalise
132 t1=1.d0/dble(nsymcrys)
133 do i=1,nd
134  call rzfftifc(3,ngridg_,1,rvfir(:,i),zfft2(:,i))
135  rvfir(1:ngtot_,i)=t1*rvfir(1:ngtot_,i)
136 end do
137 deallocate(zfft1,zfft2)
138 end subroutine
139 !EOC
140 
integer, dimension(maxsymcrys) lspnsymc
Definition: modmain.f90:369
subroutine symrvfir(tspin, tnc, ngridg_, ngtot_, ngvec_, nfgrz_, igfft_, igrzf_, ld, rvfir)
Definition: symrvfir.f90:11
integer, dimension(:,:,:), allocatable ivgig
Definition: modmain.f90:405
integer nsymcrys
Definition: modmain.f90:361
integer, dimension(3, 3, 48) symlat
Definition: modmain.f90:347
logical, dimension(maxsymcrys) tv0symc
Definition: modmain.f90:365
real(8), dimension(:,:), allocatable vgc
Definition: modmain.f90:423
subroutine zfftifc(nd, n, sgn, z)
Definition: zfftifc_fftw.f90:7
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
integer, dimension(:,:), allocatable ivg
Definition: modmain.f90:403
subroutine rzfftifc(nd, n, sgn, r, z)
real(8), dimension(3, maxsymcrys) vtcsymc
Definition: modmain.f90:363