From 9f2b57506b7d991691e8e7b6b81fa84a89c62ae1 Mon Sep 17 00:00:00 2001 From: Francois Gygi Date: Thu, 5 Dec 2013 21:29:17 +0000 Subject: [PATCH] added utility shell script git-svn-id: http://qboxcode.org/svn/qb/trunk@1419 cba15fb0-1239-40c8-b417-11db7ca47a34 --- util/egap.sh | 17 +++++++++++++++++ util/get_atomset.sh | 8 ++++++++ util/qbox_maxforce.sh | 9 +++++++++ util/qbox_replicate.sh | 31 +++++++++++++++++++++++++++++++ util/qbox_translate.sh | 17 +++++++++++++++++ util/qbox_xyz.sh | 39 +++++++++++++++++++++++++++++++++++++++ util/sample_to_move.sh | 28 ++++++++++++++++++++++++++++ util/sample_to_sys.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 190 insertions(+) create mode 100755 util/egap.sh create mode 100755 util/get_atomset.sh create mode 100755 util/qbox_maxforce.sh create mode 100755 util/qbox_replicate.sh create mode 100755 util/qbox_translate.sh create mode 100755 util/qbox_xyz.sh create mode 100755 util/sample_to_move.sh create mode 100755 util/sample_to_sys.sh diff --git a/util/egap.sh b/util/egap.sh new file mode 100755 index 0000000..6ad47d8 --- /dev/null +++ b/util/egap.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# compute Egap = E(n+1) - E(n) +# use: egap.sh n file.r +declare -i nocc=$1 +shift +declare -i nl=nocc/5+1 +#echo "nl=" $nl +declare -i nfrac=nocc-5*\(nocc/5\) +#echo "nfrac=" $nfrac + +grep -h -A$nl '" diff --git a/util/qbox_maxforce.sh b/util/qbox_maxforce.sh new file mode 100755 index 0000000..c7557b2 --- /dev/null +++ b/util/qbox_maxforce.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# get the largest force component in a file of " fx fy fz " +# use: qbox_maxforce nat file.r +grep '' $2 | tail -$1 | \ +awk '{ + if ( mx*mx < $2*$2 ) mx = $2; + if ( my*my < $3*$3 ) my = $3; + if ( mz*mz < $4*$4 ) mz = $4; +} END {printf("%9.2e %9.2e %9.2e\n", mx, my, mz)}' - diff --git a/util/qbox_replicate.sh b/util/qbox_replicate.sh new file mode 100755 index 0000000..8831a00 --- /dev/null +++ b/util/qbox_replicate.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# qbox_replicate: replicate the unit cell in the a0,a1,a2 directions. +# use: qbox_replicate cell.sys n0 n1 n2 > newcell.sys +# +if (( $# != 4 )) + then echo "use: qbox_replicate cell.sys n0 n1 n2 > newcell.sys" + exit +fi +gawk -v n0=$2 -v n1=$3 -v n2=$4 \ + ' / cell/ {a0x=$3;a0y=$4;a0z=$5; \ + a1x=$6;a1y=$7;a1z=$8; \ + a2x=$9;a2y=$10;a2z=$11; \ + print "set cell ", \ + n0*$3,n0*$4,n0*$5, n1*$6,n1*$7,n1*$8, n2*$9,n2*$10,n2*$11} \ + /ref_cell/ { \ + print "set ref_cell ", \ + n0*$3,n0*$4,n0*$5, n1*$6,n1*$7,n1*$8, n2*$9,n2*$10,n2*$11} \ + /species/ {print} \ + /atom/ {x=$4 - (n0-1)*a0x/2 - (n1-1)*a1x/2 - (n2-1)*a2x/2; \ + y=$5 - (n0-1)*a0y/2 - (n1-1)*a1y/2 - (n2-1)*a2y/2; \ + z=$6 - (n0-1)*a0z/2 - (n1-1)*a1z/2 - (n2-1)*a2z/2; \ + for ( i=0; i newcell.sys +# +if (( $# != 4 )) + then echo "use: qbox_translate cell.sys dx dy dz > newcell.sys" + exit +fi +awk -v dx=$2 -v dy=$3 -v dz=$4 \ + ' /^#/ {print} \ + / cell/ {print} \ + /ref_cell/ {print} + /species/ {print} \ + /atom/ {x=$4 + dx; y=$5 + dy; z=$6 + dz; \ + printf("atom %s %s %12.6f %12.6f %12.6f\n", \ + $2,$3,x,y,z) \ + }' $1 diff --git a/util/qbox_xyz.sh b/util/qbox_xyz.sh new file mode 100755 index 0000000..e362d1f --- /dev/null +++ b/util/qbox_xyz.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# qbox_xyz.sh: get atomic positions from an MD simulation in xyz format +# use: qbox_xyz.sh mdrun.r > file.xyz +# +xsltproc - $1 << EOF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOF diff --git a/util/sample_to_move.sh b/util/sample_to_move.sh new file mode 100755 index 0000000..f2f2e4f --- /dev/null +++ b/util/sample_to_move.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# sample_to_move.sh +# generate a set of Qbox commands to move atoms to the positions +# in a given sample. +# use: sample_to_move.sh sample.xml +# +xsltproc - $1 << EOF + + + + + + + + + + + + move + + to + + + + + +EOF diff --git a/util/sample_to_sys.sh b/util/sample_to_sys.sh new file mode 100755 index 0000000..7af3b34 --- /dev/null +++ b/util/sample_to_sys.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# sample_to_sys.sh: extract atomic positions from a sample and generate +# a Qbox input file to create atoms at these positions +# use: sample_to_sys.sh sample.xml > sample.sys +# +xsltproc - $1 << EOF + + + + + + + + + + + + set cell + + + + + + + species + + + + + + atom + + + + + + + + +EOF -- libgit2 0.26.0