hamiltonian_write_tb Subroutine

public subroutine hamiltonian_write_tb(ham_r, pos_r, real_lattice, irvec, ndegen, nrpts, num_wann, timing_level, seedname, timer, error, comm)

Uses

  • proc~~hamiltonian_write_tb~~UsesGraph proc~hamiltonian_write_tb hamiltonian_write_tb module~w90_io w90_io proc~hamiltonian_write_tb->module~w90_io module~w90_constants w90_constants module~w90_io->module~w90_constants

Write in a single file all the information that is needed to set up a Wannier-based tight-binding model: * lattice vectors * <0n|H|Rn> * <0n|r|Rn>

Arguments

Type IntentOptional Attributes Name
complex(kind=dp), intent(in) :: ham_r(:,:,:)
complex(kind=dp), intent(in) :: pos_r(:,:,:,:)
real(kind=dp), intent(in) :: real_lattice(3,3)
integer, intent(in) :: irvec(:,:)
integer, intent(in) :: ndegen(:)
integer, intent(in) :: nrpts
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~~hamiltonian_write_tb~~CallsGraph proc~hamiltonian_write_tb hamiltonian_write_tb proc~io_date io_date proc~hamiltonian_write_tb->proc~io_date proc~io_stopwatch_start io_stopwatch_start proc~hamiltonian_write_tb->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~hamiltonian_write_tb->proc~io_stopwatch_stop proc~set_error_file set_error_file proc~hamiltonian_write_tb->proc~set_error_file proc~comms_sync_error comms_sync_error proc~set_error_file->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_file->proc~set_base_error

Called by

proc~~hamiltonian_write_tb~~CalledByGraph proc~hamiltonian_write_tb hamiltonian_write_tb proc~plot_main plot_main proc~plot_main->proc~hamiltonian_write_tb proc~w90_plot w90_plot proc~w90_plot->proc~plot_main program~wannier wannier program~wannier->proc~w90_plot

Source Code

  subroutine hamiltonian_write_tb(ham_r, pos_r, real_lattice, irvec, ndegen, nrpts, num_wann, &
                                  timing_level, seedname, timer, error, comm)
    !================================================!
    !! Write in a single file all the information
    !! that is needed to set up a Wannier-based
    !! tight-binding model:
    !! * lattice vectors
    !! * <0n|H|Rn>
    !! * <0n|r|Rn>
    !================================================!

    use w90_io, only: io_stopwatch_start, io_stopwatch_stop, io_date

    ! arguments
    type(timer_list_type), intent(inout) :: timer
    type(w90_comm_type), intent(in) :: comm
    type(w90_error_type), allocatable, intent(out) :: error

    integer, intent(in) :: ndegen(:)
    integer, intent(in) :: num_wann
    integer, intent(in) :: irvec(:, :)
    integer, intent(in) :: nrpts
    integer, intent(in) :: timing_level

    real(kind=dp), intent(in) :: real_lattice(3, 3)

    complex(kind=dp), intent(in) :: ham_r(:, :, :)
    complex(kind=dp), intent(in) :: pos_r(:, :, :, :)

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

    ! local variables
    integer :: ierr
    integer :: i, j, irpt, file_unit
    character(len=33) :: header
    character(len=9) :: cdate, ctime

    if (timing_level > 1) call io_stopwatch_start('hamiltonian: write_tb', timer)

    open (newunit=file_unit, file=trim(seedname)//'_tb.dat', form='formatted', status='unknown', &
          iostat=ierr)
    if (ierr /= 0) then
      call set_error_file(error, 'Error: hamiltonian_write_tb: problem opening file '//trim(seedname)//'_tb.dat', comm)
      return
    end if

    call io_date(cdate, ctime)
    header = 'written on '//cdate//' at '//ctime

    write (file_unit, *) header ! Date and time
    !
    ! lattice vectors
    !
    write (file_unit, *) real_lattice(1, :) !a_1
    write (file_unit, *) real_lattice(2, :) !a_2
    write (file_unit, *) real_lattice(3, :) !a_3
    !
    write (file_unit, *) num_wann
    write (file_unit, *) nrpts
    write (file_unit, '(15I5)') (ndegen(i), i=1, nrpts)
    !
    ! <0n|H|Rm>
    !
    do irpt = 1, nrpts
      write (file_unit, '(/,3I5)') irvec(:, irpt)
      do i = 1, num_wann
        do j = 1, num_wann
          write (file_unit, '(2I5,3x,2(E15.8,1x))') j, i, ham_r(j, i, irpt)
        end do
      end do
    end do
    !
    ! <0n|r|Rm>
    !
    do irpt = 1, nrpts
      write (file_unit, '(/,3I5)') irvec(:, irpt)
      do i = 1, num_wann
        do j = 1, num_wann
          write (file_unit, '(2I5,3x,6(E15.8,1x))') j, i, pos_r(j, i, irpt, :)
        end do
      end do
    end do

    close (file_unit)
    if (timing_level > 1) call io_stopwatch_stop('hamiltonian: write_tb', timer)
  end subroutine hamiltonian_write_tb