-
Notifications
You must be signed in to change notification settings - Fork 0
/
XYZtoGaussian.py
180 lines (152 loc) · 6.36 KB
/
XYZtoGaussian.py
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
# python 3.8.8
##################################################################################################################################################
# #
# This script generates a .com input file (opt + freq) for Gaussian 09 and 16 from .xyz files exported from Maestro, Schrödinger #
# after conformer search! #
# #
# Cluster: Linux Cluster, Leibnitz Rechenzentrum (LRZ), Munich, Germany #
# Change method in file! #
# Adjust cluster setting! #
# Loop over all *.xyz files in current folder! #
# #
# Version: 1.12 #
# #
# Author: Fabian L. Zott #
# Last modified: 16.09.2021 #
# #
##################################################################################################################################################
import sys
import re
import os
import glob
import fileinput
################Charge and Spinmultiplicity#############
print("\n" * 4)
print("-----------------------------------------------")
print("------------Hello, beautiful!!-----------------")
print("-----------------------------------------------")
print("\n")
print("What charge does your molecule have?")
print("\n")
print("Type as: +1, 0 or -1):")
print("\n")
charge = int(input("Write here: "))
if charge > 0:
chargestr = "+" + str(charge)
else:
chargestr = str(charge)
chargestr = str(chargestr)
print("\n")
print("What spinmultiplicity does your molecule have?")
print("\n")
mult = input("Write here: ")
multstr = str(mult)
print("\n" * 2)
print("Charge is:", chargestr, " and spinmultiplicity is:", multstr)
print("\n" * 2)
print("\n")
print("Where do you want to submitt? (cm2_tiny, cm2 or mpp3)")
print("\n" *2)
cluster = input("Write here: ")
clusterstr = str(cluster)
####################Defining Cluster Settings###########
# Leibnitz Rechenzentrum (LRZ), Linux Cluster 09.2021 #
nproc = None
mem = None
cm2 = "cm2"
cm2_tiny = "cm2_tiny"
mpp3 = "mpp3"
if (clusterstr == cm2):
nproc = "28"
mem = "48Gb"
print("%nproc =", nproc,"and %mem =", mem)
elif (clusterstr == cm2_tiny):
nproc = "28"
mem = "48Gb"
print("%nproc =", nproc,"and %mem =", mem)
elif (clusterstr == mpp3):
nproc = "64"
mem = "64Gb"
print("%nproc =", nproc,"and %mem =", mem)
else:
print("---------Wrong INPUT for Cluster!!!!--------------")
print("-----------------Try again!-----------------------")
########################################################
print("\n")
print("Good choice!")
print("\n" * 2)
#######################################################
cwd = os.getcwd() #get current working directory "cwd"
os.chdir(cwd)
for file in glob.glob("*.xyz"): # parse through *.xyz files generated by Maestro, Schrödinger, LLC, New York, NY, 2021
filename = os.path.splitext(file)[0] # get basenme of .xyz file
newfile = str(filename) + ".rawxyz"
fin = open(file,"r")
lines = fin.readlines()
fin.close()
del lines[0:2]
fout = open(newfile,"w+")
for line in lines:
fout.write(line)
fout.close()
################Creating .com files##################
com = open(str(filename) + "_SMD_opt_freq.com", "w+") #create basename.com file and enable for appending text
com.write("%Nproc=")
com.write(nproc)
com.write("\n")
com.write("%Mem=")
com.write(mem)
com.write("\n")
com.write("%chk=" + filename + ".chk")
com.write("\n")
com.write("#p B3LYP/6-31+G(d,p) opt=tight scrf=(smd,solvent=water) empiricaldispersion=gd3 scf=tight int=finegrid") # method section for optimization
com.write("\n")
com.write("")
com.write("\n")
com.write(filename + " opt")
com.write("\n")
com.write("")
com.write("\n")
com.write(chargestr)
com.write(" ")
com.write(multstr)
com.write("\n")
with open(filename + ".rawxyz", 'r') as xyzinput: #open .gjf and print in file
com.write(xyzinput.read())
com.write("\n")
com.write("")
com.write("\n")
com.write("")
com.write("\n")
com.write("")
com.write("--link1--")
com.write("\n")
com.write("%Nproc=")
com.write(nproc)
com.write("\n")
com.write("%Mem=")
com.write(mem)
com.write("\n")
com.write("%chk=" + filename + ".chk")
com.write("\n")
com.write("#p B3LYP/6-31+G(d,p) freq scrf=(smd,solvent=water) empiricaldispersion=gd3 scf=tight int=finegrid guess=read geom=check") # method section for frequency calculations
com.write("\n")
com.write("")
com.write("\n")
com.write(filename + " freq")
com.write("\n")
com.write("")
com.write("\n")
com.write(chargestr)
com.write(" ")
com.write(multstr)
com.write("\n")
com.write("")
com.write("\n")
com.write("")
com.write("\n")
com.write("")
com.close() # finish and save file
if os.path.exists(newfile):
os.remove(newfile)
else: