-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkgeom
248 lines (222 loc) · 14.2 KB
/
mkgeom
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#! /bin/csh -f
#Trap to delete temporary files if quit early
onintr emergency_cleanup
echo ""
echo "Make Geom 1.2 - By Eric Loucks"
echo ""
#Version History
#1.0 - First functioning version, worked for molecules in yz plane (assuming 50 or fewer atoms and none above florine)
#1.1 - Added more specific labeling, status messages. Added some framework for support of other planes
#1.2 - Finished support of planes. Works for C2V molecules in XY, XZ, or YZ planes at the end of the guassian calculation
#Initial input definition
if ( $#argv == 0 ) then
goto error1
else
set LOG = $argv[1]
endif
#########################################################################################
#Input error messages
if ( $#argv > 1 ) goto error2
if ( ! -e $argv[1] ) then
if ( $LOG == -h ) then
echo ""
echo "Hello! This script was designed to create geom files for COLUMBUS jobs using the .log file output by a Gaussian geometry optimization. This particular script works for ONLY C2v symmetry molecules. Additionally, the number of atoms in the system must be less than 50. This script was written by Eric Loucks. If it's not working, ask him for help!"
echo ""
echo "The format of a mkgeom command is: mkgeom file_name.log"
echo ""
exit
endif
goto error3
endif
goto input
error1:
echo "Error: No file was specified. Type "mkgeom -h" for help."
exit
error2:
echo "Error: Too many arguments. Type "mkgeom -h" for help."
exit
error3:
echo "Error: Specified file does not exist"
exit
error4:
echo "Error: Molecule is not in XY, YZ, or XZ planes or is not C2v symmetry"
goto emergency_cleanup
#####################################################################################
#Input sorting
input:
#File called .mkgeom_temp_matrix containing matrix of info from log file created
grep -A 500 "Optimization completed." $LOG | sed -n '/Standard orientation/,/Rotational constants/p' | head -n -2 | sed -n '6,$p' > .mkgeom_temp_matrix
#Checks to make sure the optimization completed by seeing if .mkgeom_tem_matrix is 0 in size
if (-z ./.mkgeom_temp_matrix) then
echo "STATUS: Optimization did not converge. Initiating premature exit"
goto emergency_cleanup
else
echo "STATUS: Optimized Geometry found."
endif
######################################################################################
#Checks which plane the molecule is in by checking which coordinate column is all 0
foreach line ( "`cat .mkgeom_temp_matrix`" )
set xcol = `echo $line | awk '{print $4}' | tr -d . | bc`
if ( $xcol < -9 || $xcol > 9 ) goto testxyplane
end
echo "STATUS: Molecule is in YZ plane. Removing atoms duplicated across mirror plane."
set plane = YZ
goto remove_duplicates
testxyplane:
foreach line ( "`cat .mkgeom_temp_matrix`" )
set zcol = `echo $line | awk '{print $6}' | tr -d . | bc`
if ( $zcol < -9 || $zcol > 9 ) goto testxzplane
end
echo "STATUS: Molecule is in XY plane. Removing atoms duplicated across mirror plane."
set plane = XY
goto remove_duplicates
testxzplane:
foreach line ( "`cat .mkgeom_temp_matrix`" )
set ycol = `echo $line | awk '{print $5}' | tr -d . | bc`
if ( $ycol < -9 || $ycol > 9 ) goto error4
end
echo "STATUS: Molecule is in XZ plane. Removing atoms duplicated across mirror plane."
set plane = XZ
#####################################################################################
#Removes lines where the Y value is negative (non-unique coordinates)
remove_duplicates:
#goto emergency_cleanup
if ($plane == "YZ" || $plane == "XY") then
foreach line ( "`cat .mkgeom_temp_matrix`" )
if ( `echo $line | awk '{print $5}' | tr -d . | bc` < -9 ) then #The -9 instead of 0 is to allow a threshold of plus or minus 0.000009 in the coordinate
echo "STATUS: Duplicate atom found, moving on"
else
echo "$line" >> .mkgeom_temp_removedmatrix
endif
end
endif
if ($plane == "XZ") then
foreach line ( "`cat .mkgeom_temp_matrix`" )
if ( `echo $line | awk '{print $4}' | tr -d . | bc` < -9 ) then
echo "STATUS: Duplicate atom found, moving on"
else
echo "$line" >> .mkgeom_temp_removedmatrix
endif
end
endif
#Unit conversion, and decimal place correction
echo "STATUS: Converting units and removing unnecessary information"
cat .mkgeom_temp_removedmatrix | awk '{print $2, $4, $5, $6}' | sort -k1 -rn | awk '{x=$2*1.889725989;$2=x;y=$3*1.889725989;$3=y;z=$4*1.889725989;$4=z; printf "%s", $1; printf " "; printf "%.8f", $2; printf " "; printf "%.8f", $3; printf " "; printf "%.8f\n", $4}' > .mkgeom_temp_pregeom
##########################################################################################################################
#Geom Creation (VERY picky in terms of spaces)
echo "STATUS: Creating geom file with necessary spacing"
foreach line ( "`cat .mkgeom_temp_pregeom`" )
set x = `echo $line | awk '{print $2}' | tr -d . | bc`
set y = `echo $line | awk '{print $3}' | tr -d . | bc`
set z = `echo $line | awk '{print $4}' | tr -d . | bc`
if ( $x >= 0 && $y >= 0 && $z >= 0 ) then # spacing for +x, +y, +z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
if ( $x >= 0 && $y >= 0 && $z < 0 ) then # spacing for +x, +y, -z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
if ( $x >= 0 && $y < 0 && $z >= 0 ) then # spacing for +x, -y, +z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
if ( $x < 0 && $y >= 0 && $z >= 0 ) then # spacing for -x, +y, +z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
if ( $x >= 0 && $y < 0 && $z < 0 ) then # spacing for +x, -y, -z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
if ( $x < 0 && $y >= 0 && $z < 0 ) then # spacing for -x, +y, -z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
if ( $x < 0 && $y < 0 && $z >= 0 ) then # spacing for -x, -y, +z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
if ( $x < 0 && $y < 0 && $z < 0 ) then # spacing for -x, -y, -z
echo "$line" | awk ' \
$1 == 1 {print " " "H ", $1 ".0", " ", $2, " ", $3, " ", $4, " 1.00782504"}\
$1 == 2 {print " " "He ", $1 ".0", " ", $2, " ", $3, " ", $4, " 4.00260325"}\
$1 == 3 {print " " "Li ", $1 ".0", " ", $2, " ", $3, " ", $4, " 7.01600455"}\
$1 == 4 {print " " "Be ", $1 ".0", " ", $2, " ", $3, " ", $4, " 9.01218224"}\
$1 == 5 {print " " "B ", $1 ".0", " ", $2, " ", $3, " ", $4, " 11.00930544"}\
$1 == 6 {print " " "C ", $1 ".0", " ", $2, " ", $3, " ", $4, " 12.00000000"}\
$1 == 7 {print " " "N ", $1 ".0", " ", $2, " ", $3, " ", $4, " 14.00307401"}\
$1 == 8 {print " " "O ", $1 ".0", " ", $2, " ", $3, " ", $4, " 15.99491462"}\
$1 == 9 {print " " "F ", $1 ".0", " ", $2, " ", $3, " ", $4, " 18.99840322"} ' >> geom
endif
end
echo "STATUS: geom created successfully"
echo ""
##########################################################################################################################
#Normal termination clean up
echo "STATUS: Normal termination. Deleting temporary files."
rm .mkgeom_temp_matrix .mkgeom_temp_removedmatrix .mkgeom_temp_pregeom
echo "Finished. Have a nice day!"
exit
#Error Clean up
emergency_cleanup:
if ( -e ./.mkgeom_temp_matrix ) rm .mkgeom_temp_matrix
if ( -e ./.mkgeom_temp_removedmatrix ) rm .mkgeom_temp_removedmatrix
if ( -e ./.mkgeom_temp_pregeom ) rm .mkgeom_temp_pregeom
echo "Error: Premature script termination. Temporary files have been deleted"