-
Notifications
You must be signed in to change notification settings - Fork 0
/
vasp_bands_kpath.f90
238 lines (134 loc) · 4.61 KB
/
vasp_bands_kpath.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
!programa para ler a saida das bandas do vasp e gerar o dat para plotar as bandas
!gfortran vasp_bands_kpath.f90 -o vbands_k.x
! vbands_k.x 6 >bands.dat
program main
implicit none
integer :: nbands,nkpoints
double precision :: flag
double precision,allocatable,dimension(:,:,:) :: energies
integer :: i,j,k,l,erro
integer :: nptpath,ntrechos,nptrechos
double precision,allocatable,dimension(:,:) :: kpt
double precision,dimension(3,3) :: latvec
double precision,allocatable,dimension(:) :: kpathp
!variaveis getarg
character*30 arg
integer ios
! INPUT : lendo os parametros do modelo de tight-binding
OPEN(UNIT=100, FILE= "EIGENVAL",STATUS='old', IOSTAT=erro)
if (erro/=0) stop "Erro na abertura do arquivo de entrada 1"
OPEN(UNIT=101, FILE= "KPOINTS",STATUS='old', IOSTAT=erro)
if (erro/=0) stop "Erro na abertura do arquivo de entrada 2"
OPEN(UNIT=102, FILE= "POSCAR",STATUS='old', IOSTAT=erro)
if (erro/=0) stop "Erro na abertura do arquivo de entrada 3"
CALL getarg(1, arg)
read(arg,*,iostat=ios) nptpath
ntrechos=nptpath/2
!lendo EIGENVAL
do i=1,5
read(100,*)
end do
read(100,*) flag,nkpoints,nbands
allocate(energies(nkpoints,nbands,2))
do i=1,nkpoints
read(100,*) flag,flag,flag,flag
do j=1,nbands
energies(i,j,1) = dble(i)
read(100,*) flag,energies(i,j,2),flag
end do
end do
!termino leitura EIGENVAL
!inicio leitura KPOINTS
read(101,*)
read(101,*) nptrechos
read(101,*)
read(101,*)
allocate(kpt(nptpath,3))
do i=1,nptpath
read(101,*) kpt(i,1),kpt(i,2),kpt(i,3)
end do
!termino leitura KPOINTS
!inicio leitura POSCAR
read(102,*)
read(102,*)
read(102,*) latvec(1,1),latvec(1,2),latvec(1,3)
read(102,*) latvec(2,1),latvec(2,2),latvec(2,3)
read(102,*) latvec(3,1),latvec(3,2),latvec(3,3)
!termino leitura POSCAR
allocate(kpathp((nptpath/2)*nptrechos))
call kpath2(latvec(1,:),latvec(2,:),latvec(3,:),nptpath,kpt,nptrechos,kpathp)
do j=1,nbands
do i=1,nkpoints
write(*,*) kpathp(i),energies(i,j,2)
end do
write(*,*)
end do
deallocate(energies)
deallocate(kpt)
close(100)
close(101)
close(102)
end program main
!subrotinas auxiliares
subroutine kpath2(rlat1,rlat2,rlat3,nks,ks,npts,kpt)
implicit none
integer :: i,j
integer :: nks,npts
double precision,dimension(3) :: rlat1,rlat2,rlat3
double precision,dimension(3) :: blat1,blat2,blat3
double precision,dimension((nks/2)*npts) :: kpt
double precision,dimension(nks,3) :: ks
double precision,dimension(nks,3) :: ksaux
double precision,dimension(nks/2) :: kdis !distancia entre os pontos k do caminho
double precision :: kdistot !soma do caminho todo
double precision :: kdisaux
call recvec(rlat1,rlat2,rlat3,blat1,blat2,blat3)
do i=1,nks
ksaux(i,1) = ks(i,1)*blat1(1)+ks(i,2)*blat2(1)+ks(i,3)*blat3(1)
ksaux(i,2) = ks(i,1)*blat1(2)+ks(i,2)*blat2(2)+ks(i,3)*blat3(2)
ksaux(i,3) = ks(i,1)*blat1(3)+ks(i,2)*blat2(3)+ks(i,3)*blat3(3)
end do
kdistot= 0.0
do i=1,nks/2
call distvec(ksaux(2*i,:),ksaux(2*i-1,:),kdis(i))
!kdis(i)=sqrt((ksaux(2*i,1)-ksaux(2*i-1,1))**2+(ksaux(2*i,2)-ksaux(2*i-1,2))**2+(ksaux(2*i,3)-ksaux(2*i-1,3))**2)
kdistot=kdistot+kdis(i)
end do
kdis=kdis/kdistot
kdisaux=0.0
do j=1,nks/2
do i=1,npts
!kpt((j-1)*npts+i) = (kdisaux)+(kdis(j))*dble((i)/(npts))
kpt((j-1)*npts+i) = (kdisaux)+(kdis(j))*(i-1.)/(npts-1.)
end do
kdisaux=kdisaux+kdis(j)
end do
end subroutine kpath2
subroutine distvec(vec1,vec2,distvecout) !subroutina para calcular a distância entre dois vetores
implicit none
double precision,dimension(3) :: vec1,vec2
double precision :: distvecout
distvecout=sqrt((vec1(1)-vec2(1))**2+(vec1(2)-vec2(2))**2+(vec1(3)-vec2(3))**2)
end subroutine distvec
subroutine recvec(rlat1,rlat2,rlat3,blat1,blat2,blat3) !calcula os vetores da rede recíproca, a partir dos vetores da rede real
implicit none
double precision,parameter :: pi=acos(-1.)
double precision,dimension(3) :: rlat1,rlat2,rlat3
double precision,dimension(3) :: blat1,blat2,blat3
double precision,dimension(3) :: v23,v31,v12
double precision :: vol
call prodvec(rlat2,rlat3,v23)
call prodvec(rlat3,rlat1,v31)
call prodvec(rlat1,rlat2,v12)
vol= (rlat1(1)*v23(1))+(rlat1(2)*v23(2))+(rlat1(3)*v23(3))
blat1 = ((2.0*pi)/vol)*v23
blat2 = ((2.0*pi)/vol)*v31
blat3 = ((2.0*pi)/vol)*v12
end subroutine recvec
subroutine prodvec(v1,v2,vx) !calcula o vetor oriundo do produto vetorial entre dois vetores v1 X v2
implicit none
double precision,dimension(3) :: v1,v2,vx
vx(1) = (v1(2)*v2(3))-(v1(3)*v2(2))
vx(2) = (v1(3)*v2(1))-(v1(1)*v2(3))
vx(3) = (v1(1)*v2(2))-(v1(2)*v2(1))
end subroutine prodvec