From 7120b81ba4a4d12941d2cd116f776bc186ef08f3 Mon Sep 17 00:00:00 2001 From: nnardoto Date: Tue, 17 Sep 2024 23:00:31 -0300 Subject: [PATCH] wannier90 file reader done, DANGER: under test --- utility/wannier2xatu/utils.f90 | 55 ++++++++++++++++++++++++++++----- utility/wannier2xatu/utils.mod | Bin 203 -> 0 bytes 2 files changed, 48 insertions(+), 7 deletions(-) delete mode 100644 utility/wannier2xatu/utils.mod diff --git a/utility/wannier2xatu/utils.f90 b/utility/wannier2xatu/utils.f90 index 36bfbad..ddadba6 100644 --- a/utility/wannier2xatu/utils.f90 +++ b/utility/wannier2xatu/utils.f90 @@ -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) @@ -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 diff --git a/utility/wannier2xatu/utils.mod b/utility/wannier2xatu/utils.mod deleted file mode 100644 index 6be38a4d5307f745f6b7896c931857c6fac2ef2a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 203 zcmV;+05ty}iwFP!000001FetC3c^4PMfdX+cQ@@qs0BZucA|(iBVz|~C1OVqS_^Fz z{Cmf@f=fw49+!lZ@kpE8B#f#qj-|uNHSNAWK=ua`+s17=S76uF6+{q(_=k&U5ei@a zh#0c0H${7HJ6B1_W4A9`pC$STg1ONtDQgIpr>vLUn{ZB?W2TkOsCU(&D9yw}N91i` zheq3c!i2<_WVQAUnYE%hu_8`acc#x3Z?6*`_BOerNAGw1FceqlFXRYuC@x`#ncZ6f F002>JTEPGS