-
Notifications
You must be signed in to change notification settings - Fork 8
/
g09-mulliken-charges.zsh
executable file
·79 lines (64 loc) · 1.99 KB
/
g09-mulliken-charges.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env zsh
set -f
#
# Gaussian09 Mulliken charge for specific atom
#
function g09-mulliken-charges()
{
if [[ $(${GAUSSIAN_TOOLS_DIRECTORY:-$HOME/bin}/g09-revision.zsh "${1}") == "Gaussian 09, Revision D.01" ]]
then # using Gaussian 09, Revision D.01
if [[ -z "${2}" ]]
then # all Mulliken charges are requested
data=$(
awk '/Mulliken charges and spin densities:/,/Sum of Mulliken charges/ { print }' "${1}" |\
head -n -1 |\
/usr/bin/tail -r |\
sed -n '1,/ 1 2/p' |\
head -n -1 |\
/usr/bin/tail -r |\
awk '{print $2, $3}' |\
column -t
)
else # Mulliken charges of a specific atom are requested
data=$(
awk '/Mulliken charges and spin densities:/,/Sum of Mulliken charges/ { print }' "${1}" |\
head -n -1 |\
/usr/bin/tail -r |\
sed -n '1,/ 1 2/p' |\
head -n -1 |\
/usr/bin/tail -r |\
awk -v atom="${2}" '$0 ~ atom {print $3}'
)
fi
elif [[ $(${GAUSSIAN_TOOLS_DIRECTORY:-$HOME/bin}/g09-revision.zsh "${1}") == "Gaussian 09, Revision C.01" ]]
then # using Gaussian 09, Revision C.01
if [[ -z "${2}" ]]
then # all Mulliken charges are requested
data=$(
awk '/Mulliken atomic charges:/,/Sum of Mulliken atomic charges/ { print }' "${1}" |\
head -n -1 |\
/usr/bin/tail -r |\
sed -n '1,/ 1/p' |\
head -n -1 |\
/usr/bin/tail -r |\
awk '{print $2, $3}' |\
column -t
)
else # Mulliken charges of a specific atom are requested
data=$(
awk '/Mulliken atomic charges:/,/Sum of Mulliken atomic charges/ { print }' "${1}" |\
head -n -1 |\
/usr/bin/tail -r |\
sed -n '1,/ 1/p' |\
head -n -1 |\
/usr/bin/tail -r |\
awk -v atom="${2}" '$0 ~ atom {print $3}'
)
fi
else # perhaps unsupported?
data="Gaussian revision unsupported"
fi
"${GAUSSIAN_TOOLS_DIRECTORY:-$HOME/bin}/g09-data-test.zsh" "$data"
}
# g09-mulliken-charges file [atom]
g09-mulliken-charges "${1}" "${2}"