Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions examples/GHZsetup/GHZsetup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ using ResumableFunctions
using ConcurrentSim
using Revise
using QuantumSavory
using QuantumSavory.StatesZoo
using QuantumSavory.ProtocolZoo
using QuantumClifford: ghz
const bell = StabilizerState("XX ZZ")
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2)
const perfect_pair_dm = SProjector(perfect_pair)
const mixed_dm = MixedState(perfect_pair_dm)

noisy_pair_func_depol(p) = p*perfect_pair_dm + (1-p)*mixed_dm

function noisy_pair_func(F)
p = (4*F-1)/3
return noisy_pair_func_depol(p)
end
# noisy_pair_func_depol(p) = p*perfect_pair_dm + (1-p)*mixed_dm
# function noisy_pair_func(F)
# p = (4*F-1)/3
# return noisy_pair_func_depol(p)
# end
noisy_pair_func(F) = DepolarizedBellPair(F=F)

S = 5 # number of sensors
F = 0.99 # fidelity
Expand Down
4 changes: 3 additions & 1 deletion examples/congestionchain/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using Revise

# The workhorse for the simulation
using QuantumSavory
using QuantumSavory.StatesZoo

# Predefined useful circuits
using QuantumSavory.CircuitZoo: EntanglementSwap
Expand Down Expand Up @@ -66,7 +67,8 @@ end
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2)
const perfect_pair_dm = SProjector(perfect_pair)
const mixed_dm = MixedState(perfect_pair_dm)
noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
# noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
Comment thread
hanakl marked this conversation as resolved.
Outdated
noisy_pair_func(F) = DepolarizedBellPair(;F)
const XX = X⊗X
const ZZ = Z⊗Z
const YY = Y⊗Y
Expand Down
4 changes: 3 additions & 1 deletion examples/firstgenrepeater/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using Revise

# The workhorse for the simulation
using QuantumSavory
using QuantumSavory.StatesZoo

# Predefined useful circuits
using QuantumSavory.CircuitZoo: EntanglementSwap, Purify2to1
Expand Down Expand Up @@ -63,7 +64,8 @@ end
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2)
const perfect_pair_dm = SProjector(perfect_pair)
const mixed_dm = MixedState(perfect_pair_dm)
noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
# noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
noisy_pair_func(F) = DepolarizedBellPair(;F)
const XX = X⊗X
const ZZ = Z⊗Z
const YY = Y⊗Y
Expand Down
4 changes: 3 additions & 1 deletion examples/firstgenrepeater_v2/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using Revise

# The workhorse for the simulation
using QuantumSavory
using QuantumSavory.StatesZoo

# Predefined useful circuits
using QuantumSavory.CircuitZoo: EntanglementSwap, Purify2to1
Expand Down Expand Up @@ -58,7 +59,8 @@ end
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2)
const perfect_pair_dm = SProjector(perfect_pair)
const mixed_dm = MixedState(perfect_pair_dm)
noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
# noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
noisy_pair_func(F) = DepolarizedBellPair(;F)
const XX = X⊗X
const ZZ = Z⊗Z
const YY = Y⊗Y
Expand Down
13 changes: 7 additions & 6 deletions examples/purificationMBQC/MBQC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using ConcurrentSim
using Revise

using QuantumSavory
using QuantumSavory.StatesZoo
using QuantumSavory.ProtocolZoo
import QuantumSavory: Tag

Expand All @@ -12,12 +13,12 @@ global_logger(ConsoleLogger(stderr, Logging.Debug))
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2)
const perfect_pair_dm = SProjector(perfect_pair)
const mixed_dm = MixedState(perfect_pair_dm)
noisy_pair_func_depol(p) = p*perfect_pair_dm + (1-p)*mixed_dm

function noisy_pair_func(F)
p = (4*F-1)/3
return noisy_pair_func_depol(p)
end
# noisy_pair_func_depol(p) = p*perfect_pair_dm + (1-p)*mixed_dm
# function noisy_pair_func(F)
# p = (4*F-1)/3
# return noisy_pair_func_depol(p)
# end
noisy_pair_func(F) = DepolarizedBellPair(;F)

@kwdef struct MBQCSetUp
node::Int
Expand Down
3 changes: 3 additions & 0 deletions src/StatesZoo/StatesZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import LinearAlgebra
import LinearAlgebra: tr

export BarrettKokBellPair, BarrettKokBellPairW,
DepolarizedBellPair,
stateexplorer, stateexplorer!, stateparameters, stateparametersrange


Expand All @@ -30,6 +31,8 @@ stateparametersrange(::Any) = ()

include("barrett_kok.jl")

include("depolarized.jl")

include("genqo.jl")

include("state_explorer.jl")
Expand Down
43 changes: 43 additions & 0 deletions src/StatesZoo/depolarized.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
$TYPEDEF

Fields:

$FIELDS

