| 1 | #!@SHELL@
|
|---|
| 2 | #
|
|---|
| 3 | # Performs an molecular dynamics simulation with the BOSSANOVA method
|
|---|
| 4 |
|
|---|
| 5 | #MPIRUN="/opt/packages/mpichgm-1.2.7..15/bin/mpirun.ch_gm"
|
|---|
| 6 | MPIRUN="/usr/bin/mpirun.mpich"
|
|---|
| 7 | exec_prefix="@prefix@"
|
|---|
| 8 | database="@bindir@"
|
|---|
| 9 | MOLECUILDER="@bindir@/molecuilder"
|
|---|
| 10 | JOINER="@bindir@/joiner"
|
|---|
| 11 | CRUNCHER="/mount/bespin/heber/build/mpqc-2.3.0/bin/mpqc"
|
|---|
| 12 | CONVERTER="/mount/bespin/heber/tmp/mpqc/espack2mpqc.sh"
|
|---|
| 13 | PREPARER="/mount/bespin/heber/tmp/mpqc/convertresults.sh"
|
|---|
| 14 |
|
|---|
| 15 | . /mount/bespin/heber/scripts/check
|
|---|
| 16 |
|
|---|
| 17 | function RunSim {
|
|---|
| 18 | # 1 is the config file
|
|---|
| 19 | # 2 is the number of nodes
|
|---|
| 20 | # 3 further command line option
|
|---|
| 21 | # 4 and argument
|
|---|
| 22 | # set the maximum number of nodes
|
|---|
| 23 | MaxNodes=`cat $2 | awk 'END{print NR}'`
|
|---|
| 24 | gamma=`grep ProcPEGamma $1 | awk -F"\t" {'print $2'}`
|
|---|
| 25 | psi=`grep ProcPEPsi $1 | awk -F"\t" {'print $2'}`
|
|---|
| 26 | let nodes=$gamma*$psi
|
|---|
| 27 | if [ $nodes -gt $MaxNodes ]; then
|
|---|
| 28 | echo "Process $1 needs too many nodes! Breaking." | tee -a dynamic.log
|
|---|
| 29 | exit 1
|
|---|
| 30 | fi
|
|---|
| 31 | ${MPIRUN} -machinefile $2 -np $nodes ${CRUNCHER} $3 $4 $1 2>/dev/stdout 1>${1/in/out}
|
|---|
| 32 | check | tee -a dynamic.log
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | function MultiRunSim {
|
|---|
| 36 | # 1 is config file
|
|---|
| 37 | # 2 is the number of groups
|
|---|
| 38 |
|
|---|
| 39 | # find the next free proc group
|
|---|
| 40 | DIR=`dirname $1`
|
|---|
| 41 | started=0
|
|---|
| 42 | while [ $started -eq 0 ]; do
|
|---|
| 43 | groupnr=1
|
|---|
| 44 | while [ $groupnr -le $2 ]; do
|
|---|
| 45 | if [ ! -e "${DIR}/ProcRuns${groupnr}" ]; then
|
|---|
| 46 | MaxNodes=`cat ${DIR}/ProcGroup${groupnr} | awk 'END{print NR}'`
|
|---|
| 47 | gamma=`grep ProcPEGamma $1 | awk -F"\t" {'print $2'}`
|
|---|
| 48 | psi=`grep ProcPEPsi $1 | awk -F"\t" {'print $2'}`
|
|---|
| 49 | let nodes=$gamma*$psi
|
|---|
| 50 | if [ $nodes -gt $MaxNodes ]; then
|
|---|
| 51 | echo "Process $1 needs too many nodes! Breaking." | tee -a dynamic.log
|
|---|
| 52 | exit 1
|
|---|
| 53 | fi
|
|---|
| 54 | echo "touch ${DIR}/ProcRuns${groupnr}" >"${DIR}/ProcBatch${groupnr}"
|
|---|
| 55 | echo "#${MPIRUN} -machinefile ${DIR}/ProcGroup${groupnr} -np $nodes" >>"${DIR}/ProcBatch${groupnr}"
|
|---|
| 56 | echo "${CRUNCHER} ${1/conf/in} 2>/dev/stdout 1>${1/conf/out}" >>"${DIR}/ProcBatch${groupnr}"
|
|---|
| 57 | echo "rm -f ${DIR}/ProcRuns${groupnr}" >>"${DIR}/ProcBatch${groupnr}"
|
|---|
| 58 | /bin/sh "${DIR}/ProcBatch${groupnr}" &
|
|---|
| 59 | started=1
|
|---|
| 60 | let groupnr=${2}+1
|
|---|
| 61 | else
|
|---|
| 62 | let groupnr=$groupnr+1
|
|---|
| 63 | fi
|
|---|
| 64 | done
|
|---|
| 65 | # wait a few seconds
|
|---|
| 66 | if [ $2 -gt 1 ]; then
|
|---|
| 67 | sleep 2
|
|---|
| 68 | fi
|
|---|
| 69 | done
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | # get command line options
|
|---|
| 73 | if [ -z $4 ]; then
|
|---|
| 74 | echo "Usage: $0 <config file> <Order> <max. bond distance> <MaxNodes> [MaxMDsteps]"
|
|---|
| 75 | echo -e "\t<config file> the pcp config file of the total molecule"
|
|---|
| 76 | echo -e "\t<Order> the highest bond order (i.e. the cutoff number in ANOVA series expansion)"
|
|---|
| 77 | echo -e "\t<max. bond distance> maximum distance to look for bonds (bonds are associated by element covalent radii criterion)"
|
|---|
| 78 | echo -e "\t<MaxNodes> number of nodes to use"
|
|---|
| 79 | echo -e "\t[MaxMDSteps] overrides given MaxOuterStep in config file"
|
|---|
| 80 | exit 1;
|
|---|
| 81 | else
|
|---|
| 82 | arg=$1
|
|---|
| 83 | mainname=`grep mainname $arg | awk -F"\t" {'print $2'}`
|
|---|
| 84 | order=$2
|
|---|
| 85 | distance=$3
|
|---|
| 86 | MaxNodes=$4
|
|---|
| 87 | if [ -z $5 ]; then
|
|---|
| 88 | MaxSteps=`grep MaxOuterStep $arg | awk -F"\t" {'print $2'}`
|
|---|
| 89 | else
|
|---|
| 90 | MaxSteps=$5
|
|---|
| 91 | fi
|
|---|
| 92 | echo "Going to run for a total of $MaxSteps steps, bond order $order and maximum distance $distance of config file $arg with a total of $MaxNodes nodes." | tee -a dynamic.log
|
|---|
| 93 | fi
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | # get the directory
|
|---|
| 97 | DIR=`dirname $arg`
|
|---|
| 98 | if [ -z "`grep $DIR $arg`" ]; then
|
|---|
| 99 | echo "Cannot find the directory $DIR in the config file." | tee -a dynamic.log
|
|---|
| 100 | exit 1;
|
|---|
| 101 | else
|
|---|
| 102 | echo "Using $DIR as directory." | tee -a dynamic.log
|
|---|
| 103 | fi
|
|---|
| 104 |
|
|---|
| 105 | PBS_NODEFILE="${DIR}/machines"
|
|---|
| 106 | if [ ! -e $PBS_NODEFILE ]; then
|
|---|
| 107 | echo "localhost" >$PBS_NODEFILE
|
|---|
| 108 | fi
|
|---|
| 109 |
|
|---|
| 110 | # delete old processor group files
|
|---|
| 111 | rm ${DIR}/ProcGroup* -f
|
|---|
| 112 | rm ${DIR}/ProcRuns* -f
|
|---|
| 113 | rm ${DIR}/ProcBatch* -f
|
|---|
| 114 |
|
|---|
| 115 | # put nodes into groups
|
|---|
| 116 | gamma=`grep ProcPEGamma $arg | awk -F"\t" {'print $2'}`
|
|---|
| 117 | psi=`grep ProcPEPsi $arg | awk -F"\t" {'print $2'}`
|
|---|
| 118 | let nodes=$gamma*$psi
|
|---|
| 119 | let divisor=$MaxNodes/$nodes
|
|---|
| 120 | echo "Using $divisor processor groups." | tee -a dynamic.log
|
|---|
| 121 | nodenr=0
|
|---|
| 122 | groupnr=1
|
|---|
| 123 | for node in `cat <$PBS_NODEFILE`; do
|
|---|
| 124 | let nodenr=$nodenr+1
|
|---|
| 125 | #echo "Current node $nodenr is $node." | tee -a dynamic.log
|
|---|
| 126 | let currentgrouplimit=$groupnr*$nodes
|
|---|
| 127 | if [ $currentgrouplimit -lt $nodenr ]; then
|
|---|
| 128 | let groupnr=$groupnr+1
|
|---|
| 129 | fi
|
|---|
| 130 | #echo "Putting into group $groupnr." | tee -a dynamic.log
|
|---|
| 131 | echo "$node" >>"${DIR}/ProcGroup${groupnr}"
|
|---|
| 132 | done
|
|---|
| 133 | i=0
|
|---|
| 134 | while [ $i -lt $groupnr ]; do
|
|---|
| 135 | let i=$i+1
|
|---|
| 136 | echo "Group nr. $i" | tee -a dynamic.log
|
|---|
| 137 | echo "===========" | tee -a dynamic.log
|
|---|
| 138 | cat <"${DIR}/ProcGroup${i}"
|
|---|
| 139 | cat <"${DIR}/ProcGroup${i}" >>dynamic.log
|
|---|
| 140 | echo -e "\n" | tee -a dynamic.log
|
|---|
| 141 | done
|
|---|
| 142 |
|
|---|
| 143 | # copy first conf
|
|---|
| 144 | cp $arg ${arg}.MD
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 | i=1;
|
|---|
| 148 | while [ $i -le $MaxSteps ]; do
|
|---|
| 149 | # break down the molecule with molecuilder
|
|---|
| 150 | echo -n "Fragmenting ... " | tee -a dynamic.log
|
|---|
| 151 | ${MOLECUILDER} ${arg}.MD -e ${database} -f $distance $order 2>/dev/null >/dev/null
|
|---|
| 152 | check | tee -a dynamic.log
|
|---|
| 153 | echo "done." | tee -a dynamic.log
|
|---|
| 154 |
|
|---|
| 155 | # get the number of digits of the fragment count
|
|---|
| 156 | digits=1
|
|---|
| 157 | while [ ! -e ${DIR}/BondFragment`printf "%0${digits}d" 0`.conf ]; do
|
|---|
| 158 | let digits=$digits+1
|
|---|
| 159 | done
|
|---|
| 160 | echo "Found $digits digits for the fragment number." | tee -a dynamic.log
|
|---|
| 161 |
|
|---|
| 162 | # get the fragment count
|
|---|
| 163 | frag=0
|
|---|
| 164 | while [ -e ${DIR}/BondFragment`printf "%0${digits}d" $frag`.conf ]; do
|
|---|
| 165 | # unset MaxOuterStep in config file
|
|---|
| 166 | sed -i -e "s#MaxOuterStep.*\##MaxOuterStep\t0\t\##" ${DIR}/BondFragment`printf "%0${digits}d" $frag`.conf
|
|---|
| 167 | rm -rf ${DIR}/BondFragment`printf "%0${digits}d" $frag`
|
|---|
| 168 | let frag=$frag+1
|
|---|
| 169 | done
|
|---|
| 170 | echo "There are $frag fragments." | tee -a dynamic.log
|
|---|
| 171 |
|
|---|
| 172 | # evaluate each fragment
|
|---|
| 173 | j=0;
|
|---|
| 174 | while [ $j -lt $frag ]; do
|
|---|
| 175 | number=`printf "%0${digits}d" $j`
|
|---|
| 176 | # convert all configs
|
|---|
| 177 | echo -n "Converting ${DIR}/BondFragment${number}.conf ..."
|
|---|
| 178 | sh $CONVERTER ${DIR}/BondFragment${number}.conf
|
|---|
| 179 | check | tee -a dynamic.log
|
|---|
| 180 | # and evaluate
|
|---|
| 181 | echo -n "Starting calculation of Fragment $number at step $i ... " | tee -a dynamic.log
|
|---|
| 182 | MultiRunSim ${DIR}/BondFragment${number}.conf $divisor
|
|---|
| 183 | echo "done." | tee -a dynamic.log
|
|---|
| 184 | let j=$j+1
|
|---|
| 185 | done
|
|---|
| 186 |
|
|---|
| 187 | # wait till all ProcRuns files are gone
|
|---|
| 188 | if [ $divisor -gt 1 ]; then
|
|---|
| 189 | echo "Waiting for all running jobs at step $i to end ... " | tee -a dynamic.log
|
|---|
| 190 | while [ ! -z "${DIR}/ProcRuns*" ]; do
|
|---|
| 191 | sleep 3
|
|---|
| 192 | done
|
|---|
| 193 | echo "done." | tee -a dynamic.log
|
|---|
| 194 | fi
|
|---|
| 195 |
|
|---|
| 196 | # convert results
|
|---|
| 197 | sleep 1 # necessary for result files to close
|
|---|
| 198 | echo -n "Converting all results ... "
|
|---|
| 199 | sh $PREPARER $DIR
|
|---|
| 200 | check | tee -a dynamic.log
|
|---|
| 201 |
|
|---|
| 202 | # join the resulting forces into a single file
|
|---|
| 203 | # cp ${DIR}/pcp.full.energy.all ${DIR}/pcp.energy.all
|
|---|
| 204 | # cp ${DIR}/pcp.full.forces.all ${DIR}/pcp.forces.all
|
|---|
| 205 | echo -n "Joining fragment energies ... " | tee -a dynamic.log
|
|---|
| 206 | ${JOINER} ${DIR}/ $mainname >/dev/null 2>/dev/null
|
|---|
| 207 | check | tee -a dynamic.log
|
|---|
| 208 | echo "done." | tee -a dynamic.log
|
|---|
| 209 |
|
|---|
| 210 | # move the ions by calling pcp with this force file
|
|---|
| 211 | sed -i -e "s#MaxOuterStep.*\##MaxOuterStep\t$i\t\##" ${arg}.MD
|
|---|
| 212 | echo -n "Moving ions with obtained forces at step $i ... " | tee -a dynamic.log
|
|---|
| 213 | $MOLECUILDER ${arg}.MD -e ${database} -P "${DIR}/pcp.Order${order}.forces.all" 2>/dev/null >/dev/null
|
|---|
| 214 | echo "done" | tee -a dynamic.log
|
|---|
| 215 |
|
|---|
| 216 | # last of all, put "joined" energy and forces under this step
|
|---|
| 217 | cp ${DIR}/pcp.Order${order}.energy.all ${DIR}/pcp.step${i}.energy.all
|
|---|
| 218 | cp ${DIR}/pcp.Order${order}.forces.all ${DIR}/pcp.step${i}.forces.all
|
|---|
| 219 |
|
|---|
| 220 | # next step
|
|---|
| 221 | let i=$i+1
|
|---|
| 222 | done
|
|---|
| 223 |
|
|---|
| 224 | # draw densities of each step
|
|---|
| 225 | #sed -e "s#DoOutVis.*\##DoOutVis\t2\t\##" ${arg}.MD.MD >${arg}.MD
|
|---|
| 226 | #echo -n "Calling simulation to draw final densities of all steps ... " | tee -a dynamic.log
|
|---|
| 227 | #RunSim ${arg}.MD $PBS_NODEFILE
|
|---|
| 228 | #echo "done." | tee -a dynamic.log
|
|---|
| 229 |
|
|---|
| 230 | exit 0
|
|---|