Line data Source code
1 : module m_gnuplot_BS
2 : CONTAINS
3 :
4 : !----------------------------------------------------------------------
5 : ! once the file "bands.1" and "bands.2" are created, activate with:
6 : ! gnuplot < band.gnu > band.ps
7 : !----------------------------------------------------------------------
8 2 : SUBROUTINE gnuplot_BS(kpts,title,cell,jspins)
9 : use m_types_cell
10 : use m_types_kpts
11 : IMPLICIT NONE
12 : type(t_kpts),intent(in) :: kpts
13 : type(t_cell),intent(in) :: cell
14 : INTEGER, INTENT (IN) :: jspins
15 : CHARACTER(LEN=*), INTENT(IN) :: title
16 : CHARACTER(len=1) :: ssy
17 : real :: vkr(3),vkr_prev(3)
18 :
19 : INTEGER n,aoff,adel,k
20 : INTEGER numSpecialPoints, addFront, addBack
21 :
22 2 : REAL, ALLOCATABLE :: d(:)
23 2 : REAL, ALLOCATABLE :: specialPoints(:,:)
24 2 : CHARACTER(LEN=50), ALLOCATABLE :: specialPointNames(:)
25 :
26 2 : aoff = iachar('a')-1
27 2 : adel = iachar('a')-iachar('A')
28 : !write(*,*) aoff,adel
29 :
30 2 : numSpecialPoints = kpts%numSpecialPoints
31 2 : addFront = 0
32 2 : addBack = 0
33 :
34 2 : IF (kpts%numSpecialPoints.EQ.0) THEN
35 : numSpecialPoints = 2
36 : addFront = 1
37 : addBack = 1
38 : ELSE
39 2 : IF (kpts%specialPointIndices(1).NE.1) THEN
40 0 : addFront = 1
41 0 : numSpecialPoints = numSpecialPoints + 1
42 : END IF
43 2 : IF (kpts%specialPointIndices(kpts%numSpecialPoints).NE.kpts%nkpt) THEN
44 0 : addBack = 1
45 0 : numSpecialPoints = numSpecialPoints + 1
46 : END IF
47 : END IF
48 :
49 6 : ALLOCATE (specialPoints(3,numSpecialPoints))
50 6 : ALLOCATE (specialPointNames(numSpecialPoints))
51 6 : ALLOCATE (d(numSpecialPoints))
52 2 : IF(addFront.EQ.1) THEN
53 0 : specialPoints(:,1) = kpts%bk(:,1)
54 0 : specialPointNames(1) = '-'
55 : END IF
56 2 : IF(ALLOCATED(kpts%specialPoints)) THEN
57 18 : specialPoints(:,1+addFront:kpts%numSpecialPoints+addFront) = kpts%specialPoints(:,1:kpts%numSpecialPoints)
58 6 : specialPointNames(1+addFront:kpts%numSpecialPoints+addFront) = kpts%specialPointNames(1:kpts%numSpecialPoints)
59 : END IF
60 2 : IF(addBack.EQ.1) THEN
61 0 : specialPoints(:,kpts%numSpecialPoints+addFront+1) = kpts%bk(:,kpts%nkpt)
62 0 : specialPointNames(kpts%numSpecialPoints+addFront+1) = '-'
63 : END IF
64 :
65 :
66 :
67 : !Generate distances
68 2 : d(1)=0.0
69 26 : vkr_prev=matmul(specialPoints(:,1),cell%bmat)
70 4 : DO k=2,numSpecialPoints
71 26 : vkr=matmul(specialPoints(:,k),cell%bmat)
72 8 : d(k)=d(k-1)+sqrt(dot_product(vkr-vkr_prev,vkr-vkr_prev))
73 4 : vkr_prev=vkr
74 : ENDDO
75 :
76 :
77 2 : OPEN (27,file='band.gnu',status='unknown')
78 2 : WRITE (27,900)
79 2 : WRITE (27,901)
80 2 : WRITE (27,902)
81 2 : WRITE (27,903)
82 2 : WRITE (27,'(3a)') 'set title "', TRIM(ADJUSTL(title)), '"'
83 6 : DO n = 1, numSpecialPoints
84 6 : WRITE (27,905) d(n),d(n)
85 : ENDDO
86 2 : WRITE (27,906) d(1),d(size(d))
87 : !
88 : ! nomal labels
89 : !
90 2 : ssy=specialPointNames(1)
91 2 : IF (iachar(ssy) < aoff ) THEN
92 0 : WRITE (27,907) ssy,d(1)
93 : ELSE
94 2 : WRITE (27,907) " ",d(1)
95 : ENDIF
96 2 : DO n = 2, numSpecialPoints-1
97 0 : ssy=specialPointNames(n)
98 2 : IF (iachar(ssy) < aoff ) THEN
99 0 : WRITE (27,908) ssy,d(n)
100 : ELSE
101 0 : WRITE (27,908) " ",d(n)
102 : ENDIF
103 : ENDDO
104 2 : ssy=specialPointNames(n)
105 2 : IF (iachar(ssy) < aoff ) THEN
106 0 : WRITE (27,909) ssy,d(n)
107 : ELSE
108 2 : WRITE (27,909) " ",d(n)
109 : ENDIF
110 :
111 6 : DO n=1,numSpecialPoints
112 4 : ssy=specialPointNames(n)
113 6 : IF (iachar(ssy) > aoff ) THEN
114 4 : WRITE (27,914) achar(iachar(ssy)-adel),d(n)
115 : ENDIF
116 : ENDDO
117 :
118 : !
119 : ! now write the rest
120 2 : WRITE (27,910)
121 2 : WRITE (27,911) d(size(d))+0.00001
122 2 : IF (jspins == 2) WRITE (27,912)
123 2 : WRITE (27,913)
124 2 : CLOSE (27)
125 :
126 2 : DEALLOCATE (d,specialPoints,specialPointNames)
127 :
128 : 900 FORMAT ('set terminal postscript enhanced color "Times-Roman" 20')
129 : 901 FORMAT ('set xlabel ""')
130 : 902 FORMAT ('set ylabel "E - E_F (eV)"')
131 : 903 FORMAT ('set nokey')
132 : 905 FORMAT ('set arrow from',f9.5,', -9.0 to',f9.5,', 5.0 nohead')
133 : 906 FORMAT ('set arrow from',f9.5,', 0.0 to',f9.5,', 0.0 nohead lt 3')
134 : #if (defined(CPP_AIX) || defined(__PGI))
135 : 907 FORMAT ('set xtics ("',a1,'"',f9.5,', \\')
136 : 908 FORMAT (' "',a1,'"',f9.5,', \\')
137 : #else
138 : 907 FORMAT ('set xtics ("',a1,'"',f9.5,', \')
139 : 908 FORMAT (' "',a1,'"',f9.5,', \')
140 : #endif
141 : 909 FORMAT (' "',a1,'"',f9.5,' )')
142 : 910 FORMAT ('set ytics -8,2,4')
143 : #if (defined(CPP_AIX) || defined(__PGI))
144 : 911 FORMAT ('plot [0:',f9.5,'] [-9:5] \\')
145 : 912 FORMAT ('"bands.2" using 1:($2+0.00) w p pt 12 ps 0.5, \\')
146 : #else
147 : 911 FORMAT ('plot [0:',f9.5,'] [-9:5] \')
148 : 912 FORMAT ('"bands.2" using 1:($2+0.00) w p pt 12 ps 0.5, \')
149 : #endif
150 : 913 FORMAT ('"bands.1" using 1:($2+0.00) w p pt 7 ps 0.5')
151 : 914 FORMAT ('set label "',a1,'" at ',f9.5,', -9.65 center font "Symbol,20"')
152 :
153 : !call system("gnuplot <band.gnu >band.ps")
154 :
155 2 : END SUBROUTINE gnuplot_BS
156 :
157 1 : SUBROUTINE write_gnu_sc(banddos,kpts,title,cell,jspins)
158 : use m_types_cell
159 : use m_types_kpts
160 : use m_types_banddos
161 : USE m_inv3
162 : USE m_constants
163 : IMPLICIT NONE
164 : type(t_kpts),intent(in) :: kpts
165 : type(t_cell),intent(in) :: cell
166 : INTEGER, INTENT (IN) :: jspins
167 : type(t_banddos),INTENT(IN) :: banddos
168 : CHARACTER(LEN=*), INTENT(IN) :: title
169 : CHARACTER(len=1) :: ssy
170 : type(t_cell) :: p_cell
171 : real :: vkr(3),vkr_prev(3)
172 :
173 : INTEGER n,aoff,adel,k
174 :
175 : INTEGER numSpecialPoints, addFront, addBack
176 :
177 1 : REAL, ALLOCATABLE :: d(:)
178 1 : REAL, ALLOCATABLE :: specialPoints(:,:)
179 1 : CHARACTER(LEN=50), ALLOCATABLE :: specialPointNames(:)
180 :
181 :
182 1 : numSpecialPoints = kpts%numSpecialPoints
183 1 : addFront = 0
184 1 : addBack = 0
185 :
186 1 : IF (kpts%numSpecialPoints.EQ.0) THEN
187 : numSpecialPoints = 2
188 : addFront = 1
189 : addBack = 1
190 : ELSE
191 1 : IF (kpts%specialPointIndices(1).NE.1) THEN
192 0 : addFront = 1
193 0 : numSpecialPoints = numSpecialPoints + 1
194 : END IF
195 1 : IF (kpts%specialPointIndices(kpts%numSpecialPoints).NE.kpts%nkpt) THEN
196 0 : addBack = 1
197 0 : numSpecialPoints = numSpecialPoints + 1
198 : END IF
199 : END IF
200 :
201 3 : ALLOCATE (specialPoints(3,numSpecialPoints))
202 3 : ALLOCATE (specialPointNames(numSpecialPoints))
203 3 : ALLOCATE (d(numSpecialPoints))
204 1 : IF(addFront.EQ.1) THEN
205 0 : specialPoints(:,1) = kpts%bk(:,1)
206 0 : specialPointNames(1) = '-'
207 : END IF
208 1 : IF(ALLOCATED(kpts%specialPoints)) THEN
209 9 : specialPoints(:,1+addFront:kpts%numSpecialPoints+addFront) = kpts%specialPoints(:,1:kpts%numSpecialPoints)
210 3 : specialPointNames(1+addFront:kpts%numSpecialPoints+addFront) = kpts%specialPointNames(1:kpts%numSpecialPoints)
211 : END IF
212 1 : IF(addBack.EQ.1) THEN
213 0 : specialPoints(:,kpts%numSpecialPoints+addFront+1) = kpts%bk(:,kpts%nkpt)
214 0 : specialPointNames(kpts%numSpecialPoints+addFront+1) = '-'
215 : END IF
216 :
217 1 : aoff = iachar('a')-1
218 1 : adel = iachar('a')-iachar('A')
219 : !write(*,*) aoff,adel
220 :
221 1 : p_cell=cell
222 4 : DO k =1,3
223 3 : p_cell%amat(1,k)=cell%amat(1,k)/banddos%s_cell_x
224 3 : p_cell%amat(2,k)=cell%amat(2,k)/banddos%s_cell_y
225 4 : p_cell%amat(3,k)=cell%amat(3,k)/banddos%s_cell_z
226 : END DO
227 1 : CALL inv3(p_cell%amat,p_cell%bmat,p_cell%omtil)
228 13 : p_cell%bmat=p_cell%bmat*tpi_const
229 :
230 :
231 : !Generate distances
232 1 : d(1)=0.0
233 13 : vkr_prev=matmul(specialPoints(:,1),p_cell%bmat)
234 2 : DO k=2,numSpecialPoints
235 13 : vkr=matmul(specialPoints(:,k),p_cell%bmat)
236 4 : d(k)=d(k-1)+sqrt(dot_product(vkr-vkr_prev,vkr-vkr_prev))
237 2 : vkr_prev=vkr
238 : ENDDO
239 :
240 :
241 1 : OPEN (27,file='band_sc.gnu',status='unknown')
242 1 : WRITE (27,900)
243 1 : WRITE (27,901)
244 1 : WRITE (27,902)
245 1 : WRITE (27,903)
246 1 : WRITE (27,'(3a)') 'set title "', TRIM(ADJUSTL(title)), '"'
247 3 : DO n = 1, numSpecialPoints
248 3 : WRITE (27,905) d(n),d(n)
249 : ENDDO
250 1 : WRITE (27,906) d(1),d(size(d))
251 : !
252 : ! nomal labels
253 : !
254 1 : ssy=specialPointNames(1)
255 1 : IF (iachar(ssy) < aoff ) THEN
256 0 : WRITE (27,907) ssy,d(1)
257 : ELSE
258 1 : WRITE (27,907) " ",d(1)
259 : ENDIF
260 1 : DO n = 2, numSpecialPoints-1
261 0 : ssy=specialPointNames(n)
262 1 : IF (iachar(ssy) < aoff ) THEN
263 0 : WRITE (27,908) ssy,d(n)
264 : ELSE
265 0 : WRITE (27,908) " ",d(n)
266 : ENDIF
267 : ENDDO
268 1 : ssy=specialPointNames(n)
269 1 : IF (iachar(ssy) < aoff ) THEN
270 0 : WRITE (27,909) ssy,d(n)
271 : ELSE
272 1 : WRITE (27,909) " ",d(n)
273 : ENDIF
274 :
275 3 : DO n=1,numSpecialPoints
276 2 : ssy=specialPointNames(n)
277 3 : IF (iachar(ssy) > aoff ) THEN
278 2 : WRITE (27,914) achar(iachar(ssy)-adel),d(n)
279 : ENDIF
280 : ENDDO
281 :
282 : !
283 : ! now write the rest
284 1 : WRITE (27,910)
285 1 : WRITE (27,*) 'set palette model RGB'
286 1 : WRITE (27,*) 'set palette defined (-2 "black", -1 "white" ,0 "white",',achar(92)
287 1 : WRITE (27,*) '0.67 "light-blue",1 "blue")'
288 1 : WRITE (27,*) 'set cbrange [-2:1]'
289 1 : WRITE (27,*) 'unset colorbox'
290 1 : WRITE (27,*) 'size1(x)=0.9*x**(0.4)'
291 1 : WRITE (27,*) 'color1(x)=0.3+x/2.4'
292 1 : WRITE (27,*) 'size2(x)=0.35*(1-x**(0.01))'
293 1 : WRITE (27,*) 'color2(x)=1.15*(x-1)'
294 1 : WRITE (27,*) 'e_f=0.000000 #fermi energy is already corrected when using hdf5'
295 1 : WRITE (27,911) d(size(d))+0.00001
296 1 : IF (jspins == 2) THEN
297 1 : WRITE (27,912)
298 1 : WRITE (27,916)
299 : END IF
300 1 : WRITE (27,913)
301 1 : WRITE (27,915)
302 1 : CLOSE (27)
303 :
304 1 : DEALLOCATE (d,specialPoints,specialPointNames)
305 :
306 : 900 FORMAT ('set terminal postscript enhanced color "Times-Roman" 20')
307 : 901 FORMAT ('set xlabel ""')
308 : 902 FORMAT ('set ylabel "E - E_F (eV)"')
309 : 903 FORMAT ('set nokey')
310 : 905 FORMAT ('set arrow from',f9.5,', -9.0 to',f9.5,', 5.0 nohead')
311 : 906 FORMAT ('set arrow from',f9.5,', 0.0 to',f9.5,', 0.0 nohead lt 3')
312 : #if (defined(CPP_AIX) || defined(__PGI))
313 : 907 FORMAT ('set xtics ("',a1,'"',f9.5,', \\')
314 : 908 FORMAT (' "',a1,'"',f9.5,', \\')
315 : #else
316 : 907 FORMAT ('set xtics ("',a1,'"',f9.5,', \')
317 : 908 FORMAT (' "',a1,'"',f9.5,', \')
318 : #endif
319 : 909 FORMAT (' "',a1,'"',f9.5,' )')
320 : 910 FORMAT ('set ytics -8,2,4')
321 : #if (defined(CPP_AIX) || defined(__PGI))
322 : 911 FORMAT ('plot [0:',f9.5,'] [-9:5] \\')
323 : 912 FORMAT ('"bands_sc.2" using 1:($2-e_f):(size1($3)):(color1($3)) w p pt 7 ps variable lc palette, \\')
324 : 916 FORMAT ('"bands_sc.2" using 1:($2-e_f):(size2($3)):(color2($3)) w p pt 7 ps variable lc palette,\\')
325 : #else
326 : 911 FORMAT ('plot [0:',f9.5,'] [-9:5] \')
327 : 912 FORMAT ('"bands_sc.2" using 1:($2-e_f):(size1($3)):(color1($3)) w p pt 7 ps variable lc palette, \')
328 : 916 FORMAT ('"bands_sc.2" using 1:($2-e_f):(size2($3)):(color2($3)) w p pt 7 ps variable lc palette,\')
329 : #endif
330 : #if (defined(CPP_AIX) || defined(__PGI))
331 : 913 FORMAT ('"bands_sc.1" using 1:($2-e_f):(size1($3)):(color1($3)) w p pt 7 ps variable lc palette, \\')
332 : #else
333 : 913 FORMAT ('"bands_sc.1" using 1:($2-e_f):(size1($3)):(color1($3)) w p pt 7 ps variable lc palette, \')
334 : #endif
335 : 915 FORMAT ('"bands_sc.1" using 1:($2-e_f):(size2($3)):(color2($3)) w p pt 7 ps variable lc palette')
336 : 914 FORMAT ('set label "',a1,'" at ',f9.5,', -9.65 center font "Symbol,20"')
337 :
338 : !call system("gnuplot <band_sc.gnu >band_sc.ps")
339 49 : END SUBROUTINE write_gnu_sc
340 : end MODULE
|