Debian Codegraph @

PHonon/examples/GRID_recover_example/run_example_2

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 illustrates the use of image parallelization in ph.x."
14 $ECHO "It calculates the phonon dos of AlAs in zincblende structure as"
15 $ECHO "example02. Moreover it stop and recovers the calculation."
16 $ECHO "NB: It uses the variables PARA_IMAGE_PREFIX and PARA_IMAGE_POSTFIX"
17 $ECHO "in environment_variables"
18
19 # set the needed environment variables
20 . ../../../environment_variables
21
22 # required executables and pseudopotentials
23 BIN_LIST="pw.x ph.x q2r.x matdyn.x"
24 PSEUDO_LIST="Al.pz-vbc.UPF As.pz-bhs.UPF"
25
26 $ECHO
27 $ECHO " executables directory: $BIN_DIR"
28 $ECHO " pseudo directory: $PSEUDO_DIR"
29 $ECHO " temporary directory: $TMP_DIR"
30 $ECHO " checking that needed directories and files exist...\c"
31
32 # check for gnuplot
33 GP_COMMAND=`which gnuplot 2>/dev/null`
34 if [ "$GP_COMMAND" = "" ]; then
35 $ECHO
36 $ECHO "gnuplot not in PATH"
37 $ECHO "Results will not be plotted"
38 fi
39
40 # check for directories
41 for DIR in "$BIN_DIR" "$PSEUDO_DIR" ; do
42 if test ! -d $DIR ; then
43 $ECHO
44 $ECHO "ERROR: $DIR not existent or not a directory"
45 $ECHO "Aborting"
46 exit 1
47 fi
48 done
49 for DIR in "$TMP_DIR" "$EXAMPLE_DIR/results_2" ; do
50 if test ! -d $DIR ; then
51 mkdir $DIR
52 fi
53 done
54 cd $EXAMPLE_DIR/results_2
55
56 # check for executables
57 for FILE in $BIN_LIST ; do
58 if test ! -x $BIN_DIR/$FILE ; then
59 $ECHO
60 $ECHO "ERROR: $BIN_DIR/$FILE not existent or not executable"
61 $ECHO "Aborting"
62 exit 1
63 fi
64 done
65
66 # check for pseudopotentials
67 for FILE in $PSEUDO_LIST ; do
68 if test ! -r $PSEUDO_DIR/$FILE ; then
69 $ECHO
70 $ECHO "Downloading $FILE to $PSEUDO_DIR...\c"
71 $WGET $PSEUDO_DIR/$FILE $NETWORK_PSEUDO/$FILE 2> /dev/null
72 fi
73 if test $? != 0; then
74 $ECHO
75 $ECHO "ERROR: $PSEUDO_DIR/$FILE not existent or not readable"
76 $ECHO "Aborting"
77 exit 1
78 fi
79 done
80 $ECHO " done"
81
82 # how to run executables
83 PW_COMMAND="$PARA_PREFIX $BIN_DIR/pw.x $PARA_POSTFIX"
84 PH_IMAGE_COMMAND="$PARA_IMAGE_PREFIX $BIN_DIR/ph.x $PARA_IMAGE_POSTFIX"
85 PH_COMMAND="$PARA_PREFIX $BIN_DIR/ph.x $PARA_POSTFIX"
86 Q2R_COMMAND="$PARA_PREFIX $BIN_DIR/q2r.x $PARA_POSTFIX"
87 MATDYN_COMMAND="$PARA_PREFIX $BIN_DIR/matdyn.x $PARA_POSTFIX"
88 PLOTBAND_COMMAND="$BIN_DIR/plotband.x"
89 $ECHO
90 $ECHO " running pw.x as: $PW_COMMAND"
91 $ECHO " running ph.x with images as: $PH_IMAGE_COMMAND"
92 $ECHO " running ph.x as: $PH_COMMAND"
93 $ECHO " running q2r.x as: $Q2R_COMMAND"
94 $ECHO " running matdyn.x as: $MATDYN_COMMAND"
95 $ECHO " running plotband.x as: $PLOTBAND_COMMAND"
96 $ECHO " running gnuplot as: $GP_COMMAND"
97 $ECHO
98
99 # clean TMP_DIR
100 $ECHO " cleaning $TMP_DIR...\c"
101 rm -rf $TMP_DIR/alas*
102 rm -rf $TMP_DIR/_ph*/alas*
103 $ECHO " done"
104
105 # self-consistent calculation
106 cat > alas.scf.in << EOF
107 &control
108 calculation='scf'
109 restart_mode='from_scratch',
110 tstress = .true.
111 tprnfor = .true.
112 prefix='alas',
113 pseudo_dir = '$PSEUDO_DIR/',
114 outdir='$TMP_DIR/'
115 /
116 &system
117 ibrav= 2, celldm(1) =10.50, nat= 2, ntyp= 2,
118 ecutwfc =16.0
119 /
120 &electrons
121 conv_thr = 1.0d-8
122 mixing_beta = 0.7
123 /
124 ATOMIC_SPECIES
125 Al 26.98 Al.pz-vbc.UPF
126 As 74.92 As.pz-bhs.UPF
127 ATOMIC_POSITIONS (alat)
128 Al 0.00 0.00 0.00
129 As 0.25 0.25 0.25
130 K_POINTS
131 2
132 0.25 0.25 0.25 1.0
133 0.25 0.25 0.75 3.0
134 EOF
135 $ECHO " running the scf calculation...\c"
136 $PW_COMMAND < alas.scf.in > alas.scf.out
137 check_failure $?
138 $ECHO " done"
139 #
140 # phonon calculation on a (444) uniform grid of q-points. Stops the calculation
141 # after a certain amount of time
142 #
143 cat > alas.ph.in << EOF
144 phonons of AlAs
145 &inputph
146 tr2_ph=1.0d-12,
147 prefix='alas',
148 ldisp=.true.,
149 nq1=4, nq2=4, nq3=4
150 max_seconds=7,
151 amass(1)=26.98,
152 amass(2)=74.92,
153 outdir='$TMP_DIR/',
154 fildyn='alas.dyn',
155 /
156 EOF
157 $ECHO " running the phonon calculation using images...\c"
158 $PH_IMAGE_COMMAND < alas.ph.in > alas.ph.out
159 $ECHO " done"
160 #
161 # phonon calculation on a (444) uniform grid of q-points
162 #
163 cat > alas.ph.rec.in << EOF
164 phonons of AlAs
165 &inputph
166 tr2_ph=1.0d-12,
167 prefix='alas',
168 ldisp=.true.,
169 recover=.true.
170 nq1=4, nq2=4, nq3=4
171 amass(1)=26.98,
172 amass(2)=74.92,
173 outdir='$TMP_DIR/',
174 fildyn='alas.dyn',
175 /
176 EOF
177 $ECHO " recovering the phonon calculation using images...\c"
178 $PH_IMAGE_COMMAND < alas.ph.rec.in > alas.ph.rec.out
179 check_failure $?
180 $ECHO " done"
181
182 cat > alas.ph.collect.in << EOF
183 phonons of AlAs
184 &inputph
185 tr2_ph=1.0d-12,
186 prefix='alas',
187 ldisp=.true.,
188 nq1=4, nq2=4, nq3=4
189 recover=.true.,
190 amass(1)=26.98,
191 amass(2)=74.92,
192 outdir='$TMP_DIR/',
193 fildyn='alas.dyn',
194 /
195 EOF
196 $ECHO " running the phonon calculation without images to collect results...\c"
197 $PH_COMMAND < alas.ph.collect.in > alas.ph.collect.out
198 check_failure $?
199 $ECHO " done"
200
201
202 cat > q2r.in <<EOF
203 &input
204 fildyn='alas.dyn', zasr='simple', flfrc='alas444.fc'
205 /
206 EOF
207
208 $ECHO " transforming C(q) => C(R)...\c"
209 $Q2R_COMMAND < q2r.in > q2r.out
210 check_failure $?
211 $ECHO " done"
212
213 cat > matdyn.in <<EOF
214 &input
215 asr='simple', amass(1)=26.98, amass(2)=74.922,
216 flfrc='alas444.fc', flfrq='alas.freq', q_in_band_form=.true.,
217 /
218 6
219 0.000 0.0 0.0 40
220 1.0 0.0 0.0 20
221 1.0 0.5 0.0 20
222 1.0 1.0 0.0 40
223 0.00 0.0 0.0 40
224 0.5 0.5 0.5 1
225 EOF
226
227 $ECHO " recalculating omega(q) from C(R)...\c"
228 $MATDYN_COMMAND < matdyn.in > matdyn.out
229 check_failure $?
230 $ECHO " done"
231
232 cat > plotband.in <<EOF
233 alas.freq
234 0 600
235 freq.plot
236 freq.ps
237 0.0
238 0.0
239 0.1
240 EOF
241
242 $ECHO " writing the phonon dispersions in freq.plot...\c"
243 $PLOTBAND_COMMAND < plotband.in > /dev/null
244 check_failure $?
245 $ECHO " done"
246
247 if [ "$GP_COMMAND" = "" ]; then
248 break
249 else
250 cat > gnuplot.tmp <<EOF
251 set encoding iso_8859_15
252 set terminal postscript enhanced solid color "Helvetica" 20
253 set output "alas.dispersions.ps"
254 #
255 set key off
256
257 set xrange [0:4.280239]
258 dim=450
259 set yrange [0:dim]
260 set arrow from 1,0. to 1,dim nohead lw 2
261 set arrow from 2,0. to 2,dim nohead lw 2
262 set arrow from 1.5,0. to 1.5,dim nohead lw 2
263 set arrow from 3.4142,0. to 3.4142,dim nohead lw 2
264 set ylabel "frequency (cm^{-1})"
265 unset xtics
266 lpos=-15
267 set label "{/Symbol G}" at -0.05,lpos
268 set label "X" at 0.95,lpos
269 set label "W" at 1.45,lpos
270 set label "X" at 1.95,lpos
271 set label "{/Symbol G}" at 3.37,lpos
272 set label "L" at 4.1897,lpos
273
274 plot "freq.plot" u 1:2 w l lw 3
275 EOF
276 $ECHO " creating the postscript file alas.dispersion.ps...\c"
277 $GP_COMMAND gnuplot.tmp
278 check_failure $?
279 $ECHO " done"
280 fi
281
282
283 cat > phdos.in <<EOF
284 &input
285 asr='simple', dos=.true. amass(1)=26.98, amass(2)=74.922,
286 flfrc='alas444.fc', fldos='alas.phdos', nk1=6,nk2=6,nk3=6
287 /
288 EOF
289
290 $ECHO " calculating phonon DOS ...\c"
291 $MATDYN_COMMAND < phdos.in > phdos.out
292 check_failure $?
293 $ECHO " done"
294
295 if [ "$GP_COMMAND" = "" ]; then
296 break
297 else
298 cat > gnuplot1.tmp <<EOF
299 set encoding iso_8859_15
300 set terminal postscript enhanced solid color "Helvetica" 20
301 set output "alas.phdos.ps"
302 #
303 set key off
304 set xrange [0:450]
305 set xlabel "frequency (cm^{-1})"
306 set ylabel "DOS"
307 plot 'alas.phdos' u 1:2 w l lw 3
308 EOF
309 $ECHO " generating plot of phonon_dos in the file alas.phdos.ps...\c"
310 $GP_COMMAND gnuplot1.tmp
311 check_failure $?
312 $ECHO " done"
313 fi
314
315 $ECHO
316 $ECHO "$EXAMPLE_DIR: done"