atat-mirror/glue/pwscf/runstruct_pwscf

74 lines
2.7 KiB
Tcsh
Executable File

#!/bin/csh
#goto here
set strout="str_hint.out"
if ( ! -e $strout ) then
set strout="str.out"
endif
if (! -e $strout ) then
echo str.out or str_hint.out does not exist
echo NOTE: runstruct_xxxx needs to be run within the subdirectory containing a structure.
exit 1
endif
set wrapfilename="pwscf.wrap"
set wrapfile="$wrapfilename"
if (! -e $wrapfile) then
set wrapfile="../$wrapfilename"
if (! -e $wrapfile) then
set wrapfile="../../$wrapfilename"
if (! -e $wrapfile) then
set wrapfile="../../../$wrapfilename"
if (! -e $wrapfile) then
echo You need a $wrapfilename file in $PWD , $PWD/.. , $PWD/../.. or $PWD/../../..
echo NOTE: $0 needs to be run within the numbered subdirectory.
exit 1
endif
endif
endif
endif
( echo " ibrav="`fixcell -b < $strout | head -1 | awk '{print 1+(index("cP cF cI hP hR tP tI oP oC oF oI mP mC aP",$1)-1)/3;}'` ;\
(cellcvrt -f < $strout | fixcell -b | tail -n +3 | head -3 ; echo 1 0 0 ; echo 0 1 0; echo 0 0 1 ) | cellcvrt -f -abc | head -1 | awk '{print " a="$1; print " b="$2; print " c="$3; print " cosbc="cos($4/360*2*3.1415926535897932384626433); print " cosac="cos($5/360*2*3.1415926535897932384626433); print " cosab="cos($6/360*2*3.1415926535897932384626433);}' ; echo " nat="`cellcvrt -f < $strout | tail -n +7 | wc -l` ;\
echo " ntyp="`cellcvrt -f < $strout | tail -n +7 | awk '{print $4}' | sort -u | wc -l` \
) >& pwsystem.tmp
( echo "ATOMIC_POSITIONS (crystal)" ;\
cellcvrt -f < $strout | tail -n +7 | awk '{print " " $4,$1,$2,$3;}' \
) >& pwatom.tmp
grep -q '[kK][pP][pP][rR][aA]' < $wrapfile
if ( $status == 1 ) then
grep -q INSERTKPOINTS < $wrapfile
if ( $status == 0 ) then
echo Missing kppra token in $wrapfile
exit
endif
endif
set nbkp=`getvalue '[kK][pP][pP][rR][aA]' < $wrapfile`
set nbat=`cellcvrt -pn < $strout`
( echo "K_POINTS (automatic)" ; \
echo " "`( echo $nbkp $nbat | awk '{print $1/$2}' ; cat $strout | cellcvrt -f | head -3 ) | kmesh -q -r` 0 0 0 \
) >& pwkpoint.tmp
awk '{if ($1=="INSERTSYSTEM") {system("cat pwsystem.tmp");} \
else if ($1=="INSERTATOMS") {system("cat pwatom.tmp");} \
else if ($1=="INSERTKPOINTS") {system("cat pwkpoint.tmp");} \
else {print $0;} \
}' $wrapfile | grep -v -i kppra >! pwscf.in
pw.x < pwscf.in > pwscf.out
getlines -af 'Begin final coordinates' < pwscf.out > finalval.tmp
getvalue 'total energy' < finalval.tmp | tail -n -1 | awk '{print $1*13.605698066}' > energy
( getlines -jbt 'CELL_PARAMETERS' '^$' < finalval.tmp ; echo 1 0 0 ; echo 0 1 0 ; echo 0 0 1 ; getlines -jbt 'ATOMIC_POSITIONS' 'End' < finalval.tmp | awk '{print $2,$3,$4,$1}') | cellcvrt -sc=`getvalue alat < finalcoord.tmp` > str_relax.out
#rm -f pwsysten.tmp pwatom.tmp pwkpoint.tmp finalval.tmp