1 | #!@SHELL@
|
---|
2 | #
|
---|
3 | # Performs an adaptive simulation with molecuilder
|
---|
4 |
|
---|
5 | exec_prefix=@prefix@
|
---|
6 | MOLECUILDER="$exec_prefix/molecuilder"
|
---|
7 | JOINER="$exec_prefix/joiner"
|
---|
8 | CRUNCHER="/mount/bespin/heber/build/mpqc-2.3.0/bin/mpqc"
|
---|
9 | CONVERTER="/mount/bespin/heber/tmp/mpqc/espack2mpqc.sh"
|
---|
10 | PREPARER="/mount/bespin/heber/tmp/mpqc/convertresults.sh"
|
---|
11 | SUFFIX="in"
|
---|
12 |
|
---|
13 | function check()
|
---|
14 | {
|
---|
15 | #1 MESSAGE
|
---|
16 | if [ $? -eq 0 ]; then
|
---|
17 | if [ -z $1 ]; then
|
---|
18 | echo "ok."
|
---|
19 | else
|
---|
20 | echo "ok: $1."
|
---|
21 | fi
|
---|
22 | else
|
---|
23 | if [ -z $1 ]; then
|
---|
24 | echo "failed."
|
---|
25 | else
|
---|
26 | echo "failed: $1."
|
---|
27 | fi
|
---|
28 | exit 1
|
---|
29 | fi
|
---|
30 | }
|
---|
31 |
|
---|
32 | if [ -z $3 ]; then
|
---|
33 | echo "Usage: $0 <config> <max. bond distance> <accuracy>"
|
---|
34 | echo "i.e. $0 test.conf 1.55 -5"
|
---|
35 | exit 1
|
---|
36 | else
|
---|
37 | config=$1
|
---|
38 | DIR=`dirname $config`
|
---|
39 | distance=$2
|
---|
40 | order=$3
|
---|
41 | fi
|
---|
42 |
|
---|
43 | returncode="0"
|
---|
44 | while [ "$returncode" -eq "0" ]; do # don't go higher than 6th order
|
---|
45 | # break down the molecule with molecuilder
|
---|
46 | echo -n "Fragmenting molecule $DIR adaptively ... "
|
---|
47 | $MOLECUILDER $config -e $exec_prefix -f $distance $order 2>/dev/null 1>/dev/null
|
---|
48 | returncode=$?
|
---|
49 | check $returncode
|
---|
50 |
|
---|
51 | if [ "$returncode" -eq "0" ]; then
|
---|
52 | # find maximum number of digits
|
---|
53 | digit=1
|
---|
54 | while [ ! -e "$DIR/BondFragment`printf "%0${digit}d" 0`.conf" ]; do
|
---|
55 | let digit=$digit+1
|
---|
56 | done
|
---|
57 | let digit=$digit+1
|
---|
58 | if [ -e "$DIR/BondFragment`printf "%0${digit}d" 0`.conf" ]; then
|
---|
59 | let lesser=$digit-1
|
---|
60 | echo "Shifting found fragments with $lesser digits to those with $digit digits ..."
|
---|
61 | #dirs
|
---|
62 | for file in $DIR/BondFragment`i=0;while [ $i -lt $lesser ]; do let i=$i+1; echo -n "?"; done`; do
|
---|
63 | mv $file ${file/Fragment/Fragment0}
|
---|
64 | done
|
---|
65 | #files
|
---|
66 | for file in $DIR/BondFragment`i=0;while [ $i -lt $lesser ]; do let i=$i+1; echo -n "?"; done`.*; do
|
---|
67 | mv $file ${file/Fragment/Fragment0}
|
---|
68 | done
|
---|
69 | else
|
---|
70 | let digit=$digit-1
|
---|
71 | fi
|
---|
72 | echo "Found $digit digits."
|
---|
73 |
|
---|
74 | # evaluate each fragment
|
---|
75 | dir=`pwd`
|
---|
76 | cd $DIR
|
---|
77 | j=0;
|
---|
78 | while [ -e "BondFragment`printf "%0${digit}d" $j`.conf" ]; do
|
---|
79 | name="BondFragment`printf "%0${digit}d" $j`"
|
---|
80 | if [ ! -e "$name.out" ]; then # if not evaluated yet
|
---|
81 | echo -n "Converting $name.conf ..."
|
---|
82 | sh $CONVERTER "$name.conf"
|
---|
83 | check
|
---|
84 | #/opt/packages/mpichgm-1.2.7..15/bin/mpirun.ch_gm -machinefile $PBS_NODEFILE -np 8 /mount/bespin/heber/workspace/espack/pcp/bin/pcp -v -a 86000 $DIR/BondFragment`printf "%0${digit}d" $j`.conf
|
---|
85 |
|
---|
86 | if [ -e "$name.$SUFFIX" ]; then
|
---|
87 | echo -n "Evaluating $name.$SUFFIX ..."
|
---|
88 | $CRUNCHER "$name.$SUFFIX" >"$name.out"
|
---|
89 | check
|
---|
90 | fi
|
---|
91 | fi
|
---|
92 | let j=$j+1
|
---|
93 | done
|
---|
94 | cd $dir
|
---|
95 | echo "Evaluated $j fragments."
|
---|
96 |
|
---|
97 | # join the resulting energies into a single file and create EnergyPerFragment file
|
---|
98 | echo -n "Preparing results ..."
|
---|
99 | sh $PREPARER $DIR
|
---|
100 | check
|
---|
101 | echo -n "Joining energies ..."
|
---|
102 | $JOINER $DIR/ pcp >/dev/null
|
---|
103 | check
|
---|
104 | else
|
---|
105 | echo "Desired accuracy of 10^$order reached."
|
---|
106 | fi
|
---|
107 | # returncode=1
|
---|
108 | done
|
---|
109 |
|
---|