-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToric_code_Sn_ground_state.py
133 lines (115 loc) · 4.03 KB
/
Toric_code_Sn_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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import numpy as np
import math
import itertools
#------------------GAUGE GROUP---------------------
def generate_permutation_matrix(perm, n):
matrix = np.zeros((n, n))
for i in range(n):
matrix[i, perm[i]-1] = 1
return matrix
def generate_symmetric_group_representations(n):
representations = []
elements = list(range(1, n+1))
permutations = list(itertools.permutations(elements))
for perm in permutations:
matrix = generate_permutation_matrix(perm, n)
representations.append(np.matrix(matrix))
return representations
N = int(input("Enter the value of N: "))
representations = generate_symmetric_group_representations(N)
# Print and store the representations
def display_representation():
for i, representation in enumerate(representations):
print(f"Representation {i+1}:")
print(representation,'\n')
# Create a basis
def generate_basis(n):
basis = []
for i in range(math.factorial(n)):
basis_element = np.zeros(math.factorial(n))
basis_element[i] = 1
basis.append(basis_element)
return basis
# Create a mapping between the elements of the S_n group and the basis
def generate_basis_map(matrix,n):
for i in range(math.factorial(n)):
if (matrix == generate_symmetric_group_representations(n)[i]).all():
return np.transpose(np.matrix(generate_basis(n)[i]))
# Create the left action operator
def L_h_plus(n,h):
basis = generate_basis(n)
m = math.factorial(n)
sn_matrices = generate_symmetric_group_representations(n)
Lh = np.zeros([m,m])
for i in range(m):
temp = np.matrix(sn_matrices[h])*np.matrix(sn_matrices[i])
bas = generate_basis_map(temp,n)
for j in range(m):
bas_2 = np.matrix(basis[j])
Lh[j][i] = bas_2*bas
return Lh
# Create the right action operator
def L_h_minus(n,h):
basis = generate_basis(n)
m = math.factorial(n)
sn_matrices = generate_symmetric_group_representations(n)
Lh = np.zeros([m,m])
for i in range(m):
temp = np.matrix(sn_matrices[i])*np.linalg.inv(np.matrix(sn_matrices[h]))
bas = generate_basis_map(temp,n)
for j in range(m):
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)
# Gives the set of links emanating from the vertex i
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
# Gives the set of links on the plaquette p
def p_plaquette(p,n):
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
links = [l1,l4,l3,l2]
return links
#------------------COMPUTE GROUND STATE---------------------
def ground_state(n,N):
gnd_states = []
dim_state = 2*n**2
states = list(itertools.product(range(math.factorial(N)), repeat=dim_state))
m = len(states)
for i in range(m):
check = 1
for p in range(n**2):
link = p_plaquette(p,n)
prod = representations[states[i][link[0]]]*representations[states[i][link[1]]]*np.linalg.inv(representations[states[i][link[2]]])*np.linalg.inv(representations[states[i][link[3]]])
if (prod == np.matrix(representations[0])).all():
check *= 1
else:
check *= 0
if check == 1:
print(states[i])
gnd_states.append(states[i])
return gnd_states
ground_state(n,N)