The Elk Code
 
Loading...
Searching...
No Matches
rotrfmt.f90
Go to the documentation of this file.
1
2! Copyright (C) 2015 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
6subroutine rotrfmt(rot,nr,nri,rfmt1,rfmt2)
7use modmain
8implicit none
9! arguments
10real(8), intent(in) :: rot(3,3)
11integer, intent(in) :: nr,nri
12real(8), intent(in) :: rfmt1(*)
13real(8), intent(out) :: rfmt2(*)
14! local variables
15integer i
16! inner part of muffin-tin
17call rotrflm(rot,lmaxi,nri,lmmaxi,rfmt1,rfmt2)
18! outer part of muffin-tin
19i=lmmaxi*nri+1
20call rotrflm(rot,lmaxo,nr-nri,lmmaxo,rfmt1(i),rfmt2(i))
21return
22
23contains
24
25!BOP
26! !ROUTINE: rotrflm
27! !INTERFACE:
28subroutine rotrflm(rot,lmax,n,ld,rflm1,rflm2)
29! !INPUT/OUTPUT PARAMETERS:
30! rot : rotation matrix (in,real(3,3))
31! lmax : maximum angular momentum (in,integer)
32! n : number of functions to rotate (in,integer)
33! ld : leading dimension (in,integer)
34! rflm1 : coefficients of the real spherical harmonic expansion for each
35! function (in,real(ld,n))
36! rflm2 : coefficients of rotated functions (out,complex(ld,n))
37! !DESCRIPTION:
38! Rotates a set of real functions
39! $$ f_i({\bf r})=\sum_{lm}f_{lm}^iR_{lm}(\hat{\bf r}) $$
40! for all $i$, given the coefficients $f_{lm}^i$ and a rotation matrix $R$.
41! This is done by first the computing the Euler angles $(\alpha,\beta,\gamma)$
42! of $R^{-1}$ (see routine {\tt roteuler}) and then applying the spherical
43! harmonic rotation matrix generated by the routine {\tt rlmrot}.
44!
45! !REVISION HISTORY:
46! Created December 2008 (JKD)
47!EOP
48!BOC
49implicit none
50! arguments
51real(8), intent(in) :: rot(3,3)
52integer, intent(in) :: lmax,n,ld
53real(8), intent(in) :: rflm1(ld,*)
54real(8), intent(out) :: rflm2(ld,*)
55! local variables
56integer l,lm,nm,p
57real(8) det,ang(3),angi(3)
58! automatic arrays
59real(8) d(ld,ld)
60if (n == 0) return
61! find the determinant
62det=rot(1,1)*(rot(2,2)*rot(3,3)-rot(3,2)*rot(2,3)) &
63 +rot(2,1)*(rot(3,2)*rot(1,3)-rot(1,2)*rot(3,3)) &
64 +rot(3,1)*(rot(1,2)*rot(2,3)-rot(2,2)*rot(1,3))
65! calculate the Euler angles of the proper rotation
66if (det > 0.d0) then
67 p=1
68 call roteuler(rot,ang)
69else
70 p=-1
71 call roteuler(-rot(:,:),ang)
72end if
73! inverse rotation: the function is to be rotated, not the spherical harmonics
74angi(1)=-ang(3)
75angi(2)=-ang(2)
76angi(3)=-ang(1)
77! determine the rotation matrix for real spherical harmonics
78call rlmrot(p,angi,lmax,ld,d)
79! apply rotation matrix
80do l=0,lmax
81 nm=2*l+1
82 lm=l**2+1
83 call dgemm('N','N',nm,n,nm,1.d0,d(lm,lm),ld,rflm1(lm,1),ld,0.d0,rflm2(lm,1), &
84 ld)
85end do
86end subroutine
87!EOC
88
89!BOP
90! !ROUTINE: rlmrot
91! !INTERFACE:
92subroutine rlmrot(p,ang,lmax,ld,d)
93! !INPUT/OUTPUT PARAMETERS:
94! p : if p=-1 then the rotation matrix is improper (in,integer)
95! ang : Euler angles; alpha, beta, gamma (in,real(3))
96! lmax : maximum angular momentum (in,integer)
97! ld : leading dimension (in,integer)
98! d : real spherical harmonic rotation matrix (out,real(ld,*))
99! !DESCRIPTION:
100! Returns the rotation matrix in the basis of real spherical harmonics given
101! the three Euler angles, $(\alpha,\beta,\gamma)$, and the parity, $p$, of the
102! rotation. The matrix is determined using the formula of V. V. Nechaev,
103! [{\it J. Struct. Chem.} {\bf 35}, 115 (1994)], suitably modified for our
104! definition of the real spherical harmonics ($m_1>0$, $m_2>0$):
105! \begin{align*}
106! &\Delta^l_{00}=d^l_{00}, \\
107! &\Delta^l_{m_10}=\sqrt{2}\,(-1)^{m_1}d^l_{0m_1}\cos(m_1\alpha), \\
108! &\Delta^l_{0m_2}=\sqrt{2}\,(-1)^{m_2}d^l_{m_20}\cos(m_2\gamma), \\
109! &\Delta^l_{-m_10}=-\sqrt{2}\,d^l_{0m_1}\sin(m_1\alpha), \\
110! &\Delta^l_{0-m_2}=\sqrt{2}\,d^l_{m_20}\sin(m_2\gamma), \\
111! &\Delta^l_{m_1m_2}=(-1)^{m_1}(-1)^{m_2}\{\cos(m_1\alpha)\cos(m_2\gamma)
112! [d_A+d_B]-\sin(m_1\alpha)\sin(m_2\gamma)[d_A-d_B]\}, \\
113! &\Delta^l_{m_1-m_2}=(-1)^{m_1}\{\sin(m_1\alpha)\cos(m_2\gamma)
114! [d_A-d_B]+\cos(m_1\alpha)\sin(m_2\gamma)[d_A+d_B]\}, \\
115! &\Delta^l_{-m_1m_2}=-(-1)^{m_2}\{\sin(m_1\alpha)\cos(m_2\gamma)
116! [d_A+d_B]+\cos(m_1\alpha)\sin(m_2\gamma)[d_A-d_B]\}, \\
117! &\Delta^l_{-m_1-m_2}=\cos(m_1\alpha)\cos(m_2\gamma)
118! [d_A-d_B]-\sin(m_1\alpha)\sin(m_2\gamma)[d_A+d_B],
119! \end{align*}
120! where $d_A\equiv d^l_{-m_1-m_2}$, $d_B\equiv(-1)^{m_1}d^l_{m_1-m_2}$ and
121! $d$ is the rotation matrix about the $y$-axis for complex spherical
122! harmonics. See the routines {\tt genrlm}, {\tt roteuler} and {\tt ylmroty}.
123!
124! !REVISION HISTORY:
125! Created December 2008 (JKD)
126!EOP
127!BOC
128implicit none
129! arguments
130integer, intent(in) :: p
131real(8), intent(in) :: ang(3)
132integer, intent(in) :: lmax,ld
133real(8), intent(out) :: d(ld,*)
134! local variables
135integer l,m1,m2,lm0,lm1,lm2
136real(8), parameter :: sqtwo=1.4142135623730950488d0
137real(8) s1,s2,t1,t2,t3,t4,t5,t6,t7,t8
138! automatic arrays
139integer lmi(-lmax:lmax)
140real(8) ca(lmax),sa(lmax),cg(lmax),sg(lmax),dy(ld,ld)
141! generate the complex spherical harmonic rotation matrix about the y-axis
142call ylmroty(ang(2),lmax,ld,dy)
143do m1=1,lmax
144 ca(m1)=cos(m1*ang(1)); sa(m1)=sin(m1*ang(1))
145 cg(m1)=cos(m1*ang(3)); sg(m1)=sin(m1*ang(3))
146end do
147lm1=0
148do l=0,lmax
149 do m1=-l,l
150 lm1=lm1+1
151 lmi(m1)=lm1
152 end do
153 lm0=lmi(0)
154 d(lm0,lm0)=dy(lm0,lm0)
155 do m1=1,l
156 if (mod(m1,2) == 0) then
157 s1=1.d0
158 else
159 s1=-1.d0
160 end if
161 t1=sqtwo*dy(lm0,lmi(m1))
162 t2=sqtwo*dy(lmi(m1),lm0)
163 d(lmi(m1),lm0)=s1*t1*ca(m1)
164 d(lm0,lmi(m1))=s1*t2*cg(m1)
165 d(lmi(-m1),lm0)=-t1*sa(m1)
166 d(lm0,lmi(-m1))=t2*sg(m1)
167 do m2=1,l
168 if (mod(m2,2) == 0) then
169 s2=1.d0
170 else
171 s2=-1.d0
172 end if
173 t1=ca(m1)*cg(m2)
174 t2=sa(m1)*sg(m2)
175 t3=sa(m1)*cg(m2)
176 t4=ca(m1)*sg(m2)
177 t5=dy(lmi(-m1),lmi(-m2))
178 t6=s1*dy(lmi(m1),lmi(-m2))
179 t7=t5+t6
180 t8=t5-t6
181 d(lmi(m1),lmi(m2))=s1*s2*(t1*t7-t2*t8)
182 d(lmi(m1),lmi(-m2))=s1*(t3*t8+t4*t7)
183 d(lmi(-m1),lmi(m2))=-s2*(t3*t7+t4*t8)
184 d(lmi(-m1),lmi(-m2))=t1*t8-t2*t7
185 end do
186 end do
187end do
188! apply inversion if required
189if (p == -1) then
190 do l=1,lmax,2
191 lm1=l**2+1
192 lm2=lm1+2*l
193 d(lm1:lm2,lm1:lm2)=-d(lm1:lm2,lm1:lm2)
194 end do
195end if
196end subroutine
197!EOC
198
199end subroutine
200
integer lmmaxi
Definition modmain.f90:207
integer lmaxo
Definition modmain.f90:201
integer lmaxi
Definition modmain.f90:205
integer lmmaxo
Definition modmain.f90:203
subroutine roteuler(rot, ang)
Definition roteuler.f90:10
subroutine rotrfmt(rot, nr, nri, rfmt1, rfmt2)
Definition rotrfmt.f90:7
subroutine rlmrot(p, ang, lmax, ld, d)
Definition rotrfmt.f90:93
subroutine rotrflm(rot, lmax, n, ld, rflm1, rflm2)
Definition rotrfmt.f90:29
subroutine ylmroty(beta, lmax, ld, dy)
Definition ylmroty.f90:10