-
Notifications
You must be signed in to change notification settings - Fork 0
/
timed_testing.py
45 lines (39 loc) · 1.48 KB
/
timed_testing.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
import cProfile
import time
import numpy as np
from full_matrix.main import generation, integrals
from full_matrix.Davidson import matrix_davidson
from handy import diaconal, handy_transformer, handy_davidson
# generate the hamiltonian
start_matrix_generation = time.time()
hamiltonian = generation(integrals)
end_matrix_generation = time.time()
# print the timing out
print("matrix generation time:", end_matrix_generation - start_matrix_generation)
start_numpy = time.time()
hamiltonian = generation(integrals)
# get the eigen values and vectors of our hamiltonian
eigenvalues, eigenvectors = np.linalg.eig(hamiltonian)
# sort the eigen system
# sort the eigenvalues and eigenvectors
sorted_indices = eigenvalues.argsort()
eigenvalues = eigenvalues[sorted_indices]
eigenvectors = eigenvectors[:, sorted_indices]
numpy_result = eigenvalues[0]
and_numpy = time.time()
start_davidson = time.time()
hamiltonian = generation(integrals)
davidson_result = matrix_davidson(hamiltonian, 1)
and_davidson = time.time()
start_handy = time.time()
Diagonal = diaconal(0, 6, 6, integrals)
transformer = handy_transformer(6, 6, integrals)
handy_result = handy_davidson(transformer, Diagonal, 0, 1, 400)
and_handy = time.time()
# print out the results and the times
print("numpy_result:", numpy_result)
print("davidson_result:", davidson_result)
print("handy_result:", handy_result)
print("numpy time:", and_numpy - start_numpy)
print("davidson time:", and_davidson - start_davidson)
print("handy time:", and_handy - start_handy)