From: hackbard Date: Wed, 12 Aug 2009 18:00:11 +0000 (+0200) Subject: added trafo file (not working correctly by now) + mods to posca2moldyn script X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=dff8f18169aefa8aeb3daefc1047c60d0e343a29;p=physik%2Fposic.git added trafo file (not working correctly by now) + mods to posca2moldyn script --- diff --git a/vasp_tools/poscar2moldyn b/vasp_tools/poscar2moldyn index 1c11741..29a527e 100755 --- a/vasp_tools/poscar2moldyn +++ b/vasp_tools/poscar2moldyn @@ -2,24 +2,27 @@ mkdir -p video -echo "parsing POSCAR file ..." +file=$1 +[ -z $1 ] && file=POSCAR -sicnt=`sed -n 6p POSCAR | awk '{ print $1 }'` -ccnt=`sed -n 6p POSCAR | awk '{ print $2 }'` +echo "parsing $file file ..." -lc=`sed -n 2p POSCAR | awk '{ print $1 }'` +sicnt=`sed -n 6p $file | awk '{ print $1 }'` +ccnt=`sed -n 6p $file | awk '{ print $2 }'` -x1=`sed -n 3p POSCAR | awk '{ print $1 }'` -x2=`sed -n 3p POSCAR | awk '{ print $2 }'` -x3=`sed -n 3p POSCAR | awk '{ print $3 }'` +lc=`sed -n 2p $file | awk '{ print $1 }'` -y1=`sed -n 4p POSCAR | awk '{ print $1 }'` -y2=`sed -n 4p POSCAR | awk '{ print $2 }'` -y3=`sed -n 4p POSCAR | awk '{ print $3 }'` +x1=`sed -n 3p $file | awk '{ print $1 }'` +x2=`sed -n 3p $file | awk '{ print $2 }'` +x3=`sed -n 3p $file | awk '{ print $3 }'` -z1=`sed -n 5p POSCAR | awk '{ print $1 }'` -z2=`sed -n 5p POSCAR | awk '{ print $2 }'` -z3=`sed -n 5p POSCAR | awk '{ print $3 }'` +y1=`sed -n 4p $file | awk '{ print $1 }'` +y2=`sed -n 4p $file | awk '{ print $2 }'` +y3=`sed -n 4p $file | awk '{ print $3 }'` + +z1=`sed -n 5p $file | awk '{ print $1 }'` +z2=`sed -n 5p $file | awk '{ print $2 }'` +z3=`sed -n 5p $file | awk '{ print $3 }'` ((total=sicnt+ccnt)) @@ -39,7 +42,7 @@ cz=0.8 echo "# P $total init <$cx,$cy,$cz>" > video/atomic_conf_init.xyz -tail -${total} POSCAR | \ +tail -${total} $file | \ while read x y z fx fy fz; do type="Si" color="Yellow" diff --git a/vasp_tools/trafoXposcar b/vasp_tools/trafoXposcar new file mode 100755 index 0000000..1aebc4f --- /dev/null +++ b/vasp_tools/trafoXposcar @@ -0,0 +1,88 @@ +#!/bin/bash + +echo "parsing POSCAR file ..." + +trg=POSCAR.transformed + +theta=$1 + +sicnt=`sed -n 6p POSCAR | awk '{ print $1 }'` +ccnt=`sed -n 6p POSCAR | awk '{ print $2 }'` + +lc=`sed -n 2p POSCAR | awk '{ print $1 }'` + +x1=`sed -n 3p POSCAR | awk '{ print $1 }'` +x2=`sed -n 3p POSCAR | awk '{ print $2 }'` +x3=`sed -n 3p POSCAR | awk '{ print $3 }'` + +y1=`sed -n 4p POSCAR | awk '{ print $1 }'` +y2=`sed -n 4p POSCAR | awk '{ print $2 }'` +y3=`sed -n 4p POSCAR | awk '{ print $3 }'` + +z1=`sed -n 5p POSCAR | awk '{ print $1 }'` +z2=`sed -n 5p POSCAR | awk '{ print $2 }'` +z3=`sed -n 5p POSCAR | awk '{ print $3 }'` + +((total=sicnt+ccnt)) + +echo " Si: $sicnt, C: $ccnt, total: $total" +echo " Lattice constant: $lc A" +echo " Basis:" +echo " $x1 $y1 $z1" +echo " x = $x2 y = $y2 z = $z2" +echo " $x3 $y3 $z3" +echo +echo " -----" +echo " Trafo: x axis, $theta degree" +echo " -----" + +costheta=`echo $theta | awk '{ print cos($1*3.1415927/180.0) }'` +sintheta=`echo $theta | awk '{ print sin($1*3.1415927/180.0) }'` + +X1=$x1 +X2=`echo $x2 $x3 $costheta $sintheta | awk '{ print $3*$1-$4*$2 }'` +X3=`echo $x2 $x3 $costheta $sintheta | awk '{ print $4*$1+$3*$2 }'` + +Y1=$y1 +Y2=`echo $y2 $y3 $costheta $sintheta | awk '{ print $3*$1-$4*$2 }'` +Y3=`echo $y2 $y3 $costheta $sintheta | awk '{ print $4*$1+$3*$2 }'` + +Z1=$z1 +Z2=`echo $z2 $z3 $costheta $sintheta | awk '{ print $3*$1-$4*$2 }'` +Z3=`echo $z2 $z3 $costheta $sintheta | awk '{ print $4*$1+$3*$2 }'` + +echo +echo " Transformed basis:" +echo " $X1 $Y1 $Z1" +echo " x = $X2 y = $Y2 z = $Z2" +echo " $X3 $Y3 $Z3" +echo + +cnt=0 +tcnt=0 + +cx=1.0 +cy=1.0 +cz=0.8 + +# header +sed -n 1p POSCAR > $trg +echo " $lc" >> $trg +echo " $X1 $X2 $X3" >> $trg +echo " $Y1 $Y2 $Y3" >> $trg +echo " $Z1 $Z2 $Z3" >> $trg +echo " $sicnt $ccnt" >> $trg +echo "selective dynamics" >> $trg +echo "direct" >> $trg + +tail -${total} POSCAR | \ + while read x y z fx fy fz; do + Y=`echo $y $z $costheta $sintheta | \ + awk '{ print $3*$1+$4*$2 }'` + Z=`echo $y $z $costheta $sintheta | \ + awk '{ print $3*$2-$4*$1 }'` + echo " $x $Y $Z $fx $fy $fz" >> $trg + done + +echo "done" +