Skip to content

Commit

Permalink
density operators update
Browse files Browse the repository at this point in the history
  • Loading branch information
aarontrowbridge committed Nov 7, 2024
1 parent 68804b7 commit 1b4dae6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/isomorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export ad_vec
export

using LinearAlgebra
using SparseArrays
using TestItemRunner

(xs::AbstractVecOrMat...) = kron(xs...)
Expand Down
51 changes: 48 additions & 3 deletions src/quantum_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,42 @@ function QuantumSystem(H::Function, n_drives::Int)
end


function L_function(Ls::AbstractVector{<:AbstractMatrix})
return sum([conj(L) L - 1 / 2 * ad_vec(L'L, anti=true) for L in Ls])
end

function QuantumSystem(
H_drift::AbstractMatrix,
H_drives::Vector{<:AbstractMatrix},
dissipation_operators::Vector{<:AbstractMatrix}
)
H_drift = sparse(H_drift)
H_drives = sparse.(H_drives)

H = a -> H_drift + sum(a .* H_drives)

𝒟̃ = sparse(iso(L_function(dissipation_operators)))

G = a -> Isomorphisms.G(ad_vec(H(a))) + 𝒟̃

∂Gs = Isomorphisms.G.(ad_vec.(H_drives))
∂G = a -> ∂Gs

levels = size(H_drift, 1)

function Base.copy(sys::QuantumSystem)
return QuantumSystem(
copy(sys.H_drift),
copy.(sys.H_drives)
H,
G,
∂G,
levels,
length(H_drives)
)

end




# ============================================================================= #

@testitem "System creation" begin
Expand All @@ -132,5 +158,24 @@ end
system = QuantumSystem(H_drift, H_drives)
end

@testitem "System creation with dissipation" begin
H_drift = GATES[:Z]
H_drives = [GATES[:X], GATES[:Y]]
dissipation_operators = [GATES[:Z], GATES[:X]]

system = QuantumSystem(H_drift, H_drives, dissipation_operators)

# test jacobians
a = randn(system.n_drives)
∂G = system.∂G(a)
@test length(∂G) == system.n_drives
@test all(∂G .≈ QuantumSystems.generator_jacobian(system.G)(a))
end







end

0 comments on commit 1b4dae6

Please sign in to comment.