The Elk Code
 
Loading...
Searching...
No Matches
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
6subroutine elnes
7use modmain
8use modomp
9use modtest
10implicit none
11! local variables
12integer ik,jk,ikq,isym,nsk(3)
13integer ist,jst,iw,n,nthd
14real(8) vgqc(3),gqc
15real(8) vkql(3),v(3)
16real(8) q,wd,dw,w,t1
17! allocatable arrays
18real(8), allocatable :: jlgqr(:,:),ddcs(:)
19real(8), allocatable :: e(:,:,:),f(:,:,:)
20complex(8), allocatable :: ylmgq(:),sfacgq(:)
21complex(8), allocatable :: expmt(:,:),emat(:,:)
22! initialise universal variables
23call init0
24call init1
25call init2
26! check q-vector is commensurate with k-point grid
27v(:)=dble(ngridk(:))*vecql(:)
28v(:)=abs(v(:)-nint(v(:)))
29if ((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
36end if
37! read in the density and potentials from file
38call readstate
39! find the new linearisation energies
40call linengy
41! generate the APW radial functions
42call genapwfr
43! generate the local-orbital radial functions
44call genlofr
45! get the second-variational eigenvalues and occupation numbers from file
46do ik=1,nkpt
47 call getevalsv(filext,ik,vkl(:,ik),evalsv(:,ik))
48 call getoccsv(filext,ik,vkl(:,ik),occsv(:,ik))
49end do
50! generate the phase factor function exp(iq.r) in the muffin-tins
51allocate(jlgqr(njcmax,nspecies))
52allocate(ylmgq(lmmaxo),sfacgq(natmtot))
53allocate(expmt(npcmtmax,natmtot))
54call gengqf(1,vecqc,vgqc,gqc,jlgqr,ylmgq,sfacgq)
55call genexpmt(1,jlgqr,ylmgq,1,sfacgq,expmt)
56deallocate(jlgqr,ylmgq,sfacgq)
57allocate(e(nstsv,nstsv,nkptnr),f(nstsv,nstsv,nkptnr))
58e(:,:,:)=0.d0
59f(:,:,:)=0.d0
60! begin parallel loop over non-reduced k-points
61call 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)
66allocate(emat(nstsv,nstsv))
67!$OMP DO SCHEDULE(DYNAMIC)
68do 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
90end do
91!$OMP END DO
92deallocate(emat)
93!$OMP END PARALLEL
94call freethd(nthd)
95! number of subdivisions used for interpolation
96nsk(:)=max(ngrkf/ngridk(:),1)
98! integrate over the Brillouin zone
99allocate(ddcs(nwplot))
100call brzint(nswplot,ngridk,nsk,ivkiknr,nwplot,wplot,n,n,e,f,ddcs)
101q=sqrt(vecqc(1)**2+vecqc(2)**2+vecqc(3)**2)
102t1=2.d0/(omega*occmax)
103if (q > epslat) t1=t1/q**4
104ddcs(:)=t1*ddcs(:)
105open(50,file='ELNES.OUT',form='FORMATTED')
106wd=wplot(2)-wplot(1)
107dw=wd/dble(nwplot)
108do iw=1,nwplot
109 w=dw*dble(iw-1)+wplot(1)
110 write(50,'(2G18.10)') w,ddcs(iw)
111end do
112close(50)
113write(*,*)
114write(*,'("Info(elnes):")')
115write(*,'(" ELNES double differential cross-section written to ELNES.OUT")')
116! write ELNES distribution to test file
117call writetest(140,'ELNES cross-section',nv=nwplot,tol=1.d-2,rva=ddcs)
118deallocate(e,f,ddcs,expmt)
119end subroutine
120
subroutine brzint(nsm, ngridk, nsk, ivkik, nw, wint, n, ld, e, f, g)
Definition brzint.f90:10
subroutine elnes
Definition elnes.f90:7
subroutine findkpt(vpl, isym, ik)
Definition findkpt.f90:7
subroutine genapwfr
Definition genapwfr.f90:10
subroutine genexpmat(vpl, expmt, emat)
Definition genexpmat.f90:7
subroutine genexpmt(ngp, jlgpr, ylmgp, ld, sfacgp, expmt)
Definition genexpmt.f90:7
subroutine gengqf(ng, vqpc, vgqc, gqc, jlgqr, ylmgq, sfacgq)
Definition gengqf.f90:7
subroutine genlofr
Definition genlofr.f90:10
subroutine getevalsv(fext, ikp, vpl, evalsv_)
Definition getevalsv.f90:7
subroutine getoccsv(fext, ikp, vpl, occsvp)
Definition getoccsv.f90:7
subroutine init0
Definition init0.f90:10
subroutine init1
Definition init1.f90:10
subroutine init2
Definition init2.f90:7
subroutine linengy
Definition linengy.f90:10
integer njcmax
Definition modmain.f90:1170
integer nkptnr
Definition modmain.f90:463
integer ngrkf
Definition modmain.f90:1072
character(256) filext
Definition modmain.f90:1300
real(8), dimension(3) vecql
Definition modmain.f90:1101
real(8) omega
Definition modmain.f90:20
integer nwplot
Definition modmain.f90:1070
real(8), dimension(3) vecqc
Definition modmain.f90:1101
integer, dimension(:,:), allocatable ivk
Definition modmain.f90:465
integer nswplot
Definition modmain.f90:1074
real(8) epslat
Definition modmain.f90:24
integer nkpt
Definition modmain.f90:461
integer natmtot
Definition modmain.f90:40
real(8), dimension(2) wplot
Definition modmain.f90:1076
integer npcmtmax
Definition modmain.f90:216
integer, dimension(3) ngridk
Definition modmain.f90:448
integer nstsv
Definition modmain.f90:886
real(8), dimension(:,:), allocatable vkl
Definition modmain.f90:471
integer, dimension(:,:,:), allocatable ivkiknr
Definition modmain.f90:469
real(8) occmax
Definition modmain.f90:898
integer, dimension(:,:,:), allocatable ivkik
Definition modmain.f90:467
integer lmmaxo
Definition modmain.f90:203
integer nspecies
Definition modmain.f90:34
real(8), dimension(:,:), allocatable occsv
Definition modmain.f90:902
real(8) emaxelnes
Definition modmain.f90:1103
real(8), dimension(:,:), allocatable evalsv
Definition modmain.f90:918
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition modtest.f90:16
subroutine readstate
Definition readstate.f90:10