#!/bin/csh set wrap="gulp.wrap" set strfile="str_hint.out" if ( ! -e $strfile ) then set strfile="str.out" endif while ( $#argv != 0 ) switch ("$1") case "-h": cat - <! gulp.in grep addshell $wrap | sed 's/.*addshell *//g' | blanktonl >! shell.tmp cat $strfile | cellcvrt -f -sig=9 >! str.tmp echo vectors >> gulp.in head -3 str.tmp >> gulp.in echo fractional >> gulp.in tail -n +7 str.tmp | awk 'BEGIN {while (getline < "shell.tmp") {s[$1]=1;}} {if (s[$4]==1) {print $4,"core",$1,$2,$3; print $4,"shell",$1,$2,$3} else {print $4,"core",$1,$2,$3}}' >> gulp.in getlines -jaf 'INSERTPOS' < $wrap | grep -v addshell >> gulp.in endif if ( $?notrungulp ) exit $* gulp < gulp.in >! gulp.out endif cellcvrt -abc -f < $strfile >! str_o.tmp getvalue "Final energy" < gulp.out | tail -n -1 >! energy if (`cat energy | wc -w` == "0") then grep eV gulp.out | getvalue "Total lattice energy" >! energy endif grep -q "Final cell parameters and derivatives" gulp.out if ( $status == 1 ) then cat $strfile | cellcvrt -f | head -6 >! str_relax.tmp else echo -n >! str_relax.tmp getlines -af "Final cell parameters and derivatives" < gulp.out | tail -n +4 | getlines -jbf "\-\-\-\-\-\-" | awk '{print $2}' | nltoblank >> str_relax.tmp cat - >> str_relax.tmp <> str_relax.tmp else getlines -af "Final .* coordinates" < gulp.out | tail -n +7 | getlines -jbf "\-\-\-\-\-\-" | awk '{if ($3=="c") {print $4,$5,$6,$2}}' >> str_relax.tmp cellcvrt -osf=str_o.tmp -fsf=$strfile -f -sig=9 < str_relax.tmp >! str_relax.out endif getlines -af "Final internal derivatives" < gulp.out | tail -n +7 | getlines -jbf "\-\-\-\-\-\-" | awk '{if ($3=="c") {print $4,$5,$6; s[1]+=$4; s[2]+=$5; s[3]+=$6; n++}} END {print s[1],s[2],s[3] > "sumf.tmp"}' >! force.tmp cellcvrt -r < str_relax.out >! recip.tmp awk 'BEGIN {for (i=1; i<=3; i++) {getline < "recip.tmp"; a[1,i]=$1; a[2,i]=$2; a[3,i]=$3; } getline < "sumf.tmp"; sg[1]=$1; sg[2]=$2; sg[3]=$3;} { \ split($0,g); \ for (i=1; i<=3; i++) { \ f[i]=0; \ for (j=1; j<=3; j++) { \ f[i]-=a[i,j]*(g[j]-sg[j]); \ } \ } \ print f[1],f[2],f[3]; \ sg[1]=0; sg[2]=0; sg[3]=0; \ }' force.tmp >! force.out rm -f str_o.tmp str.tmp str_relax.tmp force.tmp sumf.tmp recip.tmp shell.tmp