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))
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"
--- /dev/null
+#!/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"
+