-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenthalpy.py
40 lines (31 loc) · 1.11 KB
/
enthalpy.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
#!/usr/bin/python3
import sys
def main():
args = sys.argv
if args[1] == "sg15":
from sg15 import psen_dict
elif args[1] == "pslibrary":
from pslibrary import psen_dict
else:
from sssp import psen_dict
for ifile in range(len(args)-2):
rx_file = args[ifile+2]
with open(rx_file) as f:
lines = f.readlines()
if "Begin final coordinates\n" in lines:
start = lines.index("Begin final coordinates\n")
end = lines.index("End final coordinates\n")
natom = len(lines[start+10:end])
enthalpy = float(lines[start-1].strip().split()[3]) / float(natom)
#
# isolated
#
enthalpy0 = 0.0
iatom = 0
for atom_pos in lines[start+10:end]:
atom = str(atom_pos.strip().split()[0])
enthalpy0 += psen_dict[atom]
iatom += 1
enthalpy0 /= float(natom)
print(rx_file, enthalpy, enthalpy0, enthalpy - enthalpy0)
main()