-
Notifications
You must be signed in to change notification settings - Fork 2
/
inf_T_SSH.py
72 lines (65 loc) · 2.48 KB
/
inf_T_SSH.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
from SSH import *
# import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
import time
import argparse
import pickle
import numpy as np
from mpi4py.futures import MPIPoolExecutor
def run(p):
L,ty,Bp,random=p
params=Params(delta=0,L=L,T=np.inf,E0=0,dE=1)
LN_0=params.log_neg(np.arange(L//2),np.arange(L//2)+L)
MI_0=params.mutual_information_m(np.arange(L//2),np.arange(L//2)+L)
if ty!='no':
step=1*(ty=='onsite')+2*(ty=='link')
if random:
assert not Bp, 'Bp cannot be true while random is True'
subA=np.arange(0,L//2,step)
subAp=np.arange(0,L//2,step)+L//2
subB=np.arange(0,L//2,step)+L
subBp=np.arange(0,L//2,step)+L//2*3
proj_range_all=np.hstack([subAp,subBp])
proj_range=np.sort(np.random.choice(proj_range_all,proj_range_all.shape[0],replace=False))
params.measure_all_Born(type=ty,proj_range=proj_range)
else:
params.measure_all_Born(type=ty)
if Bp:
params.measure_all_Born(proj_range=np.arange(L*3//2,L*2,step),type=ty)
LN=params.log_neg(np.arange(L//2),np.arange(L//2)+L)
MI=params.mutual_information_m(np.arange(L//2),np.arange(L//2)+L)
return MI_0,LN_0,MI,LN,params.E_mean
if __name__=="__main__":
parser=argparse.ArgumentParser()
parser.add_argument('--es',default=4,type=int)
parser.add_argument('--type',default='no',type=str)
parser.add_argument('--Bp',default=False,type=bool)
parser.add_argument('--random',default=False,type=bool)
args=parser.parse_args()
executor=MPIPoolExecutor()
# L_list=[16,32,64,96,128,128+64,256]
L_list=[128,256]
LN_0_dict={}
MI_0_dict={}
LN_dict={}
MI_dict={}
E_mean_dict={}
for L in L_list:
inputs=inputs=[(L,args.type,args.Bp,args.random) for _ in range(args.es)]
pool=executor.map(run,inputs)
LN_0_dict[L]=[]
MI_0_dict[L]=[]
LN_dict[L]=[]
MI_dict[L]=[]
E_mean_dict[L]=[]
for result in pool:
MI_0,LN_0,MI,LN,E_mean=result
LN_0_dict[L].append(LN_0)
MI_0_dict[L].append(MI_0)
LN_dict[L].append(LN)
MI_dict[L].append(MI)
E_mean_dict[L].append(E_mean)
executor.shutdown()
with open('inf_T_SSH_{:s}_Ap{:s}{:s}_sametype.pickle'.format(args.type,args.Bp*'Bp',args.random*'_R'),'wb') as f:
pickle.dump([MI_0_dict,LN_0_dict,MI_dict,LN_dict,E_mean_dict],f)