#!/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 calculate interatomic force constants in" $ECHO "real space for mgb in zincblende structure." # set the needed environment variables . ../environment_variables # required executables and pseudopotentials BIN_LIST="pw.x ph.x q2r.x matdyn.x" PSEUDO_LIST="Mg.pz-bhs.UPF B.pz-bhs.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 "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" PH_COMMAND="$PARA_PREFIX $BIN_DIR/ph.x $PARA_POSTFIX" Q2R_COMMAND="$PARA_PREFIX $BIN_DIR/q2r.x $PARA_POSTFIX" MATDYN_COMMAND="$PARA_PREFIX $BIN_DIR/matdyn.x $PARA_POSTFIX" $ECHO $ECHO " running pw.x as: $PW_COMMAND" $ECHO " running ph.x as: $PH_COMMAND" $ECHO " running q2r.x as: $Q2R_COMMAND" $ECHO " running matdyn.x as: $MATDYN_COMMAND" $ECHO # clean TMP_DIR $ECHO " cleaning $TMP_DIR...\c" rm -rf $TMP_DIR/* $ECHO " done" # self-consistent calculation cat > mgb.scf.in << EOF &control calculation='scf' restart_mode='from_scratch', tstress = .true. tprnfor = .true. prefix='mgb', pseudo_dir = '$PSEUDO_DIR/', outdir='$TMP_DIR/' / &SYSTEM ibrav = 4, celldm(1) = 5.803350584, celldm(3) = 1.165092804, nat = 3, ntyp = 2, ecutwfc = 30.0 , ecutrho = 120.0 , occupations = 'smearing' , degauss = 0.01 , smearing = 'gaussian' , / &ELECTRONS conv_thr = 1.0d-8 , mixing_beta = 0.7 , diagonalization = 'cg' , / ATOMIC_SPECIES Mg 24.30500 Mg.pz-bhs.UPF B 10.81100 B.pz-bhs.UPF ATOMIC_POSITIONS alat Mg 0.000000000 0.000000000 0.000000000 B 0.500000000 0.288680000 0.570500000 B 0.000000000 0.577350000 0.570500000 K_POINTS automatic 16 16 12 0 0 0 EOF $ECHO " running the scf calculation...\c" $PW_COMMAND < mgb.scf.in > mgb.scf.out $ECHO " done" # phonons cat > mgb.phG.in << EOF phonons of mgb at Gamma &inputph tr2_ph=1.0d-12, prefix='mgb', amass(1)=24.305, amass(2)=10.811, outdir='$TMP_DIR/', fildyn='mgb.dynG', / 0.0 0.0 0.0 EOF $ECHO " running the phonon calculation at Gamma...\c" $PH_COMMAND < mgb.phG.in > mgb.phG.out $ECHO " done" # These are k-points of a (666) uniform grid in the irreducible # Brillouin Zone of the fcc lattice (Gamma is treated separately) /bin/rm mgb.nscf.out mgb.ph.out qpoints="0.0000000,0.0000000,0.1430501\ 0.0000000,0.0000000,0.2861002\ 0.0000000,0.0000000,-0.4291504\ 0.0000000,0.1924501,0.0000000\ 0.0000000,0.1924501,0.1430501\ 0.0000000,0.1924501,0.2861002\ 0.0000000,0.1924501,-0.4291504\ 0.0000000,0.3849002,0.0000000\ 0.0000000,0.3849002,0.1430501\ 0.0000000,0.3849002,0.2861002\ 0.0000000,0.3849002,-0.4291504\ 0.0000000,-0.5773503,0.0000000\ 0.0000000,-0.5773503,0.1430501\ 0.0000000,-0.5773503,0.2861002\ 0.0000000,-0.5773503,-0.4291504\ 0.1666667,0.2886751,0.0000000\ 0.1666667,0.2886751,0.1430501\ 0.1666667,0.2886751,0.2861002\ 0.1666667,0.2886751,-0.4291504\ 0.1666667,0.4811252,0.0000000\ 0.1666667,0.4811252,0.1430501\ 0.1666667,0.4811252,0.2861002\ 0.1666667,0.4811252,-0.4291504\ 0.3333333,0.5773503,0.0000000\ 0.3333333,0.5773503,0.1430501\ 0.3333333,0.5773503,0.2861002\ 0.3333333,0.5773503,-0.4291504\" for qpoint in $qpoints ; do # non self-consistent calculation qx=`$ECHO $qpoint | cut -d, -f1` qy=`$ECHO $qpoint | cut -d, -f2` qz=`$ECHO $qpoint | cut -d, -f3` cat > mgb.nscf.in << EOF &control calculation='phonon' restart_mode='from_scratch', prefix='mgb', pseudo_dir = '$PSEUDO_DIR/', outdir='$TMP_DIR/' / &SYSTEM ibrav = 4, celldm(1) = 5.803350584, celldm(3) = 1.165092804, nat = 3, ntyp = 2, ecutwfc = 30.0 , ecutrho = 120.0 , occupations = 'smearing' , degauss = 0.01 , smearing = 'gaussian' , / &ELECTRONS conv_thr = 1.0d-8 , mixing_beta = 0.7 , diagonalization = 'cg' , / &phonon xqq(1) = $qx, xqq(2) = $qy, xqq(3) = $qz / ATOMIC_SPECIES Mg 24.30500 Mg.pz-bhs.UPF B 10.81100 B.pz-bhs.UPF ATOMIC_POSITIONS alat Mg 0.000000000 0.000000000 0.000000000 B 0.500000000 0.288680000 0.570500000 B 0.000000000 0.577350000 0.570500000 K_POINTS automatic 16 16 12 0 0 0 EOF $ECHO " running the nscf calculation at q=$qpoint...\c" $PW_COMMAND < mgb.nscf.in >> mgb.nscf.out $ECHO " done" # the following line prevents the appearence of a bug with PGI compiler if test -f $TMP_DIR/mgb.bar ; then /bin/rm $TMP_DIR/mgb.bar ; fi # phonon calculation cat > mgb.ph.in << EOF phonons of mgb at $qpoint &inputph tr2_ph=1.0d-12, prefix='mgb', amass(1)=24.305, amass(2)=10.811, outdir='$TMP_DIR/', fildyn='dyn.$qpoint' / $qpoint EOF $ECHO " running the phonon calculation at q=$qpoint...\c" $PH_COMMAND < mgb.ph.in >> mgb.ph.out $ECHO " done" done cat > q2r.in < C(R)...\c" $Q2R_COMMAND < q2r.in > q2r.out $ECHO " done" cat > matdyn.in < matdyn.out $ECHO " done" cat > phdos.in < phdos.out $ECHO " done" $ECHO $ECHO "$EXAMPLE_DIR: done"