Skip to content

Commit fa61b03

Browse files
committed
WIP: Cleanup ORCA interface
1 parent ecc7288 commit fa61b03

File tree

1 file changed

+62
-20
lines changed

1 file changed

+62
-20
lines changed

interfaces/ORCA/r.orca

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,73 @@
11
#!/bin/bash
2-
cd $(dirname $0)
3-
source ../SetEnvironment.sh ORCA
2+
# File interface to ORCA program.
3+
#
4+
# Modify the prepare_orca_input() function to your needs.
5+
#
6+
# NOTE: This script assumes that the 'orca' executable is already in your PATH.
7+
# If that is not the case, modify the variable 'ORCAEXE' below accordingly.
8+
#
9+
# Tested with versions 5.0.x and 6.0.x. Other versions might work, but always test
10+
# by verifying energy conservation in a short NVE simulation.
11+
cd "$(dirname "$0")" || exit 2
12+
set -uo pipefail
13+
14+
if [[ -f ../SetEnvironment.sh ]]; then
15+
# This is specific to Prague clusters
16+
source ../SetEnvironment.sh ORCA
17+
else
18+
# We assume dftb+ is in PATH already. If not, add it here.
19+
ORCAEXE=orca
20+
fi
421

522
timestep=$1
623
ibead=$2
724
input=input$ibead
825
natom=$(wc -l < ../geom.dat.$ibead)
26+
WORKDIR="CALC.$ibead"
27+
28+
function prepare_orca_input() {
29+
# Working directory for the ORCA calculation
30+
rm -rf "${WORKDIR}.previous"
31+
if [[ -d "$WORKDIR" ]];then
32+
mv "$WORKDIR" "${WORKDIR}".previous
33+
fi
34+
mkdir -p "$WORKDIR"
935

10-
rm -f *engrad
36+
cat > $input << EOF
37+
! PBE0 def2-SVP TightSCF
1138
12-
#TODO: I'm not quite sure, whether we always get the correct energies,
13-
# but perhaps we do, check the format of $input.engrad
14-
cat > $input << EOF
15-
# in the following line, specify basis sets and method,
16-
# basis sets for RI approximations are basis/J
17-
! BP86 SVP
18-
! ENGRAD AUTOSTART TightSCF
19-
* xyz 0 1
39+
# Do not modify this line, it ensures that both energies and
40+
# gradients are computed, and that wavefunction is read from previous step.
41+
! ENGRAD AUTOSTART
2042
EOF
21-
### END OF USER INPUT ###
2243

23-
cat ../geom.dat.$ibead >> $input
24-
echo '*' >>$input
44+
echo "* xyz 0 1" >> $input
45+
cat ../geom.dat.$ibead >> $input
46+
echo '*' >>$input
47+
}
48+
49+
function extract_energy_and_gradients() {
50+
orca_out="$1"
51+
engrad_file="$2"
52+
awk -v natom="$natom" '
53+
$5== "energy" {getline; getline; print $1}
54+
55+
$4 == "gradient" {
56+
getline
57+
for (i = 1; i <= natom; i++) {
58+
getline; gx=$1
59+
getline; gy=$1
60+
getline; gz=$1
61+
print x,y,z
62+
}
63+
}
64+
' "$orca_out" > "$engrad_file"
65+
}
66+
67+
#### LET'S GO! ####
68+
prepare_orca_inputs
69+
70+
cd "$WORKDIR" || exit 2
2571

2672
$ORCAEXE $input &> $input.out
2773
################################
@@ -31,11 +77,7 @@ else
3177
echo "WARNING from r.orca: ORCA calculation probably failed."
3278
echo "See $input.out.error"
3379
cp $input.out $input.out.error
80+
exit 2
3481
fi
3582

36-
### EXTRACTING ENERGY AND FORCES
37-
awk -v natom="$natom" '{if ($5=="energy") {getline;getline;print $1}
38-
if ($4=="gradient") {getline;
39-
for(i=1;i<=natom;i++) {
40-
getline; x=$1;getline;y=$1;getline;print x,y,$1
41-
}}}' $input.engrad > ../engrad.dat.$ibead
83+
extract_energy_and_gradients "$input.egrad" "../engrad.dat.$ibead"

0 commit comments

Comments
 (0)