A symbolic representation of the depolarized |Φ⁺⟩ = (|00⟩+|11⟩)/√2 Bell state:
`p |Φ⁺⟩⟨Φ⁺| + (1-p) I/4`

where `I/4` is the two-qubit maximally mixed state.

The fidelity `F = ⟨Φ⁺|ρ|Φ⁺⟩` relates to the depolarization parameter by:
- `F = (3p + 1) / 4`
- `p = (4F - 1) / 3`

Can be constructed from either parameter:
- `DepolarizedBellPair(p)` — depolarization parameter `p ∈ [0, 1]`
- `DepolarizedBellPair(F=F)` — from fidelity `F ∈ [1/4, 1]`
"""
@withmetadata struct DepolarizedBellPair <: AbstractTwoQubitState
"""Depolarization parameter `p ∈ [0, 1]`, related to fidelity by `F = (3p+1)/4`"""
p
end

DepolarizedBellPair(; F) = DepolarizedBellPair((4 * F - 1) / 3)

stateparameters(::Type{DepolarizedBellPair}) = (:p,)
stateparametersrange(::Type{DepolarizedBellPair}) = (p=(;min=0,max=1,good=1),)

symbollabel(x::DepolarizedBellPair) = "ρᵖ"

function express_nolookup(x::DepolarizedBellPair, r::QuantumOpticsRepr)
pure_dm = SProjector((Z1⊗Z1 + Z2⊗Z2) / sqrt(2))
mixed_dm = MixedState(pure_dm)
return express(x.p*pure_dm + (1-x.p)*mixed_dm, r)
end

function express_nolookup(x::DepolarizedBellPair, r::CliffordRepr)
pure_dm = SProjector(StabilizerState("ZZ XX"))
mixed_dm = MixedState(StabilizerState("ZZ XX"))
return express(x.p * pure_dm + (1 - x.p) * mixed_dm, r)
end
4 changes: 3 additions & 1 deletion test/setup_circuitzoo_purification.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using QuantumSavory.CircuitZoo
using QuantumSavory.CircuitZoo: EntanglementSwap, Purify2to1, Purify3to1, Purify3to1Node, Purify2to1Node, PurifyStringent, StringentHead, StringentBody, PurifyExpedient, PurifyStringentNode, PurifyExpedient
using QuantumSavory.StatesZoo

const bell = StabilizerState("XX ZZ")
export bell;
Expand All @@ -12,7 +13,8 @@ export bell;
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2)
const perfect_pair_dm = SProjector(perfect_pair)
const mixed_dm = MixedState(perfect_pair_dm)
noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
# noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper
noisy_pair_func(F) = DepolarizedBellPair(;F)


# Qclifford repr
Expand Down
1 change: 1 addition & 0 deletions test/test_stateszoo_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _evalf(x) = express(x)

for S in [BarrettKokBellPair, BarrettKokBellPairW,
GenqoUnheraldedSPDCBellPairW, GenqoMultiplexedCascadedBellPairW,
DepolarizedBellPair
] # TODO use some abstract supertype to automatically get all of these
params = QuantumSavory.StatesZoo.stateparameters(S)
paramdict = QuantumSavory.StatesZoo.stateparametersrange(S)
Expand Down
42 changes: 42 additions & 0 deletions test/test_stateszoo_depolarized.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@testitem "StatesZoo DepolarizedBellPair" begin
using Test
using QuantumSavory
using QuantumSavory.StatesZoo
using QuantumOpticsBase
using QuantumClifford
using LinearAlgebra

# p-constructor and fidelity-constructor consistency
p = 0.7
F = (3p + 1) / 4
s_from_p = DepolarizedBellPair(p)
s_from_F = DepolarizedBellPair(F=F)
@test express(s_from_p) ≈ express(s_from_F)

# trace is 1 for any p
for p in [0.0, 0.5, 1.0]
dm = express(DepolarizedBellPair(p))
@test tr(dm) ≈ 1
end

# at p=1, pure Bell state: ⟨ZZ⟩ = 1
reg = Register(2)
initialize!(reg[1:2], DepolarizedBellPair(1.0))
@test observable(reg[1:2], QuantumSymbolics.Z⊗QuantumSymbolics.Z) ≈ 1
reg_c = Register(2, CliffordRepr())
initialize!(reg_c[1:2], DepolarizedBellPair(1.0))
@test observable(reg_c[1:2], QuantumSymbolics.Z⊗QuantumSymbolics.Z) ≈ 1

# at p=0, maximally mixed: density matrix = I/4
dm_mixed = express(DepolarizedBellPair(0.0))
@test dm_mixed.data ≈ LinearAlgebra.I / 4

# fidelity-to-p and p-to-fidelity roundtrip
for F in [0.25, 0.5, 0.75, 1.0]
p_rt = (4F - 1) / 3
@test (3p_rt + 1) / 4 ≈ F
dm = express(DepolarizedBellPair(F=F))
@test tr(dm) ≈ 1
end

end
Loading