kestrelquantum / QuantumCollocation.jl

Quantum Optimal Control with Direct Collocation
MIT License
29 stars 7 forks source link

Subspace utility for excitation-number-restricted spaces #58

Closed andgoldschmidt closed 6 months ago

andgoldschmidt commented 10 months ago

Is your feature request related to a problem? Please describe. The current subspaces are defined for guard levels. There is also the case of excitation number restrictions, which limits the total excitation count to a specific amount.

Describe the solution you'd like An enr_subspace_indices function.

andgoldschmidt commented 6 months ago

This is the fragment to add to quantum_utils.jl:

basis_labels(levels::AbstractVector{Int}; baseline=1) =
    kron([""], [string.(baseline:level - 1 + baseline) for level ∈ levels]...)

function enr_subspace_indices(excitation_number::Int, levels::AbstractVector{Int})
    # excitation_number uses baseline of zero
    return findall(
        b -> sum([parse(Int, bᵢ) for bᵢ ∈ b]) ≤ excitation_restriction,
        basis_labels(levels, baseline=0)
    )
end

Where we also rewrite the existing subspace calls to use the basis_labels function shown here.