Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ba2tro committed Oct 18, 2023
1 parent e1f433a commit 8e421a6
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions test/test_stateszoo_api.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
using QuantumSavory
using QuantumSavory.StatesZoo: ZALMSpinPair, SingleRailMidSwapBell, DualRailMidSwapBell
using QuantumSavory.StatesZoo: ZALMSpinPairU, ZALMSpinPairN, SingleRailMidSwapBellU, SingleRailMidSwapBellN, DualRailMidSwapBellU, DualRailMidSwapBellN
using LinearAlgebra
using Test

r_zalm = Register(2)
initialize!(r_zalm[1:2], ZALMSpinPair(1e-3, 0.5, 0.5, 1, 1, 1, 1, 0.9, 1e-8, 1e-8, 1e-8, 0.99))
@test ! iszero(observable(r_zalm[1:2], ZZ))
zalmU = ZALMSpinPairU(1e-3, 0.5, 0.5, 1, 1, 1, 1, 0.9, 1e-8, 1e-8, 1e-8, 0.99)
zalmN = ZALMSpinPairN(1e-3, 0.5, 0.5, 1, 1, 1, 1, 0.9, 1e-8, 1e-8, 1e-8, 0.99)
srmsU = SingleRailMidSwapBellU(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)
srmsN = SingleRailMidSwapBellN(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)
drmsU = DualRailMidSwapBellU(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)
drmsN = DualRailMidSwapBellN(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)

r_srms = Register(2)
initialize!(r_srms[1:2], SingleRailMidSwapBell(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99))
@test ! iszero(observable(r_srms[1:2], ZZ))
r_zalmU = Register(2)
initialize!(r_zalmU[1:2], zalmU)
@test ! iszero(observable(r_zalmU[1:2], ZZ))

r_drms = Register(2)
initialize!(r_drms[1:2], DualRailMidSwapBell(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99))
@test ! iszero(observable(r_drms[1:2], ZZ))
r_zalmN = Register(2)
initialize!(r_zalmN[1:2], zalmN)
@test ! iszero(observable(r_zalmN[1:2], ZZ))

r_srmsU = Register(2)
initialize!(r_srmsU[1:2], srmsU)
@test ! iszero(observable(r_srmsU[1:2], ZZ))

r_srmsN = Register(2)
initialize!(r_srmsN[1:2], srmsN)
@test ! iszero(observable(r_srmsN[1:2], ZZ))

r_drmsU = Register(2)
initialize!(r_drmsU[1:2], drmsU)
@test ! iszero(observable(r_drmsU[1:2], ZZ))

r_drmsN = Register(2)
initialize!(r_drmsN[1:2], drmsN)
@test ! iszero(observable(r_drmsN[1:2], ZZ))

@test tr(zalmU) < 1.0
@test tr(express(zalmN).data) 1

@test tr(srmsU) < 1.0
@test tr(express(srmsN).data) 1.0

@test tr(drmsU) < 1.0
@test tr(express(drmsN).data) 1.0

0 comments on commit 8e421a6

Please sign in to comment.