Plot u_matrix and u_matrix_opt to textfiles in readable format
subroutine plot_u_matrices
!============================================!
! !
!! Plot u_matrix and u_matrix_opt to textfiles in readable format
! !
!============================================!
use w90_parameters, only: num_bands, num_kpts, num_wann, have_disentangled, &
kpt_latt, u_matrix, u_matrix_opt
use w90_io, only: io_error, stdout, io_file_unit, seedname, &
io_time, io_stopwatch, io_date
implicit none
integer :: matunit
integer :: i, j, nkp
character(len=33) :: header
character(len=9) :: cdate, ctime
call io_date(cdate, ctime)
header = 'written on '//cdate//' at '//ctime
matunit = io_file_unit()
open (matunit, file=trim(seedname)//'_u.mat', form='formatted')
write (matunit, *) header
write (matunit, *) num_kpts, num_wann, num_wann
do nkp = 1, num_kpts
write (matunit, *)
write (matunit, '(f15.10,sp,f15.10,sp,f15.10)') kpt_latt(:, nkp)
write (matunit, '(f15.10,sp,f15.10)') ((u_matrix(i, j, nkp), i=1, num_wann), j=1, num_wann)
end do
close (matunit)
if (have_disentangled) then
matunit = io_file_unit()
open (matunit, file=trim(seedname)//'_u_dis.mat', form='formatted')
write (matunit, *) header
write (matunit, *) num_kpts, num_wann, num_bands
do nkp = 1, num_kpts
write (matunit, *)
write (matunit, '(f15.10,sp,f15.10,sp,f15.10)') kpt_latt(:, nkp)
write (matunit, '(f15.10,sp,f15.10)') ((u_matrix_opt(i, j, nkp), i=1, num_bands), j=1, num_wann)
end do
close (matunit)
endif
end subroutine plot_u_matrices