File: setup_nbnd_occ.f90

package info (click to toggle)
espresso 6.7-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 311,068 kB
  • sloc: f90: 447,429; ansic: 52,566; sh: 40,631; xml: 37,561; tcl: 20,077; lisp: 5,923; makefile: 4,503; python: 4,379; perl: 1,219; cpp: 761; fortran: 618; java: 568; awk: 128
file content (101 lines) | stat: -rw-r--r-- 3,167 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
!
! Copyright (C) 2001-2016 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!-----------------------------------------------------------------------
SUBROUTINE setup_nbnd_occ
  !-----------------------------------------------------------------------
  !
  ! This subroutine computes the number of occupied bands for each k point
  !
  USE kinds,            ONLY : DP
  USE constants,        ONLY : degspin, pi
  USE klist,            ONLY : xk, ltetra, lgauss, degauss, ngauss, nks, &
                               nelec, nelup, neldw, two_fermi_energies, wk
  USE ener,             ONLY : ef
  USE wvfct,            ONLY : nbnd, et
  USE control_lr,       ONLY : nbnd_occ
  USE io_global,        ONLY : stdout
  USE noncollin_module, ONLY : noncolin
  USE lsda_mod,         ONLY : lsda, isk
  USE ktetra,           ONLY : tetra_type
  !
  IMPLICIT NONE
  !
  REAL(DP) :: target, small, fac, xmax
  ! auxiliary variables used
  ! to set nbnd_occ in the metallic case
  INTEGER :: ik, ibnd, ipol
  !
  CALL start_clock ('setup_nbnd_occ')
  !
  ALLOCATE ( nbnd_occ(nks) )
  nbnd_occ(:) = 0
  IF (lgauss) THEN
     !
     ! Discard conduction bands such that w0gauss(x,n) < small
     !
     ! hint:
     !   small = 1.0333492677046d-2  ! corresponds to 2 gaussian sigma
     !   small = 6.9626525973374d-5  ! corresponds to 3 gaussian sigma
     !   small = 6.3491173359333d-8  ! corresponds to 4 gaussian sigma
     !
     small = 6.9626525973374d-5
     !
     ! - appropriate limit for gaussian broadening (used for all ngauss)
     !
     xmax = sqrt ( - log (sqrt (pi) * small) )
     !
     ! - appropriate limit for Fermi-Dirac
     !
     IF (ngauss.eq. - 99) THEN
        fac = 1.d0 / sqrt (small)
        xmax = 2.d0 * log (0.5d0 * (fac + sqrt (fac * fac - 4.d0) ) )
     ENDIF
     !
     target = ef + xmax * degauss
     !
     DO ik = 1, nks
        DO ibnd = 1, nbnd
           IF (et(ibnd, ik) .lt.target) nbnd_occ(ik) = ibnd
        ENDDO
        IF (nbnd_occ(ik) .eq. nbnd) WRITE( stdout, '(5x,/,&
             &"Possibly too few bands at point ", i4,3f10.5)') &
             ik,  (xk (ipol, ik) , ipol = 1, 3)
     ENDDO
     !
  ELSE IF (ltetra) THEN
     IF (tetra_type /= 1 .and. tetra_type /= 2) CALL errore &
          ('setup_nbnd_occ','Optimized or linear tetrahedra only', 1)
  ELSE
     !
     IF (noncolin) THEN
        nbnd_occ = nint (nelec)
     ELSE
        IF ( two_fermi_energies ) THEN
           DO ik = 1, nks
              IF (isk(ik)==1) THEN
                 nbnd_occ (ik) = nint (nelup)
              ELSE
                 nbnd_occ (ik) = nint (neldw)
              ENDIF
           ENDDO
        ELSE
           IF (lsda) CALL infomsg('setup_nbnd_occ', &
                                 'Occupation numbers probably wrong')
           DO ik = 1, nks
              nbnd_occ (ik) = nint (nelec) / degspin
           ENDDO
        ENDIF
     ENDIF
     !
  ENDIF
  !
  CALL stop_clock ('setup_nbnd_occ')
  !
  RETURN
  !
END SUBROUTINE setup_nbnd_occ