kpoints_init.F90 37.1 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

Daniel Wortmann's avatar
Daniel Wortmann committed
7
MODULE m_kpoints_init
Daniel Wortmann's avatar
Daniel Wortmann committed
8
  USE m_judft
Daniel Wortmann's avatar
Daniel Wortmann committed
9
  use m_types_fleurinput
Daniel Wortmann's avatar
Daniel Wortmann committed
10
  IMPLICIT NONE
Daniel Wortmann's avatar
Daniel Wortmann committed
11 12
CONTAINS

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
  SUBROUTINE init(kpts,cell,sym,film)
    USE m_types_cell
    USE m_types_sym
    CLASS(t_kpts),INTENT(inout):: kpts
    TYPE(t_cell),INTENT(IN)    :: cell
    TYPE(t_sym),INTENT(IN)     :: sym
    LOGICAL,INTENT(IN)         :: film

    INTEGER :: n

    IF (kpts%numSpecialPoints>2) THEN
       CALL kpts%init_special(cell,film)
       return
    ENDIF
    DO n=1,kpts%nkpt
       kpts%l_gamma=kpts%l_gamma.OR.ALL(ABS(kpts%bk(:,n))<1E-9)
    ENDDO
    IF (kpts%nkptf==0) CALL gen_bz(kpts,sym)
  END SUBROUTINE init

Daniel Wortmann's avatar
Daniel Wortmann committed
33 34 35
  SUBROUTINE init_by_kptsfile(kpts,film)
    CLASS(t_kpts),INTENT(out):: kpts
    LOGICAL,INTENT(in)       :: film
36
    
Daniel Wortmann's avatar
Daniel Wortmann committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    LOGICAL :: l_exist
    REAL    :: scale,wscale
    INTEGER :: n,ios
    
    INQUIRE(file='kpts',exist=l_exist)
    IF (.NOT.l_exist) CALL judft_error("Could not read 'kpts' file")
    OPEN(99,file='kpts')
    READ(99,*,iostat=ios) kpts%nkpt,scale,wscale
    ALLOCATE(kpts%bk(3,kpts%nkpt),kpts%wtkpt(kpts%nkpt))
    DO n=1,kpts%nkpt
       IF (.NOT.film) THEN
          READ(99,*,iostat=ios) kpts%bk(:,n),kpts%wtkpt(n)
       ELSE
          READ(99,*,iostat=ios) kpts%bk(1:2,n),kpts%wtkpt(n)
          kpts%bk(3,n)=0.0
       ENDIF
    ENDDO
    CLOSE(99)
    IF (ios.NE.0) CALL judft_error("Error while reading 'kpts' file")
    IF (scale>0.0) kpts%bk=kpts%bk/scale
    IF (wscale>0.0) kpts%wtkpt=kpts%wtkpt/wscale
  END SUBROUTINE init_by_kptsfile

Daniel Wortmann's avatar
Daniel Wortmann committed
60
  SUBROUTINE read_xml(this,xml)
61 62
    USE m_types_xml
    USE m_calculator
Daniel Wortmann's avatar
Daniel Wortmann committed
63
    CLASS(t_kpts),INTENT(out):: this
64
    TYPE(t_xml)              :: xml
Daniel Wortmann's avatar
Daniel Wortmann committed
65
    CHARACTER(len=*)  ::name !TODO
