11using Test
22using QuantumOpticsBase
33using SparseArrays, LinearAlgebra
4- import QuantumOpticsBase: ChoiState # Remove when ChoiState is publicly exported
54
65@testset " superoperators" begin
76
8- # Test creation
9- b = GenericBasis (3 )
10- @test_throws DimensionMismatch DenseSuperOperator ((b, b), (b, b), zeros (ComplexF64, 3 , 3 ))
11- @test_throws DimensionMismatch SparseSuperOperator ((b, b), (b, b), spzeros (ComplexF64, 3 , 3 ))
12- @test_throws DimensionMismatch ChoiState ((b, b), (b, b), zeros (ComplexF64, 3 , 3 ))
13-
14- # Test copy, sparse and dense
15- b1 = GenericBasis (2 )
16- b2 = GenericBasis (7 )
17- b3 = GenericBasis (5 )
18- b4 = GenericBasis (3 )
19-
20- s = DenseSuperOperator ((b1, b2), (b3, b4))
21- s_ = dense (s)
22- s_. data[1 ,1 ] = 1
23- @test s. data[1 ,1 ] == 0
24- s_sparse = sparse (s_)
25- @test isa (s_sparse, SparseSuperOpType)
26- @test s_sparse. data[1 ,1 ] == 1
27-
28- s = SparseSuperOperator ((b1, b2), (b3, b4))
29- s_ = sparse (s)
30- s_. data[1 ,1 ] = 1
31- @test s. data[1 ,1 ] == 0
32- s_dense = dense (s_)
33- @test isa (s_dense, DenseSuperOpType)
34- @test s_dense. data[1 ,1 ] == 1
35-
367# Test length
378b1 = GenericBasis (3 )
389op = DenseOperator (b1, b1)
@@ -51,76 +22,76 @@ b2 = GenericBasis(5)
5122b3 = GenericBasis (5 )
5223b4 = GenericBasis (3 )
5324
54- d1 = DenseSuperOperator ( (b1, b2), (b3, b4))
55- d2 = DenseSuperOperator ( (b3, b4), (b1, b2))
56- s1 = SparseSuperOperator ( (b1, b2), (b3, b4))
57- s2 = SparseSuperOperator ( (b3, b4), (b1, b2))
25+ d1 = DenseOperator ( KetBraBasis (b1, b2), KetBraBasis (b3, b4))
26+ d2 = DenseOperator ( KetBraBasis (b3, b4), KetBraBasis (b1, b2))
27+ s1 = SparseOperator ( KetBraBasis (b1, b2), KetBraBasis (b3, b4))
28+ s2 = SparseOperator ( KetBraBasis (b3, b4), KetBraBasis (b1, b2))
5829
5930x = d1* d2
6031@test isa (x, DenseSuperOpType)
61- @test x. basis_l == x. basis_r == (b1, b2)
32+ @test x. basis_l == x. basis_r == KetBraBasis (b1, b2)
6233
6334x = s1* s2
6435@test isa (x, SparseSuperOpType)
65- @test x. basis_l == x. basis_r == (b1, b2)
36+ @test x. basis_l == x. basis_r == KetBraBasis (b1, b2)
6637
6738x = d1* s2
6839@test isa (x, DenseSuperOpType)
69- @test x. basis_l == x. basis_r == (b1, b2)
40+ @test x. basis_l == x. basis_r == KetBraBasis (b1, b2)
7041
7142x = s1* d2
7243@test isa (x, DenseSuperOpType)
73- @test x. basis_l == x. basis_r == (b1, b2)
44+ @test x. basis_l == x. basis_r == KetBraBasis (b1, b2)
7445
7546x = d1* 3
7647@test isa (x, DenseSuperOpType)
77- @test x. basis_l == (b1, b2)
78- @test x. basis_r == (b3, b4)
48+ @test x. basis_l == KetBraBasis (b1, b2)
49+ @test x. basis_r == KetBraBasis (b3, b4)
7950
8051x = 2.5 * s1
8152@test isa (x, SparseSuperOpType)
82- @test x. basis_l == (b1, b2)
83- @test x. basis_r == (b3, b4)
53+ @test x. basis_l == KetBraBasis (b1, b2)
54+ @test x. basis_r == KetBraBasis (b3, b4)
8455
8556x = d1 + d1
8657@test isa (x, DenseSuperOpType)
87- @test x. basis_l == (b1, b2)
88- @test x. basis_r == (b3, b4)
58+ @test x. basis_l == KetBraBasis (b1, b2)
59+ @test x. basis_r == KetBraBasis (b3, b4)
8960
9061x = s1 + s1
9162@test isa (x, SparseSuperOpType)
92- @test x. basis_l == (b1, b2)
93- @test x. basis_r == (b3, b4)
63+ @test x. basis_l == KetBraBasis (b1, b2)
64+ @test x. basis_r == KetBraBasis (b3, b4)
9465
9566x = d1 + s1
9667@test isa (x, DenseSuperOpType)
97- @test x. basis_l == (b1, b2)
98- @test x. basis_r == (b3, b4)
68+ @test x. basis_l == KetBraBasis (b1, b2)
69+ @test x. basis_r == KetBraBasis (b3, b4)
9970
10071x = d1 - d1
10172@test isa (x, DenseSuperOpType)
102- @test x. basis_l == (b1, b2)
103- @test x. basis_r == (b3, b4)
73+ @test x. basis_l == KetBraBasis (b1, b2)
74+ @test x. basis_r == KetBraBasis (b3, b4)
10475
10576x = s1 - s1
10677@test isa (x, SparseSuperOpType)
107- @test x. basis_l == (b1, b2)
108- @test x. basis_r == (b3, b4)
78+ @test x. basis_l == KetBraBasis (b1, b2)
79+ @test x. basis_r == KetBraBasis (b3, b4)
10980
11081x = d1 - s1
11182@test isa (x, DenseSuperOpType)
112- @test x. basis_l == (b1, b2)
113- @test x. basis_r == (b3, b4)
83+ @test x. basis_l == KetBraBasis (b1, b2)
84+ @test x. basis_r == KetBraBasis (b3, b4)
11485
11586x = - d1
11687@test isa (x, DenseSuperOpType)
117- @test x. basis_l == (b1, b2)
118- @test x. basis_r == (b3, b4)
88+ @test x. basis_l == KetBraBasis (b1, b2)
89+ @test x. basis_r == KetBraBasis (b3, b4)
11990
12091x = - s1
12192@test isa (x, SparseSuperOpType)
122- @test x. basis_l == (b1, b2)
123- @test x. basis_r == (b3, b4)
93+ @test x. basis_l == KetBraBasis (b1, b2)
94+ @test x. basis_r == KetBraBasis (b3, b4)
12495
12596# TODO : Clean-up this part
12697ωc = 1.2
@@ -131,7 +102,6 @@ g = 1.0
131102
132103T = Float64[0. ,1. ]
133104
134-
135105fockbasis = FockBasis (7 )
136106spinbasis = SpinBasis (1 // 2 )
137107basis = tensor (spinbasis, fockbasis)
@@ -155,45 +125,45 @@ J = [Ja, Jc]
155125ρ₀ = dm (Ψ₀)
156126
157127@test identitysuperoperator (spinbasis)* sx == sx
158- @test ChoiState (identitysuperoperator (spinbasis))* sx == sx
128+ @test choi (identitysuperoperator (spinbasis))* sx == sx
159129@test identitysuperoperator (sparse (spre (sx)))* sx == sparse (sx)
160- @test ChoiState (identitysuperoperator (sparse (spre (sx))))* sx == sparse (sx)
161- @test sparse (ChoiState (identitysuperoperator (spre (sx))))* sx == sparse (sx)
130+ @test choi (identitysuperoperator (sparse (spre (sx))))* sx == sparse (sx)
131+ @test sparse (choi (identitysuperoperator (spre (sx))))* sx == sparse (sx)
162132@test identitysuperoperator (dense (spre (sx)))* sx == dense (sx)
163- @test ChoiState (identitysuperoperator (dense (spre (sx))))* sx == dense (sx)
164- @test dense (ChoiState (identitysuperoperator (spre (sx))))* sx == dense (sx)
133+ @test choi (identitysuperoperator (dense (spre (sx))))* sx == dense (sx)
134+ @test dense (choi (identitysuperoperator (spre (sx))))* sx == dense (sx)
165135
166136op1 = DenseOperator (spinbasis, [1.2 + 0.3im 0.7 + 1.2im ;0.3 + 0.1im 0.8 + 3.2im ])
167137op2 = DenseOperator (spinbasis, [0.2 + 0.1im 0.1 + 2.3im ; 0.8 + 4.0im 0.3 + 1.4im ])
168138@test tracedistance (spre (op1)* op2, op1* op2) < 1e-12
169- @test tracedistance (ChoiState (spre (op1))* op2, op1* op2) < 1e-12
139+ @test tracedistance (choi (spre (op1))* op2, op1* op2) < 1e-12
170140@test tracedistance (spost (op1)* op2, op2* op1) < 1e-12
171- @test tracedistance (ChoiState (spost (op1))* op2, op2* op1) < 1e-12
141+ @test tracedistance (choi (spost (op1))* op2, op2* op1) < 1e-12
172142
173143@test spre (sparse (op1))* op2 == op1* op2
174- @test ChoiState (spre (sparse (op1)))* op2 == op1* op2
144+ @test choi (spre (sparse (op1)))* op2 == op1* op2
175145@test spost (sparse (op1))* op2 == op2* op1
176- @test ChoiState (spost (sparse (op1)))* op2 == op2* op1
146+ @test choi (spost (sparse (op1)))* op2 == op2* op1
177147@test spre (sparse (dagger (op1)))* op2 == dagger (op1)* op2
178- @test ChoiState (spre (sparse (dagger (op1))))* op2 == dagger (op1)* op2
148+ @test choi (spre (sparse (dagger (op1))))* op2 == dagger (op1)* op2
179149@test spre (dense (dagger (op1)))* op2 ≈ dagger (op1)* op2
180- @test ChoiState (spre (dense (dagger (op1))))* op2 ≈ dagger (op1)* op2
150+ @test choi (spre (dense (dagger (op1))))* op2 ≈ dagger (op1)* op2
181151@test sprepost (sparse (op1), op1)* op2 ≈ op1* op2* op1
182- @test ChoiState (sprepost (sparse (op1), op1))* op2 ≈ op1* op2* op1
152+ @test choi (sprepost (sparse (op1), op1))* op2 ≈ op1* op2* op1
183153
184154@test spre (sparse (op1))* sparse (op2) == sparse (op1* op2)
185- @test ChoiState (spre (sparse (op1)))* sparse (op2) == sparse (op1* op2)
155+ @test choi (spre (sparse (op1)))* sparse (op2) == sparse (op1* op2)
186156@test spost (sparse (op1))* sparse (op2) == sparse (op2* op1)
187- @test ChoiState (spost (sparse (op1)))* sparse (op2) == sparse (op2* op1)
157+ @test choi (spost (sparse (op1)))* sparse (op2) == sparse (op2* op1)
188158@test sprepost (sparse (op1), sparse (op1))* sparse (op2) ≈ sparse (op1* op2* op1)
189- @test ChoiState (sprepost (sparse (op1), sparse (op1)))* sparse (op2) ≈ sparse (op1* op2* op1)
159+ @test choi (sprepost (sparse (op1), sparse (op1)))* sparse (op2) ≈ sparse (op1* op2* op1)
190160
191161@test sprepost (op1, op2) ≈ spre (op1)* spost (op2)
192162b1 = FockBasis (1 )
193163b2 = FockBasis (5 )
194164op = fockstate (b1, 0 ) ⊗ dagger (fockstate (b2, 0 ))
195165@test sprepost (dagger (op), op)* dm (fockstate (b1, 0 )) == dm (fockstate (b2, 0 ))
196- @test ChoiState (sprepost (dagger (op), op))* dm (fockstate (b1, 0 )) == dm (fockstate (b2, 0 ))
166+ @test choi (sprepost (dagger (op), op))* dm (fockstate (b1, 0 )) == dm (fockstate (b2, 0 ))
197167@test_throws ArgumentError spre (op)
198168@test_throws ArgumentError spost (op)
199169
@@ -203,17 +173,17 @@ for j=J
203173 ρ .+ = j* ρ₀* dagger (j) - 0.5 * dagger (j)* j* ρ₀ - 0.5 * ρ₀* dagger (j)* j
204174end
205175@test tracedistance (L* ρ₀, ρ) < 1e-10
206- @test tracedistance (ChoiState (L)* ρ₀, ρ) < 1e-10
176+ @test tracedistance (choi (L)* ρ₀, ρ) < 1e-10
207177
208178# tout, ρt = timeevolution.master([0.,1.], ρ₀, H, J; reltol=1e-7)
209179# @test tracedistance(exp(dense(L))*ρ₀, ρt[end]) < 1e-6
210180# @test tracedistance(exp(sparse(L))*ρ₀, ρt[end]) < 1e-6
211181
212182@test dense (spre (op1)) == spre (op1)
213- @test dense (ChoiState (spre (op1))) == ChoiState (spre (op1))
183+ @test dense (choi (spre (op1))) == choi (spre (op1))
214184
215185@test L/ 2.0 == 0.5 * L == L* 0.5
216- @test - L == SparseSuperOperator (L. basis_l, L. basis_r, - L. data)
186+ @test - L == SparseOperator (L. basis_l, L. basis_r, - L. data)
217187
218188@test_throws AssertionError liouvillian (H, J; rates= zeros (4 , 4 ))
219189
@@ -256,12 +226,12 @@ o_l = fockstate(b_fock, 2)
256226encoder_kraus = z_l ⊗ dagger (spinup (b_logical)) + o_l ⊗ dagger (spindown (b_logical))
257227 encoder_sup = sprepost (encoder_kraus, dagger (encoder_kraus))
258228decoder_sup = sprepost (dagger (encoder_kraus), encoder_kraus)
259- @test SuperOperator ( ChoiState (encoder_sup)). data == encoder_sup. data
229+ @test super ( choi (encoder_sup)). data == encoder_sup. data
260230@test decoder_sup == dagger (encoder_sup)
261- @test ChoiState (decoder_sup) == dagger (ChoiState (encoder_sup))
231+ @test choi (decoder_sup) == dagger (choi (encoder_sup))
262232@test decoder_sup* encoder_sup ≈ dense (identitysuperoperator (b_logical))
263- @test decoder_sup* ChoiState (encoder_sup) ≈ dense (identitysuperoperator (b_logical))
264- @test ChoiState (decoder_sup)* encoder_sup ≈ dense (identitysuperoperator (b_logical))
265- @test SuperOperator ( ChoiState (decoder_sup)* ChoiState (encoder_sup)) ≈ dense (identitysuperoperator (b_logical))
233+ @test decoder_sup* choi (encoder_sup) ≈ dense (identitysuperoperator (b_logical))
234+ @test choi (decoder_sup)* encoder_sup ≈ dense (identitysuperoperator (b_logical))
235+ @test super ( choi (decoder_sup)* choi (encoder_sup)) ≈ dense (identitysuperoperator (b_logical))
266236
267237end # testset
0 commit comments