The Elk Code
wfmtfv.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2005 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: wfmtfv
8 ! !INTERFACE:
9 subroutine wfmtfv(ias,ngp,apwalm,evecfv,wfmt)
10 ! !USES:
11 use modmain
12 ! !INPUT/OUTPUT PARAMETERS:
13 ! ias : joint atom and species number (in,integer)
14 ! ngp : number of G+p-vectors (in,integer)
15 ! apwalm : APW matching coefficients (in,complex(ngkmax,apwordmax,lmmaxapw))
16 ! evecfv : first-variational eigenvector (in,complex(nmatmax))
17 ! wfmt : complex muffin-tin wavefunction passed in as real array
18 ! (out,real(2,*))
19 ! !DESCRIPTION:
20 ! Calculates the first-variational wavefunction in the muffin-tin in terms of
21 ! a spherical harmonic expansion. For atom $\alpha$ and a particular $k$-point
22 ! ${\bf p}$, the $r$-dependent $(l,m)$-coefficients of the wavefunction for
23 ! the $i$th state are given by
24 ! $$ \Phi^{i{\bf p}}_{\alpha lm}(r)=\sum_{\bf G}b^{i{\bf p}}_{\bf G}
25 ! \sum_{j=1}^{M^{\alpha}_l}A^{\alpha}_{jlm}({\bf G+p})u^{\alpha}_{jl}(r)
26 ! +\sum_{j=1}^{N^{\alpha}}b^{i{\bf p}}_{(\alpha,j,m)}v^{\alpha}_j(r)
27 ! \delta_{l,l_j}, $$
28 ! where $b^{i{\bf p}}$ is the $i$th eigenvector returned from routine
29 ! {\tt eveqn}; $A^{\alpha}_{jlm}({\bf G+p})$ is the matching coefficient;
30 ! $M^{\alpha}_l$ is the order of the APW; $u^{\alpha}_{jl}$ is the APW radial
31 ! function; $N^{\alpha}$ is the number of local-orbitals; $v^{\alpha}_j$ is
32 ! the $j$th local-orbital radial function; and $(\alpha,j,m)$ is a compound
33 ! index for the location of the local-orbital in the eigenvector. See routines
34 ! {\tt genapwfr}, {\tt genlofr}, {\tt match} and {\tt eveqn}.
35 !
36 ! !REVISION HISTORY:
37 ! Created April 2003 (JKD)
38 ! Fixed description, October 2004 (C. Brouder)
39 ! Removed argument ist, November 2006 (JKD)
40 ! Changed arguments and optimised, December 2014 (JKD)
41 !EOP
42 !BOC
43 implicit none
44 ! arguments
45 integer, intent(in) :: ias,ngp
46 complex(8), intent(in) :: apwalm(ngkmax,apwordmax,lmmaxapw),evecfv(nmatmax)
47 complex(8), intent(out) :: wfmt(*)
48 ! local variables
49 integer is,io,ilo
50 integer nrci,nrco,iro
51 integer l,lm,npci,i
52 complex(8) z
53 ! external functions
54 complex(8), external :: zdotu
55 is=idxis(ias)
56 iro=nrmti(is)+lradstp
57 nrci=nrcmti(is)
58 nrco=nrcmt(is)-nrci
59 npci=npcmti(is)
60 ! zero the wavefunction
61 wfmt(1:npcmt(is))=0.d0
62 !---------------------------------!
63 ! local-orbital functions !
64 !---------------------------------!
65 do ilo=1,nlorb(is)
66  l=lorbl(ilo,is)
67  do lm=l**2+1,(l+1)**2
68  i=npci+lm
69  z=evecfv(ngp+idxlo(lm,ilo,ias))
70  if (abs(z%re)+abs(z%im) > epswf) then
71  if (l <= lmaxi) call zfzrf(nrci,lofr(1,1,ilo,ias),lmmaxi,wfmt(lm))
72  call zfzrf(nrco,lofr(iro,1,ilo,ias),lmmaxo,wfmt(i))
73  end if
74  end do
75 end do
76 !-----------------------!
77 ! APW functions !
78 !-----------------------!
79 do l=0,lmaxo
80  do lm=l**2+1,(l+1)**2
81  i=npci+lm
82  do io=1,apword(l,is)
83  z=zdotu(ngp,evecfv,1,apwalm(:,io,lm),1)
84  if (abs(z%re)+abs(z%im) > epswf) then
85  if (l <= lmaxi) call zfzrf(nrci,apwfr(1,1,io,l,ias),lmmaxi,wfmt(lm))
86  call zfzrf(nrco,apwfr(iro,1,io,l,ias),lmmaxo,wfmt(i))
87  end if
88  end do
89  end do
90 end do
91 
92 contains
93 
94 pure subroutine zfzrf(n,rf,ld,zf)
95 implicit none
96 ! arguments
97 integer, intent(in) :: n
98 real(8), intent(in) :: rf(lradstp,n)
99 integer, intent(in) :: ld
100 complex(8), intent(inout) :: zf(ld,n)
101 zf(1,1:n)=zf(1,1:n)+z*rf(1,1:n)
102 end subroutine
103 
104 end subroutine
105 !EOC
106 
pure subroutine zfzrf(n, ld1, rf, ld2, zf)
Definition: dwfmtfv.f90:66
integer, dimension(maxspecies) npcmt
Definition: modmain.f90:214
integer, dimension(maxspecies) nlorb
Definition: modmain.f90:786
integer, dimension(:,:,:), allocatable idxlo
Definition: modmain.f90:855
real(8), dimension(:,:,:,:), allocatable lofr
Definition: modmain.f90:814
integer lmmaxo
Definition: modmain.f90:203
integer lmaxo
Definition: modmain.f90:201
integer lradstp
Definition: modmain.f90:171
integer, dimension(0:maxlapw, maxspecies) apword
Definition: modmain.f90:758
subroutine wfmtfv(ias, ngp, apwalm, evecfv, wfmt)
Definition: wfmtfv.f90:10
integer, dimension(maxspecies) npcmti
Definition: modmain.f90:214
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
integer lmmaxi
Definition: modmain.f90:207
real(8), parameter epswf
Definition: modmain.f90:845
real(8), dimension(:,:,:,:,:), allocatable apwfr
Definition: modmain.f90:774
integer, dimension(maxspecies) nrcmt
Definition: modmain.f90:173
integer, dimension(maxspecies) nrcmti
Definition: modmain.f90:211
integer, dimension(maxlorb, maxspecies) lorbl
Definition: modmain.f90:796
integer, dimension(maxspecies) nrmti
Definition: modmain.f90:211
integer lmaxi
Definition: modmain.f90:205