-
Notifications
You must be signed in to change notification settings - Fork 0
/
perfect_entanglers.jl
203 lines (170 loc) · 5.8 KB
/
perfect_entanglers.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,jl:light
# text_representation:
# extension: .jl
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.11.3
# kernelspec:
# display_name: Julia 1.8 (auto threads)
# language: julia
# name: julia-1.8-multithread
# ---
# # Example: Gate Concurrence Optimization
# $
# \newcommand{tr}[0]{\operatorname{tr}}
# \newcommand{diag}[0]{\operatorname{diag}}
# \newcommand{abs}[0]{\operatorname{abs}}
# \newcommand{pop}[0]{\operatorname{pop}}
# \newcommand{aux}[0]{\text{aux}}
# \newcommand{opt}[0]{\text{opt}}
# \newcommand{tgt}[0]{\text{tgt}}
# \newcommand{init}[0]{\text{init}}
# \newcommand{lab}[0]{\text{lab}}
# \newcommand{rwa}[0]{\text{rwa}}
# \newcommand{bra}[1]{\langle#1\vert}
# \newcommand{ket}[1]{\vert#1\rangle}
# \newcommand{Bra}[1]{\left\langle#1\right\vert}
# \newcommand{Ket}[1]{\left\vert#1\right\rangle}
# \newcommand{Braket}[2]{\left\langle #1\vphantom{#2}\mid{#2}\vphantom{#1}\right\rangle}
# \newcommand{op}[1]{\hat{#1}}
# \newcommand{Op}[1]{\hat{#1}}
# \newcommand{dd}[0]{\,\text{d}}
# \newcommand{Liouville}[0]{\mathcal{L}}
# \newcommand{DynMap}[0]{\mathcal{E}}
# \newcommand{identity}[0]{\mathbf{1}}
# \newcommand{Norm}[1]{\lVert#1\rVert}
# \newcommand{Abs}[1]{\left\vert#1\right\vert}
# \newcommand{avg}[1]{\langle#1\rangle}
# \newcommand{Avg}[1]{\left\langle#1\right\rangle}
# \newcommand{AbsSq}[1]{\left\vert#1\right\vert^2}
# \newcommand{Re}[0]{\operatorname{Re}}
# \newcommand{Im}[0]{\operatorname{Im}}
# $
using LinearAlgebra
using SparseArrays
using QuantumControl
using QuantumControl.Functionals: gate_functional, make_gate_chi
using QuantumControl.Amplitudes: ShapedAmplitude
using QuantumControl.Shapes: flattop
using TwoQubitWeylChamber: D_PE, gate_concurrence, unitarity
⊗ = kron;
const 𝕚 = 1im;
const N = 6; # levels per transmon
# +
function ket(i::Int64; N=N)
Ψ = zeros(ComplexF64, N)
Ψ[i+1] = 1
return Ψ
end
function ket(indices::Int64...; N=N)
Ψ = ket(indices[1]; N=N)
for i in indices[2:end]
Ψ = Ψ ⊗ ket(i; N=N)
end
return Ψ
end
function ket(label::AbstractString; N=N)
indices = [parse(Int64, digit) for digit in label]
return ket(indices...; N=N)
end;
# +
using Plots
Plots.default(
linewidth = 3,
size = (550, 300),
legend = :right,
foreground_color_legend = nothing,
background_color_legend = RGBA(1, 1, 1, 0.8),
)
using QuantumControl.Controls: discretize
function plot_complex_pulse(tlist, Ω; time_unit=:ns, ampl_unit=:MHz, kwargs...)
Ω = discretize(Ω, tlist) # make sure Ω is defined on *points* of `tlist`
ax1 = plot(
tlist ./ eval(time_unit),
abs.(Ω) ./ eval(ampl_unit);
label="|Ω|",
xlabel="time ($time_unit)",
ylabel="amplitude ($ampl_unit)",
kwargs...
)
ax2 = plot(
tlist ./ eval(time_unit),
angle.(Ω) ./ π;
label="ϕ(Ω)",
xlabel="time ($time_unit)",
ylabel="phase (π)"
)
plot(ax1, ax2, layout=(2, 1))
end;
# -
# ## Hamiltonian and guess pulses
# We will write the Hamiltonian in units of GHz (angular frequency; the factor
# 2π is implicit) and ns:
const GHz = 2π
const MHz = 0.001GHz
const ns = 1.0
const μs = 1000ns;
# The Hamiltonian and parameters are taken from
# [Goerz *et al.*, Phys. Rev. A 91, 062307 (2015); Table 1](https://michaelgoerz.net/#GoerzPRA2015).
# +
function guess_amplitudes(; T=400ns, E₀=35MHz, dt=0.1ns, t_rise=15ns)
tlist = collect(range(0, T, step=dt))
shape(t) = flattop(t, T=T, t_rise=t_rise)
Ωre = ShapedAmplitude(t -> E₀, tlist; shape)
Ωim = ShapedAmplitude(t -> 0.0, tlist; shape)
return tlist, Ωre, Ωim
end
tlist, Ωre_guess, Ωim_guess = guess_amplitudes();
# -
function transmon_hamiltonian(;
Ωre, Ωim, N=N, ω₁=4.380GHz, ω₂=4.614GHz, ωd=4.498GHz, α₁=-210MHz,
α₂=-215MHz, J=-3MHz, λ=1.03,
)
𝟙 = SparseMatrixCSC{ComplexF64,Int64}(sparse(I, N, N))
b̂₁ = spdiagm(1 => complex.(sqrt.(collect(1:N-1)))) ⊗ 𝟙
b̂₂ = 𝟙 ⊗ spdiagm(1 => complex.(sqrt.(collect(1:N-1))))
b̂₁⁺ = sparse(b̂₁'); b̂₂⁺ = sparse(b̂₂')
n̂₁ = sparse(b̂₁' * b̂₁); n̂₂ = sparse(b̂₂' * b̂₂)
n̂₁² = sparse(n̂₁ * n̂₁); n̂₂² = sparse(n̂₂ * n̂₂)
b̂₁⁺_b̂₂ = sparse(b̂₁' * b̂₂); b̂₁_b̂₂⁺ = sparse(b̂₁ * b̂₂')
ω̃₁ = ω₁ - ωd; ω̃₂ = ω₂ - ωd
Ĥ₀ = sparse(
(ω̃₁ - α₁ / 2) * n̂₁ +
(α₁ / 2) * n̂₁² +
(ω̃₂ - α₂ / 2) * n̂₂ +
(α₂ / 2) * n̂₂² +
J * (b̂₁⁺_b̂₂ + b̂₁_b̂₂⁺)
)
Ĥ₁re = sparse((1 / 2) * (b̂₁ + b̂₁⁺ + λ * b̂₂ + λ * b̂₂⁺))
Ĥ₁im = sparse((𝕚 / 2) * (b̂₁⁺ - b̂₁ + λ * b̂₂⁺ - λ * b̂₂))
return hamiltonian(Ĥ₀, (Ĥ₁re, Ωre), (Ĥ₁im, Ωim))
end;
H = transmon_hamiltonian(Ωre=Ωre_guess, Ωim=Ωim_guess);
# ## Maximization of Gate Concurrence
J_T_C = U -> 0.5 * (1 - gate_concurrence(U)) + 0.5 * (1 - unitarity(U));
basis = [ket("00"), ket("01"), ket("10"), ket("11")];
objectives = [Objective(; initial_state=Ψ, generator=H) for Ψ ∈ basis];
problem = ControlProblem(
objectives=objectives,
tlist=tlist,
iter_stop=100,
J_T=gate_functional(J_T_C),
chi=make_gate_chi(J_T_C, objectives),
check_convergence=res -> begin
(
(res.J_T <= 1e-3) &&
(res.converged = true) &&
(res.message = "Found a perfect entangler")
)
end,
use_threads=true,
);
res = optimize(problem; method=:GRAPE)
# +
ϵ_opt = res.optimized_controls[1] + 𝕚 * res.optimized_controls[2]
Ω_opt = ϵ_opt .* discretize(Ωre_guess.shape, tlist)
plot_complex_pulse(tlist, Ω_opt)