1#!/bin/sh 2 3# run from directory where this script is 4cd `echo $0 | sed 's/\(.*\)\/.*/\1/'` # extract pathname 5EXAMPLE_DIR=`pwd` 6 7# check whether echo has the -e option 8if 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 tests K-edge X-ray absorption spectra calculation" 14$ECHO 15 16# set the needed environment variables 17. ../../environment_variables 18 19# required executables and pseudopotentials 20BIN_LIST="pw.x xspectra.x " 21PSEUDO_LIST="Si_PBE_USPP.UPF O_PBE_USPP.UPF" 22PSEUDO_DIR="$EXAMPLE_DIR/pseudo" 23BIN_DIR="$EXAMPLE_DIR/../../bin" 24TMP_DIR="$EXAMPLE_DIR/results/tmp" 25 26$ECHO 27$ECHO " executables directory: $BIN_DIR" 28$ECHO " pseudo directory: $PSEUDO_DIR" 29$ECHO " temporary directory: $TMP_DIR" 30$ECHO 31$ECHO " checking that needed directories and files exist...\c" 32 33# check for directories 34for DIR in "$BIN_DIR" "$PSEUDO_DIR" ; do 35 if test ! -d $DIR ; then 36 $ECHO 37 $ECHO "ERROR: $DIR not existent or not a directory" 38 $ECHO "Aborting" 39 exit 1 40 fi 41done 42# clean directory results 43rm -rf ./results/* 44for DIR in "$TMP_DIR" "$EXAMPLE_DIR/results" ; do 45 if test ! -d $DIR ; then 46 mkdir $DIR 47 fi 48done 49cd $EXAMPLE_DIR/results 50 51# check for executables 52for FILE in $BIN_LIST ; do 53 if test ! -x $BIN_DIR/$FILE ; then 54 $ECHO 55 $ECHO "ERROR: $BIN_DIR/$FILE not existent or not executable" 56 $ECHO "Aborting" 57 exit 1 58 fi 59done 60 61# check for pseudopotentials 62for FILE in $PSEUDO_LIST ; do 63 if test ! -r $PSEUDO_DIR/$FILE ; then 64 $ECHO 65 $ECHO "ERROR: $PSEUDO_DIR/$FILE not existent or not readable" 66 $ECHO "Aborting" 67 exit 1 68 fi 69done 70$ECHO " done" 71 72# how to run executables 73PW_COMMAND="$PARA_PREFIX $BIN_DIR/pw.x $PARA_POSTFIX" 74X_COMMAND="$PARA_PREFIX $BIN_DIR/xspectra.x $PARA_POSTFIX" 75 76 77$ECHO 78$ECHO " running pw.x as: $PW_COMMAND" 79$ECHO " running xspectra.x as: $X_COMMAND" 80$ECHO 81 82$ECHO 83$ECHO "WARNING : All these calculations are underconverged" 84$ECHO " (These are simple quick tests) " 85$ECHO 86$ECHO 87$ECHO 88 89 90$ECHO "###########################################" 91$ECHO "# SiO2 #" 92$ECHO "# Calculation of K-edge XAS without #" 93$ECHO "# a core-hole in the final state #" 94$ECHO "# #" 95$ECHO "# The parameters of this run are not #" 96$ECHO "# converged. To obtain converged #" 97$ECHO "# parameters see : #" 98$ECHO "# C. Gougoussis, M.Calandra, #" 99$ECHO "# A. Seitsonen, F. Mauri #" 100$ECHO "# Phys. Rev. B 80, 075102 (2009) #" 101$ECHO "###########################################" 102 103# clean TMP_DIR 104$ECHO " cleaning $TMP_DIR...\c" 105rm -rf $TMP_DIR/* 106$ECHO " done" 107# extracting core wavefunction 108$ECHO " extracting core wavefunction from pseudo...\c" 109../../../XSpectra/tools/upf2plotcore.sh $PSEUDO_DIR/Si_PBE_USPP.UPF > ./Si.wfc 110$ECHO " done" 111 112$ECHO "#" 113$ECHO "# self-consistent calculation for SiO2." 114$ECHO "# Ultrasoft pseudopotentials are being used " 115$ECHO "#" 116 117cat > SiO2.scf.in << EOF 118 &control 119 calculation='scf', 120 restart_mode='from_scratch', 121 pseudo_dir = '$PSEUDO_DIR/', 122 outdir='$TMP_DIR/', 123 prefix='SiO2', 124 verbosity = 'high', 125 &end 126 &system 127 ibrav = 4 , 128 celldm(1)=9.28630318961333, 129 celldm(3)=1.10010, 130 nat = 9 , 131 ntyp = 3 , 132 nspin=1, 133 ecutwfc = 20.0, 134 ecutrho = 150.0, 135 nbnd=30, 136 smearing='mp', 137 occupations='smearing', 138 degauss=0.03, 139 &end 140 &electrons 141 diagonalization='david', 142 conv_thr = 1.d-9, 143 mixing_mode = 'plain', 144 mixing_beta = 0.3, 145 &end 146ATOMIC_SPECIES 147Sih 28.086 Si_PBE_USPP.UPF 148Si 28.086 Si_PBE_USPP.UPF 149O 15.9994 O_PBE_USPP.UPF 150ATOMIC_POSITIONS crystal 151Sih 0.47000000000000 0.000000000000 0.00000000000000 152Si 0.00000000000000 0.47000000000000 0.6666666666666666 153Si -0.47000000000000 -0.47000000000000 0.333333333333333 154O 0.4131000000000000 0.267700000000000 0.11890000000000 155O 0.267700000000000 0.4131000000000000 .54776666666666666666 156O -0.267700000000000 0.1454000000000000 .78556666666666666666 157O -0.4131000000000000 -0.1454000000000000 .21443333333333333333 158O -0.1454000000000000 -0.4131000000000000 .45223333333333333333 159O 0.1454000000000000 -0.267700000000000 -0.11890000000000 160K_POINTS automatic 1612 2 2 0 0 0 162EOF 163 164$ECHO " running pw.x for SiO2 ...\c" 165$PW_COMMAND < SiO2.scf.in > SiO2.scf.out 166check_failure $? 167$ECHO " done" 168 169$ECHO "#" 170$ECHO "# xanes calculations : Si K-edge" 171$ECHO "# ultrasoft pseudopotentials are being used" 172$ECHO "# cutting occupied states " 173$ECHO "#" 174$ECHO "# x-ray absorption spectrum calculation" 175$ECHO "# dipolar part" 176$ECHO "#" 177$ECHO "# epsilon in the plane direction" 178 179cat > SiO2.xspectra_dip_plane.in << EOF 180 &input_xspectra 181 calculation='xanes_dipole' 182 prefix='SiO2', 183 outdir='$TMP_DIR/', 184 xonly_plot=.false., 185 xniter=2000, 186 xcheck_conv=50, 187 xepsilon(1)=1.0, 188 xepsilon(2)=1.0, 189 xepsilon(3)=0.0, 190 xiabs=1, 191 x_save_file='SiO2.xspectra_dip_plane.sav', 192 xerror=0.001, 193 / 194 &plot 195 xnepoint=1000, 196 xgamma=0.8, 197 xemin=-10.0, 198 xemax=100.0, 199 terminator=.true., 200 cut_occ_states=.true., 201 &end 202 &pseudos 203 filecore='Si.wfc', 204 r_paw(1)=2.4, 205 &end 206 &cut_occ 207 cut_desmooth=0.1, 208 &end 2093 3 3 0 0 0 210EOF 211$ECHO " running xspectra.x ...\c" 212$X_COMMAND < SiO2.xspectra_dip_plane.in > SiO2.xspectra_dip_plane.out 213check_failure $? 214mv xanes.dat SiO2.xspectra_dip_plane.dat 215$ECHO " done" 216 217$ECHO "#" 218$ECHO "# epsilon in the c axis direction" 219 220cat > SiO2.xspectra_dip_c.in << EOF 221 &input_xspectra 222 calculation='xanes_dipole' 223 prefix='SiO2', 224 outdir='$TMP_DIR/', 225 xonly_plot=.false., 226 xniter=2000, 227 xcheck_conv=50, 228 xepsilon(1)=0.0, 229 xepsilon(2)=0.0, 230 xepsilon(3)=1.0, 231 xiabs=1, 232 x_save_file='SiO2.xspectra_dip_c.sav', 233 xerror=0.001, 234 / 235 &plot 236 xnepoint=1000, 237 xgamma=0.8, 238 xemin=-10.0, 239 xemax=100.0, 240 terminator=.true., 241 cut_occ_states=.true., 242 &end 243 &pseudos 244 filecore='Si.wfc', 245 r_paw(1)=2.4, 246 &end 247 &cut_occ 248 cut_desmooth=0.1, 249 &end 2503 3 3 0 0 0 251EOF 252$ECHO " running xspectra.x ...\c" 253$X_COMMAND < SiO2.xspectra_dip_c.in > SiO2.xspectra_dip_c.out 254check_failure $? 255mv xanes.dat SiO2.xspectra_dip_c.dat 256$ECHO " done" 257 258$ECHO "#" 259$ECHO "# example of the restart mode" 260$ECHO "# a time limit is put is the first calculation" 261$ECHO "# so that it is not finished at the end of the time" 262$ECHO "# then one can restart the calculation of the coefficients" 263$ECHO "# of the continued fraction" 264$ECHO "#" 265$ECHO "# calculation 1 : not finished" 266 267cat > SiO2.xspectra_dip_restart_1.in << EOF 268 &input_xspectra 269 calculation='xanes_dipole' 270 prefix='SiO2', 271 outdir='$TMP_DIR/', 272 xonly_plot=.false., 273 xniter=2000, 274 xcheck_conv=50, 275 xepsilon(1)=0.0, 276 xepsilon(2)=0.0, 277 xepsilon(3)=1.0, 278 xiabs=1, 279 x_save_file='SiO2.xspectra_dip_restart_1.sav', 280 xerror=0.001, 281 time_limit=10, 282 / 283 &plot 284 xnepoint=1000, 285 xgamma=0.8, 286 xemin=-10.0, 287 xemax=100.0, 288 terminator=.true., 289 cut_occ_states=.true., 290 &end 291 &pseudos 292 filecore='Si.wfc', 293 r_paw(1)=2.4, 294 &end 295 &cut_occ 296 cut_desmooth=0.1, 297 &end 2983 3 3 0 0 0 299EOF 300$ECHO " running xspectra.x ...\c" 301$X_COMMAND < SiO2.xspectra_dip_restart_1.in > SiO2.xspectra_dip_restart_1.out 302check_failure $? 303$ECHO " done" 304$ECHO "#" 305$ECHO "# calculation 2 : finishing the first calculation" 306$ECHO "# the result should be identical to SiO2.xspectra_dip_c.dat" 307$ECHO "# copy SiO2.xspectra_dip_restart_1.sav to SiO2.xspectra_dip_restart_2.sav" 308cp SiO2.xspectra_dip_restart_1.sav SiO2.xspectra_dip_restart_2.sav 309 310cat > SiO2.xspectra_dip_restart_2.in << EOF 311 &input_xspectra 312 calculation='xanes_dipole' 313 prefix='SiO2', 314 outdir='$TMP_DIR/', 315 xonly_plot=.false., 316 xniter=2000, 317 xcheck_conv=50, 318 xepsilon(1)=0.0, 319 xepsilon(2)=0.0, 320 xepsilon(3)=1.0, 321 xiabs=1, 322 x_save_file='SiO2.xspectra_dip_restart_2.sav', 323 xerror=0.001, 324 restart_mode='restart', 325 / 326 &plot 327 xnepoint=1000, 328 xgamma=0.8, 329 xemin=-10.0, 330 xemax=100.0, 331 terminator=.true., 332 cut_occ_states=.true., 333 &end 334 &pseudos 335 filecore='Si.wfc', 336 r_paw(1)=2.4, 337 &end 338 &cut_occ 339 cut_desmooth=0.1, 340 &end 3413 3 3 0 0 0 342EOF 343$ECHO " running xspectra.x ...\c" 344$X_COMMAND < SiO2.xspectra_dip_restart_2.in > SiO2.xspectra_dip_restart_2.out 345check_failure $? 346mv xanes.dat SiO2.xspectra_dip_restart_2.dat 347$ECHO " done" 348$ECHO "# SiO2.xspectra_dip_restart_1.sav is not complete" 349$ECHO "# SiO2.xspectra_dip_restart_2.sav should be complete" 350