kmesh_write Subroutine

public subroutine kmesh_write(exclude_bands, kmesh_info, lauto_proj, proj, print_output, kpt_latt, real_lattice, num_kpts, num_proj, calc_only_A, spinors, seedname, timer)

Uses

  • proc~~kmesh_write~~UsesGraph proc~kmesh_write kmesh_write module~w90_io w90_io proc~kmesh_write->module~w90_io module~w90_types w90_types proc~kmesh_write->module~w90_types module~w90_utility w90_utility proc~kmesh_write->module~w90_utility module~w90_constants w90_constants module~w90_io->module~w90_constants module~w90_types->module~w90_constants module~w90_comms w90_comms module~w90_utility->module~w90_comms module~w90_utility->module~w90_constants module~w90_comms->module~w90_constants module~w90_error_base w90_error_base module~w90_comms->module~w90_error_base

Writes nnkp file (list of overlaps needed)

Arguments

Type IntentOptional Attributes Name
integer, intent(in), allocatable :: exclude_bands(:)
type(kmesh_info_type), intent(in) :: kmesh_info
logical, intent(in) :: lauto_proj
type(proj_type), intent(in), allocatable :: proj(:)
type(print_output_type), intent(in) :: print_output
real(kind=dp), intent(in) :: kpt_latt(:,:)
real(kind=dp), intent(in) :: real_lattice(3,3)
integer, intent(in) :: num_kpts
integer, intent(inout) :: num_proj
logical, intent(in) :: calc_only_A
logical, intent(in) :: spinors
character(len=*), intent(in) :: seedname
type(timer_list_type), intent(inout) :: timer

Calls

proc~~kmesh_write~~CallsGraph proc~kmesh_write kmesh_write proc~io_date io_date proc~kmesh_write->proc~io_date proc~io_stopwatch_start io_stopwatch_start proc~kmesh_write->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~kmesh_write->proc~io_stopwatch_stop proc~utility_recip_lattice_base utility_recip_lattice_base proc~kmesh_write->proc~utility_recip_lattice_base proc~utility_inv3 utility_inv3 proc~utility_recip_lattice_base->proc~utility_inv3

Called by

proc~~kmesh_write~~CalledByGraph proc~kmesh_write kmesh_write proc~write_kmesh write_kmesh proc~write_kmesh->proc~kmesh_write program~wannier wannier program~wannier->proc~write_kmesh

