Skip to content

Commit

Permalink
wannier90 file reader done, DANGER: under test
Browse files Browse the repository at this point in the history
  • Loading branch information
nnardoto committed Sep 18, 2024
1 parent 17bc70d commit 7120b81
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
55 changes: 48 additions & 7 deletions utility/wannier2xatu/utils.f90
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
module utils
public :: LoadSystem
public :: Export2Xatu

private
character(len=:), allocatable :: FileName
!integer, allocatable :: iRn(:,:)
!real(kind = 8), allocatable :: H(:,:,:)
character(len=:), allocatable :: FileName
integer :: nFock, mSize
integer, allocatable :: Degen(:)
real(kind = 8) :: Rn(3, 3)
integer, allocatable :: iRn(:,:)
complex(kind = 8), allocatable :: H(:,:,:)
!VARIAVEL PARA O MOTIF

!todo
!w90 hamiltoniana
!.model hamiltoniana

contains
subroutine LoadArguments()
implicit none
integer N

call get_command_argument(1, length = N)
allocate(character(N) :: FileName)
call get_command_argument(1, FileName)
Expand All @@ -24,11 +27,49 @@ subroutine LoadArguments()
end subroutine LoadArguments

subroutine LoadSystem
integer :: fp, ii, jj, i, j
real(kind = 8) :: R, Im

!read filename by terminal arguments
call LoadArguments()

!! Implementar a leitura do arquivo wannier90 aqui
end subroutine
! open as newunit
open(action = 'read', file=FileName, newunit = fp)
read(fp, *)
read(fp, *) Rn(1, :)
read(fp, *) Rn(2, :)
read(fp, *) Rn(3, :)
read(fp, *) mSize
read(fp, *) nFock

! time to allocate
allocate(H(nFock, mSize, mSize))
allocate(degen(nFock))
allocate(iRn(nFock, 3))

! degen read, 15 elements by line
do i = 1, (nFock / 15)
read(fp, *) Degen((i - 1)*15 + 1:(i - 1)*15 + 15)
enddo

! Last line of degenerecences
read(fp, *) Degen((i - 1)*15 + 1:(i - 1)*15 + MOD(nFock, 15))
read(fp, *)

! begin hamiltonian read
do i = 1, nFock
read(fp, *) iRn(i, :)
do j = 1, mSize*mSize
read(fp, *) ii, jj, R, Im
H(i, ii, jj) = complex(R, Im)
enddo
if (i < nFock) read(fp, *)
enddo
close(fp)

end subroutine LoadSystem

!! Implementar a escrita do xatu.model aqui
subroutine Export2Xatu()
end subroutine
end module utils
Binary file removed utility/wannier2xatu/utils.mod
Binary file not shown.

0 comments on commit 7120b81

Please sign in to comment.