Skip to content

Commit 7c2c394

Browse files
committed
small changes
1 parent 5b7a318 commit 7c2c394

File tree

8 files changed

+179
-20
lines changed

8 files changed

+179
-20
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
1111
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
1212
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
1313
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
14+
FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e"
1415
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1516
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1617
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
@@ -37,6 +38,7 @@ CSV = "0.10.14"
3738
CUDA = "5.7.2"
3839
DataFrames = "1.6.1"
3940
FileIO = "1.16.3"
41+
FunctionWrappers = "1.1.3"
4042
Graphs = "1.11.1"
4143
MPI = "0.20.22"
4244
Makie = "0.22.2"

examples/Nishimori/NishimorisCat.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import JLD2
33
import ProgressMeter
44
function simulate(; path="", L=12, averaging=10, tApi=1/4)
55
geometry = HoneycombGeometry(Open, L, L)
6-
circuit = compile(NishimorisCat(geometry; tApi))
6+
circuit = compile(NishimorisCatClifford(geometry))
7+
78
end

src/Backends/QuantumClifford/QuantumClifford.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ include("operations/XX.jl")
1818
include("operations/YY.jl")
1919
include("operations/ZZ.jl")
2020
include("operations/I.jl")
21-
# include("operations/H.jl")
22-
# include("operations/CNOT.jl")
21+
include("operations/H.jl")
22+
include("operations/CNOT.jl")
2323
include("operations/Pauli.jl")
2424
include("operations/Measure_X.jl")
2525
include("operations/Measure_Y.jl")

src/Backends/QuantumClifford/operations/H.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ function apply!(
44
::MonitoredQuantumCircuits.H,
55
p)
66

7-
QC.apply!(register, QC.sHadamard(p))
7+
QC.apply!(register, QC.sHadamard(p[1]))
88
end

src/MonitoredQuantumCircuits.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ include("circuits/MTFIM.jl")
6161
include("circuits/kekule_floquet.jl")
6262
include("circuits/shastry_sutherland.jl")
6363
include("circuits/nishimoris_cat.jl")
64+
include("circuits/nishimoris_cat_clifford.jl")
6465
include("circuits/squareOctagon.jl")
6566
include("circuits/fibonacci_drive.jl")
6667

@@ -81,6 +82,7 @@ export random_qubit
8182
export to_grid
8283
export to_linear
8384
export neighbor
85+
export qubits
8486

8587
export I
8688
export ZZ
@@ -121,6 +123,7 @@ export MeasurementOnlyKekule_Floquet
121123
export MonitoredTransverseFieldIsing
122124
export MeasurementOnlyShastrySutherland
123125
export NishimorisCat
126+
export NishimorisCatClifford
124127
export MeasurementOnlySquareOctagon
125128
export MeasurementOnlyFibonacciDrive
126129

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function NishimorisCatClifford(geometry::HoneycombGeometry{Open})
2+
circuit = Circuit(geometry)
3+
4+
for position in 1:nQubits(geometry)
5+
apply!(circuit, H(), position)
6+
end
7+
for position in eachcol(bonds(geometry; kitaevType=:Z))
8+
apply!(circuit, ZZ(), position...)
9+
end
10+
for position in eachcol(bonds(geometry; kitaevType=:X))
11+
apply!(circuit, ZZ(), position...)
12+
end
13+
for position in eachcol(bonds(geometry; kitaevType=:Y))
14+
apply!(circuit, ZZ(), position...)
15+
end
16+
for position in 1:nQubits(geometry)
17+
apply!(circuit, Measure_Z(), position)
18+
end
19+
20+
21+
22+
return circuit
23+
end

src/geometries/HoneycombLattice.jl

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function kitaevZ(geometry::HoneycombGeometry{Open})
200200
return bonds
201201
end
202202

