|
160 | 160 | # @test X_warn == X3 |
161 | 161 | # end |
162 | 162 |
|
163 | | - @testset "Time Dependent Operators" begin |
| 163 | + @testset "Time Dependent Operators and SuperOperators" begin |
164 | 164 | N = 10 |
165 | 165 | a = destroy(N) |
166 | 166 | coef1(p, t) = exp(-1im * p.ω1 * t) |
167 | 167 | coef2(p, t) = sin(p.ω2 * t) |
168 | | - |
169 | | - @test_throws MethodError QobjEvo([[a, coef1], a' * a, [a', coef2]]) |
170 | | - |
171 | | - op1 = QobjEvo(((a, coef1), a' * a, (a', coef2))) |
172 | | - op1 = QobjEvo(((a, coef1), a' * a, (a', coef2))) |
173 | | - |
174 | | - p = (ω1 = 1, ω2 = 2) |
175 | | - @test op1(p, 0.1) ≈ coef1(p, 0.1) * a + a' * a + coef2(p, 0.1) * a' |
176 | | - |
177 | | - ψ = fock(N, 1) |
178 | | - @test op1(ψ, p, 0.1) ≈ (coef1(p, 0.1) * a + a' * a + coef2(p, 0.1) * a') * ψ |
179 | | - |
| 168 | + t = rand() |
| 169 | + p = (ω1 = rand(), ω2 = rand()) |
| 170 | + |
| 171 | + # Operator |
| 172 | + H_td = QobjEvo(((a, coef1), a' * a, (a', coef2))) |
| 173 | + H_ti = coef1(p, t) * a + a' * a + coef2(p, t) * a' |
| 174 | + ψ = rand_ket(N) |
| 175 | + @test H_td(p, t) ≈ H_ti |
| 176 | + @test H_td(ψ, p, t) ≈ H_ti * ψ |
180 | 177 | @test isconstant(a) == true |
181 | | - @test isconstant(op1) == false |
| 178 | + @test isconstant(H_td) == false |
182 | 179 | @test isconstant(Qobj(a)) == true |
| 180 | + @test isoper(H_td) == true |
| 181 | + |
| 182 | + # SuperOperator |
| 183 | + c_ops = [sqrt(rand()) * a] |
| 184 | + L_td = liouvillian(H_td, c_ops) |
| 185 | + L_td2 = -1im * spre(H_td) + 1im * spost(H_td) + lindblad_dissipator(c_ops[1]) |
| 186 | + ρvec = mat2vec(rand_dm(N)) |
| 187 | + @test L_td(p, t) ≈ L_td2(p, t) |
| 188 | + @test L_td(ρvec, p, t) ≈ L_td2(ρvec, p, t) |
| 189 | + @test isconstant(L_td) == false |
| 190 | + @test issuper(L_td) == true |
| 191 | + |
| 192 | + @test_throws MethodError QobjEvo([[a, coef1], a' * a, [a', coef2]]) |
| 193 | + @test_throws ArgumentError H_td(ρvec, p, t) |
| 194 | + @test_throws ArgumentError L_td(ψ, p, t) |
183 | 195 | end |
184 | 196 | end |
0 commit comments