66 67 68 69 70 71 72 73 74 75 76 77 78
    
    INTEGER:: number_sets,n
    CHARACTER(len=200)::str,path,path2
    


     number_sets = xml%GetNumberOfNodes('/fleurInput/calculationSetup/bzIntegration/kPointList')

     DO n=1,number_sets
        WRITE(path,"(a,i0,a)") '/fleurInput/calculationSetup/bzIntegration/kPointList[',n,']'
        IF(TRIM(ADJUSTL(name))==xml%GetAttributeValue(TRIM(path)//'/@name')) EXIT
     enddo
     IF (n>number_sets) CALL judft_error(("No kpoints named:"//TRIM(name)//" found"))
Daniel Wortmann's avatar
Daniel Wortmann committed
79
     this%nkpt=evaluateFirstOnly(xml%GetAttributeValue(TRIM(path)//'/@count'))
80

Daniel Wortmann's avatar
Daniel Wortmann committed
81
     this%numSpecialPoints=xml%GetNumberOfNodes(TRIM(path)//"specialPoint")
82

Daniel Wortmann's avatar
Daniel Wortmann committed
83 84 85 86 87
     IF (this%numSpecialPoints>0) THEN
        If (this%numSpecialPoints<2) CALL judft_error(("Giving less than two sepcial points make no sense:"//TRIM(name)))
        ALLOCATE(this%specialPoints(3,this%numSpecialPoints))
        ALLOCATE(this%specialPointNames(this%numSpecialPoints))
        DO n=1,this%numSpecialPoints
88
           WRITE(path2,"(a,a,i0,a)") path,"specialPoint[",n,"]"
Daniel Wortmann's avatar
Daniel Wortmann committed
89
           this%specialPointNames(n)=xml%getAttributeValue(path2//"/@name")
90
           str=xml%getAttributeValue(path2)
Daniel Wortmann's avatar
Daniel Wortmann committed
91 92 93
           this%specialPoints(1,n) = evaluatefirst(str)
           this%specialPoints(2,n) = evaluatefirst(str)
           this%specialPoints(3,n) = evaluatefirst(str)
94 95 96
        ENDDO
     ELSE
        n=xml%GetNumberOfNodes(TRIM(path)//'kPoint')
Daniel Wortmann's avatar
Daniel Wortmann committed
97 98 99 100
        IF (n.NE.this%nkpt) CALL judft_error(("Inconsistent number of k-points in:"//name))
        ALLOCATE(this%bk(3,this%nkpt))
        ALLOCATE(this%wtkpt(this%nkpt))
        DO n=1,this%nkpt
101
           WRITE(path2,"(a,a,i0,a)") path,"/kPoint[",n,"]"
Daniel Wortmann's avatar
Daniel Wortmann committed
102
           this%wtkpt(n) = evaluateFirstOnly(xml%GetAttributeValue(TRIM(path2)//'/@weight'))
103
           str= xml%getAttributeValue(path2)
Daniel Wortmann's avatar
Daniel Wortmann committed
104 105 106
           this%bk(1,n) = evaluatefirst(str)
           this%bk(2,n) = evaluatefirst(str)
           this%bk(3,n) = evaluatefirst(str)
107
        ENDDO
Daniel Wortmann's avatar
Daniel Wortmann committed
108 109 110
        this%ntet=xml%GetNumberOfNodes(TRIM(path)//'/tetraeder/tet')
        ALLOCATE(this%voltet(this%ntet),this%ntetra(4,this%ntet))
        DO n=1,this%ntet
111
           WRITE(path2,"(a,a,i0,a)") path,"/tetraeder/tet[",n,"]"
Daniel Wortmann's avatar
Daniel Wortmann committed
112
           this%voltet(n)=evaluateFirstOnly(xml%GetAttributeValue(TRIM(path2)//'/@vol'))
113
           str= xml%getAttributeValue(path2)
Daniel Wortmann's avatar
Daniel Wortmann committed
114
           READ(str,*) this%ntetra(:,n)
115 116 117 118
        ENDDO
     END IF
   END SUBROUTINE read_xml

Daniel Wortmann's avatar
Daniel Wortmann committed
119

120 121
  SUBROUTINE init_special(kpts,cell,film)
    USE m_types_cell
Daniel Wortmann's avatar
Daniel Wortmann committed
122 123
    CLASS(t_kpts),INTENT(inout):: kpts
    LOGICAL,INTENT(IN)         :: film
Daniel Wortmann's avatar
Daniel Wortmann committed
124
    TYPE(t_cell),INTENT(IN)    :: cell
Daniel Wortmann's avatar
Daniel Wortmann committed
125

126 127 128
    REAL:: nextp(3),lastp(3),d(MAX(kpts%nkpt,kpts%numSpecialPoints))
    INTEGER:: nk(MAX(kpts%nkpt,kpts%numSpecialPoints)),i,ii
    IF (kpts%numSpecialPoints<2) CALL add_special_points_default(kpts,film,cell)
Daniel Wortmann's avatar
Daniel Wortmann committed
129 130 131 132 133 134 135
    kpts%nkpt=MAX(kpts%nkpt,kpts%numSpecialPoints)
    !all sepecial kpoints are now set already

    !Distances
    lastp=0
    DO i=1,kpts%numSpecialPoints
       nextp(:)=MATMUL(kpts%specialPoints(:,i),cell%bmat)
Daniel Wortmann's avatar
Daniel Wortmann committed
136
       d(i)=SQRT(DOT_PRODUCT(nextp-lastp,nextp-lastp))
Daniel Wortmann's avatar
Daniel Wortmann committed
137 138 139 140 141 142 143 144 145
       lastp=nextp
    ENDDO
    d(1)=0.0
    !Distribute points
    nk(1)=0
    DO i=2,kpts%numSpecialPoints
       nk(i)=NINT((kpts%nkpt-kpts%numSpecialPoints)*(d(i)/SUM(d)))
    ENDDO

146
    ALLOCATE(kpts%bk(3,kpts%numSpecialPoints+SUM(nk)))
Daniel Wortmann's avatar
Daniel Wortmann committed
147

Daniel Wortmann's avatar
Daniel Wortmann committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
    !Generate lines
    kpts%nkpt=1
    DO i=1,kpts%numSpecialPoints-1
       kpts%bk(:,kpts%nkpt)=kpts%specialPoints(:,i)
       kpts%specialPointIndices(i)=kpts%nkpt
       kpts%nkpt=kpts%nkpt+1
       d=(kpts%specialPoints(:,i+1)-kpts%specialPoints(:,i))/(nk(i)+2) 
       DO ii=1,nk(i)
          kpts%bk(:,kpts%nkpt)=kpts%specialPoints(:,i)+d*ii
          kpts%nkpt=kpts%nkpt+1
       ENDDO
    ENDDO
    kpts%bk(:,kpts%nkpt)=kpts%specialPoints(:,kpts%numSpecialPoints)
    kpts%specialPointIndices(kpts%numSpecialPoints)=kpts%nkpt
    ALLOCATE(kpts%wtkpt(kpts%nkpt))
    kpts%wtkpt = 1.0
  END SUBROUTINE init_special
Daniel Wortmann's avatar
Daniel Wortmann committed
165 166


167 168 169 170 171
  SUBROUTINE init_defaults(kpts,cell,sym,film,tria,l_soc_or_ss,l_gamma)
    USE m_types_cell
    USE m_types_sym
    CLASS(t_kpts),INTENT(out):: kpts
    LOGICAL,INTENT(in)       :: film,tria,l_soc_or_ss,l_gamma
Daniel Wortmann's avatar
Daniel Wortmann committed
172 173
    TYPE(t_cell),INTENT(IN)  :: cell
    TYPE(t_sym),INTENT(IN)   :: sym
Daniel Wortmann's avatar
Daniel Wortmann committed
174

Daniel Wortmann's avatar
Daniel Wortmann committed
175
    INTEGER:: nkpt
Daniel Wortmann's avatar
Daniel Wortmann committed
176
    IF (film) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
177
       nkpt = MAX(NINT((3600/cell%area)/sym%nop2),1)
Daniel Wortmann's avatar
Daniel Wortmann committed
178
    ELSE
Daniel Wortmann's avatar
Daniel Wortmann committed
179
       nkpt = MAX(NINT((216000/cell%omtil)/sym%nop),1)
Daniel Wortmann's avatar
Daniel Wortmann committed
180
    ENDIF
Daniel Wortmann's avatar
Daniel Wortmann committed
181 182
    CALL kpts%init_by_number(nkpt,cell,sym,film,tria,l_soc_or_ss,l_gamma)
  END SUBROUTINE init_defaults
Daniel Wortmann's avatar
Daniel Wortmann committed
183

184
  SUBROUTINE init_by_density(kpts,density,cell,sym,film,tria,l_soc_or_ss,l_gamma)
Daniel Wortmann's avatar
Daniel Wortmann committed
185 186 187
    USE m_types_cell
    USE m_types_sym
    CLASS(t_kpts),INTENT(out):: kpts
Daniel Wortmann's avatar
Daniel Wortmann committed
188 189 190
    REAL,INTENT(in)          :: density
    TYPE(t_cell),INTENT(IN)  :: cell
    TYPE(t_sym),INTENT(IN)   :: sym
191
    LOGICAL,INTENT(IN)             :: film,tria,l_soc_or_ss,l_gamma
Daniel Wortmann's avatar
Daniel Wortmann committed
192 193
    REAL    :: length
    INTEGER :: n,grid(3)
Daniel Wortmann's avatar
Daniel Wortmann committed
194

Daniel Wortmann's avatar
Daniel Wortmann committed
195 196 197 198 199 200 201
    DO n=1,3
       length=SQRT(DOT_PRODUCT(cell%bmat(n,:),cell%bmat(n,:)))  !TODO why not bmat(:,n)???
       grid(n)=CEILING(density*length)
    END DO
    CALL kpts%init_by_grid(grid,cell,sym,film,tria,l_soc_or_ss,l_gamma)

  END SUBROUTINE init_by_density
Daniel Wortmann's avatar
Daniel Wortmann committed
202

203
  SUBROUTINE init_by_number(kpts,nkpt,cell,sym,film,tria,l_soc_or_ss,l_gamma)
Daniel Wortmann's avatar
Daniel Wortmann committed
204
    USE m_divi
Daniel Wortmann's avatar
Daniel Wortmann committed
205
    USE m_types_cell
206
    USE m_types_sym
Daniel Wortmann's avatar
Daniel Wortmann committed
207 208 209 210
    CLASS(t_kpts),INTENT(out):: kpts
    INTEGER,INTENT(IN)       :: nkpt
    TYPE(t_cell),INTENT(IN)  :: cell
    TYPE(t_sym),INTENT(IN)   :: sym
211
    LOGICAL,INTENT(IN)             :: film,tria,l_soc_or_ss,l_gamma
Daniel Wortmann's avatar
Daniel Wortmann committed
212

Daniel Wortmann's avatar
Daniel Wortmann committed
213 214
    INTEGER :: grid(3)

215 216
    CALL divi(nkpt,cell%bmat,film,sym%nop,sym%nop2,grid)
    CALL kpts%init_by_grid(grid,cell,sym,film,tria,l_soc_or_ss,l_gamma)
Daniel Wortmann's avatar
Daniel Wortmann committed
217 218
  END SUBROUTINE init_by_number

219
  SUBROUTINE init_by_grid(kpts,grid,cell,sym,film,tria,l_soc_or_ss,l_gamma)
Daniel Wortmann's avatar
Daniel Wortmann committed
220 221 222 223 224 225 226 227 228 229 230
    !----------------------------------------------------------------------+
    ! Generate a k-point file with approx. nkpt k-pts or a Monkhorst-Pack  |
    ! set with nmod(i) divisions in i=x,y,z direction. Interface to kptmop |
    ! and kpttet routines of the MD-programm.                              |
    !                                                          G.B. 07/01  |
    !----------------------------------------------------------------------+
    USE m_constants
    USE m_bravais
    USE m_brzone2
    USE m_kptmop
    USE m_kpttet
231 232 233
    USE m_types_cell
    USE m_types_sym
    !USE m_kptgen_hybrid
Daniel Wortmann's avatar
Daniel Wortmann committed
234 235 236 237 238
    IMPLICIT NONE
    CLASS(t_kpts),INTENT(out):: kpts

    TYPE(t_sym),     INTENT(IN)    :: sym
    TYPE(t_cell),    INTENT(IN)    :: cell
239 240
    INTEGER,INTENT(INout)          :: grid(3)
    LOGICAL,INTENT(IN)             :: film,tria,l_soc_or_ss,l_gamma
Daniel Wortmann's avatar
Daniel Wortmann committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297


    INTEGER, PARAMETER :: nop48  = 48
    INTEGER, PARAMETER :: mface  = 51
    INTEGER, PARAMETER :: mdir   = 10
    INTEGER, PARAMETER :: nbsz   =  3
    INTEGER, PARAMETER :: ibfile =  6
    INTEGER, PARAMETER :: nv48   = (2*nbsz+1)**3+48

    INTEGER ndiv3              ! max. number of tetrahedrons (< 6*(kpts%nkpt+1)

    REAL, ALLOCATABLE    :: vkxyz(:,:)  ! vector of kpoint generated; in cartesian representation
    REAL, ALLOCATABLE    :: wghtkp(:)   !   associated with k-points for BZ integration
    INTEGER, ALLOCATABLE :: ntetra(:,:) ! corners of the tetrahedrons
    REAL, ALLOCATABLE    :: voltet(:)   ! voulmes of the tetrahedrons
    REAL, ALLOCATABLE    :: vktet(:,:)

    REAL    divis(4)           ! Used to find more accurate representation of k-points
    ! vklmn(i,kpt)/divis(i) and weights as wght(kpt)/divis(4)
    REAL    bltv(3,3)          ! cartesian Bravais lattice basis (a.u.)
    REAL    rltv(3,3)          ! reciprocal lattice basis (2\pi/a.u.)
    REAL    ccr(3,3,nop48)     ! rotation matrices in cartesian repr.
    REAL    rlsymr(3,3,nop48)  ! rotation matrices in reciprocal lattice basis representation
    REAL    talfa(3,nop48)     ! translation vector associated with (non-symmorphic)
    ! symmetry elements in Bravais lattice representation
    INTEGER ncorn,nedge,nface  ! number of corners, faces and edges of the IBZ
    REAL    fnorm(3,mface)     ! normal vector of the planes bordering the IBZ
    REAL    fdist(mface)       ! distance vector of the planes bordering t IBZ
    REAL    cpoint(3,mface)    ! cartesian coordinates of corner points of IBZ
    REAL    xvec(3)            ! arbitrary vector lying in the IBZ

    INTEGER idsyst   ! crystal system identification in MDDFT programs
    INTEGER idtype   ! lattice type identification in MDDFT programs

    INTEGER idimens  ! number of dimensions for k-point set (2 or 3)
    INTEGER nreg     ! 1 kpoints in full BZ; 0 kpoints in irrBZ
    INTEGER nfulst   ! 1 kpoints ordered in full stars
    !    (meaningful only for nreg =1; full BZ)
    INTEGER nbound   ! 0 no primary points on BZ boundary;
    ! 1 with boundary points (not for BZ integration!!!)
    INTEGER ikzero   ! 0 no shift of k-points;
    ! 1 shift of k-points for better use of sym in irrBZ
    REAL    kzero(3) ! shifting vector to bring one k-point to or 
    ! away from (0,0,0) (for even/odd nkpt3)

    INTEGER i,j,k,l,mkpt,addSym,nsym
    LOGICAL random,trias
    REAL help(3),binv(3,3),rlsymr1(3,3),ccr1(3,3)

    IF (ANY(grid==0)) THEN
       PRINT *,"Warning, k-point grid dimension increased to 1"
       WHERE(grid==0) grid=1
    END IF


    IF (l_gamma) THEN
       IF (tria) CALL judft_error("tria and l_gamma incompatible")
Daniel Wortmann's avatar
Daniel Wortmann committed
298
       CALL judft_error("l_gamma not supported at present")
299
       !CALL kptgen_hybrid(film,grid,cell,sym,kpts,l_soc_or_ss)
Daniel Wortmann's avatar
Daniel Wortmann committed
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
    ELSE
       !------------------------------------------------------------
       !
       !        idsyst         idtype 
       !
       !   1  cubic          primitive
       !   2  tetragonal     body centered
       !   3  orthorhombic   face centered
       !   4  hexagonal      A-face centered
       !   5  trigonal       B-face centered
       !   6  monoclinic     C-face centered
       !   7  triclinic 
       !
       ! --->   for 2 dimensions only the following Bravais lattices exist:
       !
       !    TYPE                    EQUIVALENT 3-DIM        idsyst/idtype
       !   square               = p-tetragonal ( 1+2 axis )      2/1
       !   rectangular          = p-orthorhomb ( 1+2 axis )      3/1
       !   centered rectangular = c-face-orthorhomb( 1+2 axis)   3/6
       !   hexagonal            = p-hexagonal  ( 1+2 axis )      4/1
       !   oblique              = p-monoclinic ( 1+2 axis )      6/1
       !
       !------------------------------------------------------------


       CALL bravais(cell%amat,idsyst,idtype) 

       nsym = MERGE(sym%nop2,sym%nop,film)    
       nbound  = MERGE(1,0,film.AND.tria)
       random  = tria.AND..NOT.film
       idimens = MERGE(2,3,film)

       ! Lattice information

       bltv=TRANSPOSE(cell%amat)
335
       binv=TRANSPOSE(cell%bmat)/tpi_const
Daniel Wortmann's avatar
Daniel Wortmann committed
336 337
       rltv=TRANSPOSE(cell%bmat)
       DO i=1,nsym
338
          rlsymr(:,:,i)=REAL(TRANSPOSE(sym%mrot(:,:,i)))
Daniel Wortmann's avatar
Daniel Wortmann committed
339 340 341 342 343 344 345 346 347 348 349
       ENDDO

       talfa=MATMUL(bltv,sym%tau(:,:nsym))
       DO i = 1, nsym
          ccr(:,:,i) = MATMUL(MATMUL(binv(:,:),rlsymr(:,:,i)),bltv(:,:))
       END DO
       DO i = 1, nsym
          rlsymr(:,:,i)=TRANSPOSE(rlsymr(:,:,i))
          ccr(:,:,i)=TRANSPOSE(ccr(:,:,i))
       END DO

Daniel Wortmann's avatar
Daniel Wortmann committed
350 351
       IF ((.NOT.l_soc_or_ss).AND.(2*nsym<nop48)) THEN
          IF ((film.AND.(.NOT.sym%invs2)).OR.((.NOT.film).AND.(.NOT.sym%invs))) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
             addSym = 0
             ! Note: We have to add the negative of each symmetry operation
             !       to exploit time reversal symmetry. However, if the new
             !       symmetry operation is the identity matrix it is excluded.
             !       This is the case iff it is (-Id) + a translation vector.
             DO i = 1, nsym
                ! This test assumes that ccr(:,:,1) is the identity matrix.
                IF(.NOT.ALL(ABS(ccr(:,:,1)+ccr(:,:,i)).LT.10e-10) ) THEN
                   ccr(:,:,nsym+addSym+1 ) = -ccr(:,:,i)
                   rlsymr(:,:,nsym+addSym+1 ) = -rlsymr(:,:,i)
                   addSym = addSym + 1
                END IF
             END DO
             nsym = nsym + addSym
          END IF
       END IF

       ! brzone and brzone2 find the corner-points, the edges, and the
       ! faces of the irreducible wedge of the brillouin zone (IBZ).
       CALL brzone2(rltv,nsym,ccr,mface,nbsz,nv48,cpoint,xvec,ncorn,nedge,nface,fnorm,fdist)

       IF (nbound.EQ.1) THEN
374
          mkpt = PRODUCT((2*grid(:idimens)+1))
Daniel Wortmann's avatar
Daniel Wortmann committed
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
       ELSE
          mkpt=PRODUCT(grid(:idimens))
       END IF
       ALLOCATE (vkxyz(3,mkpt),wghtkp(mkpt) )


       IF (tria.AND.random) THEN
          ! Calculate the points for tetrahedron method
          ndiv3 = 6*(mkpt+1)
          ALLOCATE (voltet(ndiv3),vktet(3,mkpt),ntetra(4,ndiv3))
          kpts%nkpt=mkpt
          CALL kpttet(0,mkpt,ndiv3,&
               rltv,cell%omtil,nsym,ccr,mdir,mface,&
               ncorn,nface,fdist,fnorm,cpoint,voltet,ntetra,kpts%ntet,vktet,&
               kpts%nkpt,vkxyz,wghtkp)
       ELSE
          ! Now calculate Monkhorst-Pack k-points:
          CALL kptmop(idsyst,idtype,grid,&
               rltv,bltv,nbound,idimens,xvec,fnorm,fdist,ncorn,nface,&
               nedge,cpoint,nsym,ccr,rlsymr,talfa,mkpt,mface,mdir,&
               kpts%nkpt,vkxyz,wghtkp)
       END IF

       DO j=1,kpts%nkpt
          vkxyz(:,j)=MATMUL(vkxyz(:,j),cell%amat)/tpi_const
       END DO

       ALLOCATE(kpts%bk(3,kpts%nkpt),kpts%wtkpt(kpts%nkpt))
       kpts%bk(:,:) = vkxyz(:,:kpts%nkpt)
       kpts%wtkpt(:) = wghtkp(:kpts%nkpt)

       IF (tria.AND.random) THEN
          ALLOCATE(kpts%ntetra(4,kpts%ntet))
          ALLOCATE(kpts%voltet(kpts%ntet))
          DO j = 1, kpts%ntet
             kpts%ntetra(:,j) = ntetra(:,j)
             kpts%voltet(j) = ABS(voltet(j))
          END DO
       END IF
    ENDIF
    !Generate kpts in full BZ
    IF (.NOT.tria) CALL gen_bz(kpts,sym)


  END SUBROUTINE init_by_grid


Daniel Wortmann's avatar
Daniel Wortmann committed
422 423 424 425 426 427 428 429
  SUBROUTINE add_special_points_default(kpts,film,cell)
    USE m_judft
    USE m_bravais
    USE m_types_cell
    TYPE(t_kpts),INTENT(inout):: kpts
    LOGICAL,INTENT(in)        :: film
    TYPE(t_cell),INTENT(in)   :: cell

Daniel Wortmann's avatar
Daniel Wortmann committed
430 431 432 433 434
    REAL, PARAMETER :: f12 = 1./2., f14 = 1./4., zro = 0.0
    REAL, PARAMETER :: f34 = 3./4., f38 = 3./8., one = 1.0
    REAL, PARAMETER :: f13 = 1./3., f23 = 2./3.

    INTEGER:: idsyst,idtype
435
    CALL bravais(cell%amat,idsyst,idtype) 
Daniel Wortmann's avatar
Daniel Wortmann committed
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614

    IF (.NOT.film) THEN
       IF ( (idsyst == 1).AND.(idtype ==  3) ) THEN       ! fcc
          CALL kpts%add_special_line((/f12,f12,one/) ,"X")
          CALL kpts%add_special_line((/f38,f38,f34/) ,"K")
          CALL kpts%add_special_line((/zro,zro,zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12,f12/) ,"L")
          CALL kpts%add_special_line((/f12,f14,f34/) ,"W")
          CALL kpts%add_special_line((/f12,zro,f12/) ,"X")
          CALL kpts%add_special_line((/zro,zro,zro/) ,"g")
       ENDIF
       IF ( (idsyst == 5).AND.(idtype ==  1) ) THEN       ! rhombohedric (trigonal)
          CALL kpts%add_special_line((/f12,f12, f12/) ,"Z")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f14,f14,-f14/) ,"K")
          CALL kpts%add_special_line((/f12,f12,-f12/) ,"Z")
          CALL kpts%add_special_line((/f14,f12,-f14/) ,"W")
          CALL kpts%add_special_line((/zro,f12, zro/) ,"L")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"F")
       ENDIF
       IF ( (idsyst == 4).AND.(idtype ==  1) ) THEN       ! hexagonal
          IF (cell%bmat(1,1)*cell%bmat(2,1)+cell%bmat(1,2)*cell%bmat(2,2) > 0.0) THEN
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f13, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
             CALL kpts%add_special_line((/zro,f12, f12/) ,"L")
             CALL kpts%add_special_line((/f13,f13, f12/) ,"H")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
          ELSE                                             ! hexagonal (angle = 60)
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f23, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
             CALL kpts%add_special_line((/f12,f12, f12/) ,"L")
             CALL kpts%add_special_line((/f13,f23, f12/) ,"H")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
          ENDIF
       ENDIF
       IF ( (idsyst == 1).AND.(idtype ==  1) ) THEN       ! simple cubic
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
          CALL kpts%add_special_line((/f12,f12, f12/) ,"R")
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12, f12/) ,"R")
       ENDIF
       IF ( (idsyst == 1).AND.(idtype ==  2) ) THEN       ! body centered cubic
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,-f12,f12/) ,"H")
          CALL kpts%add_special_line((/zro,zro, f12/) ,"N")
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/zro,zro, f12/) ,"N")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  2) ) THEN       ! body centered tetragonal (a > c)
          CALL kpts%add_special_line((/f12,f12,-f12/) ,"Z")    ! via Lambda and V)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Sigma)
          CALL kpts%add_special_line((/-f12,f12,f12/) ,"Z")    ! via Y)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"X")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    
          CALL kpts%add_special_line((/zro,f12, zro/) ,"N")    ! via Q)
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")    ! via W)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"X")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  2) ) THEN       ! body centered tetragonal (a < c)
          CALL kpts%add_special_line((/-f12,f12,f12/) ,"Z")    ! via F and Sigma)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"X")    ! via W)
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")    ! via Q)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"N")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
          CALL kpts%add_special_line((/f12,f12,-f12/) ,"Z")    ! via U and Y)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"X")
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Delta)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via Y)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")    ! via Sigma)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"Z")    ! via U)
          CALL kpts%add_special_line((/f12,zro, f12/) ,"R")    ! via T)
          CALL kpts%add_special_line((/f12,f12, f12/) ,"A")    ! via S)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"Z")
       ENDIF
       IF ( (idsyst == 3).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Sigma)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via D)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"S")    ! via C)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"Y")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"Z")    ! via A)
          CALL kpts%add_special_line((/f12,zro, f12/) ,"U")    ! via P)
          CALL kpts%add_special_line((/f12,f12, f12/) ,"R")    ! via E)
          CALL kpts%add_special_line((/zro,f12, f12/) ,"T")    ! via B)
          CALL kpts%add_special_line((/zro,zro, f12/), "Z")
       ENDIF
    ELSE
       WRITE(*,*) 'Note:'
       WRITE(*,*) 'Default k point paths for film band structures'
       WRITE(*,*) 'are experimental. If the generated k point path'
       WRITE(*,*) 'is not correct please specify it directly.'
       IF ( (idsyst == 5).AND.(idtype ==  1) ) THEN       ! rhombohedric (trigonal)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"L")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"F")
       ENDIF
       IF ( (idsyst == 4).AND.(idtype ==  1) ) THEN       ! hexagonal
          IF (cell%bmat(1,1)*cell%bmat(2,1)+cell%bmat(1,2)*cell%bmat(2,2) > 0.0) THEN
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f13, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")

          ELSE                                             ! hexagonal (angle = 60)
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f23, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          ENDIF
       ENDIF
       IF ( (idsyst == 1).AND.(idtype ==  1) ) THEN       ! simple cubic
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Delta)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via Y)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")    ! via Sigma)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
       ENDIF
       IF ( (idsyst == 3).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Sigma)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via D)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"S")    ! via C)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"Y")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
       ENDIF
    END IF
    IF (kpts%numspecialPoints<2) CALL judft_error("Not enough special points given and no default found")
  END SUBROUTINE add_special_points_default


  SUBROUTINE gen_bz( kpts,sym)
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ! gen_bz generates the (whole) Brillouin zone from the          !
    ! (irreducible) k-points given                                  !
    !                                     M.Betzinger (09/07)       !
    !                        Refactored in 2017 by G.M.             !
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !     bk     ::    irreducible k-points
    !     nkpt   ::    number of irr. k-points
    !     bkf    ::    all k-points
    !     nkptf  ::    number of all k-points
    !     bkp    ::    k-point parent
    !     bksym  ::    symmetry operation, that connects the parent
    !                  k-point with the current one
    USE m_juDFT
    USE m_types_sym
    TYPE(t_kpts),INTENT(INOUT) :: kpts
    TYPE(t_sym),INTENT(IN)     :: sym
    !  - local scalars -
    INTEGER                 ::  ic,iop,ikpt,ikpt1
    LOGICAL                 ::  l_found

    !  - local arrays - 
    INTEGER,ALLOCATABLE     ::  iarr(:)
    REAL                    ::  rrot(3,3,2*sym%nop),rotkpt(3)
    REAL,ALLOCATABLE        ::  rarr1(:,:)

    INTEGER:: nsym,ID_mat(3,3)
