Quantum Systems
PiccoloQuantumObjects.QuantumSystems.AbstractQuantumSystem
— TypeAbstractQuantumSystem
Abstract type for defining systems.
PiccoloQuantumObjects.QuantumSystems.OpenQuantumSystem
— TypeOpenQuantumSystem(
H_drift::AbstractMatrix{<:Number},
H_drives::AbstractVector{<:AbstractMatrix{<:Number}}
dissipation_operators::AbstractVector{<:AbstractMatrix{<:Number}};
kwargs...
)
OpenQuantumSystem(
H_drift::Matrix{<:Number}, H_drives::AbstractVector{Matrix{<:Number}};
dissipation_operators::AbstractVector{<:AbstractMatrix{<:Number}}=Matrix{ComplexF64}[],
kwargs...
)
OpenQuantumSystem(H_drift::Matrix{<:Number}; kwargs...)
OpenQuantumSystem(H_drives::Vector{Matrix{<:Number}}; kwargs...)
OpenQuantumSystem(H::Function, n_drives::Int; kwargs...)
Constructs an OpenQuantumSystem
object from the drift and drive Hamiltonian terms and dissipation operators.
PiccoloQuantumObjects.QuantumSystems.QuantumSystem
— TypeQuantumSystem(H_drift::Matrix{<:Number}, H_drives::Vector{Matrix{<:Number}}; kwargs...)
QuantumSystem(H_drift::Matrix{<:Number}; kwargs...)
QuantumSystem(H_drives::Vector{Matrix{<:Number}}; kwargs...)
QuantumSystem(H::Function, n_drives::Int; kwargs...)
Constructs a QuantumSystem
object from the drift and drive Hamiltonian terms.
PiccoloQuantumObjects.QuantumSystems.get_drift
— Methodget_drift(sys::AbstractQuantumSystem)
Returns the drift Hamiltonian of the system.
PiccoloQuantumObjects.QuantumSystems.get_drives
— Methodget_drives(sys::AbstractQuantumSystem)
Returns the drive Hamiltonians of the system.
Composite Quantum Systems
PiccoloQuantumObjects.CompositeQuantumSystems.CompositeQuantumSystem
— TypeCompositeQuantumSystem <: AbstractQuantumSystem
A composite quantum system consisting of subsystems
. Couplings between subsystems can be additionally defined. Subsystem drives are always appended to any new coupling drives.
PiccoloQuantumObjects.CompositeQuantumSystems.lift
— Functionlift(operator::AbstractMatrix{<:Number}, i::Int, subsystem_levels::Vector{Int})
lift(operator::AbstractMatrix{<:Number}, i::Int, n_qubits::Int; kwargs...)
lift(operators::AbstractVector{<:AbstractMatrix{T}}, indices::AbstractVector{Int}, subsystem_levels::Vector{Int})
lift(operators::AbstractVector{<:AbstractMatrix{T}}, indices::AbstractVector{Int}, n_qubits::Int; kwargs...)
lift(operator::AbstractMatrix{T}, indices::AbstractVector{Int}, subsystem_levels::AbstractVector{Int})
lift(operator::AbstractMatrix{T}, indices::AbstractVector{Int}, n_qubits::Int; kwargs...)
Lift an operator
acting on the i
-th subsystem within subsystem_levels
to an operator acting on the entire system spanning subsystem_levels
.
Gates
PiccoloQuantumObjects.Gates.GATES
— ConstantA constant dictionary GATES
containing common quantum gate matrices as complex-valued matrices. Each gate is represented by its unitary matrix.
GATES[:I]
- Identity: Leaves the state unchanged.GATES[:X]
- Pauli-X (NOT): Flips the qubit state.GATES[:Y]
- Pauli-Y: Rotates the qubit state around the Y-axis of the Bloch sphere.GATES[:Z]
- Pauli-Z: Flips the phase of the qubit state.GATES[:H]
- Hadamard: Creates superposition by transforming basis states.GATES[:CX]
- Controlled-X (CNOT): Flips the 2nd qubit (target) if the first qubit (control) is |1⟩.GATES[:CZ]
- Controlled-Z (CZ): Flips the phase of the 2nd qubit (target) if the 1st qubit (control) is |1⟩.GATES[:XI]
- Complex: A gate for complex operations.GATES[:sqrtiSWAP]
- Square root of iSWAP: Partially swaps two qubits with a phase.
PiccoloQuantumObjects.Gates.PAULIS
— ConstantThe 2×2 Pauli matrics and identity.
Embedded Operators
PiccoloQuantumObjects.EmbeddedOperators.AbstractPiccoloOperator
— TypeAbstractPiccoloOperator
Union type for operators.
PiccoloQuantumObjects.EmbeddedOperators.EmbeddedOperator
— TypeEmbeddedOperator
Embedded operator type to represent an operator embedded in a subspace of a larger quantum system.
Fields
operator::Matrix{ComplexF64}
: Embedded operator of sizeprod(subsystem_levels) x prod(subsystem_levels)
.subspace::Vector{Int}
: Indices of the subspace the operator is embedded in.subsystem_levels::Vector{Int}
: Levels of the subsystems in the composite system.
PiccoloQuantumObjects.EmbeddedOperators.EmbeddedOperator
— MethodEmbeddedOperator(
subspace_operator::AbstractMatrix{<:Number},
subsystem_indices::AbstractVector{Int},
subspaces::AbstractVector{<:AbstractVector{Int}},
subsystem_levels::AbstractVector{Int}
)
Embed the subspace_operator
into the provided subspaces
of a composite system, where the subsystem_indices
list the subspaces at which the operator is defined, and the subsystem_levels
list the levels of the subsystems in which the operator is embedded.
PiccoloQuantumObjects.EmbeddedOperators.EmbeddedOperator
— MethodEmbeddedOperator(
subspace_operator::AbstractMatrix{<:Number},
subsystem_indices::AbstractVector{Int},
subspaces::AbstractVector{<:AbstractVector{Int}},
composite_system::CompositeQuantumSystem
)
Embed the subspace_operator
into the provided subspaces
of a composite system.
PiccoloQuantumObjects.EmbeddedOperators.EmbeddedOperator
— MethodEmbeddedOperator(subspace_operator::Matrix{<:Number}, subspace::AbstractVector{Int}, subsystem_levels::AbstractVector{Int})
Create an embedded operator. The operator
is embedded at the subspace
of the system spanned by the subsystem_levels
.
PiccoloQuantumObjects.EmbeddedOperators.EmbeddedOperator
— MethodEmbeddedOperator(subspace_operator::AbstractMatrix{<:Number}, system::QuantumSystem; kwargs...)
Embed the subspace_operator
into a quantum system
.
PiccoloQuantumObjects.EmbeddedOperators.embed
— Methodembed(subspace_operator::AbstractMatrix{<:Number}, embedded_operator::EmbeddedOperator)
Embed the subspace_operator
in the subspace of a larger embedded_operator
.
PiccoloQuantumObjects.EmbeddedOperators.embed
— Methodembed(operator::AbstractMatrix{<:Number}, subspace::AbstractVector{Int}, levels::Int)
Embed an operator
in the subspace
of a larger matrix of size levels x levels
.
PiccoloQuantumObjects.EmbeddedOperators.get_enr_subspace_indices
— Methodget_enr_subspace_indices(excitation_restriction::Int, subsystem_levels::AbstractVector{Int})
Get the indices for the subspace of the quantum system with an excitation restriction.
PiccoloQuantumObjects.EmbeddedOperators.get_iso_vec_leakage_indices
— Functionget_iso_vec_leakage_indices(subspace::AbstractVector{Int}, levels::Int)
get_iso_vec_leakage_indices(subspaces::AbstractVector{<:AbstractVector{Int}}, subsystem_levels::AbstractVector{Int})
get_iso_vec_leakage_indices(subsystem_levels::AbstractVector{Int}; subspace=1:2)
get_iso_vec_leakage_indices(op::EmbeddedOperator)
Get the indices for the leakage in the isomorphic vector space for operators.
PiccoloQuantumObjects.EmbeddedOperators.get_iso_vec_subspace_indices
— Functionget_iso_vec_subspace_indices(subspace::AbstractVector{Int}, subsystem_levels::AbstractVector{Int})
get_iso_vec_subspace_indices(op::EmbeddedOperator)
Get the indices for the subspace in the isomorphic vector space for operators.
PiccoloQuantumObjects.EmbeddedOperators.get_leakage_indices
— Functionget_leakage_indices(subspace::AbstractVector{Int}, levels::Int)
get_leakage_indices(subspaces::AbstractVector{<:AbstractVector{Int}}, subsystem_levels::AbstractVector{Int})
get_leakage_indices(subsystem_levels::AbstractVector{Int}; subspace=1:2)
get_leakage_indices(op::EmbeddedOperator)
Get the indices for the states that are outside of the provided subspace of the quantum system.
PiccoloQuantumObjects.EmbeddedOperators.get_subspace_indices
— Functionget_subspace_indices(subspace::AbstractVector{Int}, levels::Int)
get_subspace_indices(subspaces::Vector{<:AbstractVector{Int}}, subsystem_levels::AbstractVector{Int})
get_subspace_indices(subsystem_levels::AbstractVector{Int}; subspace=1:2)
get_subspace_indices(op::EmbeddedOperator)
Get the indices for the provided subspace of the quantum system.
PiccoloQuantumObjects.EmbeddedOperators.unembed
— Methodunembed(matrix::AbstractMatrix{<:Number}, subspace::AbstractVector{Int})
Unembed a subspace operator from the matrix
. This is equivalent to calling matrix[subspace, subspace]
.
PiccoloQuantumObjects.EmbeddedOperators.unembed
— Methodunembed(op::AbstractMatrix, embedded_op::EmbeddedOperator)
Unembed a sub-matrix from the op
at the subspace defined by embedded_op
.
PiccoloQuantumObjects.EmbeddedOperators.unembed
— Methodunembed(embedded_op::EmbeddedOperator)::Matrix{ComplexF64}
Unembed an embedded operator, returning the original operator.
Isomorphisims
PiccoloQuantumObjects.Isomorphisms.G
— MethodG(H::AbstractMatrix)::Matrix{Float64}
Returns the isomorphism of $-iH$, i.e. $G(H) = \text{iso}(-iH)$.
See also Isomorphisms.iso
, Isomorphisms.H
.
PiccoloQuantumObjects.Isomorphisms.H
— MethodH(G::AbstractMatrix{<:Real})
Returns the inverse of $G(H) = iso(-iH)$, i.e. returns H.
See also Isomorphisms.iso
, Isomorphisms.G
.
PiccoloQuantumObjects.Isomorphisms.ad_vec
— Methodad_vec(H::AbstractMatrix{ℂ}; anti::Bool=false) where ℂ <: Number
Returns the vectorized adjoint action of a matrix H
:
\[\text{ad_vec}(H) = \mqty(1 & 0 \\ 0 & 1) \otimes H - (-1)^{\text{anti}} \mqty(0 & 1 \\ 1 & 0) \otimes H^*\]
PiccoloQuantumObjects.Isomorphisms.density_to_iso_vec
— Methoddensity_to_iso_vec(ρ::AbstractMatrix{<:Number})
Returns the isomorphism ρ⃗̃ = ket_to_iso(vec(ρ))
of a density matrix ρ
PiccoloQuantumObjects.Isomorphisms.iso
— Methodiso(H::AbstractMatrix{<:Number})
Returns the isomorphism of $H$:
\[iso(H) = \widetilde{H} = \mqty(1 & 0 \\ 0 & 1) \otimes \Re(H) + \mqty(0 & -1 \\ 1 & 0) \otimes \Im(H)\]
where $\Im(H)$ and $\Re(H)$ are the imaginary and real parts of $H$ and the tilde indicates the standard isomorphism of a complex valued matrix:
\[\widetilde{H} = \mqty(1 & 0 \\ 0 & 1) \otimes \Re(H) + \mqty(0 & -1 \\ 1 & 0) \otimes \Im(H)\]
See also Isomorphisms.G
, Isomorphisms.H
.
PiccoloQuantumObjects.Isomorphisms.iso_D
— Methodiso_D(L::AbstractMatrix{ℂ}) where ℂ <: Number
Returns the isomorphic representation of the Lindblad dissipator L
.
PiccoloQuantumObjects.Isomorphisms.iso_operator_to_iso_vec
— Methodiso_operator_to_iso_vec(Ũ::AbstractMatrix{ℝ}) where ℝ <: Real
Convert a real matrix Ũ
representing an isomorphism operator into a real vector.
PiccoloQuantumObjects.Isomorphisms.iso_operator_to_operator
— Methodiso_operator_to_operator(Ũ)
PiccoloQuantumObjects.Isomorphisms.iso_to_ket
— Methodiso_to_ket(ψ̃::AbstractVector{<:Real})
Convert a real isomorphism vector ψ̃
into a ket vector.
PiccoloQuantumObjects.Isomorphisms.iso_vec_to_density
— Methodiso_vec_to_density(ρ⃗̃::AbstractVector{<:Real})
Returns the density matrix ρ
from its isomorphism ρ⃗̃
PiccoloQuantumObjects.Isomorphisms.iso_vec_to_iso_operator
— Methodiso_vec_to_iso_operator(Ũ⃗::AbstractVector{ℝ}) where ℝ <: Real
Convert a real vector Ũ⃗
into a real matrix representing an isomorphism operator.
PiccoloQuantumObjects.Isomorphisms.iso_vec_to_operator
— Methodiso_vec_to_operator(Ũ⃗::AbstractVector{ℝ}) where ℝ <: Real
Convert a real vector Ũ⃗
into a complex matrix representing an operator.
PiccoloQuantumObjects.Isomorphisms.ket_to_iso
— Methodket_to_iso(ψ::AbstractVector{<:Number})
Convert a ket vector ψ
into a complex vector with real and imaginary parts.
PiccoloQuantumObjects.Isomorphisms.mat
— Methodmat(x::AbstractVector)
Convert a vector x
into a square matrix. The length of x
must be a perfect square.
PiccoloQuantumObjects.Isomorphisms.operator_to_iso_operator
— Methodoperator_to_iso_operator(U)
PiccoloQuantumObjects.Isomorphisms.operator_to_iso_vec
— Methodoperator_to_iso_vec(U::AbstractMatrix{ℂ}) where ℂ <: Number
Convert a complex matrix U
representing an operator into a real vector.
Quantum Object Utilities
PiccoloQuantumObjects.QuantumObjectUtils.annihilate
— Methodannihilate(levels::Int)
Get the annihilation operator for a system with levels
.
PiccoloQuantumObjects.QuantumObjectUtils.create
— Methodcreate(levels::Int)
Get the creation operator for a system with levels
.
PiccoloQuantumObjects.QuantumObjectUtils.haar_identity
— Methodhaar_identity(n::Int, radius::Number)
Generate a random unitary matrix close to the identity matrix using the Haar measure for an n
-dimensional system with a given radius
. The smaller the radius, the closer the matrix will be to the identity.
PiccoloQuantumObjects.QuantumObjectUtils.haar_random
— Methodhaar_random(n::Int)
Generate a random unitary matrix using the Haar measure for an n
-dimensional system.
PiccoloQuantumObjects.QuantumObjectUtils.ket_from_bitstring
— Methodket_from_bitstring(ket::String)
Get the state vector for a qubit system given a ket string ket
of 0s and 1s.
PiccoloQuantumObjects.QuantumObjectUtils.ket_from_string
— Methodket_from_string(
ket::String,
levels::Vector{Int};
level_dict=Dict(:g => 0, :e => 1, :f => 2, :h => 2),
return_states=false
)
Construct a quantum state from a string ket representation.
PiccoloQuantumObjects.QuantumObjectUtils.operator_from_string
— Methodoperator_from_string(operator::String; lookup=PAULIS)
Reduce the string (each character is one key) via operators from a dictionary.
Quantum System Utilities
PiccoloQuantumObjects.QuantumSystemUtils.is_reachable
— Methodis_reachable(gate::AbstractMatrix{<:Number}, system::AbstractQuantumSystem; kwargs...)
Check if the gate
is reachable using the given system
.
Keyword Arguments
use_drift::Bool=true
: include drift Hamiltonian in the generatorskwargs...
: keyword arguments foris_reachable
PiccoloQuantumObjects.QuantumSystemUtils.is_reachable
— Methodis_reachable(gate, hamiltonians; kwargs...)
Check if the gate
is reachable using the given hamiltonians
.
Arguments
gate::AbstractMatrix
: target gatehamiltonians::AbstractVector{<:AbstractMatrix}
: generators of the Lie algebra
Keyword Arguments
subspace::AbstractVector{<:Int}=1:size(gate, 1)
: subspace indicescompute_basis::Bool=true
: compute the basis or use the Hamiltonians directlyremove_trace::Bool=true
: remove trace from generatorsverbose::Bool=true
: print information about the operator algebraatol::Float32=eps(Float32)
: absolute tolerance
See also QuantumSystemUtils.operator_algebra
.
PiccoloQuantumObjects.QuantumSystemUtils.operator_algebra
— Methodoperator_algebra(generators; kwargs...)
Compute the Lie algebra basis for the given generators
.
Arguments
generators::Vector{<:AbstractMatrix}
: generators of the Lie algebra
Keyword Arguments
return_layers::Bool=false
: return the Lie tree layersnormalize::Bool=false
: normalize the basisverbose::Bool=false
: print informationremove_trace::Bool=true
: remove trace from generators