Source Code

  subroutine kmesh_write(exclude_bands, kmesh_info, lauto_proj, proj, print_output, kpt_latt, &
                         real_lattice, num_kpts, num_proj, calc_only_A, spinors, seedname, timer)
    !==================================================================!
    !                                                                  !
    !! Writes nnkp file (list of overlaps needed)
    !                                                                  !
    ! Note that the format is different to (and more compact than)     !
    ! that used by the old f77 code.                                   !
    !                                                                  !
    ! The file consists of num_kpts blocks of data, one block for each !
    ! k-point of the mesh. Each block consists of nntot+1 lines,       !
    ! where nntot is the (integer) number of nearest neighbours        !
    ! belonging to k-point nkp.                                        !
    !                                                                  !
    ! The first line in each block is just nntot.                      !
    !                                                                  !
    ! The second line consists of 5 integers. The first is the k-point !
    ! nkp. The second to the fifth specify it's nearest neighbours     !
    ! k+b: the second integer points to the k-point that is the        !
    ! periodic image of k+b that we want; the last three integers give !
    ! the G-vector, in reciprocal lattice units, that brings the       !
    ! k-point specified by the second integer (which is in the first   !
    ! BZ) to the actual k+b that we need.                              !
    !                                                                  !
    ! So wannier.nnkp specifies the nearest neighbours of each         !
    ! k-point, and therefore provides the information required to      !
    ! calculate the M_mn(k,b) matrix elements -- Marzari & Vanderbilt  !
    ! PRB 56, 12847 (1997) Eq. (25) -- for each pair of band indices   !
    ! m and n.                                                         !
    !==================================================================!

    use w90_io, only: io_date, io_stopwatch_start, io_stopwatch_stop
    use w90_utility, only: utility_recip_lattice_base
    use w90_types, only: kmesh_info_type, kmesh_input_type, &
                         proj_type, print_output_type, timer_list_type

    implicit none

    character(len=*), intent(in)  :: seedname
    integer, allocatable, intent(in) :: exclude_bands(:)
    integer, intent(in) :: num_kpts
    integer, intent(inout) :: num_proj
    logical, intent(in) :: calc_only_A
    logical, intent(in) :: spinors
    logical, intent(in) :: lauto_proj
    real(kind=dp), intent(in) :: kpt_latt(:, :)
    real(kind=dp), intent(in) :: real_lattice(3, 3)
    type(kmesh_info_type), intent(in) :: kmesh_info
    type(print_output_type), intent(in) :: print_output
    type(proj_type), allocatable, intent(in) :: proj(:) ! alloc only because allocation status is tested
    type(timer_list_type), intent(inout) :: timer

    real(kind=dp) :: recip_lattice(3, 3), volume
    integer           :: i, nkp, nn, nnkpout, num_exclude_bands
    character(len=9) :: cdate, ctime

    if (print_output%timing_level > 0) call io_stopwatch_start('kmesh: write', timer)

    open (newunit=nnkpout, file=trim(seedname)//'.nnkp', form='formatted')

    ! Date and time
    call io_date(cdate, ctime)
    write (nnkpout, '(4(a),/)') '# File written on ', cdate, ' at ', ctime

    ! Calc_only_A
    write (nnkpout, '(a,l2,/)') 'calc_only_A  : ', calc_only_A

    ! Real lattice
    write (nnkpout, '(a)') 'begin real_lattice'
    write (nnkpout, '(3(f12.7))') (real_lattice(1, i), i=1, 3)
    write (nnkpout, '(3(f12.7))') (real_lattice(2, i), i=1, 3)
    write (nnkpout, '(3(f12.7))') (real_lattice(3, i), i=1, 3)
    write (nnkpout, '(a/)') 'end real_lattice'

    ! Reciprocal lattice
    call utility_recip_lattice_base(real_lattice, recip_lattice, volume)
    write (nnkpout, '(a)') 'begin recip_lattice'
    write (nnkpout, '(3f12.7)') (recip_lattice(1, i), i=1, 3)
    write (nnkpout, '(3f12.7)') (recip_lattice(2, i), i=1, 3)
    write (nnkpout, '(3f12.7)') (recip_lattice(3, i), i=1, 3)
    write (nnkpout, '(a/)') 'end recip_lattice'

    ! K-points
    write (nnkpout, '(a)') 'begin kpoints'
    write (nnkpout, '(i6)') num_kpts
    do nkp = 1, num_kpts
      write (nnkpout, '(3f14.8)') (kpt_latt(i, nkp), i=1, 3)
    end do
    write (nnkpout, '(a/)') 'end kpoints'

    if (spinors) then
      ! Projections
      write (nnkpout, '(a)') 'begin spinor_projections'
      if (allocated(proj)) then
        write (nnkpout, '(i6)') num_proj
        do i = 1, num_proj
          write (nnkpout, '(3(f10.5,1x),2x,3i3)') &
            proj(i)%site(1), proj(i)%site(2), proj(i)%site(3), &
            proj(i)%l, proj(i)%m, proj(i)%radial
          write (nnkpout, '(2x,3f11.7,1x,3f11.7,1x,f7.2)') &
            proj(i)%z(1), proj(i)%z(2), proj(i)%z(3), &
            proj(i)%x(1), proj(i)%x(2), proj(i)%x(3), &
            proj(i)%zona
          write (nnkpout, '(2x,1i3,1x,3f11.7)') &
            proj(i)%s, &
            proj(i)%s_qaxis(1), proj(i)%s_qaxis(2), proj(i)%s_qaxis(3)
        end do
      else
        ! No projections
        write (nnkpout, '(i6)') 0
      end if
      write (nnkpout, '(a/)') 'end spinor_projections'
    else
      ! Projections
      write (nnkpout, '(a)') 'begin projections'
      if (allocated(proj)) then
        write (nnkpout, '(i6)') num_proj
        do i = 1, num_proj
          write (nnkpout, '(3(f10.5,1x),2x,3i3)') &
            proj(i)%site(1), proj(i)%site(2), proj(i)%site(3), &
            proj(i)%l, proj(i)%m, proj(i)%radial
          write (nnkpout, '(2x,3f11.7,1x,3f11.7,1x,f7.2)') &
            proj(i)%z(1), proj(i)%z(2), proj(i)%z(3), &
            proj(i)%x(1), proj(i)%x(2), proj(i)%x(3), &
            proj(i)%zona
        end do
      else
        ! No projections
        write (nnkpout, '(i6)') 0
      end if
      write (nnkpout, '(a/)') 'end projections'
    end if

    ! Info for automatic generation of projections
    if (lauto_proj) then
      write (nnkpout, '(a)') 'begin auto_projections'
      write (nnkpout, '(i6)') num_proj
      write (nnkpout, '(i6)') 0
      write (nnkpout, '(a/)') 'end auto_projections'
    end if

    ! Nearest neighbour k-points
    write (nnkpout, '(a)') 'begin nnkpts'
    write (nnkpout, '(i4)') kmesh_info%nntot
    do nkp = 1, num_kpts
      do nn = 1, kmesh_info%nntot
        write (nnkpout, '(2i8,3x,3i4)') &
          nkp, kmesh_info%nnlist(nkp, nn), (kmesh_info%nncell(i, nkp, nn), i=1, 3)
      end do
    end do
    write (nnkpout, '(a/)') 'end nnkpts'

    !states to exclude
    num_exclude_bands = 0
    if (allocated(exclude_bands)) num_exclude_bands = size(exclude_bands)
    write (nnkpout, '(a)') 'begin exclude_bands'
    write (nnkpout, '(i4)') num_exclude_bands
    if (num_exclude_bands > 0) then
      do i = 1, num_exclude_bands
        write (nnkpout, '(i4)') exclude_bands(i)
      end do
    end if
    write (nnkpout, '(a)') 'end exclude_bands'

    close (nnkpout)

    if (print_output%timing_level > 0) call io_stopwatch_stop('kmesh: write', timer)

    return

  end subroutine kmesh_write