Skip to content

Commit bb7ecec

Browse files
authored
Merge pull request #210 from harmoniqs/fix/docs-examples
Docs fixes (part 3): fixing inconsistent minimum time problem solver runs via a) bounding state variables and b) verifying fidelity is sufficiently close to unity
2 parents 6a7cc95 + 869c02d commit bb7ecec

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

docs/literate/examples/two_qubit_gates.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ prob = UnitarySmoothPulseProblem(
101101
R_da=0.01,
102102
R_dda=0.01,
103103
Δt_max=Δt_max,
104-
piccolo_options=PiccoloOptions()
104+
piccolo_options=PiccoloOptions(bound_state=true),
105105
)
106106
fid_init = unitary_rollout_fidelity(prob.trajectory, sys)
107107
println(fid_init)
@@ -112,6 +112,7 @@ solve!(prob; max_iter=100)
112112
## Let's take a look at the final fidelity
113113
fid_final = unitary_rollout_fidelity(prob.trajectory, sys)
114114
println(fid_final)
115+
@assert fid_final > 0.99
115116

116117
# Looks good!
117118

@@ -120,10 +121,11 @@ plot_unitary_populations(prob.trajectory)
120121

121122

122123
# For fun, let's look at a minimum time pulse for this problem
123-
min_time_prob = UnitaryMinimumTimeProblem(prob, U_goal; final_fidelity=.99)
124+
min_time_prob = UnitaryMinimumTimeProblem(prob, U_goal; final_fidelity=.995)
124125
solve!(min_time_prob; max_iter=300)
125126
fid_final_min_time = unitary_rollout_fidelity(min_time_prob.trajectory, sys)
126127
println(fid_final_min_time)
128+
@assert fid_final_min_time > 0.99
127129

128130
# And let's plot this solution
129131
plot_unitary_populations(min_time_prob.trajectory)
@@ -170,7 +172,7 @@ prob = UnitarySmoothPulseProblem(
170172
R_da=0.01,
171173
R_dda=0.01,
172174
Δt_max=Δt_max,
173-
piccolo_options=PiccoloOptions()
175+
piccolo_options=PiccoloOptions(bound_state=true),
174176
)
175177
fid_init = unitary_rollout_fidelity(prob.trajectory, sys)
176178
println(fid_init)
@@ -180,6 +182,7 @@ solve!(prob; max_iter=100)
180182
## Let's take a look at the final fidelity
181183
fid_final = unitary_rollout_fidelity(prob.trajectory, sys)
182184
println(fid_final)
185+
@assert fid_final > 0.999
183186

184187
# Again, looks good!
185188

@@ -188,10 +191,11 @@ plot_unitary_populations(prob.trajectory)
188191

189192
# For fun, let's look at a minimum time pulse for this problem
190193

191-
min_time_prob = UnitaryMinimumTimeProblem(prob, U_goal; final_fidelity=.999)
194+
min_time_prob = UnitaryMinimumTimeProblem(prob, U_goal; final_fidelity=.9995)
192195
solve!(min_time_prob; max_iter=300)
193196
fid_final_min_time = unitary_rollout_fidelity(min_time_prob.trajectory, sys)
194197
println(fid_final_min_time)
198+
@assert fid_final_min_time > 0.999
195199

196200
# And let's plot this solution
197201
plot_unitary_populations(min_time_prob.trajectory)

0 commit comments

Comments
 (0)