-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToric_code_Z2_ground_state.py
101 lines (83 loc) · 2.39 KB
/
Toric_code_Z2_ground_state.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import numpy as np
import random
#------------------GAUGE GROUP---------------------
basis = [[1,0],[0,1]]
def basis_map(g):
if g == 0:
return np.transpose(np.matrix(basis[0]))
else:
return np.transpose(np.matrix(basis[1]))
def inverse_map(vector):
if (vector == basis[0]).all():
return 0
else:
return 1
def L_h_plus(h,basis):
Lh = np.zeros([2,2])
for i in range(2):
temp = (h+i)%2
bas = basis_map(temp)
for j in range(2):
bas_2 = np.matrix(basis[j])
Lh[j][i] = bas_2*bas
return Lh
#------------------LATTICE---------------------
# Number of links in the x direction with constant y is: n
n = 2
lattice = np.zeros([n,n],np.int32)
def v_links(v,lattice):
m = lattice.shape[0]
n = lattice.shape[1]
i = v[0]
j = v[1]
if i == 0:
if j == 0:
links = [n*i+j,n*i+j+n-1,n**2+n*i+j,2*n**2-n]
else:
links = [n*i+j,n*i+j-1,n**2+n*i+j,2*n**2-n+j]
else:
if j == 0:
links = [n*i+j,n*i+j+n-1,n**2+n*i+j,n**2+n*i-n+j]
else:
links = [n*i+j,n*i+j-1,n**2+n*i+j,n**2+n*i-n+j]
return links
def A_v(v,state):
sig_x = np.matrix([[0,1],[1,0]])
links = v_links(v,lattice)
for k in range(4):
vec = sig_x*basis_map(state[links[k]])
state[links[k]] = inverse_map(np.transpose(vec))
def B_p(p,state):
l1 = p
l2 = n**2+p
l3 = (p+n)%(n**2)
if (l2+1)%n == 0:
l4 = l2-(p%n)
else:
l4 = l2-(p%n)+1
sig_z = np.matrix([[1,0],[0,-1]])
links = [l1,l2,l3,l4]
for k in range(4):
vec = sig_z*basis_map(state[links[k]])
state[links[k]] = inverse_map(np.transpose(vec))
def dectobin(decimal,arr,dim,i):
if(decimal > 0):
arr[len(arr)-1-i] = decimal%2
dectobin(int(decimal/2),arr,dim,i+1)
return arr
def generate_basis_state(i,dim):
arr = np.zeros(dim)
return dectobin(i,arr,dim,0)
print(generate_basis_state(0,2*n**2))
def ground_state_coeff_A():
c = np.zeros(2**n)
# Define random basis
state = []
for i in range(2*n**2):
state.append(random.choice([0,1]))
state = [1, 1, 1, 1, 1, 1, 1, 1]
temp = state
print(state)
A_v([1,1],state)
print(v_links([1,1],lattice))
print(state)