source: util/src/CalculateMass.sh@ 41c2f1

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

Two new shell scripts to calculate mass (with elements.db) and the resulting density (with volume out of BoxLength)

  • Property mode set to 100755
File size: 578 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"
12fi
13
14elements=(`grep -v ^# ${ELEMENTSDB} | awk -F" " {'print $2'}`)
15masses=(`grep -v ^# ${ELEMENTSDB} | awk -F" " {'print $7'}`)
16
17i=0
18totalmass=0
19while [ $i -lt ${#elements[*]} ]; do
20 nr=`grep -E "^${elements[$i]}[[:space:]]+" $XYZ | wc -l`
21 totalmass=`echo "$totalmass $nr ${masses[$i]}" | awk -F" " {'print $1+$2*$3'}`
22 let i=$i+1
23done
24
25echo "Totalmass is $totalmass atomicunits"
26exit 0
Note: See TracBrowser for help on using the repository browser.