The Elk Code
 
Loading...
Searching...
No Matches
genvmatk.f90
Go to the documentation of this file.
1
2! Copyright (C) 2007 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
6subroutine genvmatk(vmt,vir,ngp,igpig,wfmt,ld,wfgp,vmat)
7use modmain
8use moddftu
9use modomp
10implicit none
11! arguments
12! the potential is multiplied by the radial integration weights in the
13! muffin-tin and by the characteristic function in the interstitial region
14real(8), intent(in) :: vmt(npcmtmax,natmtot),vir(ngtc)
15integer, intent(in) :: ngp(nspnfv),igpig(ngkmax,nspnfv)
16complex(4), intent(in) :: wfmt(npcmtmax,natmtot,nspinor,nstsv)
17integer, intent(in) :: ld
18complex(4), intent(in) :: wfgp(ld,nspinor,nstsv)
19complex(8), intent(out) :: vmat(nstsv,nstsv)
20! local variables
21integer ist,jst,nj,ispn,jspn
22integer is,ias,nrc,nrci,nrco
23integer npc,npc2,ipco
24integer ld1,ld2,n,igp,nthd
25! automatic arrays
26complex(4) wfmt1(npcmtmax),wfmt2(npcmtmax)
27complex(4) wfir(ngtc),c(ngkmax),y(nstsv)
28! external functions
29real(4), external :: sdot
30ld1=npcmtmax*natmtot*nspinor
31ld2=ld*nspinor
32! zero the upper triangular matrix elements
33do jst=1,nstsv
34 vmat(1:jst,jst)=0.d0
35end do
36call holdthd(nstsv,nthd)
37!$OMP PARALLEL DEFAULT(SHARED) &
38!$OMP PRIVATE(wfmt1,wfmt2,wfir,c,y) &
39!$OMP PRIVATE(jst,nj,ispn,jspn) &
40!$OMP PRIVATE(ias,is,nrc,nrci,nrco) &
41!$OMP PRIVATE(npc,npc2,ipco,n,igp) &
42!$OMP NUM_THREADS(nthd)
43!-------------------------!
44! muffin-tin part !
45!-------------------------!
46!$OMP DO SCHEDULE(DYNAMIC)
47do jst=1,nstsv
48 nj=jst-1
49 do ispn=1,nspinor
50 do ias=1,natmtot
51 is=idxis(ias)
52 nrc=nrcmt(is)
53 nrci=nrcmti(is)
54 nrco=nrc-nrci
55 npc=npcmt(is)
56 npc2=npc*2
57 ipco=npcmti(is)+1
58 wfmt1(1:npc)=vmt(1:npc,ias)*wfmt(1:npc,ias,ispn,jst)
59! apply muffin-tin DFT+U potential matrix if required (note that this should be
60! used only in the spin-unpolarised case)
61 if (dftu /= 0) then
62 if (any(tvmmt(0:lmaxdm,ias))) then
63 call cgemm('N','N',lmmaxi,nrci,lmmaxi,cone,vmatmti(1,1,1,1,ias), &
64 lmmaxi,wfmt(1,ias,ispn,jst),lmmaxi,czero,wfmt2,lmmaxi)
65 call cgemm('N','N',lmmaxo,nrco,lmmaxo,cone,vmatmto(1,1,1,1,ias), &
66 lmmaxo,wfmt(ipco,ias,ispn,jst),lmmaxo,czero,wfmt2(ipco),lmmaxo)
67 call cfcmtwr(nrc,nrci,wr2cmt(:,is),wfmt2)
68 wfmt1(1:npc)=wfmt1(1:npc)+wfmt2(1:npc)
69 end if
70 end if
71! compute the inner products
72 call cgemv('C',npc,nj,cone,wfmt(1,ias,ispn,1),ld1,wfmt1,1,czero,y,1)
73 vmat(1:nj,jst)=vmat(1:nj,jst)+y(1:nj)
74 vmat(jst,jst)=vmat(jst,jst)+sdot(npc2,wfmt(1,ias,ispn,jst),1,wfmt1,1)
75 end do
76 end do
77end do
78!$OMP END DO
79!---------------------------!
80! interstitial part !
81!---------------------------!
82!$OMP DO SCHEDULE(DYNAMIC)
83do jst=1,nstsv
84 nj=jst-1
85 do ispn=1,nspinor
86 jspn=jspnfv(ispn)
87 n=ngp(jspn)
88! Fourier transform wavefunction to real-space
89 wfir(1:ngtc)=0.e0
90 do igp=1,n
91 wfir(igfc(igpig(igp,jspn)))=wfgp(igp,ispn,jst)
92 end do
93 call cfftifc(3,ngdgc,1,wfir)
94! apply potential to wavefunction
95 wfir(1:ngtc)=vir(1:ngtc)*wfir(1:ngtc)
96! Fourier transform to G+p-space
97 call cfftifc(3,ngdgc,-1,wfir)
98 do igp=1,n
99 c(igp)=wfir(igfc(igpig(igp,jspn)))
100 end do
101! compute the inner products
102 call cgemv('C',n,nj,cone,wfgp(1,ispn,1),ld2,c,1,czero,y,1)
103 vmat(1:nj,jst)=vmat(1:nj,jst)+y(1:nj)
104 vmat(jst,jst)=vmat(jst,jst)+sdot(n*2,wfgp(1,ispn,jst),1,c,1)
105 end do
106end do
107!$OMP END DO
108!$OMP END PARALLEL
109call freethd(nthd)
110! lower triangular part
111do ist=1,nstsv
112 do jst=1,ist-1
113 vmat(ist,jst)=conjg(vmat(jst,ist))
114 end do
115end do
116end subroutine
117
pure subroutine cfcmtwr(nr, nri, wr, cfmt)
Definition cfcmtwr.f90:7
subroutine cfftifc(nd, n, sgn, c)
subroutine genvmatk(vmt, vir, ngp, igpig, wfmt, ld, wfgp, vmat)
Definition genvmatk.f90:7
logical, dimension(:,:), allocatable tvmmt
Definition moddftu.f90:26
integer dftu
Definition moddftu.f90:32
complex(4), dimension(:,:,:,:,:), allocatable vmatmto
Definition moddftu.f90:22
integer, parameter lmaxdm
Definition moddftu.f90:13
complex(4), dimension(:,:,:,:,:), allocatable vmatmti
Definition moddftu.f90:22
complex(4), parameter czero
Definition modmain.f90:1236
integer, dimension(3) ngdgc
Definition modmain.f90:388
integer, dimension(maxspecies) npcmti
Definition modmain.f90:214
integer lmmaxi
Definition modmain.f90:207
integer, dimension(maxspecies) nrcmt
Definition modmain.f90:173
integer, dimension(:), allocatable igfc
Definition modmain.f90:410
integer, dimension(maxatoms *maxspecies) idxis
Definition modmain.f90:44
real(8), dimension(:,:), allocatable wr2cmt
Definition modmain.f90:189
integer, dimension(maxspecies) npcmt
Definition modmain.f90:214
complex(4), parameter cone
Definition modmain.f90:1236
integer, dimension(2) jspnfv
Definition modmain.f90:291
integer lmmaxo
Definition modmain.f90:203
integer, dimension(maxspecies) nrcmti
Definition modmain.f90:211
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106