IDM: Difference between revisions
Jump to navigation
Jump to search
m Replacing page with 'go back to Main Page, Computational Resources, Chemistry & More, Computational Codes, VASP, Scripts for VASP = Introduction = = Script = = Alternativ...' |
|||
| Line 4: | Line 4: | ||
= Script = | = Script = | ||
Please copy the following lines in your ~/bin folder. Recommended name: getdimer | |||
#!/bin/bash | |||
# | |||
# Generates the POSCAR of a dimer calculation | |||
# Rodrigo García-Muelas | |||
# July 18th, 2014. Tarragona. | |||
# | |||
# Use with VASP 5.x or higher | |||
# | |||
# INPUT | |||
# $1 Path of the POSCAR file containing the coordinates | |||
# $2 Path of the OUTCAR file containing the frequencies of the structure | |||
# $3 <OUTPUT> POSCAR file | |||
# | |||
# | |||
# Indexes | |||
# a number of line | |||
# b number of column | |||
# c number of lattice vector, related to a | |||
# d number of element, related to a | |||
# | |||
# VECTORS | |||
# lattice | |||
# element | |||
# numelem | |||
# coordin | |||
# | |||
# PART 0 - SECURITY CHECKS | |||
if [ -e $3 ] ; then | |||
echo "Warning! $3 already exist. Overwrite? (y/Y for yes)" | |||
read overwrite | |||
case $overwrite in | |||
y|Y|Yes|yes|YES) echo "$3 will be overwriten" ;; | |||
*) echo "No actions taken " ; exit 1 ;; | |||
esac | |||
fi | |||
IBRION=`grep IBRION $2 | awk '{print $3}'` | |||
if [[ $IBRION -gt "8" || $IBRION -lt "5" ]] ; then | |||
echo "$2 is not an OUTCAR of a frequency job." | |||
echo "No actions taken" ; exit 1 ; fi | |||
# PART 1 - READ POSCAR | |||
a=0 | |||
totalelem=0 | |||
totalatom=0 | |||
while read linea ; do ##### 1 ##### | |||
a=$(($a+1)) ; b=0 ; d=$(($a-9)) ; line[$a]=$linea ; | |||
# echo $a; #echo $line; if [ $a -lt 10 ] ; then echo "${line[$a]}" ; fi | |||
for word in ${line[$a]} ; do ##### 2 ##### | |||
b=$(($b+1)) | |||
#if [ $a -lt 10 ] ; then echo "previous to case a is $a" ; fi | |||
case $a in | |||
1) title=${line[$a]} ;; | |||
2) scaling=$word ;; | |||
[3-5]) c=$(($a-2)) ; lattice[$c$b]=$word ;; #; echo "coordinates $c $b $word ${lattice[$c$b]}" | |||
6) totalelem=$(($totalelem+1)) ; element[$b]=$word ;; | |||
7) numelem[$b]=$word ; totalatom=$(($totalatom+$word)) ;; | |||
8) selective=${line[$a]} ;; | |||
9) directcartesian=${line[$a]} ;; | |||
*) coord[$d$b]=$word ;; # echo "${coord[$d$b]}" ;; | |||
esac | |||
#if [ $a -lt 10 ] ; then echo "word value is $word" ; fi | |||
done ##### 2 ##### | |||
done < "$1" ##### 1 ##### | |||
# PART 2 - READ OUTCAR | |||
grep -A $(($totalatom+1)) 'cm-1' OUTCAR > temp1.tmp | |||
tail -n $totalatom temp1.tmp | awk '{printf " %12.6f%12.6f%12.6f\n",$4,$5,$6}' > temp2.tmp | |||
# PART 3 - PRINT POSCAR | |||
touch $3 | |||
echo "$title " >$3 | |||
echo "$scaling " >>$3 | |||
echo "${lattice[11]} ${lattice[12]} ${lattice[13]} " >>$3 | |||
echo "${lattice[21]} ${lattice[22]} ${lattice[23]} " >>$3 | |||
echo "${lattice[31]} ${lattice[32]} ${lattice[33]} " >>$3 | |||
echo "${element[1]} ${element[2]} ${element[3]} ${element[4]} ${element[5]} ${element[6]} ${element[7]} ${element[8]} ${element[9]} ${element[10]} ${element[11]} ${element[12]} ${element[13]} ${element[14]} ${element[15]} ${element[16]} ${element[17]} ${element[18]} ${element[19]} ${element[20]} " >>$3 | |||
echo "${numelem[1]} ${numelem[2]} ${numelem[3]} ${numelem[4]} ${numelem[5]} ${numelem[6]} ${numelem[7]} ${numelem[8]} ${numelem[9]} ${numelem[10]} ${numelem[11]} ${numelem[12]} ${numelem[13]} ${numelem[14]} ${numelem[15]} ${numelem[16]} ${numelem[17]} ${numelem[18]} ${numelem[19]} ${numelem[20]} " >>$3 | |||
echo "$selective " >>$3 | |||
echo "$directcartesian " >>$3 | |||
d=0 ; until [ $d -eq $(($totalatom*10)) ] ; do d=$(($d+10)) ; echo "${coord[$(($d+1))]} ${coord[$(($d+2))]} ${coord[$(($d+3))]} ${coord[$(($d+4))]} ${coord[$(($d+5))]} ${coord[$(($d+6))]} " >>$3 ; done | |||
echo " " >>$3 | |||
# PUT AS TAIL THE COORDINATES READ FROM THE OUTCAR | |||
cat temp2.tmp >> $3 | |||
echo "" >> $3 | |||
rm -f temp?.tmp | |||
= Alternative (old) versions = | = Alternative (old) versions = | ||
Revision as of 14:44, 18 July 2014
go back to Main Page, Computational Resources, Chemistry & More, Computational Codes, VASP, Scripts for VASP
Introduction
Script
Please copy the following lines in your ~/bin folder. Recommended name: getdimer
#!/bin/bash
#
# Generates the POSCAR of a dimer calculation
# Rodrigo García-Muelas
# July 18th, 2014. Tarragona.
#
# Use with VASP 5.x or higher
#
# INPUT
# $1 Path of the POSCAR file containing the coordinates
# $2 Path of the OUTCAR file containing the frequencies of the structure
# $3 <OUTPUT> POSCAR file
#
#
# Indexes
# a number of line
# b number of column
# c number of lattice vector, related to a
# d number of element, related to a
#
# VECTORS
# lattice
# element
# numelem
# coordin
#
# PART 0 - SECURITY CHECKS
if [ -e $3 ] ; then
echo "Warning! $3 already exist. Overwrite? (y/Y for yes)"
read overwrite
case $overwrite in
y|Y|Yes|yes|YES) echo "$3 will be overwriten" ;;
*) echo "No actions taken " ; exit 1 ;;
esac
fi
IBRION=`grep IBRION $2 | awk '{print $3}'`
if | $IBRION -lt "5" ; then
echo "$2 is not an OUTCAR of a frequency job."
echo "No actions taken" ; exit 1 ; fi
# PART 1 - READ POSCAR
a=0
totalelem=0
totalatom=0
while read linea ; do ##### 1 #####
a=$(($a+1)) ; b=0 ; d=$(($a-9)) ; line[$a]=$linea ;
# echo $a; #echo $line; if [ $a -lt 10 ] ; then echo "${line[$a]}" ; fi
for word in ${line[$a]} ; do ##### 2 #####
b=$(($b+1))
#if [ $a -lt 10 ] ; then echo "previous to case a is $a" ; fi
case $a in
1) title=${line[$a]} ;;
2) scaling=$word ;;
[3-5]) c=$(($a-2)) ; lattice[$c$b]=$word ;; #; echo "coordinates $c $b $word ${lattice[$c$b]}"
6) totalelem=$(($totalelem+1)) ; element[$b]=$word ;;
7) numelem[$b]=$word ; totalatom=$(($totalatom+$word)) ;;
8) selective=${line[$a]} ;;
9) directcartesian=${line[$a]} ;;
*) coord[$d$b]=$word ;; # echo "${coord[$d$b]}" ;;
esac
#if [ $a -lt 10 ] ; then echo "word value is $word" ; fi
done ##### 2 #####
done < "$1" ##### 1 #####
# PART 2 - READ OUTCAR
grep -A $(($totalatom+1)) 'cm-1' OUTCAR > temp1.tmp
tail -n $totalatom temp1.tmp | awk '{printf " %12.6f%12.6f%12.6f\n",$4,$5,$6}' > temp2.tmp
# PART 3 - PRINT POSCAR
touch $3
echo "$title " >$3
echo "$scaling " >>$3
echo "${lattice[11]} ${lattice[12]} ${lattice[13]} " >>$3
echo "${lattice[21]} ${lattice[22]} ${lattice[23]} " >>$3
echo "${lattice[31]} ${lattice[32]} ${lattice[33]} " >>$3
echo "${element[1]} ${element[2]} ${element[3]} ${element[4]} ${element[5]} ${element[6]} ${element[7]} ${element[8]} ${element[9]} ${element[10]} ${element[11]} ${element[12]} ${element[13]} ${element[14]} ${element[15]} ${element[16]} ${element[17]} ${element[18]} ${element[19]} ${element[20]} " >>$3
echo "${numelem[1]} ${numelem[2]} ${numelem[3]} ${numelem[4]} ${numelem[5]} ${numelem[6]} ${numelem[7]} ${numelem[8]} ${numelem[9]} ${numelem[10]} ${numelem[11]} ${numelem[12]} ${numelem[13]} ${numelem[14]} ${numelem[15]} ${numelem[16]} ${numelem[17]} ${numelem[18]} ${numelem[19]} ${numelem[20]} " >>$3
echo "$selective " >>$3
echo "$directcartesian " >>$3
d=0 ; until [ $d -eq $(($totalatom*10)) ] ; do d=$(($d+10)) ; echo "${coord[$(($d+1))]} ${coord[$(($d+2))]} ${coord[$(($d+3))]} ${coord[$(($d+4))]} ${coord[$(($d+5))]} ${coord[$(($d+6))]} " >>$3 ; done
echo " " >>$3
# PUT AS TAIL THE COORDINATES READ FROM THE OUTCAR
cat temp2.tmp >> $3 echo "" >> $3 rm -f temp?.tmp
Alternative (old) versions
To see the other comments about the Improved Dimer Method, please see
WARNING: Some of the topics discussed by David Karhánek are outdated. For instance, it is not necessary to set NWRITE=3 for the frequency calculation: IDM-old get-dimer-dir.sh get-irc-path.sh (by David Karhanek)