autophonon

All you need to get going is a vasp.in file with the RELAXED structure in it, as well as comp.config and fitfc.config files.

Typical usage:

autophonon > log.out

This will just show you progress and not actually launch any jobs automatically. To do that,

autophonon run > log.out

comp.config file:

# job identifier (careful, don't make it longer than 2 or 3 characters!)

FO

# nodes to use for relaxation

1

# number of cpus to use for relaxation

2

# walltime to use for relaxation

8

# nodes to use for static calculations

1

# number of cpus to use for static calculations

4

# walltime to use for static calculations

16

fitfc.config file:

# Format: value for er, then ns, then ms, then dr

5

3

0.04

0.1

autophonon script:

#!/bin/sh

function cleanhouse {

echo "Cleaning old files..."

foreachfile vasp.in rm OSZICAR OUTCAR *.q str_relax.out &> /dev/null

foreachfile -d 2 vasp.in rm OSZICAR OUTCAR *.q str_relax.out &> /dev/null

}

function jobsub {

jobname=$1

jobtype=$2

if [ $jobtype = "relax" ]; then

sed -e '/ISIF/d' INCAR > INCAR.new

echo "ISIF = 4" >> INCAR.new

mv INCAR.new INCAR

else

sed -e '/ISIF/d' INCAR > INCAR.new

echo "ISIF = 2" >> INCAR.new

mv INCAR.new INCAR

sed -e '/IBRION/d' INCAR > INCAR.new

echo "IBRION = -1" >> INCAR.new

mv INCAR.new INCAR

sed -e '/NSW/d' INCAR > INCAR.new

echo "NSW = 0" >> INCAR.new

mv INCAR.new INCAR

sed -e '/ISMEAR/d' INCAR > INCAR.new

echo "ISMEAR = -5" >> INCAR.new

mv INCAR.new INCAR

sed -e '/ALGO/d' INCAR > INCAR.new

echo "ALGO = FAST" >> INCAR.new

mv INCAR.new INCAR

fi

if [ $jobtype = "relax" -o $jobtype = "volstatic" ]; then

makeqfile $jobname $relaxnodes $relaxcpu $relaxtime

else makeqfile $jobname $staticnodes $staticcpu $statictime

fi

qsub $jobname.q

sleep 10

}

function statuscheck {

jobname=$1

jobtype=$2

user=`whoami`

if [ -e OSZICAR ]; then

tail -1 OSZICAR

else echo "No OSZICAR; this step has not made any progress"

fi

if [ "$runmode" = "run" ]; then

queuestatus=`qstat | grep $user | grep $jobname`

if [ "$queuestatus" ]; then

echo "Job $jobname is running"

echo $queuestatus

else echo "Job $jobname is not running"

jobsub $jobname $jobtype

fi

fi

}

function printenergy {

file=$1

grep TOTEN $1 | tail -1

}

function relax1check {

vol=$1

if [ -e OUTCAR.relax1 ]; then

echo "vol_$vol is done with the first relaxation!"

printenergy OUTCAR.relax1

elif [ -e OUTCAR ] && grep -q "required accuracy" OUTCAR && [ ! -e OUTCAR.relax1 ]; then

sleep 30

mv OUTCAR OUTCAR.relax1

mv OSZICAR OSZICAR.relax1

cp INCAR INCAR.relax1

cp CONTCAR POSCAR

elif [ ! -e OUTCAR.relax1 ]; then

echo "vol_$vol first relaxation in progress"

statuscheck "$id"v"$vol"r1 relax

fi

}

function relax2check {

vol=$1

if [ -e OUTCAR.relax2 ]; then

echo "vol_$vol is done with the second relaxation!"

printenergy OUTCAR.relax2

elif [ -e OUTCAR ] && [ -e OUTCAR.relax1 ] && grep -q "required accuracy" OUTCAR; then

sleep 30

mv OUTCAR OUTCAR.relax2

mv OSZICAR OSZICAR.relax2

cp INCAR INCAR.relax2

cp CONTCAR POSCAR

elif [ -e OUTCAR.relax1 ]; then

echo "vol_$vol second relaxation in progress"

statuscheck "$id"v"$vol"r2 relax

fi

}

function volstatic {

vol=$1

volindex=$2

if [ -e OUTCAR.static ]; then

echo "vol_$vol is done with its static calculation"

printenergy OUTCAR.static

let volindex=$volindex+1

if [ ! -e str_relax.out ]; then

extract_vasp

fi

elif [ -e OUTCAR ] && [ -e OUTCAR.relax2 ] && grep -q "aborting loop" OUTCAR; then

sleep 30

mv OUTCAR OUTCAR.static

mv OSZICAR OSZICAR.static

cp INCAR INCAR.static

elif [ -e OUTCAR.relax2 ]; then

echo "vol_$vol static calculation in progress"

statuscheck "$id"v"$vol"st volstatic

fi

return $[$volindex]

}

