The Elk Code
genpmatk.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2026 Wenhan Chen, 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 genpmatk(ik,pmat)
7 use modmain
8 implicit none
9 ! arguments
10 integer, intent(in) :: ik
11 complex(8), intent(out) :: pmat(nstsv,nstsv,3)
12 ! local variables
13 integer ispn
14 ! allocatable arrays
15 complex(8), allocatable :: apwalm(:,:,:,:,:),evecfv(:,:,:),evecsv(:,:)
16 complex(8), allocatable :: wfmt(:,:,:,:),wfgk(:,:,:)
17 ! get the eigenvectors from file
18 allocate(evecfv(nmatmax,nstfv,nspnfv),evecsv(nstsv,nstsv))
19 call getevecfv(filext,ik,vkl(:,ik),vgkl(:,:,:,ik),evecfv)
20 call getevecsv(filext,ik,vkl(:,ik),evecsv)
21 ! find the matching coefficients
22 allocate(apwalm(ngkmax,apwordmax,lmmaxapw,natmtot,nspnfv))
23 do ispn=1,nspnfv
24  call match(ngk(ispn,ik),vgkc(:,:,ispn,ik),gkc(:,ispn,ik), &
25  sfacgk(:,:,ispn,ik),apwalm(:,:,:,:,ispn))
26 end do
27 ! calculate the wavefunctions for all states
28 allocate(wfmt(npcmtmax,natmtot,nspinor,nstsv),wfgk(ngkmax,nspinor,nstsv))
29 call genwfsv(.true.,.true.,nstsv,[0],ngridg,igfft,ngk(:,ik),igkig(:,:,ik), &
30  apwalm,evecfv,evecsv,wfmt,ngkmax,wfgk)
31 deallocate(evecfv,evecsv,apwalm)
32 ! calculate the momentum matrix elements
33 call genpmatp(ngk(:,ik),igkig(:,:,ik),vgkc(:,:,:,ik),wfmt,wfgk,pmat)
34 deallocate(wfmt,wfgk)
35 end subroutine
36 
integer nmatmax
Definition: modmain.f90:854
subroutine getevecsv(fext, ikp, vpl, evecsv)
Definition: getevecsv.f90:7
integer npcmtmax
Definition: modmain.f90:218
integer, dimension(3) ngridg
Definition: modmain.f90:389
character(256) filext
Definition: modmain.f90:1301
subroutine genwfsv(tsh, tgp, nst, idx, ngridg_, igfft_, ngp, igpig, apwalm, evecfv, evecsv, wfmt, ld, wfir)
Definition: genwfsv.f90:11
integer lmmaxapw
Definition: modmain.f90:201
subroutine genpmatp(ngp, igpig, vgpc, wfmt, wfgp, pmat)
Definition: genpmatp.f90:10
integer ngkmax
Definition: modmain.f90:502
subroutine getevecfv(fext, ikp, vpl, vgpl, evecfv)
Definition: getevecfv.f90:10
subroutine match(ngp, vgpc, gpc, sfacgp, apwalm)
Definition: match.f90:10
complex(8), dimension(:,:,:,:), allocatable sfacgk
Definition: modmain.f90:512
integer, dimension(:,:), allocatable ngk
Definition: modmain.f90:500
integer, dimension(:), allocatable igfft
Definition: modmain.f90:409
real(8), dimension(:,:,:,:), allocatable vgkl
Definition: modmain.f90:506
integer nspinor
Definition: modmain.f90:269
real(8), dimension(:,:,:,:), allocatable vgkc
Definition: modmain.f90:508
real(8), dimension(:,:), allocatable vkl
Definition: modmain.f90:474
integer apwordmax
Definition: modmain.f90:763
real(8), dimension(:,:,:), allocatable gkc
Definition: modmain.f90:510
subroutine genpmatk(ik, pmat)
Definition: genpmatk.f90:7
integer natmtot
Definition: modmain.f90:40
integer, dimension(:,:,:), allocatable igkig
Definition: modmain.f90:504
integer nstfv
Definition: modmain.f90:883
integer nspnfv
Definition: modmain.f90:291