The Elk Code
elnes.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2008 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 subroutine elnes
7 use modmain
8 use modomp
9 use modtest
10 implicit none
11 ! local variables
12 integer ik,jk,ikq,isym,nsk(3)
13 integer ist,jst,iw,n,nthd
14 real(8) vgqc(3),gqc
15 real(8) vkql(3),v(3)
16 real(8) q,wd,dw,w,t1
17 ! allocatable arrays
18 real(8), allocatable :: jlgqr(:,:),ddcs(:)
19 real(8), allocatable :: e(:,:,:),f(:,:,:)
20 complex(8), allocatable :: ylmgq(:),sfacgq(:)
21 complex(8), allocatable :: expmt(:,:),emat(:,:)
22 ! initialise universal variables
23 call init0
24 call init1
25 call init2
26 ! check q-vector is commensurate with k-point grid
27 v(:)=dble(ngridk(:))*vecql(:)
28 v(:)=abs(v(:)-nint(v(:)))
29 if ((v(1) > epslat).or.(v(2) > epslat).or.(v(3) > epslat)) then
30  write(*,*)
31  write(*,'("Error(elnes): q-vector incommensurate with k-point grid")')
32  write(*,'(" ngridk : ",3I6)') ngridk
33  write(*,'(" vecql : ",3G18.10)') vecql
34  write(*,*)
35  stop
36 end if
37 ! read in the density and potentials from file
38 call readstate
39 ! find the new linearisation energies
40 call linengy
41 ! generate the APW radial functions
42 call genapwfr
43 ! generate the local-orbital radial functions
44 call genlofr
45 ! get the second-variational eigenvalues and occupation numbers from file
46 do ik=1,nkpt
47  call getevalsv(filext,ik,vkl(:,ik),evalsv(:,ik))
48  call getoccsv(filext,ik,vkl(:,ik),occsv(:,ik))
49 end do
50 ! generate the phase factor function exp(iq.r) in the muffin-tins
51 allocate(jlgqr(njcmax,nspecies))
52 allocate(ylmgq(lmmaxo),sfacgq(natmtot))
53 allocate(expmt(npcmtmax,natmtot))
54 call gengqf(1,vecqc,vgqc,gqc,jlgqr,ylmgq,sfacgq)
55 call genexpmt(1,jlgqr,ylmgq,1,sfacgq,expmt)
56 deallocate(jlgqr,ylmgq,sfacgq)
57 allocate(e(nstsv,nstsv,nkptnr),f(nstsv,nstsv,nkptnr))
58 e(:,:,:)=0.d0
59 f(:,:,:)=0.d0
60 ! begin parallel loop over non-reduced k-points
61 call holdthd(nkptnr,nthd)
62 !$OMP PARALLEL DEFAULT(SHARED) &
63 !$OMP PRIVATE(emat,jk,vkql,isym) &
64 !$OMP PRIVATE(ikq,ist,jst,t1) &
65 !$OMP NUM_THREADS(nthd)
66 allocate(emat(nstsv,nstsv))
67 !$OMP DO SCHEDULE(DYNAMIC)
68 do ik=1,nkptnr
69 !$OMP CRITICAL(elnes_)
70  write(*,'("Info(elnes): ",I6," of ",I6," k-points")') ik,nkptnr
71 !$OMP END CRITICAL(elnes_)
72 ! equivalent reduced k-point
73  jk=ivkik(ivk(1,ik),ivk(2,ik),ivk(3,ik))
74 ! k+q-vector in lattice coordinates
75  vkql(:)=vkl(:,ik)+vecql(:)
76 ! index to k+q-vector
77  call findkpt(vkql,isym,ikq)
78 ! compute < i,k+q | exp(iq.r) | j,k > matrix elements
79  call genexpmat(vkl(:,ik),expmt,emat)
80 ! add to the double differential scattering cross-section
81  do jst=1,nstsv
82  if (evalsv(jst,jk) < emaxelnes) then
83  do ist=1,nstsv
84  e(ist,jst,ik)=evalsv(ist,ikq)-evalsv(jst,jk)
85  t1=dble(emat(ist,jst))**2+aimag(emat(ist,jst))**2
86  f(ist,jst,ik)=t1*occsv(jst,jk)*(occmax-occsv(ist,ikq))
87  end do
88  end if
89  end do
90 end do
91 !$OMP END DO
92 deallocate(emat)
93 !$OMP END PARALLEL
94 call freethd(nthd)
95 ! number of subdivisions used for interpolation
96 nsk(:)=max(ngrkf/ngridk(:),1)
97 n=nstsv*nstsv
98 ! integrate over the Brillouin zone
99 allocate(ddcs(nwplot))
100 call brzint(nswplot,ngridk,nsk,ivkiknr,nwplot,wplot,n,n,e,f,ddcs)
101 q=sqrt(vecqc(1)**2+vecqc(2)**2+vecqc(3)**2)
102 t1=2.d0/(omega*occmax)
103 if (q > epslat) t1=t1/q**4
104 ddcs(:)=t1*ddcs(:)
105 open(50,file='ELNES.OUT',form='FORMATTED')
106 wd=wplot(2)-wplot(1)
107 dw=wd/dble(nwplot)
108 do iw=1,nwplot
109  w=dw*dble(iw-1)+wplot(1)
110  write(50,'(2G18.10)') w,ddcs(iw)
111 end do
112 close(50)
113 write(*,*)
114 write(*,'("Info(elnes):")')
115 write(*,'(" ELNES double differential cross-section written to ELNES.OUT")')
116 ! write ELNES distribution to test file
117 call writetest(140,'ELNES cross-section',nv=nwplot,tol=1.d-2,rva=ddcs)
118 deallocate(e,f,ddcs,expmt)
119 end subroutine
120 
integer ngrkf
Definition: modmain.f90:1075
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition: modtest.f90:16
subroutine genexpmat(vpl, expmt, emat)
Definition: genexpmat.f90:7
integer npcmtmax
Definition: modmain.f90:216
character(256) filext
Definition: modmain.f90:1301
real(8), dimension(:,:), allocatable evalsv
Definition: modmain.f90:921
integer lmmaxo
Definition: modmain.f90:203
integer nkpt
Definition: modmain.f90:461
subroutine genlofr
Definition: genlofr.f90:10
subroutine gengqf(ng, vqpc, vgqc, gqc, jlgqr, ylmgq, sfacgq)
Definition: gengqf.f90:7
real(8) omega
Definition: modmain.f90:20
subroutine getevalsv(fext, ikp, vpl, evalsv_)
Definition: getevalsv.f90:7
Definition: modomp.f90:6
integer, dimension(:,:,:), allocatable ivkik
Definition: modmain.f90:467
subroutine brzint(nsm, ngridk, nsk, ivkik, nw, wint, n, ld, e, f, g)
Definition: brzint.f90:10
integer nkptnr
Definition: modmain.f90:463
real(8), dimension(3) vecql
Definition: modmain.f90:1104
subroutine linengy
Definition: linengy.f90:10
integer nstsv
Definition: modmain.f90:889
real(8), dimension(2) wplot
Definition: modmain.f90:1079
real(8) occmax
Definition: modmain.f90:901
subroutine elnes
Definition: elnes.f90:7
subroutine init2
Definition: init2.f90:7
integer, dimension(3) ngridk
Definition: modmain.f90:448
real(8), dimension(:,:), allocatable occsv
Definition: modmain.f90:905
subroutine init1
Definition: init1.f90:10
subroutine genexpmt(ngp, jlgpr, ylmgp, ld, sfacgp, expmt)
Definition: genexpmt.f90:7
real(8), dimension(:,:), allocatable vkl
Definition: modmain.f90:471
subroutine genapwfr
Definition: genapwfr.f90:10
real(8) epslat
Definition: modmain.f90:24
subroutine getoccsv(fext, ikp, vpl, occsvp)
Definition: getoccsv.f90:7
subroutine readstate
Definition: readstate.f90:10
integer nswplot
Definition: modmain.f90:1077
integer nspecies
Definition: modmain.f90:34
subroutine freethd(nthd)
Definition: modomp.f90:106
subroutine holdthd(nloop, nthd)
Definition: modomp.f90:78
integer njcmax
Definition: modmain.f90:1173
real(8) emaxelnes
Definition: modmain.f90:1106
subroutine init0
Definition: init0.f90:10
integer natmtot
Definition: modmain.f90:40
subroutine findkpt(vpl, isym, ik)
Definition: findkpt.f90:7
integer nwplot
Definition: modmain.f90:1073
integer, dimension(:,:), allocatable ivk
Definition: modmain.f90:465
real(8), dimension(3) vecqc
Definition: modmain.f90:1104
integer, dimension(:,:,:), allocatable ivkiknr
Definition: modmain.f90:469