-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcomparison.py
More file actions
58 lines (44 loc) · 1.59 KB
/
Copy pathcomparison.py
File metadata and controls
58 lines (44 loc) · 1.59 KB
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
import os
from time import perf_counter
from ase.io.gaussian import read_gaussian_out
from cclib.parser import Gaussian
from fastlogfileparser.gaussian import DATA_FIELDS
from fastlogfileparser.gaussian import fast_gaussian_logfile_parser as fglp
FNAME = "test/data/ts_opt_three_step_semi_all_success.log"
def timeit(func):
def wrapper_function(*args, **kwargs):
print("Starting {:s}...".format(func.__name__))
start = perf_counter()
func(*args, **kwargs)
stop = perf_counter()
print("{:s} took {:.4f} seconds.\n".format(func.__name__, stop - start))
return wrapper_function
@timeit
def test_fglp():
job_1, job_2, job_3 = fglp(FNAME, get=("gibbs", "scf"))
print("Per-job free energy:", job_1.gibbs, job_2.gibbs, job_3.gibbs)
print("Total Energy (eV)", job_1.scf[-1])
@timeit
def test_cclib():
# cclib does not support reading from link jobs, so we have to split the logfile manually
f_text = ""
with open(FNAME, "r") as file:
for line in file:
f_text += line
separate_files = f_text.split(" Entering Link")[1:]
temp_fname = "temp.log"
for i in range(3):
with open(temp_fname, "w") as temp_file:
temp_file.write(separate_files[i])
p = Gaussian(temp_fname)
cclib_result = p.parse()
print("Free energy:", cclib_result.freeenergy)
os.remove(temp_fname)
@timeit
def test_ase():
with open(FNAME, "r") as file:
res = read_gaussian_out(file)
print("Total Energy (eV):", res.get_total_energy() * 0.03674930495120813)
test_fglp()
test_cclib()
test_ase()