tran_get_ht Subroutine

private subroutine tran_get_ht(fermi_energy_list, transport, hB0, hB1, hr_one_dim, irvec_max, num_pl, num_wann, timing_level, seedname, timer, error, comm)

Uses

  • proc~~tran_get_ht~~UsesGraph proc~tran_get_ht tran_get_ht module~w90_constants w90_constants proc~tran_get_ht->module~w90_constants module~w90_error w90_error proc~tran_get_ht->module~w90_error module~w90_io w90_io proc~tran_get_ht->module~w90_io module~w90_types w90_types proc~tran_get_ht->module~w90_types module~w90_wannier90_types w90_wannier90_types proc~tran_get_ht->module~w90_wannier90_types module~w90_comms w90_comms module~w90_error->module~w90_comms module~w90_error_base w90_error_base module~w90_error->module~w90_error_base module~w90_io->module~w90_constants module~w90_types->module~w90_constants module~w90_wannier90_types->module~w90_constants module~w90_comms->module~w90_constants module~w90_comms->module~w90_error_base

Construct h00 and h01

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in), allocatable :: fermi_energy_list(:)
type(transport_type), intent(inout) :: transport
real(kind=dp), intent(inout), allocatable :: hB0(:,:)
real(kind=dp), intent(inout), allocatable :: hB1(:,:)
real(kind=dp), intent(in) :: hr_one_dim(:,:,-irvec_max:)
integer, intent(in) :: irvec_max
integer, intent(in) :: num_pl
integer, intent(in) :: num_wann
integer, intent(in) :: timing_level
character(len=50), intent(in) :: seedname
type(timer_list_type), intent(inout) :: timer
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~tran_get_ht~~CallsGraph proc~tran_get_ht tran_get_ht proc~io_date io_date proc~tran_get_ht->proc~io_date proc~io_stopwatch_start io_stopwatch_start proc~tran_get_ht->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~tran_get_ht->proc~io_stopwatch_stop proc~set_error_alloc set_error_alloc proc~tran_get_ht->proc~set_error_alloc proc~set_error_fatal set_error_fatal proc~tran_get_ht->proc~set_error_fatal proc~comms_sync_error comms_sync_error proc~set_error_alloc->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_alloc->proc~set_base_error proc~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error

Called by

proc~~tran_get_ht~~CalledByGraph proc~tran_get_ht tran_get_ht proc~tran_main tran_main proc~tran_main->proc~tran_get_ht proc~w90_transport w90_transport proc~w90_transport->proc~tran_main program~wannier wannier program~wannier->proc~w90_transport

Source Code

  subroutine tran_get_ht(fermi_energy_list, transport, hB0, hB1, hr_one_dim, irvec_max, num_pl, &
                         num_wann, timing_level, seedname, timer, error, comm)
    !================================================!
    !
    !!  Construct h00 and h01
    !
    !================================================!

    use w90_constants, only: dp
    use w90_io, only: io_stopwatch_start, io_stopwatch_stop, io_date
    use w90_wannier90_types, only: transport_type
    use w90_error, only: w90_error_type, set_error_alloc, set_error_fatal
    use w90_types, only: timer_list_type

    implicit none

    ! arguments
    real(kind=dp), allocatable, intent(in) :: fermi_energy_list(:)
    type(transport_type), intent(inout) :: transport
    type(timer_list_type), intent(inout) :: timer
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    integer, intent(in) :: num_pl
    integer, intent(in) :: num_wann
    integer, intent(in) :: irvec_max
    integer, intent(in) :: timing_level

    real(kind=dp), intent(in) :: hr_one_dim(:, :, -irvec_max:)
    real(kind=dp), allocatable, intent(inout) :: hB0(:, :)
    real(kind=dp), allocatable, intent(inout) :: hB1(:, :)

    character(len=50), intent(in)  :: seedname

    ! local variables
    integer :: ierr, file_unit
    integer :: i, j, n1, im, jm
    integer :: fermi_n
    character(len=9) :: cdate, ctime

    if (timing_level > 1) call io_stopwatch_start('tran: get_ht', timer)

    fermi_n = 0
    if (allocated(fermi_energy_list)) fermi_n = size(fermi_energy_list)
    if (fermi_n > 1) then
      call set_error_fatal(error, "Error in tran_get_ht: nfermi>1. " &
                           //"Set the fermi level using the input parameter 'fermi_evel'", comm)
      return
    end if

    transport%num_bb = num_pl*num_wann

    allocate (hB0(transport%num_bb, transport%num_bb), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating hB0 in tran_get_ht', comm)
      return
    end if
    allocate (hB1(transport%num_bb, transport%num_bb), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating hB1 in tran_get_ht', comm)
      return
    end if

    hB0 = 0.0_dp
    hB1 = 0.0_dp

    ! h00
    do j = 0, num_pl - 1
      do i = 0, num_pl - 1
        n1 = i - j
        im = i*num_wann
        jm = j*num_wann
        hB0(jm + 1:jm + num_wann, im + 1:im + num_wann) = hr_one_dim(:, :, n1)
      end do
    end do

    ! h01
    do j = 1, num_pl
      do i = 0, j - 1
        n1 = i - (j - 1) + num_pl
        im = i*num_wann
        jm = (j - 1)*num_wann
        hB1(jm + 1:jm + num_wann, im + 1:im + num_wann) = hr_one_dim(:, :, n1)
      end do
    end do

    ! shift by fermi_energy
    do i = 1, transport%num_bb
      hB0(i, i) = hB0(i, i) - fermi_energy_list(1)
    end do

    if (transport%write_ht) then

      open (newunit=file_unit, file=trim(seedname)//'_htB.dat', status='unknown', form='formatted', &
            action='write')

      call io_date(cdate, ctime)
      write (file_unit, *) 'written on '//cdate//' at '//ctime ! Date and time
      write (file_unit, '(I6)') transport%num_bb
      write (file_unit, '(6F12.6)') ((hB0(j, i), j=1, transport%num_bb), i=1, transport%num_bb)
      write (file_unit, '(I6)') transport%num_bb
      write (file_unit, '(6F12.6)') ((hB1(j, i), j=1, transport%num_bb), i=1, transport%num_bb)

      close (file_unit)

    end if

    if (timing_level > 1) call io_stopwatch_stop('tran: get_ht', timer)

    return

  end subroutine tran_get_ht