qe vc-relax to poscar

We’re doing some comparisons between structural optimizations in vasp versus qe. Here’s a little script for converting intermediate structures in a qe vc-relax run to poscar format; I was able to open files in vmd and create simulations from output. You may need to modify the assumptions made with regards to structure format etc

 #!/bin/bash

#a little script to get all the structures from a qe file & write them to separate poscar files

if [ $# -lt 1 ]
then
	echo "need to supply input qe filename, with extension .out"
	exit
fi

ext=${1##*.}
if [ "$ext" != "out" ]
then
	echo "filename must end in .out"
	exit
fi


file=${1}
base=$(basename $1 .out)


echo $output

#number of atoms
atoms=$(more $file | awk '/number of atoms/ {print $5}')

#multiplier in angstrom
mult=$(echo "$(more $file | awk 'BEGIN{i=1} /CELL_PARAMETERS/{if (i==1) {print $0; i=2} }' \
| sed 's/)/\ )/g' | awk '{print $3}') * 0.5291772083" | bc)


#atomic symbols
declare -a symb
symb=$(more $file | awk '/PseudoPot. #/{print $5; }')

#all array objects in same string
symbols=""

#find the frequency of each
declare -a freq
cnt=0

for x in $symb
do
	freq[cnt]=$(more $file | awk 'BEGIN{i=1; j=0; } /site n./{ {while (i<='$atoms') {getline; {if ($2=="'$x'") j++;}; i++}}} END{print j;}')
	symbols+=$x" "
	let "cnt+=1";
done

#write out intermediate structures
dt=$(date)
awk "BEGIN{i=0;} /CELL_PARAMETERS/{{str=\"$base\"i\".poscar\"; print \"$symbols\",\"   #generated by qe2pos \",\"$dt\" > str; \
print \"$mult\" >> str;\
getline; print \$0 >> str;\
getline; print \$0 >> str;\
getline; print \$0 >> str;\
print \"${freq[*]}\" >> str;\
print \"Direct\" >> str;\
getline; getline;\
for (j=0; j<=$atoms; j++){\
getline; print \$2,\$3,\$4 >> str;}\
} \
i++;}" $file

exit
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s