The Elk Code
 
Loading...
Searching...
No Matches
bandstrulr.f90
Go to the documentation of this file.
1
2! Copyright (C) 2024 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
6subroutine bandstrulr
7use modmain
8use modulr
9use modmpi
10use modomp
11use moddelf
12implicit none
13! local variables
14integer nkpa0,ikpa,nthd
15integer ik0,ist,iv,iw,lp
16real(8) dw,emin,emax,t1
17! allocatable arrays
18real(8), allocatable :: vvlp1d0(:,:),vql0(:,:)
19real(8), allocatable :: w(:),chkpa(:,:),sfu(:,:)
20complex(8), allocatable :: evecu(:,:)
21! store the 1D plot vertices
22allocate(vvlp1d0(3,nvp1d))
23vvlp1d0(1:3,1:nvp1d)=vvlp1d(1:3,1:nvp1d)
24! initialise global variables
25call init0
26call init1
27if (task == 720) then
28! use only κ=0
29 nkpa0=1
30else
31! use all κ-points
32 nkpa0=nkpa
33end if
34! store the κ-points
35allocate(vql0(3,nkpa0))
36vql0(1:3,1:nkpa0)=vql(1:3,1:nkpa0)
37! generate frequency grid
38allocate(w(nwplot))
39dw=(wplot(2)-wplot(1))/dble(nwplot)
40do iw=1,nwplot
41 w(iw)=dw*dble(iw-1)+wplot(1)
42end do
43allocate(chkpa(nstsv*nkpa,nkpt0))
44! allocate and zero the ULR spectral function
45allocate(sfu(nwplot,nkpt0))
46sfu(1:nwplot,1:nkpt0)=0.d0
47! delete the BANDULR.OUT file
48call delfile('BANDULR.OUT')
49! loop over the κ-points
50do ikpa=1,nkpa0
51 if (mp_mpi) then
52 write(*,*)
53 write(*,κ'("Info(bandstrulr): ",I6," of ",I6," -points")') ikpa,nkpa0
54 write(*,*)
55 end if
56! subtract current κ-point from 1D plot vertices
57 do iv=1,nvp1d
58 vvlp1d(1:3,iv)=vvlp1d0(1:3,iv)-vql0(1:3,ikpa)
59 end do
60 call init0
61 call init1
62 call readstate
63 call genvsig
64 call gencore
65 call linengy
66 call genapwlofr
67 call gensocfr
68 call genevfsv
69 call occupy
70 call initulr
71! read in the potential STATE_ULR.OUT
72 call readstulr
73! initialise the external Coulomb potential
74 call vclqinit
75! apply required local operations to the potential and magnetic field
76 call vblocalu
77! loop over original k-points
78 call holdthd(nkpt0/np_mpi,nthd)
79!$OMP PARALLEL DEFAULT(SHARED) &
80!$OMP PRIVATE(evecu) &
81!$OMP NUM_THREADS(nthd)
82 allocate(evecu(nstulr,nstulr))
83!$OMP DO SCHEDULE(DYNAMIC)
84 do ik0=1,nkpt0
85! distribute among MPI processes
86 if (mod(ik0-1,np_mpi) /= lp_mpi) cycle
87!$OMP CRITICAL(bandstrulr_)
88 write(*,'("Info(bandstrulr): ",I6," of ",I6," k-points")') ik0,nkpt0
89!$OMP END CRITICAL(bandstrulr_)
90! solve the ultra long-range eigenvalue equation
91 call eveqnulr(ik0,evecu)
92! determine the current κ-point characteristic for each ULR state
93 call charkpa(ikpa,evecu,chkpa(:,ik0))
94! add to the ULR spectral function
95 call sfuadd(ik0,w,chkpa(:,ik0),sfu(:,ik0))
96 end do
97!$OMP END DO
98 deallocate(evecu)
99!$OMP END PARALLEL
100 call freethd(nthd)
101! broadcast arrays to every process
102 if (np_mpi > 1) then
103 do ik0=1,nkpt0
104 lp=mod(ik0-1,np_mpi)
105 call mpi_bcast(evalu(:,ik0),nstulr,mpi_double_precision,lp,mpicom,ierror)
106 call mpi_bcast(chkpa(:,ik0),nstulr,mpi_double_precision,lp,mpicom,ierror)
107 end do
108 end if
109! subtract the Fermi energy
110 evalu(:,:)=evalu(:,:)-efermi
111 if (mp_mpi) then
112! output the band structure
113 open(50,file='BANDULR.OUT',form='FORMATTED',action='WRITE', &
114 position='APPEND')
115 do ist=1,nstulr
116 do ik0=1,nkpt0
117 write(50,'(3G18.10)') dpp1d(ik0),evalu(ist,ik0),chkpa(ist,ik0)
118 end do
119 write(50,*)
120 end do
121 close(50)
122! output the vertex location lines
123 if (ikpa == 1) then
124! find the minimum and maximum eigenvalues
125 emin=minval(evalu(:,:))
126 emax=maxval(evalu(:,:))
127 open(50,file='BANDLINES.OUT',form='FORMATTED',action='WRITE')
128 do iv=1,nvp1d
129 write(50,'(2G18.10)') dvp1d(iv),emin
130 write(50,'(2G18.10)') dvp1d(iv),emax
131 write(50,*)
132 end do
133 close(50)
134 end if
135 end if
136! synchronise MPI processes
137 call mpi_barrier(mpicom,ierror)
138end do
139! add the spectral function from each process and redistribute
140call mpi_allreduce(mpi_in_place,sfu,nwplot*nkpt0,mpi_double_precision,mpi_sum, &
142! normalise
143t1=1.d0/nkpa0
144sfu(1:nwplot,1:nkpt0)=t1*sfu(1:nwplot,1:nkpt0)
145! write spectral function band structure
146if (mp_mpi) then
147 open(50,file='BANDSFU.OUT',form='FORMATTED')
148 write(50,'(2I6," : grid size")') nkpt0,nwplot
149 do iw=1,nwplot
150 do ik0=1,nkpt0
151 write(50,'(3G18.10)') dpp1d(ik0),w(iw),sfu(iw,ik0)
152 end do
153 end do
154 close(50)
155 write(*,*)
156 write(*,'("Info(bandstrulr):")')
157 write(*,'(" Ultra long-range band structure plot written to BANDULR.OUT")')
158 write(*,'(" Plotted k-point character written in third column")')
159 write(*,*)
160 write(*,'(" Vertex location lines written to BANDLINES.OUT")')
161 write(*,*)
162 write(*,'(" Ultra long-range spectral function band structure written to &
163 &BANDSFU.OUT")')
164end if
165deallocate(vvlp1d0,vql0,w,chkpa,sfu)
166end subroutine
167
subroutine bandstrulr
Definition bandstrulr.f90:7
pure subroutine charkpa(ikpa, evecu, chkpa)
Definition charkpa.f90:7
subroutine eveqnulr(ik0, evecu)
Definition eveqnulr.f90:7
subroutine genapwlofr
Definition genapwlofr.f90:7
subroutine gencore
Definition gencore.f90:10
subroutine genevfsv
Definition genevfsv.f90:7
subroutine gensocfr
Definition gensocfr.f90:7
subroutine genvsig
Definition genvsig.f90:10
subroutine init0
Definition init0.f90:10
subroutine init1
Definition init1.f90:10
subroutine initulr
Definition initulr.f90:7
subroutine linengy
Definition linengy.f90:10
subroutine delfile(fname)
Definition moddelf.f90:15
real(8) efermi
Definition modmain.f90:904
integer nvp1d
Definition modmain.f90:1111
integer nwplot
Definition modmain.f90:1070
real(8), dimension(:,:), allocatable vvlp1d
Definition modmain.f90:1117
real(8), dimension(2) wplot
Definition modmain.f90:1076
real(8), dimension(:,:), allocatable vql
Definition modmain.f90:545
real(8), dimension(:), allocatable dvp1d
Definition modmain.f90:1119
integer task
Definition modmain.f90:1298
integer nstsv
Definition modmain.f90:886
real(8), dimension(:), allocatable dpp1d
Definition modmain.f90:1123
integer lp_mpi
Definition modmpi.f90:15
integer ierror
Definition modmpi.f90:19
integer mpicom
Definition modmpi.f90:11
integer np_mpi
Definition modmpi.f90:13
logical mp_mpi
Definition modmpi.f90:17
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
integer nstulr
Definition modulr.f90:94
integer nkpa
Definition modulr.f90:24
real(8), dimension(:,:), allocatable evalu
Definition modulr.f90:96
integer nkpt0
Definition modulr.f90:18
subroutine occupy
Definition occupy.f90:10
subroutine readstate
Definition readstate.f90:10
subroutine readstulr
Definition readstulr.f90:7
subroutine sfuadd(ik0, w, chkpa, sfu)
Definition sfuadd.f90:7
subroutine vblocalu
Definition vblocalu.f90:7
subroutine vclqinit
Definition vclqinit.f90:7