|
| 1 | +""" |
| 2 | + ChargeBasis(ncut) <: Basis |
| 3 | +
|
| 4 | +Basis spanning `-ncut, ..., ncut` charge states, which are the fourier modes |
| 5 | +(irreducible representations) of a continuous U(1) degree of freedom, truncated |
| 6 | +at `ncut`. |
| 7 | +
|
| 8 | +The charge basis is a natural representation for circuit-QED elements such as |
| 9 | +the "transmon", which has a hamiltonian of the form |
| 10 | +```julia |
| 11 | +b = ChargeBasis(ncut) |
| 12 | +H = 4E_C * (n_g * identityoperator(b) + chargeop(b))^2 - E_J * cosφ(b) |
| 13 | +``` |
| 14 | +with energies periodic in the charge offset `n_g`. |
| 15 | +See e.g. https://arxiv.org/abs/2005.12667. |
| 16 | +""" |
| 17 | +struct ChargeBasis{T} <: Basis |
| 18 | + shape::Vector{T} |
| 19 | + dim::T |
| 20 | + ncut::T |
| 21 | + function ChargeBasis(ncut::T) where {T} |
| 22 | + if ncut < 0 |
| 23 | + throw(DimensionMismatch()) |
| 24 | + end |
| 25 | + dim = 2 * ncut + 1 |
| 26 | + new{T}([dim], dim, ncut) |
| 27 | + end |
| 28 | +end |
| 29 | + |
| 30 | +Base.:(==)(b1::ChargeBasis, b2::ChargeBasis) = (b1.ncut == b2.ncut) |
| 31 | + |
| 32 | +""" |
| 33 | + ShiftedChargeBasis(nmin, nmax) <: Basis |
| 34 | +
|
| 35 | +Basis spanning `nmin, ..., nmax` charge states. See [`ChargeBasis`](@ref). |
| 36 | +""" |
| 37 | +struct ShiftedChargeBasis{T} <: Basis |
| 38 | + shape::Vector{T} |
| 39 | + dim::T |
| 40 | + nmin::T |
| 41 | + nmax::T |
| 42 | + function ShiftedChargeBasis(nmin::T, nmax::T) where {T} |
| 43 | + if nmax <= nmin |
| 44 | + throw(DimensionMismatch()) |
| 45 | + end |
| 46 | + dim = nmax - nmin + 1 |
| 47 | + new{T}([dim], dim, nmin, nmax) |
| 48 | + end |
| 49 | +end |
| 50 | + |
| 51 | +Base.:(==)(b1::ShiftedChargeBasis, b2::ShiftedChargeBasis) = |
| 52 | + (b1.nmin == b2.nmin && b1.nmax == b2.nmax) |
| 53 | + |
| 54 | +""" |
| 55 | + chargestate([T=ComplexF64,] b::ChargeBasis, n) |
| 56 | + chargestate([T=ComplexF64,] b::ShiftedChargeBasis, n) |
| 57 | +
|
| 58 | +Charge state ``|n⟩`` for given [`ChargeBasis`](@ref) or [`ShiftedChargeBasis`](@ref). |
| 59 | +""" |
| 60 | +chargestate(::Type{T}, b::ChargeBasis, n::Integer) where {T} = |
| 61 | + basisstate(T, b, n + b.ncut + 1) |
| 62 | + |
| 63 | +chargestate(::Type{T}, b::ShiftedChargeBasis, n::Integer) where {T} = |
| 64 | + basisstate(T, b, n - b.nmin + 1) |
| 65 | + |
| 66 | +chargestate(b, n) = chargestate(ComplexF64, b, n) |
| 67 | + |
| 68 | +""" |
| 69 | + chargeop([T=ComplexF64,] b::ChargeBasis) |
| 70 | + chargeop([T=ComplexF64,] b::ShiftedChargeBasis) |
| 71 | +
|
| 72 | +Return diagonal charge operator ``N`` for given [`ChargeBasis`](@ref) or |
| 73 | +[`ShiftedChargeBasis`](@ref). |
| 74 | +""" |
| 75 | +function chargeop(::Type{T}, b::ChargeBasis) where {T} |
| 76 | + data = spdiagm(T.(-b.ncut:1:b.ncut)) |
| 77 | + return SparseOperator(b, b, data) |
| 78 | +end |
| 79 | + |
| 80 | +function chargeop(::Type{T}, b::ShiftedChargeBasis) where {T} |
| 81 | + data = spdiagm(T.(b.nmin:1:b.nmax)) |
| 82 | + return SparseOperator(b, b, data) |
| 83 | +end |
| 84 | + |
| 85 | +chargeop(b) = chargeop(ComplexF64, b) |
| 86 | + |
| 87 | +""" |
| 88 | + expiφ([T=ComplexF64,] b::ChargeBasis, k=1) |
| 89 | + expiφ([T=ComplexF64,] b::ShiftedChargeBasis, k=1) |
| 90 | +
|
| 91 | +Return operator ``\\exp(i k φ)`` for given [`ChargeBasis`](@ref) or |
| 92 | +[`ShiftedChargeBasis`](@ref), representing the continous U(1) degree of |
| 93 | +freedom conjugate to the charge. This is a "shift" operator that shifts |
| 94 | +the charge by `k`. |
| 95 | +""" |
| 96 | +function expiφ(::Type{T}, b::ChargeBasis; k=1) where {T} |
| 97 | + if abs(k) > 2 * b.ncut |
| 98 | + data = spzeros(T, b.dim, b.dim) |
| 99 | + else |
| 100 | + v = ones(T, b.dim - abs(k)) |
| 101 | + data = spdiagm(-k => v) |
| 102 | + end |
| 103 | + return SparseOperator(b, b, data) |
| 104 | +end |
| 105 | + |
| 106 | +function expiφ(::Type{T}, b::ShiftedChargeBasis; k=1) where {T} |
| 107 | + if abs(k) > b.dim - 1 |
| 108 | + data = spzeros(T, b.dim, b.dim) |
| 109 | + else |
| 110 | + v = ones(T, b.dim - abs(k)) |
| 111 | + data = spdiagm(-k => v) |
| 112 | + end |
| 113 | + return SparseOperator(b, b, data) |
| 114 | +end |
| 115 | + |
| 116 | +expiφ(b; kwargs...) = expiφ(ComplexF64, b; kwargs...) |
| 117 | + |
| 118 | +""" |
| 119 | + cosφ([T=ComplexF64,] b::ChargeBasis; k=1) |
| 120 | + cosφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1) |
| 121 | +
|
| 122 | +Return operator ``\\cos(k φ)`` for given charge basis. See [`expiφ`](@ref). |
| 123 | +""" |
| 124 | +function cosφ(::Type{T}, b::Union{ChargeBasis,ShiftedChargeBasis}; k=1) where {T} |
| 125 | + d = expiφ(b; k=k) |
| 126 | + return (d + d') / 2 |
| 127 | +end |
| 128 | + |
| 129 | +cosφ(b; kwargs...) = cosφ(ComplexF64, b; kwargs...) |
| 130 | + |
| 131 | +""" |
| 132 | + sinφ([T=ComplexF64,] b::ChargeBasis; k=1) |
| 133 | + sinφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1) |
| 134 | +
|
| 135 | +Return operator ``\\sin(k φ)`` for given charge basis. See [`expiφ`](@ref). |
| 136 | +""" |
| 137 | +function sinφ(::Type{T}, b::Union{ChargeBasis,ShiftedChargeBasis}; k=1) where {T} |
| 138 | + d = expiφ(b; k=k) |
| 139 | + return (d - d') / 2im |
| 140 | +end |
| 141 | + |
| 142 | +sinφ(b; kwargs...) = sinφ(ComplexF64, b; kwargs...) |
0 commit comments