source: util/src/CalculateDensity.sh.in@ 94ca12

Last change on this file since 94ca12 was 94ca12, checked in by Frederik Heber <heber@…>, 17 years ago

replaced absolute paths by @prefix@ and so on

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!@SHELL@
2#
3# calculates the density of a molecule contained in a espack config file
4
5MOLECUILDER="@bindir@/molecuilder"
6
7if [ -z $1 ]; then
8 echo "Usage: $0 <config file>"
9 echo "We assume, that there is also an xyz file to the config file."
10 exit 1
11else
12 config=$1
13 if [ ! -e $config ]; then
14 echo "Config file $config does not exist!"
15 exit 1
16 fi
17fi
18
19# if xyz is missing, call molecuilder to create it
20if [ ! -e ${config}.xyz ]; then
21 echo "Config xyz file ${config}.xyz does not exist, creating it"
22 $MOLECUILDER ${config} -t 0. 0. 0.
23fi
24
25mass=`/home/heber/workspace/ESPACK/bin/CalculateMass.sh ${config}.xyz | awk -F" " {'print $3'}`
26echo "Mass is $mass atomicmassunit"
27boxlengths=`grep ^Box --after-context=3 ${config} | tail -n 3`
28volume=`echo $boxlengths | awk -F" " {'print $1*$3*$6'}`
29if [ `grep IsAngstroem ${config} | awk -F" " {'print $2'}` == "1" ]; then
30 unit="angstrom^3"
31else
32 unit="atomiclength^3"
33fi
34echo "Volume is $volume $unit"
35density=`units "$mass atomicmassunit / $volume $unit" "g/cm^3" | grep \* | awk -F" " {'print $2'}`
36echo "Density is $density g/cm^3"
37
38exit 0
Note: See TracBrowser for help on using the repository browser.