-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpxscplot_main.py
97 lines (79 loc) · 2.33 KB
/
pxscplot_main.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
#!/C/Users/goldfuss/AppData/Local/Programs/Python/Python310/python
#!/data/data/com.termux/files/usr/bin/python
# out of xtb-scan.xyz extract energies
# set arr[0] = 0 to fill it,
# then do all from 1 to end via [1:];
# plot curve
# find minima and maxima
import re
import sys
#import plotext as plt
import matplotlib.pyplot as plt
arr=[]
arr=[0]
ARR=[]
MinInd=[]
MinARR=[]
MinSum=[]
#MinSumA={}
MaxInd=[]
MaxARR=[]
MaxSum=[]
try:
file= open(sys.argv[1],"r")
except:
print("dummer OpenFile Fehler")
# extract energies-2nd-word in line
# append into string array arr
for lines in file:
# if re.search(sys.argv[1], lines):
if re.search('energy:', lines):
arr.append(lines.split()[1])
file.close()
#larr= len(arr)
#print("arr-Length is " , larr)
## convert arr-string to ARR-float
## but key starts at 0
for i in arr:
ARR.append(float(i))
lARR= len(ARR)
#print("ARR-Length is " , lARR)
#for i in ARR[1:]:
# print("ARR= " , i , "at: ", ARR.index(i))
# for plotext
# plt.theme('clear')
plt.plot(ARR[1:])
# plt.show()
plt.savefig('PLOT.png')
### GLOBAL Mini and Maxi
Maxi = max(ARR[1:])
Mini = min(ARR[1:])
print("GloMax: " , Maxi, " at: ", (ARR.index(Maxi)))
print("GloMin: " , Mini, " at: ", (ARR.index(Mini)))
### global end ######
# find LOCAL MINIMA in ARR-float: index-list MinInd
for i in range(2, lARR-1):
if (ARR[i - 1] > ARR[i] < ARR[i + 1]) and (ARR[i - 2] > ARR[i] < ARR[i + 2]):
MinInd.append(i)
# find LOCAL MAXIMA in ARR-float: index-list MaxInd
for i in range(2, lARR-1):
if (ARR[i - 1] < ARR[i] > ARR[i + 1]) and (ARR[i - 2] < ARR[i] > ARR[i + 2]):
MaxInd.append(i)
## PRINT LocMinima
lMin= len(MinInd)
print("\nNumb. of LocMinima is " ,lMin)
#print("LocMin-INDEX: ", MinInd )
print("Local-Minima at Index: " )
for i in range(0, lMin):
print(ARR[MinInd[i]] , " at ",MinInd[i])
kcal = float( (ARR[MinInd[i]] - Mini) * 627.51 )
print("%.2f" %kcal , " kcal/mol " , "\n"+ int(kcal) * "#")
## PRINT LocMaxima
lMax= len(MaxInd)
print("\nNumb. of LocMaxima is " ,lMax)
#print("LocMax-INDEX: ", MaxInd )
print("Local-Maxima at Index: " )
for i in range(0, lMax):
print(ARR[MaxInd[i]] , " at ",MaxInd[i])
kcal = float( (ARR[MaxInd[i]] - Maxi) * 627.51 )
print("%.2f" %kcal , " kcal/mol " , "\n"+ (-1) * int(kcal) * "#")