Debian Codegraph @

PHonon/examples/GRID_recover_example/run_example

raw
1 #!/bin/sh
2
3 # run from directory where this script is
4 cd `echo $0 | sed 's/\(.*\)\/.*/\1/'` # extract pathname
5 EXAMPLE_DIR=`pwd`
6
7 # check whether echo has the -e option
8 if test "`echo -e`" = "-e" ; then ECHO=echo ; else ECHO="echo -e" ; fi
9
10 $ECHO
11 $ECHO "$EXAMPLE_DIR : starting"
12 $ECHO
13 $ECHO "This example shows how to calculate the phonon dispersion on a GRID"
14 $ECHO "for AlAs in zincblende structure. Both q-points and irreps are split."
15
16 # set the needed environment variables
17 . ../../../environment_variables
18
19 # required executables and pseudopotentials
20 BIN_LIST="pw.x ph.x q2r.x matdyn.x plotband.x"
21 PSEUDO_LIST="Al.pz-vbc.UPF As.pz-bhs.UPF"
22
23 $ECHO
24 $ECHO " executables directory: $BIN_DIR"
25 $ECHO " pseudo directory: $PSEUDO_DIR"
26 $ECHO " temporary directory: $TMP_DIR"
27 $ECHO " checking that needed directories and files exist...\c"
28
29 # check for gnuplot
30 GP_COMMAND=`which gnuplot 2>/dev/null`
31 if [ "$GP_COMMAND" = "" ]; then
32 $ECHO
33 $ECHO "gnuplot not in PATH"
34 $ECHO "Results will not be plotted"
35 fi
36
37 # check for directories
38 for DIR in "$BIN_DIR" "$PSEUDO_DIR" ; do
39 if test ! -d $DIR ; then
40 $ECHO
41 $ECHO "ERROR: $DIR not existent or not a directory"
42 $ECHO "Aborting"
43 exit 1
44 fi
45 done
46 for DIR in "$TMP_DIR" "$EXAMPLE_DIR/results" ; do
47 if test ! -d $DIR ; then
48 mkdir $DIR
49 fi
50 done
51 cd $EXAMPLE_DIR/results
52
53 # check for executables
54 for FILE in $BIN_LIST ; do
55 if test ! -x $BIN_DIR/$FILE ; then
56 $ECHO
57 $ECHO "ERROR: $BIN_DIR/$FILE not existent or not executable"
58 $ECHO "Aborting"
59 exit 1
60 fi
61 done
62
63 # check for pseudopotentials
64 for FILE in $PSEUDO_LIST ; do
65 if test ! -r $PSEUDO_DIR/$FILE ; then
66 $ECHO
67 $ECHO "Downloading $FILE to $PSEUDO_DIR...\c"
68 $WGET $PSEUDO_DIR/$FILE $NETWORK_PSEUDO/$FILE 2> /dev/null
69 fi
70 if test $? != 0; then
71 $ECHO
72 $ECHO "ERROR: $PSEUDO_DIR/$FILE not existent or not readable"
73 $ECHO "Aborting"
74 exit 1
75 fi
76 done
77 $ECHO " done"
78
79 # how to run executables
80 PW_COMMAND="$PARA_PREFIX $BIN_DIR/pw.x $PARA_POSTFIX"
81 PH_COMMAND="$PARA_PREFIX $BIN_DIR/ph.x $PARA_POSTFIX"
82 Q2R_COMMAND="$PARA_PREFIX $BIN_DIR/q2r.x $PARA_POSTFIX"
83 MATDYN_COMMAND="$PARA_PREFIX $BIN_DIR/matdyn.x $PARA_POSTFIX"
84 PLOTBAND_COMMAND="$BIN_DIR/plotband.x"
85 $ECHO
86 $ECHO " running pw.x as: $PW_COMMAND"
87 $ECHO " running ph.x as: $PH_COMMAND"
88 $ECHO " running q2r.x as: $Q2R_COMMAND"
89 $ECHO " running matdyn.x as: $MATDYN_COMMAND"
90 $ECHO " running plotband.x as: $PLOTBAND_COMMAND"
91 $ECHO " running gnuplot as: $GP_COMMAND"
92 $ECHO
93
94 # clean TMP_DIR
95 $ECHO " cleaning $TMP_DIR...\c"
96 rm -rf $TMP_DIR/alas*
97 rm -rf $TMP_DIR/_ph0/alas*
98 for q in `seq 1 8 ` ; do
99 for irr in `seq 1 6` ; do
100 rm -rf $TMP_DIR/$q.$irr
101 done
102 done
103 $ECHO " done"
104
105 PREFIX='alas'
106
107 # self-consistent calculation
108 cat > alas.scf.in << EOF
109 &control
110 calculation='scf'
111 restart_mode='from_scratch',
112 tstress = .true.
113 tprnfor = .true.
114 prefix='$PREFIX',
115 pseudo_dir = '$PSEUDO_DIR/',
116 outdir='$TMP_DIR/'
117 /
118 &system
119 ibrav= 2, celldm(1) =10.50, nat= 2, ntyp= 2,
120 ecutwfc =16.0
121 /
122 &electrons
123 conv_thr = 1.0d-8
124 mixing_beta = 0.7
125 /
126 ATOMIC_SPECIES
127 Al 26.98 Al.pz-vbc.UPF
128 As 74.92 As.pz-bhs.UPF
129 ATOMIC_POSITIONS (alat)
130 Al 0.00 0.00 0.00
131 As 0.25 0.25 0.25
132 K_POINTS
133 2
134 0.25 0.25 0.25 1.0
135 0.25 0.25 0.75 3.0
136 EOF
137 $ECHO " running the scf calculation...\c"
138 $PW_COMMAND < alas.scf.in > alas.scf.out
139 check_failure $?
140 $ECHO " done"
141
142 # phonon calculation on a (444) uniform grid of q-points
143 cat > alas.ph.prep.in << EOF
144 phonons of AlAs
145 &inputph
146 tr2_ph=1.0d-12,
147 prefix='$PREFIX',
148 ldisp=.true.,
149 nq1=4, nq2=4, nq3=4
150 amass(1)=26.98,
151 amass(2)=74.92,
152 start_irr=0,
153 last_irr=0,
154 outdir='$TMP_DIR/',
155 fildyn='$PREFIX.dyn',
156 /
157 EOF
158 $ECHO " running the phonon calculation ...\c"
159 $PH_COMMAND < alas.ph.prep.in > alas.ph.prep.out
160 check_failure $?
161 $ECHO " done"
162
163 for q in `seq 1 8 ` ; do
164
165 for irr in `seq 1 6` ; do
166
167 cat > alas.ph.in.$q.$irr << EOF
168 phonons of AlAs
169 &inputph
170 tr2_ph=1.0d-12,
171 prefix='$PREFIX',
172 ldisp=.true.,
173 nq1=4, nq2=4, nq3=4
174 start_q=$q
175 last_q=$q
176 start_irr=$irr
177 last_irr=$irr
178 max_seconds=0.5,
179 recover=.true.,
180 amass(1)=26.98,
181 amass(2)=74.92,
182 outdir="$TMP_DIR/$q.$irr",
183 fildyn='$PREFIX.dyn',
184 /
185 EOF
186
187 mkdir $TMP_DIR/$q.$irr
188 cp -r $TMP_DIR/$PREFIX.* $TMP_DIR/$q.$irr
189 mkdir -p $TMP_DIR/$q.$irr/_ph0/$PREFIX.phsave
190 cp -r $TMP_DIR/_ph0/$PREFIX.phsave/* $TMP_DIR/$q.$irr/_ph0/$PREFIX.phsave
191
192 $ECHO " running the phonon calculation for q= " $q " irr=" $irr "...\c"
193 $PH_COMMAND < alas.ph.in.$q.$irr > alas.ph.out.$q.$irr
194 $ECHO " done"
195
196 done
197 done
198 #
199 # redo the previous calculation another time to complete the
200 # unfinished calculations
201 #
202 for q in `seq 1 8 ` ; do
203
204 for irr in `seq 1 6` ; do
205
206 cat > alas.ph.rec.in.$q.$irr << EOF
207 phonons of AlAs
208 &inputph
209 tr2_ph=1.0d-12,
210 prefix='$PREFIX',
211 ldisp=.true.,
212 nq1=4, nq2=4, nq3=4
213 start_q=$q
214 last_q=$q
215 start_irr=$irr
216 last_irr=$irr
217 recover=.true.,
218 amass(1)=26.98,
219 amass(2)=74.92,
220 outdir="$TMP_DIR/$q.$irr",
221 fildyn='$PREFIX.dyn',
222 /
223 EOF
224
225 $ECHO " recovering the phonon calculation for q= " $q " irr=" $irr "...\c"
226 $PH_COMMAND < alas.ph.rec.in.$q.$irr > alas.ph.rec.out.$q.$irr
227 $ECHO " done"
228
229 done
230 done
231 #
232 # Collecting all results in a single directory:
233 #
234
235 for q in `seq 1 8 ` ; do
236
237 for irr in `seq 1 6` ; do
238
239 \cp -f $TMP_DIR/$q.$irr/_ph0/$PREFIX.phsave/dynmat.$q.$irr.xml $TMP_DIR/_ph0/$PREFIX.phsave 2> /dev/null
240
241 done
242 #
243 # collect also the representation 0 (contribution to the dynamical
244 # matrix independent from the induced charge).
245 #
246 \cp -f $TMP_DIR/$q.1/_ph0/$PREFIX.phsave/dynmat.$q.0.xml $TMP_DIR/_ph0/$PREFIX.phsave 2> /dev/null
247
248 done
249 #
250 # cp electric field part
251 #
252 \cp -f $TMP_DIR/1.1/_ph0/$PREFIX.phsave/tensors.xml $TMP_DIR/_ph0/$PREFIX.phsave
253
254 cat > alas.ph.collect.in << EOF
255 phonons of AlAs
256 &inputph
257 tr2_ph=1.0d-12,
258 prefix='$PREFIX',
259 ldisp=.true.,
260 nq1=4, nq2=4, nq3=4
261 amass(1)=26.98,
262 amass(2)=74.92,
263 recover=.true.,
264 outdir='$TMP_DIR/',
265 fildyn='$PREFIX.dyn',
266 /
267 EOF
268 $ECHO " running the phonon calculation to collect the results...\c"
269 $PH_COMMAND < alas.ph.collect.in > alas.ph.collect.out
270 check_failure $?
271 $ECHO " done"
272
273 cat > q2r.in <<EOF
274 &input
275 fildyn='$PREFIX.dyn', zasr='simple', flfrc='$PREFIX.444.fc'
276 /
277 EOF
278
279 $ECHO " transforming C(q) => C(R)...\c"
280 $Q2R_COMMAND < q2r.in > q2r.out
281 check_failure $?
282 $ECHO " done"
283
284 cat > matdyn.in <<EOF
285 &input
286 asr='simple', amass(1)=26.98, amass(2)=74.922,
287 flfrc='$PREFIX.444.fc', flfrq='$PREFIX.freq', q_in_band_form=.true.,
288 /
289 6
290 0.000 0.0 0.0 40
291 1.0 0.0 0.0 20
292 1.0 0.5 0.0 20
293 1.0 1.0 0.0 40
294 0.00 0.0 0.0 40
295 0.5 0.5 0.5 1
296 EOF
297
298 $ECHO " recalculating omega(q) from C(R)...\c"
299 $MATDYN_COMMAND < matdyn.in > matdyn.out
300 check_failure $?
301 $ECHO " done"
302
303 cat > plotband.in <<EOF
304 alas.freq
305 0 600
306 freq.plot
307 freq.ps
308 0.0
309 50.0 0.0
310 EOF
311
312 $ECHO " writing the phonon dispersions in freq.plot...\c"
313 $PLOTBAND_COMMAND < plotband.in > /dev/null
314 check_failure $?
315 $ECHO " done"
316
317 if [ "$GP_COMMAND" = "" ]; then
318 break
319 else
320 cat > gnuplot.tmp <<EOF
321 set encoding iso_8859_15
322 set terminal postscript enhanced solid color "Helvetica" 20
323 set output "alas.dispersions.ps"
324 #
325 set key off
326
327 set xrange [0:4.280239]
328 dim=450
329 set yrange [0:dim]
330 set arrow from 1,0. to 1,dim nohead lw 2
331 set arrow from 2,0. to 2,dim nohead lw 2
332 set arrow from 1.5,0. to 1.5,dim nohead lw 2
333 set arrow from 3.4142,0. to 3.4142,dim nohead lw 2
334 set ylabel "frequency (cm^{-1})"
335 unset xtics
336 lpos=-15
337 set label "{/Symbol G}" at -0.05,lpos
338 set label "X" at 0.95,lpos
339 set label "W" at 1.45,lpos
340 set label "X" at 1.95,lpos
341 set label "{/Symbol G}" at 3.37,lpos
342 set label "L" at 4.1897,lpos
343
344 plot "freq.plot" u 1:2 w l lw 3
345 EOF
346 $ECHO " creating the postscript file alas.dispersion.ps...\c"
347 $GP_COMMAND gnuplot.tmp
348 check_failure $?
349 $ECHO " done"
350 fi
351
352 cat > phdos.in <<EOF
353 &input
354 asr='simple', dos=.true. amass(1)=26.98, amass(2)=74.922,
355 flfrc='$PREFIX.444.fc', fldos='$PREFIX.phdos', nk1=6,nk2=6,nk3=6
356 /
357 EOF
358
359 $ECHO " calculating phonon DOS ...\c"
360 $MATDYN_COMMAND < phdos.in > phdos.out
361 check_failure $?
362 $ECHO " done"
363
364 if [ "$GP_COMMAND" = "" ]; then
365 break
366 else
367 cat > gnuplot1.tmp <<EOF
368 set encoding iso_8859_15
369 set terminal postscript enhanced solid color "Helvetica" 20
370 set output "alas.phdos.ps"
371 #
372 set key off
373 set xrange [0:450]
374 set xlabel "frequency (cm^{-1})"
375 set ylabel "DOS"
376 plot 'alas.phdos' u 1:2 w l lw 3
377 EOF
378 $ECHO " generating plot of phonon_dos in the file alas.phdos.ps...\c"
379 $GP_COMMAND gnuplot1.tmp
380 check_failure $?
381 $ECHO " done"
382 fi
383
384 $ECHO
385 $ECHO "$EXAMPLE_DIR: done"
386