203-
function isKitaevX(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int64})
203+
function isKitaevX(geometry::HoneycombGeometry, bond::Tuple{Int64,Int64})
204204
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
205205
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
206206
neighbor1 = kitaevX_neighbor(geometry, bond[1])
@@ -211,7 +211,9 @@ function isKitaevX(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int6
211211
return false
212212
end
213213

214-
function isKitaevY(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int64})
214+
215+
216+
function isKitaevY(geometry::HoneycombGeometry, bond::Tuple{Int64,Int64})
215217
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
216218
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
217219
neighbor1 = kitaevY_neighbor(geometry, bond[1])
@@ -222,7 +224,7 @@ function isKitaevY(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int6
222224
return false
223225
end
224226

225-
function isKitaevZ(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int64})
227+
function isKitaevZ(geometry::HoneycombGeometry, bond::Tuple{Int64,Int64})
226228
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
227229
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
228230
neighbor1 = kitaevZ_neighbor(geometry, bond[1])
@@ -233,7 +235,7 @@ function isKitaevZ(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int6
233235
return false
234236
end
235237

236-
function isKekuleRed(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int64})
238+
function isKekuleRed(geometry::HoneycombGeometry, bond::Tuple{Int64,Int64})
237239
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
238240
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
239241
neighbor1 = kekuleRed_neighbor(geometry, bond[1])
@@ -244,7 +246,7 @@ function isKekuleRed(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,In
244246
return false
245247
end
246248

247-
function isKekuleGreen(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int64})
249+
function isKekuleGreen(geometry::HoneycombGeometry, bond::Tuple{Int64,Int64})
248250
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
249251
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
250252
neighbor1 = kekuleGreen_neighbor(geometry, bond[1])
@@ -255,7 +257,7 @@ function isKekuleGreen(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,
255257
return false
256258
end
257259

258-
function isKekuleBlue(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,Int64})
260+
function isKekuleBlue(geometry::HoneycombGeometry, bond::Tuple{Int64,Int64})
259261
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
260262
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
261263
neighbor1 = kekuleBlue_neighbor(geometry, bond[1])
@@ -266,38 +268,70 @@ function isKekuleBlue(geometry::HoneycombGeometry{Periodic}, bond::Tuple{Int64,I
266268
return false
267269
end
268270

269-
function kitaevX_neighbor(geometry::HoneycombGeometry{Periodic}, site::Integer)
271+
272+
273+
function kitaevX_neighbor(geometry::HoneycombGeometry, site::Integer)
270274
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
271275
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
272276
i, j = to_grid(geometry, site)
273277
if isodd(i)
274-
return to_linear(geometry, (i + 1, j))
278+
new = to_linear(geometry, (i + 1, j))
279+
if (site,new) in edges(geometry.graph)
280+
return new
281+
else
282+
return nothing
283+
end
275284
else
276-
return to_linear(geometry, (i - 1, j))
285+
new = to_linear(geometry,(i - 1, j))
286+
if (site,new) in edges(geometry.graph)
287+
return new
288+
else
289+
return nothing
290+
end
277291
end
278292
end
279293

280294

281295

282-
function kitaevY_neighbor(geometry::HoneycombGeometry{Periodic}, site::Integer)
296+
function kitaevY_neighbor(geometry::HoneycombGeometry, site::Integer)
283297
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
284298
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
285299
i, j = to_grid(geometry, site)
286300
if iseven(i)
287-
return to_linear(geometry, (i + 1, j))
301+
new = to_linear(geometry, (i + 1, j))
302+
if (site,new) in edges(geometry.graph)
303+
return new
304+
else
305+
return nothing
306+
end
288307
else
289-
return to_linear(geometry, (i - 1, j))
308+
new = to_linear(geometry, (i - 1, j))
309+
if (site,new) in edges(geometry.graph)
310+
return new
311+
else
312+
return nothing
313+
end
290314
end
291315
end
292316

293-
function kitaevZ_neighbor(geometry::HoneycombGeometry{Periodic}, site::Integer)
317+
function kitaevZ_neighbor(geometry::HoneycombGeometry, site::Integer)
294318
geometry.sizeX % 2 == 0 || throw(ArgumentError("The sizeX must be even"))
295319
geometry.sizeY % 2 == 0 || throw(ArgumentError("The sizeY must be even"))
296320
i, j = to_grid(geometry, site)
297321
if iseven(i)
298-
return to_linear(geometry, (i - 1, j + 1))
322+
new = to_linear(geometry, (i - 1, j + 1))
323+
if (site,new) in edges(geometry.graph)
324+
return new
325+
else
326+
return nothing
327+
end
299328
else
300-
return to_linear(geometry, (i + 1, j - 1))
329+
new = to_linear(geometry, (i + 1, j - 1))
330+
if (site,new) in edges(geometry.graph)
331+
return new
332+
else
333+
return nothing
334+
end
301335
end
302336
end
303337

@@ -488,7 +522,7 @@ function kekuleBlue_neighbor(geometry::HoneycombGeometry{Periodic}, site::Intege
488522
end
489523
end
490524

491-
function bonds(geometry::HoneycombGeometry{Periodic}; kitaevType=:All, kekuleType=:All)
525+
function bonds(geometry::HoneycombGeometry; kitaevType=:All, kekuleType=:All)
492526
positions = Int64[]
493527
if kitaevType == :All
494528
if kekuleType == :All

thesis/code.jl

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
function MeasurementTransverseFieldIsingFibonacci(
2+
geometry::ChainGeometry, p::Float64; depth=10)
3+
4+
circuit = Circuit(geometry)
5+
X_random = DistributedOperation(Measure_X(), qubits(geometry), p)
6+
ZZ_random = DistributedOperation(ZZ(), bonds(geometry), 1 - p)
7+
for n in 1:word_length(depth)
8+
if fibonacci_word(n)
9+
apply!(circuit, X_random)
10+
else
11+
apply!(circuit, ZZ_random)
12+
end
13+
end
14+
return circuit
15+
end
16+
function MonitoredTransverseFieldIsing(
17+
geometry::ChainGeometry{Periodic}, p::Float64; depth=100)
18+
19+
circuit = Circuit(geometry)
20+
X_random = DistributedOperation(Measure_X(), qubits(geometry), p)
21+
ZZ_random = DistributedOperation(ZZ(), bonds(geometry), 1 - p)
22+
for _ in 1:depth
23+
apply!(circuit, ZZ_random)
24+
apply!(circuit, X_random)
25+
end
26+
apply!(circuit, ZZ_random)
27+
return circuit
28+
end
29+
30+
function MeasurementOnlyKitaev(
31+
geometry::HoneycombGeometry{Periodic},
32+
px::Float64, py::Float64, pz::Float64;
33+
depth::Integer=100)
34+
35+
circuit = Circuit(geometry)
36+
for position in eachcol(bonds(geometry; kitaevType=:Z))
37+
apply!(circuit, ZZ(), position...)
38+
end
39+
for position in eachcol(plaquettes(geometry))
40+
apply!(circuit, NPauli(Y, X, Z, Y, X, Z), position...)
41+
end
42+
xy_loop = loops(geometry; kitaevTypes=(:X, :Y))[:, 1]
43+
xz_loop = loops(geometry; kitaevTypes=(:X, :Z))[:, 1]
44+
apply!(circuit, NPauli(Z(), length(xy_loop)), xy_loop...)
45+
apply!(circuit, NPauli(Y(), length(xy_loop)), xz_loop...)
46+
randomParityMeasurement = RandomOperation()
47+
push!(randomParityMeasurement, XX(), bonds(geometry; kitaevType=:X);
48+
probability=px)
49+
push!(randomParityMeasurement, YY(), bonds(geometry; kitaevType=:Y);
50+
probability=py)
51+
push!(randomParityMeasurement, ZZ(), bonds(geometry; kitaevType=:Z);
52+
probability=pz)
53+
for i in 1:depth*nQubits(geometry)
54+
apply!(circuit, randomParityMeasurement)
55+
end
56+
return circuit
57+
end
58+
59+
60+
execute(compile(circuit), QuantumClifford.TableauSimulator(nQubits(geometry)))
61+
62+
operation = RandomOperation()
63+
64+
geometry = HoneycombGeometry(Periodic, L, L)
65+
66+
sim = QuantumClifford.TableauSimulator(nQubits(geometry);
67+
mixed=false, basis=:X)
68+
69+
geometry = ChainGeometry(Periodic, N)
70+
71+
operation = DistributedOperation(Measure_X(), qubits(geometry), p)
72+
73+
function fibonacci_word(n)
74+
golden_ratio = (1 + sqrt(5)) / 2
75+
return Bool(div(n + 1, golden_ratio) - div(n, golden_ratio))
76+
end
77+
78+
p = 0.5
79+
circuit = compile(MonitoredTransverseFieldIsing(geometry, p; depth=2^15))
80+
result = execute(circuit, sim)
81+
half_ent = QuantumClifford.entanglement_entropy(result.stab, 1:div(N, 2))
82+
83+
function MonitoredTransverseFieldIsing(
84+
geometry::ChainGeometry{Periodic}, p::Float64; depth=100)
85+
86+
circuit = Circuit(geometry)
87+
X_random = DistributedOperation(Measure_X(), MonitoredQuantumCircuits.qubits(geometry), p)
88+
ZZ_random = DistributedOperation(ZZ(), bonds(geometry), 1 - p)
89+
for _ in 1:depth
90+
apply!(circuit, ZZ_random)
91+
apply!(circuit, X_random)
92+
end
93+
apply!(circuit, ZZ_random)
94+
return circuit
95+
end
96+

0 commit comments

Comments
 (0)