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
|
#!/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 will calculate the water dipole and calculate the work"
$ECHO "function on a Ni slab with a CO molecule adsorbed using the dipole"
$ECHO "correction"
# set the needed environment variables
. ../../../environment_variables
# required executables and pseudopotentials
BIN_LIST="pw.x pp.x average.x"
PSEUDO_LIST="C.pbe-rrkjus.UPF O.pbe-rrkjus.UPF Ni.pbe-nd-rrkjus.UPF HUSPBE.RRKJ3"
$ECHO
$ECHO " executables directory: $BIN_DIR"
$ECHO " pseudo directory: $PSEUDO_DIR"
$ECHO " temporary directory: $TMP_DIR"
$ECHO
$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 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
# 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"
# how to run executables
PW_COMMAND="$PARA_PREFIX $BIN_DIR/pw.x $PARA_POSTFIX"
PP_COMMAND="$PARA_PREFIX $BIN_DIR/pp.x $PARA_POSTFIX"
AVERAGE_COMMAND="$BIN_DIR/average.x"
$ECHO
$ECHO " running pw.x as: $PW_COMMAND"
$ECHO " running pp.x as: $PP_COMMAND"
$ECHO " running average.x as: $AVERAGE_COMMAND"
$ECHO " running gnuplot as: $GP_COMMAND"
$ECHO
#
# Run the calculation for the Ni+CO slab with the dipole correction
# emaxpos, the starting of the potential inversion, has to be carefully
# placed in a position where there's almost no charge.
#
cat > ni+co.scf.in << EOF
&control
calculation='scf',
restart_mode='from_scratch',
prefix='ni+co',
pseudo_dir = '$PSEUDO_DIR',
outdir='$TMP_DIR'
tefield=.true.,
dipfield=.true.,
/
&system
nat=5, ntyp=3,
ibrav=0, celldm(1)=4.70366666,
ecutwfc = 30.0
occupations='smearing', smearing='m-v', degauss=0.03
edir=3,
emaxpos=0.55,
eopreg=0.06,
eamp=0,
/
&electrons
mixing_beta = 0.3
conv_thr = 1.0d-6
/
ATOMIC_SPECIES
C 1.0 C.pbe-rrkjus.UPF
O 1.0 O.pbe-rrkjus.UPF
Ni 1.0 Ni.pbe-nd-rrkjus.UPF
CELL_PARAMETERS alat
1.00000000 0.00000000 0.00000000
0.00000000 1.41421356 0.00000000
0.00000000 0.00000000 9.10000001
ATOMIC_POSITIONS (alat)
C -0.00364039 0.02119538 1.54673745
O -0.00634860 0.04192428 2.02021975
Ni 0.48527378 0.00197332 0.97713547
Ni -0.00049546 0.70236680 0.45417840
Ni 0.50000000 0.00000000 0.00000000
K_POINTS {gamma}
EOF
$ECHO
$ECHO " running pw.x for Ni+CO slab...\c"
$PW_COMMAND < ni+co.scf.in > ni+co.scf.out
check_failure $?
$ECHO " done"
#
# Extract the potential from the SCF calculation
#
cat > ni+co.pp.in << EOF
&inputpp
prefix='ni+co',
outdir='$TMP_DIR',
filplot = 'ni+co.vpot'
plot_num= 11
/
EOF
$ECHO
$ECHO " running pp.x to extract ni+co potential...\c"
$PP_COMMAND < ni+co.pp.in > ni+co.pp.out
check_failure $?
$ECHO " done"
#
# Average the potential to obtain the planar average along edir
#
cat > ni+co.avg.in << EOF
1
ni+co.vpot
1.D0
150
3
3.000000
EOF
$ECHO
$ECHO " running average.x to obtain the potential along Z...\c"
$AVERAGE_COMMAND < ni+co.avg.in > ni+co.vpot-z
check_failure $?
$ECHO " done"
mv avg.dat ni+co.vpot-z
#
# If gnuplot is present plot the potential. In the graph it's clear where
# the potential reaches a constant value thanks to the dipole correction.
#
if [ "$GP_COMMAND" = "" ]; then
break
else
cat > ni+co.gnuplot <<EOF
set terminal postscript enhanced color
set output 'ni+co.eps'
set multiplot
set size 1,1
set origin 0,0
set style line 1 lt 1
set style line 2 lt 2
set style line 3 lt 3
set arrow 1 from 8,-2.2976 to 8,4.75 ls 3
set arrow 2 from 8,4.75 to 8,-2.2976 ls 3
#set arrow 3 from 18,4.488 to 16.5,-4 nohead ls 3
#set object 1 rect from 16.5,4.488 to 19.05048,4.896 fc ls 3 fs empty
set xlabel "Length (Angstroms)"
set ylabel "Energy (eV)"
set label 'W_{funct} = 7.04 eV' at 8.2,0
plot '< tail -150 ni+co.vpot-z' u (\$1*0.52918):(\$2*13.6) w l ls 1 title 'Pot.' , '< tail -150 ni+co.vpot-z' u (\$1*0.52918):(-2.2976) w l ls 2 title 'E_{f}'
set size 0.4,0.4
set origin 0.45,0.1
set xrange [8:18]
set yrange[4.74:4.76]
set xtics 8.2,2.8,18
set ytics 4.742, 0.005, 4.758
set style line 1 lt 1
set style line 2 lt 2
set style line 3 lt 3
set arrow 1 from 10,4.7566 to 10,4.7529 ls 3
set arrow 2 from 10,4.7529 to 10,4.7566 ls 3
#unset arrow 3
set label "Dipole corr." at 10.8,4.748
unset xlabel
unset ylabel
plot [8:18][4.74:4.76] "< tail -150 ni+co.vpot-z" u (\$1*0.52918):(\$3*13.6) w l ls 1 notitle, "< tail -150 ni+co.vpot-z" u (\$1*0.52918):(4.7566) w l ls 2 notitle, "< tail -150 ni+co.vpot-z" u (\$1*0.52918):(4.7529) w l ls 2 notitle
unset multiplot
set output
reset
EOF
$ECHO " Plotting averages and work function results ...\c"
$GP_COMMAND < ni+co.gnuplot
$ECHO " done"
rm ni+co.gnuplot
fi
###############################
# WATER
###############################
#
# Run the calculation for the water molecule with the dipole correction
#
cat > water.scf.in << EOF
&control
calculation='scf',
restart_mode='from_scratch',
prefix='water',
pseudo_dir = '$PSEUDO_DIR',
outdir='$TMP_DIR'
tefield=.true.,
dipfield=.true.
/
&SYSTEM
ibrav=1, celldm(1) = 15
nat=3, ntyp=2
ecutwfc=30.0
occupations='smearing', degauss=0.01
edir=3
eamp=0.D0
eopreg=0.1
emaxpos=0.6
/
&ELECTRONS
mixing_beta = 0.7
conv_thr = 1.0d-8
/
ATOMIC_SPECIES
O 15.9994 O.pbe-rrkjus.UPF
H 1.00794 HUSPBE.RRKJ3
ATOMIC_POSITIONS { Angstrom }
O 0.0 0.0 0.0
H 0.77 0.0 0.62
H -0.77 0.0 0.62
K_POINTS { gamma }
EOF
$ECHO
$ECHO " running pw.x for water molecule ...\c"
$PW_COMMAND < water.scf.in > water.scf.out
check_failure $?
$ECHO " done"
#
# Extract the potential from the SCF calculation
#
cat > water.pp.in << EOF
&inputpp
prefix='water',
outdir='$TMP_DIR',
filplot = 'water.vpot'
plot_num= 11
/
EOF
$ECHO
$ECHO " running pp.x to extract water potential...\c"
$PP_COMMAND < water.pp.in > water.pp.out
check_failure $?
$ECHO " done"
#
# If gnuplot is present plot the potential. In the graph it's clear how the
# dipole influences the potential slope
#
cat > water.avg.in << EOF
1
water.vpot
1.D0
90
3
3.000000
EOF
$ECHO
$ECHO " running average.x to obtain the potential along Z...\c"
$AVERAGE_COMMAND < water.avg.in > water.vpot-z
check_failure $?
$ECHO " done"
mv avg.dat water.vpot-z
if [ "$GP_COMMAND" = "" ]; then
break
else
cat > water.gnuplot <<EOF
set terminal postscript enhanced color
set output 'water.eps'
set style line 1 lt 1
set style line 2 lt 2
set style line 3 lt 3
set arrow 1 from 2.5,-0.15 to 2.5,0.93 ls 3
set arrow 2 from 2.5,0.93 to 2.5,-0.15 ls 3
set label "Dipole correction" at 3,0.5
set yrange [-1.2:1.2]
set xlabel "Length (Angstroms)"
set ylabel "Energy (eV)"
plot "< tail -90 water.vpot-z" u (\$1*0.52918):(\$2*13.6) w l ls 1 title "Pot.", "< tail -90 water.vpot-z" u (\$1*0.52918):(-0.15) w l ls 2 notitle, "< tail -90 water.vpot-z" u (\$1*0.52918):(0.93) w l ls 2 notitle
set output
reset
EOF
$ECHO " Plotting averages and work function results ...\c"
$GP_COMMAND < water.gnuplot
$ECHO " done"
rm water.gnuplot
fi
$ECHO " cleaning $TMP_DIR...\c"
rm -rf $TMP_DIR/ni+co.* $TMP_DIR/water.*
$ECHO "Calculations done."
$ECHO ""
$ECHO "----------------------------------------------------"
$ECHO " results/ni+co.eps -> Graph for the slab calculation"
$ECHO " results/water.eps -> Graph for the water molecule"
$ECHO "----------------------------------------------------"
|