-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_example_device.py
More file actions
61 lines (46 loc) · 1.26 KB
/
create_example_device.py
File metadata and controls
61 lines (46 loc) · 1.26 KB
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
from defective_surface_code_adapter import (
Device,
Adapter,
Analyzer,
plot_graph,
)
import matplotlib.pyplot as plt
from math import log
device = Device(11, 11)
defective_nodes = [
(9, 1),
(17, 1),
(12, 2),
(5, 7),
(20, 10),
(9, 11),
(7, 13),
(16, 14),
(9, 15),
(1, 21),
(7, 21),
]
defective_edges = [
((12, 4), (13, 5)),
((12, 8), (11, 7)),
((1, 11), (0, 12)),
((16, 14), (15, 15)),
]
for node in defective_nodes:
device.graph.nodes[node]["defective"] = True
for edge in defective_edges:
device.graph.edges[edge]["defective"] = True
result = Adapter.adapt_device(device)
plt.subplot(121)
plot_graph(device.graph, [])
plt.subplot(122)
super_stabilizers = [stabilizer for stabilizer in result.stabilizers if len(stabilizer) > 1]
print(super_stabilizers)
super_stabilizer_nodes = [node for stabilizer in super_stabilizers for node in stabilizer]
logical_operator_nodes = result.logical_x_data_qubits + result.logical_z_data_qubits
ana_result = Analyzer.analyze_device(device)
print(ana_result)
print(log(ana_result.x_shortest_path_count))
print(log(ana_result.z_shortest_path_count))
plot_graph(device.graph, result.disabled_nodes, logical_operator_nodes=result.logical_x_data_qubits)
plt.show()