diff --git a/Project.toml b/Project.toml index b6571756..469ed53c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "QuantumInputOutput" uuid = "18f9eda6-924c-47c7-a881-996695cfd7c6" -version = "0.4.1" +version = "0.4.2" [deps] DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0" diff --git a/examples/03-1_beam-combiner__PRA2023_107-023715_fig2-fig3.jl b/examples/03-1_beam-combiner__PRA2023_107-023715_fig2-fig3.jl index 709befb4..88ce932b 100644 --- a/examples/03-1_beam-combiner__PRA2023_107-023715_fig2-fig3.jl +++ b/examples/03-1_beam-combiner__PRA2023_107-023715_fig2-fig3.jl @@ -32,6 +32,7 @@ av1 = Destroy(h, :av_2, 4) ## symbolic parameters @variables γ::Real Δ::Real gu_1::Number gu_2::Number gv_1::Number +nothing # hide # We use the symbolic operators and parameters to define the SLH triples and cascade them to obtain the Hamiltonian and Lindblad for the system. diff --git a/examples/04-2_two-sided-cavity_with-atom_coh-drive__cumulants.jl b/examples/04-2_two-sided-cavity_with-atom_coh-drive__cumulants.jl index 59bfbc04..117fd513 100644 --- a/examples/04-2_two-sided-cavity_with-atom_coh-drive__cumulants.jl +++ b/examples/04-2_two-sided-cavity_with-atom_coh-drive__cumulants.jl @@ -136,9 +136,9 @@ p # In the following, we include $N=2$ two-level atoms in the cavity and simulate the transmission and reflection of a coherent Gaussian pulse with a mean photon number of $|\alpha|^2 = 1/10$. We assume that the atoms are on resonance with the cavity, i.e. $\Delta = \Delta_c = \Delta_a$. -# Obtain the ModelingToolkit independent variable from a seed mean-field problem and -# register the classical drive as a function of it (QuantumCumulants v0.5 convention). -t = meanfield([a], -Δ*a'a, [a]).iv +# Define the ModelingToolkit independent variable and register the classical drive as a +# function of it. +@independent_variables t @register_symbolic Et(tt) G_d_t = SLH(1, Et(t), 0) diff --git a/examples/05-1_N-QDs_bidirectional-waveguide_coherent-pulse.jl b/examples/05-1_N-QDs_bidirectional-waveguide_coherent-pulse.jl index 2a2c5c00..09b72af3 100644 --- a/examples/05-1_N-QDs_bidirectional-waveguide_coherent-pulse.jl +++ b/examples/05-1_N-QDs_bidirectional-waveguide_coherent-pulse.jl @@ -158,6 +158,7 @@ p lT = length(T) G2 = zeros(lT, lT) # transmission G2_ref = zeros(lT, lT) # reflection +nothing # hide # Materialize the lazy `TimeDependentSum` to a concrete operator at each time, so the # quantum-regression products below give a plain operator usable as the solver's initial state. diff --git a/examples/08-1_pulse-delay__simple.jl b/examples/08-1_pulse-delay__simple.jl index a8ae33c9..ac01fe24 100644 --- a/examples/08-1_pulse-delay__simple.jl +++ b/examples/08-1_pulse-delay__simple.jl @@ -189,6 +189,7 @@ nothing # hide p_t_sym = [g_u, g_in, g_out, g_v, M_ls...] p_t_num = [gu_, gin_, gout_, gv_, M_t_ls...] dict_p_t_int = Dict(p_t_sym .=> p_t_num) +nothing # hide # The interaction picture eliminates the delay cavity `d`, so the numeric operators live # on the two-mode basis `bu ⊗ bv` (with `ad` mapped to the identity). Build on that basis. diff --git a/src/SLH.jl b/src/SLH.jl index 4ab6bccb..65cea3b3 100644 --- a/src/SLH.jl +++ b/src/SLH.jl @@ -288,6 +288,14 @@ function ▷(G1::SLH{N}, G2::SLH{N}) where {N} return _build_slh(S_t, L_t, H_t, op_hint) end +function ▷(::SLH{N1}, ::SLH{N2}) where {N1,N2} + throw( + DimensionMismatch( + "cannot cascade SLH systems with different numbers of ports: $N1 and $N2", + ), + ) +end + ▷(a::SLH, b::SLH, c::SLH...) = ▷(a ▷ b, c...) """ diff --git a/test/test_SLH.jl b/test/test_SLH.jl index dbf43ee5..1ac400e7 100644 --- a/test/test_SLH.jl +++ b/test/test_SLH.jl @@ -58,6 +58,22 @@ using Test @test iszero(simplify(jump_operator(G2)[1] - (gu'*au + √(γ)*c + gv'*av))) end + @testset "cascade port mismatch" begin + G_two_port = G_u ⊞ G_c + expected_message = "cannot cascade SLH systems with different numbers of ports: 1 and 2" + + for compose in (▷, cascade) + exception = try + compose(G_u, G_two_port) + nothing + catch exception + exception + end + @test exception isa DimensionMismatch + @test exception.msg == expected_message + end + end + @testset "simple_concatenate" begin G1 = SLH(1, gu'*au, 0) G2 = SLH(1, √(γ)*c, Δ*c'c)