Skip to content

Commit

Permalink
Added analytic rabi oscillation
Browse files Browse the repository at this point in the history
  • Loading branch information
leespen1 committed Mar 27, 2024
1 parent a835633 commit 86bdd16
Showing 1 changed file with 51 additions and 7 deletions.
58 changes: 51 additions & 7 deletions examples/Proposal/parameter_tuning_example.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

using QuantumGateDesign
using LinearAlgebra
using Plots
# Single qubit in the rotating frame
system_sym = zeros(2,2)
system_sym[1,1] = 0.84
system_sym[2,2] = 1.78
# These entries make the problem more challenging (more like lab frame)
#system_sym[1,1] = 0.84
#system_sym[2,2] = 1.78
system_asym = zeros(2,2)

a = [0.0 1; 0 0]
Expand All @@ -15,7 +17,7 @@ u0 = [1.0 0; 0 1]
v0 = [0.0 0; 0 0]

tf = 3.5 # Change this
nsteps = 500
nsteps = 100
N_ess_levels = 2

prob = SchrodingerProb(
Expand All @@ -39,13 +41,55 @@ target = [0.0 1.0

control = QuantumGateDesign.GRAPEControl(1, prob.tf+0.1) # For now, it doesn't matter since amplitudes last for whole duration

N_samples = 31
N_samples = 11
var_range = LinRange(-2, 2, N_samples)
var1s = zeros(N_samples, N_samples)
var2s = zeros(N_samples, N_samples)
infidelities = zeros(N_samples, N_samples)

for (j, var1) in enumerate(var_range)
println("j=", j)
for (k, var2) in enumerate(var_range)
pcof = [var1, var2]
infidelities[j,k] = infidelity(prob, control, pcof, target, order=4)
#infidelities[j,k] = 1
end
end


pl = heatmap(var_range, var_range, infidelities, color=:thermal,
pl1 = heatmap(var_range, var_range, infidelities, color=:thermal,
xlabel="θ₁", ylabel="θ₂", colorbar_title="Infidelity")

"""
Analytic result for rabi oscillation in rotating frame
(assuming control is constant, could asl)
"""
function analytic_infidelity(complex_Ω, T)
Ω = abs(complex_Ω)
θ = angle(complex_Ω)

U_evo = [cos*T) (sin(θ)-im*cos(θ))*sin*T)
-(sin(θ)+im*cos(θ))*sin*T) cos*T)]

U_init = [1 0; 0 1]
U_final = U_evo*U_init
U_targ = [0 1; 1 0]

this_infidelity = 1 - 0.25*abs( dot(U_final, U_targ) )^2

return this_infidelity
end

analytic_N_samples = 20001
analytic_var_range = LinRange(-2,2,analytic_N_samples)
analytic_infidelities = zeros(analytic_N_samples, analytic_N_samples)

for (j, var1) in enumerate(analytic_var_range)
println("j=", j)
for (k, var2) in enumerate(analytic_var_range)
complex_Ω = var1+im*var2
analytic_infidelities[j,k] = analytic_infidelity(complex_Ω, prob.tf)
#infidelities[j,k] = 1
end
end

pl2 = heatmap(analytic_var_range, analytic_var_range, analytic_infidelities, color=:thermal,
xlabel="Re(Ω)", ylabel="Im(Ω)", colorbar_title="Infidelity")

0 comments on commit 86bdd16

Please sign in to comment.