Skip to content

Instantly share code, notes, and snippets.

@jarvist
Created July 11, 2012 14:25
Show Gist options
  • Save jarvist/3090695 to your computer and use it in GitHub Desktop.
Save jarvist/3090695 to your computer and use it in GitHub Desktop.
NWCHEM Dump
for i #in */*.out
do
# echo -n "${i}"
#'sed -n 1p' will print 1st line, etc.
ELECTRONS=` grep "No. of electrons :" "${i}" | sed -n 1p | awk '{print $5/2}' `
#OK, this is now orbitals, not electrons (i.e. #electrons / 2)
ENERGY=` grep "Total DFT energy" "${i}" | sed -n 1p | awk '{print $5}' `
CAM=` grep " cam " "${i}" | sed -n 1p | awk '{print $2}' `
# echo "${i} Electrons: $ELECTRONS Energy: $ENERGY"
#Molecular orbitals we get
#Neutral: Just alpha
#Cation: Alpha then Beta
#Anion: Alpha then Beta
#Believe we just want the Alpha orbitals?
echo -n "${i} ${CAM}"
#echo "NEUTRAL"
H=` grep "Vector ${ELECTRONS}" "${i}" | sed -n 1p | sed s/=/\ /g | awk '{printf(" %f ",$6*2.7211)}' `
let LUMO=${ELECTRONS}+1
L=` grep "Vector ${LUMO}" "${i}" | sed -n 1p | sed s/=/\ /g | awk '{printf(" %f ",$6*0.27211)}' `
#echo "CATION"
# grep "Vector ${ELECTRONS}" "${i}" | sed -n 2p | sed s/=/\ /g | awk '{printf (" %f ",$6*0.27211)}'
IP=` grep "Total DFT energy" "${i}" | sed -n 2p | awk '{printf (" %f ",27.211*-($5-('$ENERGY')))}' `
#echo "ANION"
# grep "Vector ${ELECTRONS+1}" "${i}" | sed -n 4p | sed s/=/\ /g | awk '{printf (" %f ",$6*0.27211)}'
EA=` grep "Total DFT energy" "${i}" | sed -n 3p | awk '{printf (" %f ",27.211*($5-('$ENERGY')))}' `
echo $H $L $IP $EA | awk '{print $1,$2,$3,$4,$3-$1,$4-$2}'
# grep "Root 1" "${i}"
done
for i
do
NW=${i%.*}.nw
echo $NW
cat HEADER > $NW
jkp_extract_geom.awk $i >> $NW
cat FOOTER >> $NW
done
title "6-Thiophene - Geom from b3lyp/6-31g* Gaussian job. BNL calcs."
echo "This is a story about an ordinary teddy bear."
memory stack 300 mb heap 300 mb global 600 mb
echo
geometry noautoz units angstroms
#!/bin/sh
#Automagic .com CX1 (Imperial College London HPC) job submitter. A WIP.
#JMF 2007-09
#Bash is a stranger in an open car...
#2012-04-27: Finally got around to adding single CPU defaults (for quick semi-empirical QC)
#2012-05-26: Forking this code to use for running NWCHEM .nw programs
#2012-06: Now runs multi-host over MPI for NWCHEM
#2012-06-18: Extended to restart NWCHEM jobs. Also, I actually learnt how to use 'getopts' as part of this.
# RUN AS ./executable.sh OTHERWISE OPTIONS WILL NOT BE GATHERED!
#Get Options
NCPUS=8
MEM=11800mb #Simon Burbidge correction - lots of nodes with 12GB physical memory, leaves no overhead for OS
QUEUE="" #default route
TIME="71:58:02" # Two minutes to midnight :^)
HOSTS=1 #Ah, the Host!
RESTART="NAH"
function USAGE()
{
cat << EOF
Jarv's NWCHEM .nw file runner.
USAGE: ./launch_nw.sh [-nmqtsl] NWCHEM_RUN_FILES(S)
Suggested memory command for nwchem:
memory stack 300 mb heap 300 mb global 600 mb
Nb: Memory is (global seperate from stack and heap) cummulative, and per MPI process
OPTIONS:
-n number of cpus
-m amount of memory
-q queue
-t time
-h hosts
-s short queue (-n 1 -m 1899mb -t 0:59:59)
-l long queue (-n 1 -m 1899mb -t 21:58:00)
-r restart (copies run files, adds restart line to NWCHEM input deck)
DEFAULTS (+ inspect for formatting):
NCPUS = ${NCPUS}
MEM = ${MEM}
QUEUE = ${QUEUE}
TIME = ${TIME}
The defaults above will require something like the following in your COM files:
%mem=8GB
%nprocshared=8
EOF
}
while getopts ":n:m:q:t:h:slr?" Option
do
case $Option in
#OPTIONS
n ) NCPUS=$OPTARG;;
m ) MEM=$OPTARG;;
q ) QUEUE=$OPTARG;;
t ) TIME="${OPTARG}";;
h ) HOSTS="${OPTARG}";;
#FLAGS
s ) NCPUS=1
TIME="0:59:59"
MEM="1899mb";;
l ) NCPUS=1
TIME="21:58:00"
MEM="1899mb";;
r ) RESTART="YEAH";;
? ) USAGE
exit 0;;
* ) echo ""
echo "Unimplemented option chosen."
USAGE # DEFAULT
esac
done
#OK, now we should have our options
cat <<EOF
Well, here's what I understood / defaulted to:
HOSTS = ${HOSTS}
NCPUS = ${NCPUS}
MEM = ${MEM}
QUEUE = ${QUEUE}
TIME = ${TIME}
RESTART = ${RESTART}
EOF
shift $(($OPTIND - 1))
# Decrements the argument pointer so it points to next argument.
# $1 now references the first non option item supplied on the command line
#+ if one exists.
PWD=` pwd `
for COM in $*
do
WD=${COM%/*} #subdirectory that .com file is in
FIL=${COM#*/} #strip filetype off
echo $PWD $WD $FIL
if [ "${WD}" = "${FIL}" ]
then
echo "WD: ${WD} equiv to File: ${FIL}. Resetting WD to null."
WD=""
fi
#filth to prevent error when .com is in current directory
cat > ${COM%.*}.sh << EOF
#!/bin/sh
#PBS -l walltime=${TIME}
#PBS -l select=${HOSTS}:ncpus=${NCPUS}:mem=${MEM}
module load nwchem/6.0 intel-suite mpi
#cp ${PWD}/${WD}/${FIL%.*}.chk ./
#collect all the random files dotted around
cp ${PWD}/${WD}/${FIL%.*}/*.* ./
#Do this before copying the .nw job file, in case (local directory) job file has changes (i.e. a restart / continuation)
cp ${PWD}/${WD}/${FIL} ./
EOF
#RESTART TAH NAUGHTY JOBS
if [ "${RESTART}" = "YEAH" ]
then
cat >> ${COM%.*}.sh << EOF
echo >> ${FIL}
echo "restart" >> ${FIL}
EOF
fi
#OK, RUN AND CLEANUP TIME
cat >> ${COM%.*}.sh << EOF
pbsexec mpiexec /work/jmf02/nwchem-6.1/bin/LINUX64/nwchem ${FIL} >& ${FIL%.*}.out
#nwchem vomits files everywhere, so lets bundle them up into a folder
mkdir "${FIL%.*}"
mv *.* "${FIL%.*}"
cp -a "${FIL%.*}" ${PWD}/${WD}/
echo "I CAME SO FAR FOR BEAUTY."
EOF
# echo "CAPTURED QSUB COMMAND: "
# cat ${COM%.*}.sh
qsub -q "${QUEUE}" ${COM%.*}.sh
done
title "6-Thiophene - Geom from b3lyp/6-31g* Gaussian job. BNL calcs."
echo "This is a story about an ordinary teddy bear."
memory stack 300 mb heap 300 mb global 600 mb
echo
geometry noautoz units angstroms
C -2.295845 4.347985 -0.747490
H -2.287798 3.930756 -1.750280
C -1.910590 5.674810 -0.547039
H -1.610139 6.281829 -1.396983
C -1.910769 6.218084 0.737898
H -1.609458 7.250279 0.895028
C -2.300763 5.428126 1.821178
H -2.305460 5.842821 2.825603
C -2.686162 4.103623 1.618584
H -2.988357 3.493362 2.465633
C -2.686694 3.546715 0.332561
C -3.190373 2.135218 0.126844
C -4.719520 2.041069 0.028868
H -5.027045 0.990908 0.053392
H -5.141887 2.519288 0.919041
C -5.298493 2.704834 -1.229318
H -5.068591 3.775127 -1.224558
H -4.820492 2.273937 -2.118203
C -6.812947 2.516061 -1.365878
H -7.093263 1.456378 -1.310389
H -7.153762 2.857479 -2.352534
C -7.622124 3.276107 -0.330644
O -7.183357 4.071735 0.472648
O -8.934219 2.963811 -0.426606
C -9.800871 3.648912 0.492570
H -9.739328 4.730659 0.346522
H -9.528292 3.415113 1.525264
H -10.805818 3.288481 0.270853
C 3.868274 2.566502 2.592886
H 3.002863 3.120399 2.240986
C 4.477456 2.924019 3.797098
H 4.083390 3.757693 4.372172
C 5.584542 2.213210 4.260901
H 6.057305 2.489608 5.199478
C 6.081228 1.143688 3.513140
H 6.943290 0.584235 3.866182
C 5.471472 0.788331 2.310882
H 5.860712 -0.046496 1.733841
C 4.357138 1.493874 1.837248
C 3.767551 1.142905 0.488969
C 4.527227 1.771636 -0.687804
H 5.580760 1.486614 -0.594696
H 4.164760 1.350605 -1.630752
C 4.418037 3.302235 -0.747928
H 4.859118 3.742730 0.151795
H 3.359260 3.589968 -0.765848
C 5.095677 3.899922 -1.985757
H 4.723790 3.440374 -2.910137
H 4.858217 4.968914 -2.072452
C 6.609214 3.783852 -1.970704
O 7.285976 3.428234 -1.029362
O 7.130144 4.155149 -3.162175
C 8.564073 4.111961 -3.248612
H 9.014618 4.786399 -2.515394
H 8.805776 4.431633 -4.262708
H 8.929836 3.097671 -3.067792
C -2.470877 1.022841 0.870170
C -2.364942 1.194064 -0.729539
C -0.987595 1.439146 -1.256809
C 0.115518 1.663336 -0.442957
C 0.017915 1.509950 1.015719
C -1.179670 1.138800 1.614399
C -1.152235 0.149587 2.650479
C -2.303978 -0.717816 2.490365
C -3.057481 -0.267273 1.344203
C -3.621356 -1.205339 0.492189
C -3.523840 -1.049808 -0.974486
C -2.869378 0.038259 -1.533731
C -1.964835 -0.176764 -2.639420
C -0.812867 0.687274 -2.463466
C 0.459471 0.253785 -2.857071
C 1.603944 0.538291 -2.031209
C 1.434631 1.250903 -0.848426
C 2.261398 1.008360 0.372003
C 1.275869 0.999660 1.493600
C 1.302548 0.058194 2.515245
C 0.064216 -0.374762 3.106431
C 0.166881 -1.789076 3.420452
C -0.941504 -2.621951 3.276961
C -2.202960 -2.076060 2.800215
C -2.818388 -3.049742 1.932624
C -3.502004 -2.618019 0.790367
C -3.339600 -3.338336 -0.459161
C -3.347303 -2.371519 -1.541973
C -2.515386 -2.566401 -2.650185
C -1.805667 -1.442320 -3.209148
C -0.485157 -1.895017 -3.618898
C 0.621292 -1.065882 -3.441473
C 1.877883 -1.612231 -2.965636
C 2.498857 -0.632690 -2.094871
C 3.203571 -1.049547 -0.974872
C 3.248942 -0.272773 0.301120
C 3.048106 -1.296415 1.371735
C 2.199026 -1.110072 2.451937
C 1.483103 -2.241423 3.010487
C 1.633558 -3.522443 2.467336
C 0.477503 -4.388228 2.304970
C -0.786174 -3.947476 2.702584
C -1.944893 -4.209769 1.867312
C -1.795167 -4.902588 0.663739
C -2.509743 -4.459060 -0.522137
C -1.640414 -4.656278 -1.670754
C -1.641719 -3.726774 -2.713161
C -0.387737 -3.312787 -3.316887
C 0.819386 -3.844267 -2.858393
C 1.974352 -2.979595 -2.684929
C 2.679865 -3.410445 -1.502341
C 3.256804 -2.454956 -0.659579
C 3.161249 -2.606257 0.781063
C 2.493479 -3.708710 1.324135
C 1.881250 -4.692614 0.446680
C 1.973072 -4.547446 -0.936759
C 0.818476 -4.814613 -1.776533
C -0.388074 -5.211527 -1.194653
C -0.483818 -5.363355 0.250127
C 0.630468 -5.112071 1.054176
end
basis
* library 6-31g*
end
dft
iterations 50
print kinetic_energy
xc xbnl07 0.90 lyp 1.00 hfexch 1.00
cam 0.20 cam_alpha 0.0 cam_beta 1.0
direct
decomp
end
task dft energy
#Cations are POSITIVE
charge 1
dft
odft
mult 2 #Multiplicity!
iterations 50
print kinetic_energy
xc xbnl07 0.90 lyp 1.00 hfexch 1.00
cam 0.20 cam_alpha 0.0 cam_beta 1.0
direct
decomp
end
task dft energy
#Anions are NEGATIVE
charge -1
dft
odft
mult 2 #Multiplicity!
iterations 50
print kinetic_energy
xc xbnl07 0.90 lyp 1.00 hfexch 1.00
cam 0.20 cam_alpha 0.0 cam_beta 1.0
direct
decomp
end
task dft energy
#Let's get our TDDDFT on
#dft
# iterations 50
# print kinetic_energy
#
# xc xbnl07 0.90 lyp 1.00 hfexch 1.00
# cam 0.25 cam_alpha 0.0 cam_beta 1.0
# direct
#
# decomp
# end
#task dft energy
#
#tddft
# nroots 6
# singlet triplet
#end
#
#task tddft energy
for file
do
for i in 15 16 17 18 19 20 21 22 23 25 30
do
cat "${file}" | sed s/CAM/0.${i}/ > "${file%.*}_CAMp${i}.nw"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment