|
1 | 1 | @testset "Correlations and Spectrum" begin |
| 2 | + Id = qeye(10) |
2 | 3 | a = destroy(10) |
3 | 4 | H = a' * a |
4 | 5 | c_ops = [sqrt(0.1 * (0.01 + 1)) * a, sqrt(0.1 * (0.01)) * a'] |
5 | 6 |
|
6 | 7 | t_l = range(0, 333 * π, length = 1000) |
7 | | - corr = correlation_2op_1t(H, nothing, t_l, c_ops, a', a; progress_bar = Val(false)) |
8 | | - ω_l1, spec1 = spectrum_correlation_fft(t_l, corr) |
| 8 | + corr1 = correlation_2op_1t(H, nothing, t_l, c_ops, a', a; progress_bar = Val(false)) |
| 9 | + corr2 = correlation_3op_1t(H, nothing, t_l, c_ops, Id, a', a; progress_bar = Val(false)) |
| 10 | + ω_l1, spec1 = spectrum_correlation_fft(t_l, corr1) |
9 | 11 |
|
10 | 12 | ω_l2 = range(0, 3, length = 1000) |
11 | 13 | spec2 = spectrum(H, ω_l2, c_ops, a', a) |
|
21 | 23 | idxs2 = test_func2 .> 0.05 |
22 | 24 | @test sum(abs2.(spec1[idxs1] .- test_func1[idxs1])) / sum(abs2.(test_func1[idxs1])) < 0.01 |
23 | 25 | @test sum(abs2.(spec2[idxs2] .- test_func2[idxs2])) / sum(abs2.(test_func2[idxs2])) < 0.01 |
| 26 | + @test all(corr1 .≈ corr2) |
24 | 27 | @test all(spec2 .≈ spec3) |
25 | 28 |
|
26 | 29 | @testset "Type Inference spectrum" begin |
27 | 30 | @inferred correlation_2op_1t(H, nothing, t_l, c_ops, a', a; progress_bar = Val(false)) |
28 | | - @inferred spectrum_correlation_fft(t_l, corr) |
| 31 | + @inferred spectrum_correlation_fft(t_l, corr1) |
29 | 32 | @inferred spectrum(H, ω_l2, c_ops, a', a) |
30 | 33 | @inferred spectrum(H, ω_l2, c_ops, a', a; solver = PseudoInverse()) |
31 | 34 | end |
32 | 35 |
|
| 36 | + t_wrong1 = [1, 2, 3] |
| 37 | + t_wrong2 = [-1, 0, 1] |
| 38 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_l, t_wrong1, c_ops, Id, a', a) |
| 39 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_l, t_wrong2, c_ops, Id, a', a) |
| 40 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_wrong1, t_l, c_ops, Id, a', a) |
| 41 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_wrong2, t_l, c_ops, Id, a', a) |
| 42 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_wrong1, t_wrong1, c_ops, Id, a', a) |
| 43 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_wrong1, t_wrong2, c_ops, Id, a', a) |
| 44 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_wrong2, t_wrong1, c_ops, Id, a', a) |
| 45 | + @test_throws ArgumentError correlation_3op_2t(H, nothing, t_wrong2, t_wrong2, c_ops, Id, a', a) |
33 | 46 | @test_throws ErrorException FFTCorrelation() |
34 | 47 | end |
0 commit comments