615 616

    
Daniel Wortmann's avatar
Daniel Wortmann committed
617 618
    nsym=sym%nop
    IF (.NOT.sym%invs) nsym=2*sym%nop
619
    
Daniel Wortmann's avatar
Daniel Wortmann committed
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
    ALLOCATE (kpts%bkf(3,nsym*kpts%nkpt))
    ALLOCATE (kpts%bkp(nsym*kpts%nkpt))
    ALLOCATE (kpts%bksym(nsym*kpts%nkpt))

    ! Generate symmetry operations in reciprocal space
    DO iop=1,nsym
       IF( iop .LE. sym%nop ) THEN
          rrot(:,:,iop) = TRANSPOSE( sym%mrot(:,:,sym%invtab(iop)) )
       ELSE
          rrot(:,:,iop) = -rrot(:,:,iop-sym%nop)
       END IF
    END DO


    !Add existing vectors to list of full vectors
    id_mat=0
    ID_mat(1,1)=1;ID_mat(2,2)=1;ID_mat(3,3)=1
    IF (ANY(sym%mrot(:,:,1).NE.ID_mat)) CALL judft_error("Identity must be first symmetry operation",calledby="gen_bz")

    ic=0
    DO iop=1,nsym
       DO ikpt=1,kpts%nkpt
          rotkpt = MATMUL(rrot(:,:,iop), kpts%bk(:,ikpt))
          !transform back into 1st-BZ (Do not use nint to deal properly with inaccuracies)
          do while(any(rotkpt<-0.5))
             where (rotkpt<-0.5) rotkpt=rotkpt+1.0
          enddo
          do while(any(rotkpt>0.5+1E-8))
             where (rotkpt>0.5+1E-8) rotkpt=rotkpt-1.0
          enddo
          DO ikpt1=1,ic
             IF (MAXVAL(ABS(kpts%bkf(:,ikpt1) - rotkpt)).LE.1e-07) EXIT
          END DO

          IF(ikpt1>ic) THEN !new point
             ic = ic + 1
             kpts%bkf(:,ic) = rotkpt
             kpts%bkp(ic) = ikpt
             kpts%bksym(ic) = iop
          END IF
       END DO
    END DO

    kpts%nkptf = ic
    ! Reallocate bkf, bkp, bksym
    ALLOCATE (iarr(kpts%nkptf))
    iarr = kpts%bkp(:kpts%nkptf)
    DEALLOCATE(kpts%bkp)
    ALLOCATE (kpts%bkp(kpts%nkptf))
    kpts%bkp = iarr
    iarr= kpts%bksym(:kpts%nkptf)
    DEALLOCATE (kpts%bksym )
    ALLOCATE (kpts%bksym(kpts%nkptf))
    kpts%bksym = iarr
    DEALLOCATE(iarr)
    ALLOCATE (rarr1(3,kpts%nkptf))
    rarr1 = kpts%bkf(:,:kpts%nkptf)
    DEALLOCATE (kpts%bkf )
    ALLOCATE (kpts%bkf(3,kpts%nkptf))
    kpts%bkf = rarr1
    DEALLOCATE(rarr1)

  END SUBROUTINE gen_bz

