3 echo "parsing POSCAR file ..."
7 trg=POSCAR.Xtrafo$theta
9 sicnt=`sed -n 6p POSCAR | awk '{ print $1 }'`
10 ccnt=`sed -n 6p POSCAR | awk '{ print $2 }'`
12 lc=`sed -n 2p POSCAR | awk '{ print $1 }'`
14 x1=`sed -n 3p POSCAR | awk '{ print $1 }'`
15 x2=`sed -n 3p POSCAR | awk '{ print $2 }'`
16 x3=`sed -n 3p POSCAR | awk '{ print $3 }'`
18 y1=`sed -n 4p POSCAR | awk '{ print $1 }'`
19 y2=`sed -n 4p POSCAR | awk '{ print $2 }'`
20 y3=`sed -n 4p POSCAR | awk '{ print $3 }'`
22 z1=`sed -n 5p POSCAR | awk '{ print $1 }'`
23 z2=`sed -n 5p POSCAR | awk '{ print $2 }'`
24 z3=`sed -n 5p POSCAR | awk '{ print $3 }'`
28 echo " Si: $sicnt, C: $ccnt, total: $total"
29 echo " Lattice constant: $lc A"
32 echo " x = $x2 y = $y2 z = $z2"
36 echo " Trafo: x axis, $theta degree"
40 # determine trafo of cartesian coordinates to this one
41 normx=`echo $x1 $x2 $x3 | awk '{ print sqrt($1*$1+$2*$2+$3*$3) }'`
42 normy=`echo $y1 $y2 $y3 | awk '{ print sqrt($1*$1+$2*$2+$3*$3) }'`
43 normz=`echo $z1 $z2 $z3 | awk '{ print sqrt($1*$1+$2*$2+$3*$3) }'`
44 echo $normx $normz $normy
45 t11=`echo $x1 $normx | awk '{ print $1/$2 }'`
46 t12=`echo $x2 $normx | awk '{ print $1/$2 }'`
47 t13=`echo $x3 $normx | awk '{ print $1/$2 }'`
48 t21=`echo $y1 $normy | awk '{ print $1/$2 }'`
49 t22=`echo $y2 $normy | awk '{ print $1/$2 }'`
50 t23=`echo $y3 $normy | awk '{ print $1/$2 }'`
51 t31=`echo $z1 $normz | awk '{ print $1/$2 }'`
52 t32=`echo $z2 $normz | awk '{ print $1/$2 }'`
53 t33=`echo $z3 $normz | awk '{ print $1/$2 }'`
54 echo " Matrix from cartesian to used coordinates:"
55 echo " | $t11 $t21 $t31 |"
56 echo " | $t12 $t22 $t32 |"
57 echo " | $t13 $t23 $t33 |"
68 echo " Inverse matrix (i=t^T):"
69 echo " | $i11 $i21 $i31 |"
70 echo " | $i12 $i22 $i32 |"
71 echo " | $i13 $i23 $i33 |"
74 X1=`echo $i11 $i21 $i31 $x1 $x2 $x3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
75 X2=`echo $i12 $i22 $i32 $x1 $x2 $x3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
76 X3=`echo $i13 $i23 $i33 $x1 $x2 $x3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
78 Y1=`echo $i11 $i21 $i31 $y1 $y2 $y3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
79 Y2=`echo $i12 $i22 $i32 $y1 $y2 $y3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
80 Y3=`echo $i13 $i23 $i33 $y1 $y2 $y3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
82 Z1=`echo $i11 $i21 $i31 $z1 $z2 $z3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
83 Z2=`echo $i12 $i22 $i32 $z1 $z2 $z3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
84 Z3=`echo $i13 $i23 $i33 $z1 $z2 $z3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
85 echo " Basis (in rotation system):"
87 echo " x = $X2 y = $Y2 z = $Z2"
91 costheta=`echo $theta | awk '{ print cos($1*3.1415927/180.0) }'`
92 sintheta=`echo $theta | awk '{ print sin($1*3.1415927/180.0) }'`
98 X2=`echo $x2 $x3 $costheta $sintheta | awk '{ print $3*$1-$4*$2 }'`
99 X3=`echo $x2 $x3 $costheta $sintheta | awk '{ print $4*$1+$3*$2 }'`
105 Y2=`echo $y2 $y3 $costheta $sintheta | awk '{ print $3*$1-$4*$2 }'`
106 Y3=`echo $y2 $y3 $costheta $sintheta | awk '{ print $4*$1+$3*$2 }'`
112 Z2=`echo $z2 $z3 $costheta $sintheta | awk '{ print $3*$1-$4*$2 }'`
113 Z3=`echo $z2 $z3 $costheta $sintheta | awk '{ print $4*$1+$3*$2 }'`
115 echo " Transformed basis (in rotation system):"
117 echo " x' = $X2 y' = $Y2 z' = $Z2"
122 x1=`echo $t11 $t21 $t31 $X1 $X2 $X3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
123 x2=`echo $t12 $t22 $t32 $X1 $X2 $X3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
124 x3=`echo $t13 $t23 $t33 $X1 $X2 $X3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
129 y1=`echo $t11 $t21 $t31 $Y1 $Y2 $Y3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
130 y2=`echo $t12 $t22 $t32 $Y1 $Y2 $Y3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
131 y3=`echo $t13 $t23 $t33 $Y1 $Y2 $Y3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
136 z1=`echo $t11 $t21 $t31 $Z1 $Z2 $Z3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
137 z2=`echo $t12 $t22 $t32 $Z1 $Z2 $Z3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
138 z3=`echo $t13 $t23 $t33 $Z1 $Z2 $Z3 | awk '{ print $1*$4+$2*$5+$3*$6 }'`
144 echo " Transformed basis (cartesian coordinates):"
146 echo " x' = $X2 y' = $Y2 z' = $Z2"
158 sed -n 1p POSCAR > $trg
160 echo " $X1 $X2 $X3" >> $trg
161 echo " $Y1 $Y2 $Y3" >> $trg
162 echo " $Z1 $Z2 $Z3" >> $trg
163 echo " $sicnt $ccnt" >> $trg
164 echo "selective dynamics" >> $trg
165 echo "direct" >> $trg
167 tail -${total} POSCAR | \
168 while read x y z fx fy fz; do
169 Y=`echo $y $z $costheta $sintheta | \
170 awk '{ print $3*$1+$4*$2 }'`
171 Z=`echo $y $z $costheta $sintheta | \
172 awk '{ print $3*$2-$4*$1 }'`
173 echo " $x $Y $Z $fx $fy $fz" >> $trg