-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_subclusters.py
44 lines (35 loc) · 1.75 KB
/
find_subclusters.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
import sys
import pickle
import scipy.sparse as sp
import numpy as np
import time
import exact_diag.ed_spins as tvi
import exact_diag.ed_fermions as hubb
from exact_diag import ed_nlce
def find_subclusters(cluster_index,
cluster_data_out_fname,
cluster_data_in_fname):
with open(cluster_data_in_fname, 'rb') as f:
data = pickle.load(f)
order_indices_full = data[2]
full_cluster_list = data[1]
cluster = full_cluster_list[cluster_index]
cluster_mult_mat = sp.csr_matrix((len(full_cluster_list), len(full_cluster_list)))
# get all sub clusters of each cluster
subclusters_list, subcluster_mult_mat, order_indices_subclusters = ed_nlce.get_reduced_subclusters(cluster)
cluster_reduction_mat = ed_nlce.map_between_cluster_bases(full_cluster_list,
order_indices_full,
subclusters_list,
order_indices_subclusters,
use_symmetry=True)
# now convert subcluster_mult_mat to correct indices...
final_sub_cluster_mat = cluster_reduction_mat.transpose().dot(subcluster_mult_mat.dot(cluster_reduction_mat))
data_out = [cluster_index, final_sub_cluster_mat, cluster]
with open(cluster_data_out_fname, 'wb') as f:
pickle.dump(data_out, f)
if __name__ == "__main__":
# bash arrays start at 1, so lets keep that convention for terminal arguments
cluster_index = int(sys.argv[1]) - 1
out_fname = sys.argv[2]
in_fname = sys.argv[3]
find_subclusters(cluster_index, out_fname, in_fname)