Daniel Wortmann's avatar
Daniel Wortmann committed
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
  SUBROUTINE add_special_points_default(kpts,film,cell)
    USE m_judft
    USE m_bravais
    USE m_types_cell
    TYPE(t_kpts),INTENT(inout):: kpts
    LOGICAL,INTENT(in)        :: film
    TYPE(t_cell),INTENT(in)   :: cell

    REAL, PARAMETER :: f12 = 1./2., f14 = 1./4., zro = 0.0
    REAL, PARAMETER :: f34 = 3./4., f38 = 3./8., one = 1.0
    REAL, PARAMETER :: f13 = 1./3., f23 = 2./3.

    INTEGER:: idsyst,idtype
    CALL bravais(cell%amat,idsyst,idtype) 

    IF (.NOT.film) THEN
       IF ( (idsyst == 1).AND.(idtype ==  3) ) THEN       ! fcc
          CALL kpts%add_special_line((/f12,f12,one/) ,"X")
          CALL kpts%add_special_line((/f38,f38,f34/) ,"K")
          CALL kpts%add_special_line((/zro,zro,zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12,f12/) ,"L")
          CALL kpts%add_special_line((/f12,f14,f34/) ,"W")
          CALL kpts%add_special_line((/f12,zro,f12/) ,"X")
          CALL kpts%add_special_line((/zro,zro,zro/) ,"g")
       ENDIF
       IF ( (idsyst == 5).AND.(idtype ==  1) ) THEN       ! rhombohedric (trigonal)
          CALL kpts%add_special_line((/f12,f12, f12/) ,"Z")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f14,f14,-f14/) ,"K")
          CALL kpts%add_special_line((/f12,f12,-f12/) ,"Z")
          CALL kpts%add_special_line((/f14,f12,-f14/) ,"W")
          CALL kpts%add_special_line((/zro,f12, zro/) ,"L")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"F")
       ENDIF
       IF ( (idsyst == 4).AND.(idtype ==  1) ) THEN       ! hexagonal
          IF (cell%bmat(1,1)*cell%bmat(2,1)+cell%bmat(1,2)*cell%bmat(2,2) > 0.0) THEN
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f13, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
             CALL kpts%add_special_line((/zro,f12, f12/) ,"L")
             CALL kpts%add_special_line((/f13,f13, f12/) ,"H")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
          ELSE                                             ! hexagonal (angle = 60)
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f23, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
             CALL kpts%add_special_line((/f12,f12, f12/) ,"L")
             CALL kpts%add_special_line((/f13,f23, f12/) ,"H")
             CALL kpts%add_special_line((/zro,zro, f12/) ,"A")
          ENDIF
       ENDIF
       IF ( (idsyst == 1).AND.(idtype ==  1) ) THEN       ! simple cubic
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
          CALL kpts%add_special_line((/f12,f12, f12/) ,"R")
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12, f12/) ,"R")
       ENDIF
       IF ( (idsyst == 1).AND.(idtype ==  2) ) THEN       ! body centered cubic
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,-f12,f12/) ,"H")
          CALL kpts%add_special_line((/zro,zro, f12/) ,"N")
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/zro,zro, f12/) ,"N")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  2) ) THEN       ! body centered tetragonal (a > c)
          CALL kpts%add_special_line((/f12,f12,-f12/) ,"Z")    ! via Lambda and V)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Sigma)
          CALL kpts%add_special_line((/-f12,f12,f12/) ,"Z")    ! via Y)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"X")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    
          CALL kpts%add_special_line((/zro,f12, zro/) ,"N")    ! via Q)
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")    ! via W)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"X")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  2) ) THEN       ! body centered tetragonal (a < c)
          CALL kpts%add_special_line((/-f12,f12,f12/) ,"Z")    ! via F and Sigma)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"X")    ! via W)
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")    ! via Q)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"N")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
          CALL kpts%add_special_line((/f12,f12,-f12/) ,"Z")    ! via U and Y)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"X")
          CALL kpts%add_special_line((/f14,f14, f14/) ,"P")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Delta)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via Y)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")    ! via Sigma)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"Z")    ! via U)
          CALL kpts%add_special_line((/f12,zro, f12/) ,"R")    ! via T)
          CALL kpts%add_special_line((/f12,f12, f12/) ,"A")    ! via S)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"Z")
       ENDIF
       IF ( (idsyst == 3).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Sigma)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via D)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"S")    ! via C)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"Y")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
          CALL kpts%add_special_line((/zro,zro, f12/) ,"Z")    ! via A)
          CALL kpts%add_special_line((/f12,zro, f12/) ,"U")    ! via P)
          CALL kpts%add_special_line((/f12,f12, f12/) ,"R")    ! via E)
          CALL kpts%add_special_line((/zro,f12, f12/) ,"T")    ! via B)
          CALL kpts%add_special_line((/zro,zro, f12/), "Z")
       ENDIF
    ELSE
       WRITE(*,*) 'Note:'
       WRITE(*,*) 'Default k point paths for film band structures'
       WRITE(*,*) 'are experimental. If the generated k point path'
       WRITE(*,*) 'is not correct please specify it directly.'
       IF ( (idsyst == 5).AND.(idtype ==  1) ) THEN       ! rhombohedric (trigonal)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"L")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"F")
       ENDIF
       IF ( (idsyst == 4).AND.(idtype ==  1) ) THEN       ! hexagonal
          IF (cell%bmat(1,1)*cell%bmat(2,1)+cell%bmat(1,2)*cell%bmat(2,2) > 0.0) THEN
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/zro,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f13, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")

          ELSE                                             ! hexagonal (angle = 60)
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
             CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
             CALL kpts%add_special_line((/f13,f23, zro/) ,"K")
             CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          ENDIF
       ENDIF
       IF ( (idsyst == 1).AND.(idtype ==  1) ) THEN       ! simple cubic
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")
       ENDIF
       IF ( (idsyst == 2).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Delta)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via Y)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"M")    ! via Sigma)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
       ENDIF
       IF ( (idsyst == 3).AND.(idtype ==  1) ) THEN       ! primitive tetragonal (a < c)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Sigma)
          CALL kpts%add_special_line((/f12,zro, zro/) ,"X")    ! via D)
          CALL kpts%add_special_line((/f12,f12, zro/) ,"S")    ! via C)
          CALL kpts%add_special_line((/zro,f12, zro/) ,"Y")    ! via Delta)
          CALL kpts%add_special_line((/zro,zro, zro/) ,"g")    ! via Lambda)
       ENDIF
    END IF
    IF (kpts%numspecialPoints<2) CALL judft_error("Not enough special points given and no default found")
  END SUBROUTINE add_special_points_default


Daniel Wortmann's avatar
Daniel Wortmann committed
849

Daniel Wortmann's avatar
Daniel Wortmann committed
850
END MODULE m_kpoint_init