-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathplot_energies.py
63 lines (45 loc) · 1.28 KB
/
plot_energies.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
#!/usr/bin/python
# Anna Tomberg
# Plot info from orca run using *.out file
# Last updated : 02-12-2015
import sys
import re
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
# ------------- GET INPUT FILE ------------- #
if len(sys.argv) <= 1:
name = raw_input("Enter path to input: ")
else:
name = sys.argv[1]
fo = open(name, "r")
lines = fo.readlines()
fo.close()
# ------------------------------------------ #
# -------------- EXTRACT INFO -------------- #
print lines[2]
if re.search(" O R C A ", lines[2]):
print 'this is an orca output'
we_continue = True
else :
print 'dunno this output format!'
we_continue = False
if we_continue:
Energy = []
for line in lines:
if re.search("Total Energy : ", line):
temp = line.split()[3]
Energy.append(temp)
# convert string to float
Energy=[(lambda x: float(x))(x) for x in Energy]
# ------------- PLOTTING STUFF ------------- #
# If only SCF cycle, plot OPTION 1.
# If got passed 1st SCF cycle, plot OPTION 2.
# ------------------------------------------ #
# OPTION 1:
if Energy != []:
plt.figure()
ax = plt.subplot(111)
plt.title("Energy")
ax.yaxis.set_major_formatter(FormatStrFormatter('%.2f'))
ax.plot(list(range(1, len(Energy)+1)), Energy, 'r-')
plt.show()