|
1 | 1 | #!/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 |
4 | 21 |
|
5 | 22 | timestep=$1
|
6 | 23 | ibead=$2
|
7 | 24 | input=input$ibead
|
8 | 25 | 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" |
9 | 35 |
|
10 |
| -rm -f *engrad |
| 36 | + cat > $input << EOF |
| 37 | +! PBE0 def2-SVP TightSCF |
11 | 38 |
|
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 |
20 | 42 | EOF
|
21 |
| -### END OF USER INPUT ### |
22 | 43 |
|
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 |
25 | 71 |
|
26 | 72 | $ORCAEXE $input &> $input.out
|
27 | 73 | ################################
|
|
31 | 77 | echo "WARNING from r.orca: ORCA calculation probably failed."
|
32 | 78 | echo "See $input.out.error"
|
33 | 79 | cp $input.out $input.out.error
|
| 80 | + exit 2 |
34 | 81 | fi
|
35 | 82 |
|
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