-
Notifications
You must be signed in to change notification settings - Fork 0
/
vasp_gap_vbm-finder_sp.f90
414 lines (242 loc) · 6.78 KB
/
vasp_gap_vbm-finder_sp.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
!programa para achar o bandgap
!gfortran vasp_gap_vbm-finder_sp.f90 -o gapf_sp.x
program main
implicit none
integer :: nbands,nkpts
integer :: erro
integer :: i,j
double precision :: flag
double precision,allocatable,dimension(:,:) :: kpt
integer,allocatable,dimension(:) :: nocp,nocp2
double precision,allocatable,dimension(:,:,:) :: energy
double precision :: gapdir,cbm,vbm
integer :: cbmkpt,vbmkpt,gapdirkpt
double precision :: gaux,vaux,caux
double precision :: gapdir2,cbm2,vbm2
integer :: cbmkpt2,vbmkpt2,gapdirkpt2
double precision :: gaux2,vaux2,caux2
integer :: gapdirkptf
double precision :: gapfaux
double precision :: gapdirf,cbmf,vbmf
double precision :: cbmdir,vbmdir
double precision,parameter :: ocptol=0.05
!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"
! OUTPUT : lendo os parametros do modelo de tight-binding
OPEN(UNIT=200, FILE= "gap_vasp_sp.dat",STATUS='unknown', IOSTAT=erro)
if (erro/=0) stop "Erro na abertura do arquivo de saida 1"
! CALL getarg(1, arg)
! read(arg,*,iostat=ios) nbands
!CALL getarg(2, arg)
! read(arg,*,iostat=ios) nkpts
!nbands=20
!nkpts=27
do i=1,5
read(100,*)
end do
read(100,*) flag,nkpts,nbands
allocate(kpt(nkpts,3),nocp(nkpts),energy(nkpts,nbands,4))
allocate(nocp2(nkpts))
!lendo os valores de energia nos pontos k
do i=1,nkpts
read(100,*) kpt(i,1),kpt(i,2),kpt(i,3),flag
do j=1,nbands
read(100,*) flag,energy(i,j,1),energy(i,j,2),energy(i,j,3),energy(i,j,4)
end do
end do
!termino da leitura
!####################### parte spin 1
!identificando a primeira banda desocupada de cada ponto k - spin 1
do i=1,nkpts
do j=1,nbands
if (energy(i,j,3) .lt. 1.0) then
nocp(i)=j
go to 50
else
continue
end if
end do
50 continue
end do
!termino
gapdir=500
cbm=500
vbm=-500
!calculando os gaps
!teste metalico
do i=1,nkpts
if ( (energy(i,nocp(i),3) .gt. 0.0) .and. (energy(i,nocp(i),3) .lt. 1.0-ocptol)) then
go to 70
else
continue
end if
end do
!fim teste metalico
cbmkpt=1
vbmkpt=1
gapdirkpt=1
do i=1,nkpts
if (energy(i,nocp(i),1) .lt. cbm) then
cbm=energy(i,nocp(i),1)
cbmkpt=i
else
continue
end if
if (energy(i,nocp(i)-1,1) .gt. vbm) then
vbm=energy(i,nocp(i)-1,1)
vbmkpt=i
else
continue
end if
gaux=energy(i,nocp(i),1)-energy(i,nocp(i)-1,1)
if (gaux .lt. gapdir) then
gapdir=gaux
gapdirkpt=i
else
end if
end do
write(200,*) "spin 1"
write(200,*) "spin 1 gap direto:",real(gapdir)
write(200,*) "spin 1 gap indireto", real(cbm-vbm)
write(200,*)
write(200,*) "spin 1 cbm", real(cbm)
write(200,*) "spin 1 vbm", real(vbm)
write(200,*)
write(200,*) "spin 1 ponto k cbm:",real(kpt(cbmkpt,1)),real(kpt(cbmkpt,2)),real(kpt(cbmkpt,3))
write(200,*) "spin 1 ponto k vbm:",real(kpt(vbmkpt,1)),real(kpt(vbmkpt,2)),real(kpt(vbmkpt,3))
write(200,*)
write(200,*) "spin 1 ponto k gap direto:",real(kpt(gapdirkpt,1)),real(kpt(gapdirkpt,2)),real(kpt(gapdirkpt,3))
write(200,*) "spin 1 gp dir cb:", real(energy(gapdirkpt,nocp(gapdirkpt),1))
write(200,*) "spin 1 gp dir vb:",real(energy(gapdirkpt,nocp(gapdirkpt)-1,1))
go to 60
70 write(200,*) "sistema metalico"
60 continue
!####################### parte spin 2
!identificando a primeira banda desocupada de cada ponto k - spin 2
do i=1,nkpts
do j=1,nbands
if (energy(i,j,4) .lt. 1.0) then
nocp2(i)=j
go to 100
else
continue
end if
end do
100 continue
end do
gapdir2=500
cbm2=500
vbm2=-500
!calculando os gaps
!teste metalico
do i=1,nkpts
if ( (energy(i,nocp2(i),4) .gt. 0.0) .and. (energy(i,nocp2(i),4) .lt. 1.0-ocptol)) then
go to 140
else
continue
end if
end do
!fim teste metalico
cbmkpt2=1
vbmkpt2=1
gapdirkpt2=1
do i=1,nkpts
if (energy(i,nocp2(i),2) .lt. cbm2) then
cbm2=energy(i,nocp2(i),2)
cbmkpt2=i
else
continue
end if
if (energy(i,nocp2(i)-1,2) .gt. vbm2) then
vbm2=energy(i,nocp2(i)-1,2)
vbmkpt2=i
else
continue
end if
gaux2=energy(i,nocp2(i),2)-energy(i,nocp2(i)-1,2)
if (gaux2 .lt. gapdir2) then
gapdir2=gaux2
gapdirkpt2=i
else
end if
end do
write(200,*) " "
write(200,*) "spin 2"
write(200,*) "spin 2 gap direto:",real(gapdir2)
write(200,*) "spin 2 gap indireto", real(cbm2-vbm2)
write(200,*)
write(200,*) "spin 2 cbm", real(cbm2)
write(200,*) "spin 2 vbm", real(vbm2)
write(200,*)
write(200,*) "spin 2 ponto k cbm:",real(kpt(cbmkpt2,1)),real(kpt(cbmkpt2,2)),real(kpt(cbmkpt2,3))
write(200,*) "spin 2 ponto k vbm:",real(kpt(vbmkpt2,1)),real(kpt(vbmkpt2,2)),real(kpt(vbmkpt2,3))
write(200,*)
write(200,*) "spin 2 ponto k gap direto:",real(kpt(gapdirkpt2,1)),real(kpt(gapdirkpt2,2)),real(kpt(gapdirkpt2,3))
write(200,*) "spin 2 gp dir cb:", real(energy(gapdirkpt2,nocp2(gapdirkpt2),2))
write(200,*) "spin 2 gp dir vb:",real(energy(gapdirkpt2,nocp2(gapdirkpt2)-1,2))
write(200,*) " "
!definindo gap e gap dir completo
if ( cbm .gt. cbm2) then
cbmf= cbm2
else
cbmf= cbm
end if
if ( vbm .gt. vbm2) then
vbmf= vbm
else
vbmf= vbm2
end if
write(200,*) "gap indireto", real(cbmf-vbmf)
! if ( gapdirkpt2 .eq. gapdirkpt) then
! if (real(energy(gapdirkpt2,nocp2(gapdirkpt2),2)) .gt. real(energy(gapdirkpt,nocp(gapdirkpt),1))) then
! cbmdir= energy(gapdirkpt,nocp(gapdirkpt),1)
! else
! cbmdir= energy(gapdirkpt2,nocp2(gapdirkpt2),2)
! end if
! if (real(energy(gapdirkpt2,nocp2(gapdirkpt2)-1,2)) .gt. real(energy(gapdirkpt,nocp(gapdirkpt)-1,1))) then
! vbmdir= energy(gapdirkpt2,nocp2(gapdirkpt2)-1,2)
! else
! vbmdir= energy(gapdirkpt2,nocp2(gapdirkpt2)-1,1)
! end if
! write(200,*) "gap direto", real(cbmdir-vbmdir)
! else
! if (gapdir .gt. gapdir2) then
! write(200,*) "gap direto s2", real(gapdir2)
! else
! write(200,*) "gap direto s1", real(gapdir)
! end if
! end if
gapdirf=500
gapdirkptf=1
do i=1,nkpts
if (energy(i,nocp2(i),2) .gt. energy(i,nocp(i),1)) then
cbmdir = energy(i,nocp(i),1)
else
cbmdir = energy(i,nocp2(i),2)
end if
if (energy(i,nocp2(i)-1,2) .gt. energy(i,nocp(i)-1,1)) then
vbmdir = energy(i,nocp2(i)-1,2)
else
vbmdir = energy(i,nocp(i)-1,1)
end if
gapfaux= cbmdir-vbmdir
if (gapfaux .lt. gapdirf) then
gapdirf=gapfaux
gapdirkptf=i
else
end if
end do
write(200,*) "gap direto",real(gapdirf)
write(200,*) " "
write(200,*) "ponto k gap direto:",real(kpt(gapdirkptf,1)),real(kpt(gapdirkptf,2)),real(kpt(gapdirkptf,3))
go to 120
140 write(200,*) "sistema metalico"
120 continue
deallocate(kpt,nocp,energy,nocp2)
close(100)
close(200)
end program main