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
|
#!/bin/sh
# run from directory where this script is
cd `echo $0 | sed 's/\(.*\)\/.*/\1/'` # extract pathname
EXAMPLE_DIR=`pwd`
# check whether ECHO has the -e option
if test "`echo -e`" = "-e" ; then ECHO=echo ; else ECHO="echo -e" ; fi
$ECHO
$ECHO "$EXAMPLE_DIR : starting"
$ECHO
$ECHO "This example shows how to use pw.x and ph.x to compute IR and Raman spectra"
$ECHO "for a CO2 molecule and for ZnO in the Wurtzite structure."
$ECHO "After the calculation, a gnuplot window posp up with both spectra."
$ECHO "NOTE: Raman calculation currently disabled (not implemented for GGA)."
$ECHO " "
# set the needed environment variables
. ../../../environment_variables
# Uncomment the following line if you want to calculate in parallel and the PARA_PREFIX was not set
#PARA_PREFIX="mpirun -np 8 "
# required executables and pseudopotentials
BIN_LIST="pw.x ph.x dynmat.x"
PSEUDO_LIST=" C.pbe-hgh.UPF O.pbe-hgh.UPF Zn.pbe-d-hgh.UPF"
$ECHO
$ECHO " executables directory: $BIN_DIR"
$ECHO " pseudo directory: $PSEUDO_DIR"
$ECHO " temporary directory: $TMP_DIR"
$ECHO " checking that needed directories and files exist...\c"
# check for directories
for DIR in "$BIN_DIR" "$PSEUDO_DIR" ; do
if test ! -d $DIR ; then
$ECHO
$ECHO "ERROR: $DIR not existent or not a directory"
$ECHO "Aborting"
exit 1
fi
done
for DIR in "$TMP_DIR" "$EXAMPLE_DIR/results" ; do
if test ! -d $DIR ; then
mkdir $DIR
fi
done
cd $EXAMPLE_DIR/results
# check for executables
for FILE in $BIN_LIST ; do
if test ! -x $BIN_DIR/$FILE ; then
$ECHO
$ECHO "ERROR: $BIN_DIR/$FILE not existent or not executable"
$ECHO "Aborting"
exit 1
fi
done
# check for pseudopotentials
for FILE in $PSEUDO_LIST ; do
if test ! -r $PSEUDO_DIR/$FILE ; then
$ECHO
$ECHO "Downloading $FILE to $PSEUDO_DIR...\c"
$WGET $PSEUDO_DIR/$FILE $NETWORK_PSEUDO/$FILE 2> /dev/null
fi
if test $? != 0; then
$ECHO
$ECHO "ERROR: $PSEUDO_DIR/$FILE not existent or not readable"
$ECHO "Aborting"
exit 1
fi
done
$ECHO " done"
$ECHO
# how to run executables
PW_COMMAND="$PARA_PREFIX $BIN_DIR/pw.x $PARA_POSTFIX"
$ECHO " running pw.x as: $PW_COMMAND"
PH_COMMAND="$PARA_PREFIX $BIN_DIR/ph.x $PARA_POSTFIX"
$ECHO " running ph.x as: $PH_COMMAND"
DM_COMMAND=" $BIN_DIR/dynmat.x"
$ECHO " running dynmat.x as: $DM_COMMAND"
$ECHO
# check for gnuplot
GP_COMMAND=`which gnuplot 2>/dev/null`
if [ "$GP_COMMAND" = "" ]; then
$ECHO
$ECHO "gnuplot not in PATH"
$ECHO "Results will not be plotted"
fi
# clean TMP_DIR
$ECHO " cleaning $TMP_DIR...\c"
rm -rf $TMP_DIR/CO2*
rm -rf $TMP_DIR/_ph0/CO2*
$ECHO " done"
# self-consistent calculation for CO2
cat > co2.scf.in << EOF
&CONTROL
calculation = "scf",
prefix = "CO2",
pseudo_dir = "$PSEUDO_DIR",
outdir = "$TMP_DIR",
/
&SYSTEM
ibrav = 1,
celldm(1) =14.0,
nat = 3,
ntyp = 2,
ecutwfc = 80.D0, !better 120
/
&ELECTRONS
conv_thr = 1.D-8,
mixing_beta = 0.7,
/
&IONS
/
ATOMIC_SPECIES
C 12.010 C.pbe-hgh.UPF
O 15.999 O.pbe-hgh.UPF
ATOMIC_POSITIONS (angstrom)
C 3.000042068 3.000042068 3.544613556
O 3.835408973 3.835408973 3.543705292
O 2.164548959 2.164548959 3.543681153
K_POINTS (automatic)
1 1 1 0 0 0
EOF
$ECHO " running the SCF for CO2...\c"
$PW_COMMAND < co2.scf.in > co2.scf.out
check_failure $?
$ECHO " done"
# self-consistent phonon calculation with ph.x for CO2
cat > co2.ph.in << EOF
Normal modes for CO2
&inputph
tr2_ph=1.0d-14,
prefix='CO2',
amass(1)=12.010,
amass(2)=15.999,
outdir='$TMP_DIR'
epsil=.true.,
trans=.true.,
asr=.true.
! lraman=.true.
fildyn='dmat.co2'
/
0.0 0.0 0.0
EOF
$ECHO " running phonon calculation of CO2...\c"
$PH_COMMAND < co2.ph.in > co2.ph.out
check_failure $?
$ECHO " done"
# extract phonon data with dynmat.x
cat > co2.dm.in << EOF
&input fildyn='dmat.co2', asr='zero-dim' /
EOF
$ECHO " Extracting phonon data with dynmat...\c"
$DM_COMMAND < co2.dm.in > co2.dm.out
check_failure $?
$ECHO " done"
$ECHO "The data for spectrum is after '# mode [cm-1] [THz] IR' on co2.dm.out"
awk 'NR==1,/mode/{next}/DYNMAT/,NR==0{next}{print}' co2.dm.out > plotdata_co2.dat
$ECHO "Trying to plot it with gnuplot..."
cat > plot_command_co2.cmd << EOF
set lmargin 8
set rmargin 3
set multiplot
set key left top
set origin 0.0,0.5
set size 1,0.5
set yrange [0:]
set format x ""
set tmargin 1
plot 'plotdata_co2.dat' u (\$2):(\$3) title ' CO2-RAMAN' w i lw 2
set key left bottom
set origin 0.0,0.0
set size 1,0.587
set yrange [0:] reverse
set format x
set xlabel "Wavenumber [cm-1]"
set bmargin 3
set ylabel "Intensity" offset 0,5
plot 'plotdata_co2.dat' u (\$2):(\$4) title 'CO2-IR' w i lw 2 lc 2
set nomultiplot
EOF
if [ "$GP_COMMAND" = "" ]; then
$ECHO "No plot will be produced, because gnuplot was not found in the \$PATH "
break
else
$GP_COMMAND -persist plot_command_co2.cmd &
fi
# clean TMP_DIR
$ECHO " cleaning $TMP_DIR...\c"
rm -rf $TMP_DIR/ZNO*
rm -rf $TMP_DIR/_ph0/ZNO*
$ECHO " done"
# self-consistent calculation for Wurtzite (ZnO)
cat > zno.scf.in << EOF
&CONTROL
calculation = "scf",
prefix = "ZNO",
pseudo_dir = "$PSEUDO_DIR",
outdir = "$TMP_DIR",
/
&SYSTEM
ibrav=0, celldm(1) =6.330582528, nat=4, ntyp= 2,
occupations='smearing', smearing='marzari-vanderbilt', degauss=0.02,
ecutwfc =80.0, !better 140
/
&ELECTRONS
mixing_mode='plain'
mixing_beta = 0.5,
startingwfc='random',
conv_thr = 1.0d-8
/
CELL_PARAMETERS alat
1.55820896 0.00000000 0.00000000
0.00000000 0.86602540 -0.50000000
0.00000000 0.00000000 1.00000000
ATOMIC_SPECIES
Zn 65.409 Zn.pbe-d-hgh.UPF
O 15.999 O.pbe-hgh.UPF
ATOMIC_POSITIONS (alat)
Zn 2.010975287 0.487933254 -0.051360548
Zn 1.234717421 0.199473387 0.448322227
O 1.051679030 0.488287222 -0.051814333
O 1.830251369 0.199830262 0.448810714
K_POINTS (automatic)
2 2 2 0 0 0
EOF
$ECHO " running the SCF for Wurtzite...\c"
$PW_COMMAND < zno.scf.in > zno.scf.out
check_failure $?
$ECHO " done"
# self-consistent phonon calculation with ph.x for Wurtzite
cat > zno.ph.in << EOF
Normal modes for Wurtzite
&inputph
tr2_ph=1.0d-14,
prefix='ZNO',
amass(1)=65.409,
amass(2)=15.999,
outdir='$TMP_DIR'
epsil=.false.,
! lraman=.true.
trans=.true.,
asr=.true.
fildyn='dmat.zno'
/
0.0 0.0 0.0
EOF
$ECHO " running phonon calculation of ZnO...\c"
$PH_COMMAND < zno.ph.in > zno.ph.out
check_failure $?
$ECHO " done"
# extract phonon data with dynmat.x
cat > zno.dm.in << EOF
&input fildyn='dmat.zno', asr='zero-dim' /
EOF
$ECHO " Extracting phonon data with dynmat...\c"
$DM_COMMAND < zno.dm.in > zno.dm.out
check_failure $?
$ECHO " done"
$ECHO "The data for spectrum is after '# mode [cm-1] [THz] IR' on zno.dm.out"
awk 'NR==1,/mode/{next}/DYNMAT/,NR==0{next}{print}' zno.dm.out > plotdata_zno.dat
$ECHO "Trying to plot it with gnuplot..."
cat > plot_command_zno.cmd << EOF
set lmargin 8
set rmargin 3
set multiplot
set key left top
set origin 0.0,0.5
set size 1,0.5
set yrange [0:]
set format x ""
set tmargin 1
plot 'plotdata_zno.dat' u (\$2):(\$3) title ' ZnO-RAMAN' w i lw 2
set key left bottom
set origin 0.0,0.0
set size 1,0.587
set yrange [0:] reverse
set format x
set xlabel "Frequency [cm-1]"
set bmargin 3
set ylabel "Intensity" offset 0,5
plot 'plotdata_zno.dat' u (\$2):(\$4) title 'ZnO-IR' w i lw 2 lc 2
set nomultiplot
EOF
if [ "$GP_COMMAND" = "" ]; then
$ECHO "No plot will be produced, because gnuplot was not found in the \$PATH "
break
else
$GP_COMMAND -persist plot_command_zno.cmd &
fi
$ECHO "The results on the ZnO spectrum can be compared with"
$ECHO "http://www.nature.com/srep/2013/131021/srep02999/pdf/srep02999.pdf"
$ECHO " providing acceptable values for such a cheap calculation."
$ECHO
$ECHO "$EXAMPLE_DIR: done"
|