The Elk Code
gencrm.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2016 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 pure subroutine gencrm(n,wf11,wf12,wf21,wf22,crho,ld,cmag)
7 use modmain
8 implicit none
9 ! arguments
10 integer, intent(in) :: n
11 complex(4), intent(in) :: wf11(n),wf12(n),wf21(n),wf22(n)
12 complex(4), intent(out) :: crho(n)
13 integer, intent(in) :: ld
14 complex(4), intent(out) :: cmag(ld,ndmag)
15 ! local variables
16 integer i
17 complex(4) c11,c12,c21,c22,c1,c2
18 if (ncmag) then
19 ! non-collinear case
20 !$OMP SIMD PRIVATE(c11,c12,c21,c22,c1,c2) SIMDLEN(8)
21  do i=1,n
22  c11=wf11(i); c12=wf12(i)
23  c21=wf21(i); c22=wf22(i)
24 ! up-dn spin density
25  c1=conjg(c11)*c22
26 ! dn-up spin density
27  c2=conjg(c12)*c21
28 ! x-component: up-dn + dn-up
29  cmag(i,1)=c1+c2
30 ! y-component: i*(dn-up - up-dn)
31  c2=c2-c1
32  cmag(i,2)=cmplx(-c2%im,c2%re,4)
33  c1=conjg(c11)*c21
34  c2=conjg(c12)*c22
35 ! z-component: up-up - dn-dn
36  cmag(i,3)=c1-c2
37 ! density: up-up + dn-dn
38  crho(i)=c1+c2
39  end do
40 else
41 ! collinear case
42 !$OMP SIMD PRIVATE(c1,c2) SIMDLEN(8)
43  do i=1,n
44  c1=conjg(wf11(i))*wf21(i)
45  c2=conjg(wf12(i))*wf22(i)
46  cmag(i,1)=c1-c2
47  crho(i)=c1+c2
48  end do
49 end if
50 end subroutine
51 
integer ndmag
Definition: modmain.f90:238
pure subroutine gencrm(n, wf11, wf12, wf21, wf22, crho, ld, cmag)
Definition: gencrm.f90:7
logical ncmag
Definition: modmain.f90:240