Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/SLH.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)

"""
Expand Down
16 changes: 16 additions & 0 deletions test/test_SLH.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading