The Elk Code
occupyulr.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2018 T. Mueller, J. K. Dewhurst, S. Sharma and E. K. U. Gross.
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 occupyulr
7 use modmain
8 use modulr
9 implicit none
10 ! local variables
11 integer, parameter :: maxit=1000
12 integer ik0,ik,ist,it
13 real(8) e0,e1,e,chg,x,t0
14 ! external functions
15 real(8), external :: stheta
16 ! find minimum and maximum eigenvalues
17 e0=evalu(1,1)
18 e1=e0
19 do ik0=1,nkpt0
20  do ist=1,nstulr
21  e=evalu(ist,ik0)
22  if (e < e0) e0=e
23  if (e > e1) e1=e
24  end do
25 end do
26 if (e0 < e0min) then
27  write(*,*)
28  write(*,'("Warning(occupyulr): minimum eigenvalue less than minimum &
29  &linearisation energy : ",2G18.10)') e0,e0min
30  write(*,'(" for s.c. loop ",I5)') iscl
31 end if
32 t0=1.d0/swidth
33 ! determine the Fermi energy using the bisection method
34 do it=1,maxit
35  efermi=0.5d0*(e0+e1)
36  chg=0.d0
37  do ik0=1,nkpt0
38 ! central k-point
39  ik=(ik0-1)*nkpa+1
40  do ist=1,nstulr
41  e=evalu(ist,ik0)
42  if (e < e0min) then
43  occulr(ist,ik0)=0.d0
44  else
45  x=(efermi-e)*t0
46  occulr(ist,ik0)=occmax*stheta(stype,x)
47  chg=chg+wkpt(ik)*occulr(ist,ik0)
48  end if
49  end do
50  end do
51  if (chg < chgval) then
52  e0=efermi
53  else
54  e1=efermi
55  end if
56  if ((e1-e0) < 1.d-12) return
57 end do
58 write(*,*)
59 write(*,'("Warning(occupyulr): could not find Fermi energy")')
60 end subroutine
61 
real(8) efermi
Definition: modmain.f90:907
integer nstulr
Definition: modulr.f90:95
integer iscl
Definition: modmain.f90:1051
real(8) swidth
Definition: modmain.f90:895
integer nkpt0
Definition: modulr.f90:18
subroutine occupyulr
Definition: occupyulr.f90:7
real(8) e0min
Definition: modmain.f90:825
real(8), dimension(:), allocatable wkpt
Definition: modmain.f90:475
real(8) occmax
Definition: modmain.f90:901
real(8), dimension(:,:), allocatable occulr
Definition: modulr.f90:99
integer stype
Definition: modmain.f90:891
real(8) chgval
Definition: modmain.f90:722
Definition: modulr.f90:6
integer nkpa
Definition: modulr.f90:24
real(8), dimension(:,:), allocatable evalu
Definition: modulr.f90:97