source: util/src/CalculateMass.sh@ 0ab37b

Last change on this file since 0ab37b was 0779a9, checked in by Frederik Heber <heber@…>, 17 years ago

some mor changes to fine-tune the cluster generation.

Sadly, VolumeOfConvexEnvelope() is not robust/stable, with Ratio1.4-1/1800K/compundH.*.xyz no usable convex envelope was found but points were connected right through the cluster.

  • Property mode set to 100755
File size: 780 bytes
Line 
1#!/bin/sh
2#
3# calculates mass of a molecule in a XYZ file
4
5ELEMENTSDB="/home/heber/workspace/ESPACK/bin/elements.db"
6
7if [ -z "$1" ]; then
8 echo "Usage $0 <XYZ file>"
9 exit 1
10else
11 XYZ="$1"
12 if [ ! -e $XYZ ]; then
13 echo "The xyz file $XYZ does not exist!"
14 exit 1
15 fi
16fi
17
18# check for db presence
19if [ ! -e $ELEMENTSDB ]; then
20 echo "The database file $ELEMENTSDB does not exist!"
21 exit 1
22fi
23
24elements=(`grep -v ^# ${ELEMENTSDB} | awk -F" " {'print $2'}`)
25masses=(`grep -v ^# ${ELEMENTSDB} | awk -F" " {'print $7'}`)
26
27i=0
28totalmass=0
29while [ $i -lt ${#elements[*]} ]; do
30 nr=`grep -E "^${elements[$i]}[[:space:]]+" $XYZ | wc -l`
31 totalmass=`echo "$totalmass $nr ${masses[$i]}" | awk -F" " {'print $1+$2*$3'}`
32 let i=$i+1
33done
34
35echo "Totalmass is $totalmass atomicunits"
36exit 0
Note: See TracBrowser for help on using the repository browser.