The Elk Code
 
Loading...
Searching...
No Matches
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
6subroutine gencrho(tsh,tspc,ngt,wfmt1,wfir1,wfmt2,wfir2,crhomt,crhoir)
7use modmain
8implicit none
9! arguments
10logical, intent(in) :: tsh,tspc
11integer, intent(in) :: ngt
12complex(4), intent(in) :: wfmt1(npcmtmax,natmtot,*),wfir1(ngt,*)
13complex(4), intent(in) :: wfmt2(npcmtmax,natmtot,*),wfir2(ngt,*)
14complex(4), intent(out) :: crhomt(npcmtmax,natmtot),crhoir(ngt)
15! local variables
16integer is,ias
17! muffin-tin part
18do 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
39end do
40! interstitial part
41if (tspc.and.spinpol) then
42 call crho2(ngt,wfir1,wfir1(:,2),wfir2,wfir2(:,2),crhoir)
43else
44 call crho1(ngt,wfir1,wfir2,crhoir)
45end if
46return
47
48contains
49
50pure subroutine crho1(n,wf1,wf2,crho)
51implicit none
52integer, intent(in) :: n
53complex(4), intent(in) :: wf1(n),wf2(n)
54complex(4), intent(out) :: crho(n)
55crho(1:n)=conjg(wf1(1:n))*wf2(1:n)
56end subroutine
57
58pure subroutine crho2(n,wf11,wf12,wf21,wf22,crho)
59implicit none
60integer, intent(in) :: n
61complex(4), intent(in) :: wf11(n),wf12(n),wf21(n),wf22(n)
62complex(4), intent(out) :: crho(n)
63crho(1:n)=conjg(wf11(1:n))*wf21(1:n)+conjg(wf12(1:n))*wf22(1:n)
64end subroutine
65
66end subroutine
67
subroutine cfshtip(nr, nri, cfmt)
Definition cfshtip.f90:7
pure subroutine crho2(n, wf11, wf12, wf21, wf22, crho)
Definition exxengy.f90:86
pure subroutine crho1(n, wf1, wf2, crho)
Definition exxengyk.f90:174
subroutine gencrho(tsh, tspc, ngt, wfmt1, wfir1, wfmt2, wfir2, crhomt, crhoir)
Definition gencrho.f90:7
logical spinpol
Definition modmain.f90:228
integer, dimension(maxspecies) nrcmt
Definition modmain.f90:173
integer, dimension(maxatoms *maxspecies) idxis
Definition modmain.f90:44
integer, dimension(maxspecies) npcmt
Definition modmain.f90:214
integer, dimension(maxspecies) nrcmti
Definition modmain.f90:211