function staticcheck {

vol=$1

staticindex=0

staticdone=0

for file in $(ls); do

if [ -d $file ]; then

echo "Checking static calculation directory $file"

cd $file

if [ -e OUTCAR.static ]; then

echo "$file static calculation is done!"

let staticdone=$staticdone+1

printenergy OUTCAR.static

if [ ! -e str_relax.out ]; then

extract_vasp

fi

elif [ -e OUTCAR ] && grep -q "aborting loop" OUTCAR; then

sleep 30

mv OUTCAR OUTCAR.static

mv OSZICAR OSZICAR.static

cp INCAR INCAR.static

elif [ -e ../OUTCAR.relax2 ]; then

echo "$file static calculation in progress"

statuscheck "$id"v"$vol"s"$staticindex" static

cd ..

fi

let staticindex=$staticindex+1

fi

done

return $[$staticindex-$staticdone]

}

# get necessary variables

runmode=$1

erval=`sed -n '2p' fitfc.config`

nsval=`sed -n '3p' fitfc.config`

msval=`sed -n '4p' fitfc.config`

drval=`sed -n '5p' fitfc.config`

id=`sed -n '2p' comp.config`

relaxnodes=`sed -n '4p' comp.config`

relaxcpu=`sed -n '6p' comp.config`

relaxtime=`sed -n '8p' comp.config`

staticnodes=`sed -n '10p' comp.config`

staticcpu=`sed -n '12p' comp.config`

statictime=`sed -n '14p' comp.config`

# set up str.out and str_relax.out files

function str_out {

rm str.out

sed -e '/./{H;$!d;}' -e 'x;/POSCAR/!d;' vasp.in | sed 's/^[ \t]*//' > tmp

sed -n '5,7p' tmp > str.out

latparam=`sed -n '4p' tmp | sed 's/^[ \t]*//'`

cat >> str.out << EOF

$latparam 0 0

0 $latparam 0

0 0 $latparam

EOF

sed '1,8d' tmp >> str.out

rm tmp

cp str.out str_relax.out

}

# set up vasp.wrap file

function vasp_wrap {

sed '/POSCAR/,$d' vasp.in > vasp.wrap

}

# get list of the volume folders ATAT creates

function getvollist {

i=1

for file in $(ls); do

if echo $file | grep vol_; then

vollist[i]=`echo $file`

fi

done

echo $vollist

}

# Function to generate a queue file for encina

# $1: name of .q file; $2: ncpus; $3: walltime

function makeqfile {

if [ `hostname` == "encina" ]; then

cat > $1.q << EOF

#PBS -l ncpus=$3

#PBS -l walltime=$4:00:00

cd $`echo PBS_O_WORKDIR`

echo Running on host \`hostname\`

echo Time is \`date\`

echo Directory is \`pwd\`

echo ""

mpirun -np $3 /usr/local/bin/vasp

EOF

elif [ `hostname` == "master.cl.northwestern.edu" ]; then

cat > $1.q << EOF

#PBS -l nodes=$2:ppn=$3

#PBS -l walltime=$4:00:00

# This job's working directory

# echo Working directory is $`echo PBS_O_WORKDIR`

cd $`echo PBS_O_WORKDIR`

echo ""

echo Running on host \`hostname\`

echo Time is \`date\`

echo Directory is \`pwd\`

echo This jobs runs on the following processors:

echo \`cat $`echo PBS_NODEFILE`\`

# Define number of processors

NPROCS=\`wc -l < $`echo PBS_NODEFILE`\`

echo This job has allocated $`echo NPROCS` nodes

echo ""

echo ==========================================================================

echo ""

mpirun -machinefile $`echo PBS_NODEFILE` -np $`echo NPROCS` /usr/local/bin/vasp

EOF

fi

}

# if runmode is "run", submit jobs; otherwise, just print status

function getnewcalcs {

fitfc -er=$erval -ns=$nsval -ms=$msval -dr=$drval

sleep 10

foreachfile str.out str2ezvasp

foreachfile -d 2 str.out str2ezvasp

foreachfile vasp.in ezvasp -n vasp.in

foreachfile -d 2 vasp.in ezvasp -n vasp.in

}

# main body of script

cleanhouse

str_out

vasp_wrap

getnewcalcs

vollist=`getvollist`

while [ 1 ]; do

sleep 15

voldone=0

staticremaining=0

for i in $vollist; do

echo "Checking $i..."

cd $i

relax1check $i

relax2check $i

volstatic $i $voldone

voldone=$?

dirs_here=`ls -l | egrep '^d'`

# prepare static calculations if all volumes are done and they do not already exist

if [ "$voldone" == "$nsval" ] && [ ! "$dirs_here" ]; then

cd ..

getnewcalcs

fi

staticcheck $i

let staticremaining=$staticremaining+$?

cd ..

done

if [ "$voldone" == "$nsval" ] && [ "$staticremaining" == "0" ] && ls vol_0 | grep p+; then

echo "Phonon calculation complete!"

break

fi

echo "$voldone of $nsval volume calculations complete"

echo "$staticremaining static calculations remaining"

echo "*****************************************"

done