diff --git a/README.md b/README.md index 41c56c1..7e766bd 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ It combines a symbolic layer for the SLH formalism based on [SecondQuantizedAlge ## Development status [![Tests](https://github.com/qojulia/QuantumInputOutput.jl/actions/workflows/Tests.yml/badge.svg)](https://github.com/qojulia/QuantumInputOutput.jl/actions/workflows/Tests.yml) +[![codecov](https://codecov.io/gh/qojulia/QuantumInputOutput.jl/graph/badge.svg)](https://codecov.io/gh/qojulia/QuantumInputOutput.jl) [![Documentation dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://qojulia.github.io/QuantumInputOutput.jl/dev/) Note that **QuantumInputOutput.jl** is still at an early stage of development. diff --git a/TODO.md b/TODO.md index c7f70f2..2fd2aa9 100644 --- a/TODO.md +++ b/TODO.md @@ -11,21 +11,16 @@ - [ ] create more tests (cov +80%) - [x] simple full example - [ ] QC.jl: comparison cavity drive with full quantum (example) - - [ ] translate.jl - - [ ] utils.jl - - [ ] codecov + - [x] translate.jl + - [x] utils.jl + - [x] codecov - [ ] interaction picture: test general A(t) - [ ] cumulants: comparison example 04-1 and 04-2 - - [ ] u_Gaussian, v_Gaussian; slower? - [ ] more functionalities - [ ] pulse delay - [ ] better method for u_eff and v_eff (Victor) -- [] docu - - [x] u_eff and v_eff theory - - [ ] development status - ## Additional TODOs - [x] u_eff and v_eff equation (PRA 2020, appendix) theory, API, implementation @@ -90,4 +85,8 @@ - [x] Formatter/SpellCheck - [x] JET -- [x] Aqua \ No newline at end of file +- [x] Aqua + +- [x] docu + - [x] u_eff and v_eff theory + - [x] development status diff --git a/test/runtests.jl b/test/runtests.jl index 0a14d45..2f6c82f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,7 @@ names = [ "test_SLH.jl", "test_feedback.jl", "test_translate.jl", + "test_correlations.jl", "test_example_cavity_scattering.jl", "test_compare_example_05_1_05_2.jl", "test_interaction_picture.jl", diff --git a/test/test_SLH.jl b/test/test_SLH.jl index 2ee292d..9e5ea20 100644 --- a/test/test_SLH.jl +++ b/test/test_SLH.jl @@ -4,7 +4,7 @@ using QuantumOptics using SymbolicUtils using FunctionWrappers: FunctionWrapper using StaticArrays -using Test +using Test @testset "SLH" begin hu1 = FockSpace(:u1) diff --git a/test/test_correlations.jl b/test/test_correlations.jl new file mode 100644 index 0000000..0d364e2 --- /dev/null +++ b/test/test_correlations.jl @@ -0,0 +1,47 @@ +using QuantumInputOutput +using QuantumOptics +using LinearAlgebra +using Test + +@testset "correlations_single_tls_decay" begin + γ = 1.0 + ba = NLevelBasis(2) + σm = transition(ba, 1, 2) + ψ0 = nlevelstate(ba, 2) # initially excited + + H = 0.0 * one(ba) + J = [sqrt(γ) * σm] + Ls = J[1] + + T_end = 10 / γ + T = collect(0.0:0.01:T_end) + ΔT = T[2] - T[1] + + function f_const(t, ρ) + return H, J, dagger.(J) + end + + _, ρt_dyn = timeevolution.master_dynamic(T, ψ0, f_const) + g1_dyn = correlation_matrix(T, ρt_dyn, f_const, Ls) + + _, ρt_static = timeevolution.master(T, ψ0, H, J) + g1_static = correlation_matrix(T, ρt_static, H, J, Ls) + + @test maximum(abs.(g1_dyn .- g1_static)) < 1e-8 + + F = eigen(Hermitian((g1_static + g1_static') / 2)) + n_modes = real.(F.values) * ΔT + + expected_n = 1 - exp(-γ * T_end) + @test abs(n_modes[end] - expected_n) < 1e-2 + @test abs(n_modes[end-1]) < 1e-2 + + mode_num = F.vectors[:, end] / sqrt(ΔT) + mode_exp = sqrt.(γ) .* exp.(-0.5 * γ .* T) + mode_exp ./= sqrt(sum(abs2.(mode_exp)) * ΔT) + + overlap = sum(conj.(mode_exp) .* mode_num) * ΔT + mode_num_aligned = mode_num * exp(-1im * angle(overlap)) + overlap_aligned = abs(sum(conj.(mode_exp) .* mode_num_aligned) * ΔT) + @test overlap_aligned > 0.99 +end diff --git a/test/test_translate.jl b/test/test_translate.jl index 8d90dd2..c2dc5f4 100644 --- a/test/test_translate.jl +++ b/test/test_translate.jl @@ -136,6 +136,39 @@ using Test @test sum(abs.((F_multi(0.4) - expected).data)) < 1e-8 end + @testset "translate_qo vector overload" begin + ops = [a, Δ, a * E] + translated_ops = translate_qo( + ops, + bc1; + parameter = dict_p1, + time_parameter = dict_p_t2, + operators = ops_dict, + ) + @test length(translated_ops) == length(ops) + @test all(op -> op isa Function, translated_ops) + @test isequal(translated_ops[1](0.3), a_QO) + @test isequal(translated_ops[2](0.3), one(bc1) * Δn) + @test isequal(translated_ops[3](0.3), a_QO * E_t(0.3)) + end + + @testset "translate_qo SLH overload" begin + G_sym = SLH(1, [sqrt(κ_R) * a * E], Δ * a' * a) + H_QO, L_QO = translate_qo( + G_sym, + bc1; + parameter = dict_p1, + time_parameter = dict_p_t2, + operators = ops_dict, + ) + + @test H_QO isa Function + @test length(L_QO) == 1 + @test L_QO[1] isa Function + @test sum(abs.((H_QO(0.4) - dense(Δn * dagger(a_QO) * a_QO)).data)) < 1e-8 + @test sum(abs.((L_QO[1](0.4) - dense(sqrt(κ_Rn) * a_QO * E_t(0.4))).data)) < 1e-8 + end + @testset "substitute_operators_qmul" begin h2 = FockSpace(:h2) a = Destroy(h2, :a, 1) @@ -151,6 +184,8 @@ using Test @test isequal(simplify(y - (a_1*a_1*c1 + a_1*c3)), 0) @test isequal(simplify(y2 - (a_2*a_2*c1 + a_2*c3)), 0) + + @test substitute_operators(5, dict_sub) == 5 end @testset "substitute_operators adjoint in args_nc" begin