The Elk Code
gencrho.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2023 J. K. Dewhurst and S. Sharma.
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 gencrho(tsh,tspc,ngt,wfmt1,wfir1,wfmt2,wfir2,crhomt,crhoir)
7 use modmain
8 implicit none
9 ! arguments
10 logical, intent(in) :: tsh,tspc
11 integer, intent(in) :: ngt
12 complex(4), intent(in) :: wfmt1(npcmtmax,natmtot,*),wfir1(ngt,*)
13 complex(4), intent(in) :: wfmt2(npcmtmax,natmtot,*),wfir2(ngt,*)
14 complex(4), intent(out) :: crhomt(npcmtmax,natmtot),crhoir(ngt)
15 ! local variables
16 integer is,ias
17 ! muffin-tin part
18 do ias=1,natmtot
19  is=idxis(ias)
20  if (tsh) then
21  if (tspc.and.spinpol) then
22 ! contract over spin
23  call crho2(npcmt(is),wfmt1(:,ias,1),wfmt1(:,ias,2),wfmt2(:,ias,1), &
24  wfmt2(:,ias,2),crhomt(:,ias))
25  else
26 ! no spin contraction
27  call crho1(npcmt(is),wfmt1(:,ias,1),wfmt2(:,ias,1),crhomt(:,ias))
28  end if
29 ! convert to spherical harmonics
30  call cfshtip(nrcmt(is),nrcmti(is),crhomt(:,ias))
31  else
32  if (tspc.and.spinpol) then
33  call crho2(npcmt(is),wfmt1(:,ias,1),wfmt1(:,ias,2),wfmt2(:,ias,1), &
34  wfmt2(:,ias,2),crhomt(:,ias))
35  else
36  call crho1(npcmt(is),wfmt1(:,ias,1),wfmt2(:,ias,1),crhomt(:,ias))
37  end if
38  end if
39 end do
40 ! interstitial part
41 if (tspc.and.spinpol) then
42  call crho2(ngt,wfir1,wfir1(:,2),wfir2,wfir2(:,2),crhoir)
43 else
44  call crho1(ngt,wfir1,wfir2,crhoir)
45 end if
46 
47 contains
48 
49 pure subroutine crho1(n,wf1,wf2,crho)
50 implicit none
51 integer, intent(in) :: n
52 complex(4), intent(in) :: wf1(n),wf2(n)
53 complex(4), intent(out) :: crho(n)
54 crho(1:n)=conjg(wf1(1:n))*wf2(1:n)
55 end subroutine
56 
57 pure subroutine crho2(n,wf11,wf12,wf21,wf22,crho)
58 implicit none
59 integer, intent(in) :: n
60 complex(4), intent(in) :: wf11(n),wf12(n),wf21(n),wf22(n)
61 complex(4), intent(out) :: crho(n)
62 crho(1:n)=conjg(wf11(1:n))*wf21(1:n)+conjg(wf12(1:n))*wf22(1:n)
63 end subroutine
64 
65 end subroutine
66 
integer, dimension(maxspecies) npcmt
Definition: modmain.f90:214
logical spinpol
Definition: modmain.f90:228
subroutine gencrho(tsh, tspc, ngt, wfmt1, wfir1, wfmt2, wfir2, crhomt, crhoir)
Definition: gencrho.f90:7
pure subroutine crho1(n, wf1, wf2, crho)
Definition: exxengyk.f90:173
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
subroutine cfshtip(nr, nri, cfmt)
Definition: cfshtip.f90:7
pure subroutine crho2(n, wf11, wf12, wf21, wf22, crho)
Definition: exxengy.f90:85
integer, dimension(maxspecies) nrcmt
Definition: modmain.f90:173
integer, dimension(maxspecies) nrcmti
Definition: modmain.f90:211