-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathout2xyz.py
More file actions
executable file
·50 lines (37 loc) · 930 Bytes
/
out2xyz.py
File metadata and controls
executable file
·50 lines (37 loc) · 930 Bytes
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
#!/usr/bin/env python
# Converts MOPAC output file to XYZ file.
# Usage: out2xyz.py out-file xyz-file
import sys
if len(sys.argv) != 3:
print("Usage: out2xyz.py out-file xyz-file")
sys.exit(1)
print(sys.argv[0])
f_out = sys.argv[1]
print(f_out)
f_xyz = sys.argv[2]
print(f_xyz)
# Reads the Cartesian coordinates from the MOPAC output file and stores them in XYZ (a list of lists :)
f = open(f_out, "r")
XYZ = []
for line in f:
#print(line)
if " CARTESIAN COORDINATES" in line:
#print(line)
empty = f.next()
for line in f:
if not line.strip():
break
#print(line)
Tokens = line.split()
#print(Tokens)
XYZ.append(Tokens)
f.close()
print(XYZ)
f = open(f_xyz, "w")
NAtom = len(XYZ)
f.write("%d\n" % NAtom)
f.write("\n")
for line in XYZ:
print(line)
f.write("%s %10.6f %10.6f %10.6f\n" % (line[1], float(line[2]), float(line[3]), float(line[4])))
f.close()