Skip to content

Commit 2db43e0

Browse files
Merge main into feature/ntbk_floquet
commit 7fd9e6e Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Wed May 7 17:39:52 2025 +0900 Reverted wget to qutip repo files commit fc1f200 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Wed Apr 16 11:03:52 2025 +0900 Prevent line break before version number commit 5fb9229 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Tue Apr 15 13:45:31 2025 +0900 Added container for centering, logo for nav bar commit 6acab30 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Tue Apr 15 11:05:56 2025 +0900 re-added liquid header commit d94dbc6 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Mon Apr 14 18:39:21 2025 +0900 Temporary worklfow change to trigger page build in fork commit fd16c0b Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Mon Apr 14 16:58:54 2025 +0900 Updated tutorial index html structure, temporary change of download links in workflow commit 6531566 Merge: b24e4ca cead2b9 Author: Paul <[email protected]> Date: Fri Apr 11 22:42:26 2025 +0900 Merge pull request qutip#124 from YousefElbrolosy/implement-grape-cnot-tutorial Migrate optimal control notebook to qutip-tutorials commit cead2b9 Author: YousefElbrolosy <[email protected]> Date: Fri Apr 11 14:45:40 2025 +0200 refactor: renamed tutorial commit 20cd146 Author: YousefElbrolosy <[email protected]> Date: Thu Apr 10 12:14:42 2025 +0200 chore: modified to conform with flake8 commit 967b3f7 Author: YousefElbrolosy <[email protected]> Date: Thu Apr 10 12:07:49 2025 +0200 chore: removed some comments and print statements commit 578b15e Author: YousefElbrolosy <[email protected]> Date: Thu Apr 10 12:04:33 2025 +0200 chore: replaced version_table with qt.about() commit 6585945 Author: YousefElbrolosy <[email protected]> Date: Thu Apr 10 12:04:00 2025 +0200 chore: used qutips own compute fidelity commit 89eca0c Author: YousefElbrolosy <[email protected]> Date: Thu Apr 10 12:01:08 2025 +0200 refactor: made U_f to correct dimnensions and returned U_t dimensions to original form commit 55ca193 Author: YousefElbrolosy <[email protected]> Date: Thu Apr 10 08:22:58 2025 +0200 chore: removed uniform_axes parameter in the plotting function commit f00617f Author: YousefElbrolosy <[email protected]> Date: Wed Apr 9 08:18:53 2025 +0200 chore: returned drift hamiltonian to be zero to be consistent with old notebook commit 5df7466 Author: YousefElbrolosy <[email protected]> Date: Wed Apr 9 08:14:13 2025 +0200 fix: remove redundant file commit f2139d6 Author: YousefElbrolosy <[email protected]> Date: Mon Apr 7 09:53:39 2025 +0200 chore: renamed folder to follow structure in pr qutip#122 commit 6c9e2e1 Author: YousefElbrolosy <[email protected]> Date: Mon Apr 7 09:51:33 2025 +0200 feat: formated the tutorial commit a098ec9 Author: YousefElbrolosy <[email protected]> Date: Mon Apr 7 09:40:05 2025 +0200 feat: added reference to original notebook commit 879db7b Author: YousefElbrolosy <[email protected]> Date: Thu Apr 3 17:59:04 2025 +0200 feat: implement new optimal control example commit b24e4ca Author: Rochisha Agarwal <[email protected]> Date: Fri Apr 11 14:57:43 2025 +0530 Fix links in optimal control overview (qutip#125) * fix links in optimal control * remove overview notebook to fix links for now commit 2be5a07 Author: Rochisha Agarwal <[email protected]> Date: Tue Apr 8 16:41:06 2025 +0530 Migrate and fix Optimal control tutorials from qutip-notebooks to qutip-tutorials (qutip#122) * migrate and fix opt-control tutorials * removed dependence on qutip-qip * change names * notebooks to markdown * change links commit a8b6a13 Author: Simon Cross <[email protected]> Date: Fri Apr 4 22:49:41 2025 +0200 Add ability to generate a notebook index for Try QuTiP. (qutip#90) * Fix grammar in version notes. * Replace prefix and suffix with Jinja escaping. * Factor out loading the list of tutorials. * Make url_prefix a class variable rather than an accidental global one. * Add notebook index template. * Replace HTML lists with Markdown lists. * Uppercase name of Notebook class. * Update create index to allow more control over what is indexed and where outpout is written. * Move raw after start of Markdown header. * Remove remaining HTML from notebook index. * Rename notebook index template to .notebook.jinja. * Fix typo in root folder reference, update name of notebook index template and add options to argparse parameter help. * Update HTML index creation to use new script. * Add option to generate Try QuTiP URLs. * Update order of arguments to create index. * Fix regular expression escape. * Fix list formatting. * Update try-qutip template to follow the hierarchy of the usual tutorial website. * Remove try-qutip URL hardcoding (jupyterlib seems happier with relative links now). commit 5e563a2 Merge: 0d87e07 a5df6a5 Author: Neill Lambert <[email protected]> Date: Mon Mar 3 11:22:36 2025 +0900 Merge pull request qutip#110 from Langhaarzombie/feature/ntbk_smesolve QuTiPv5 Paper Notebook: smesolve commit a5df6a5 Merge: 305e0da 0d87e07 Author: Maximilian MM <[email protected]> Date: Mon Feb 17 16:43:45 2025 +0900 Merge branch 'qutip:main' into feature/ntbk_smesolve commit 305e0da Merge: cd8b688 71ad984 Author: Neill Lambert <[email protected]> Date: Tue Dec 24 15:09:30 2024 +0900 Merge remote-tracking branch 'upstream/main' into feature/ntbk_smesolve commit cd8b688 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Mon Dec 9 14:39:01 2024 +0900 Added v5 paper ref commit 78a8cdc Author: Paul Menczel <[email protected]> Date: Mon Dec 2 14:13:59 2024 +0900 Typos commit b5c5a73 Merge: ceb2fe7 522e7b7 Author: Maximilian MM <[email protected]> Date: Wed Nov 27 11:57:28 2024 +0900 Merge branch 'qutip:main' into feature/ntbk_smesolve commit ceb2fe7 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Fri Nov 22 13:35:06 2024 +0900 Fixed Latex formatting issue with dagger commit 634993e Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Thu Nov 21 14:42:02 2024 +0900 Added reference to docs commit ade19b7 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Thu Nov 21 11:47:39 2024 +0900 Fixed test, faster computation, content fixes - added higher tolerance to test - improved simulation speed - added Neill :) commit b5d8cce Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Thu Nov 14 16:14:57 2024 +0900 Corrected typos, added tests commit c82e911 Author: Maximilian Meyer-Mölleringhof <[email protected]> Date: Fri Nov 8 17:11:51 2024 +0900 Added smesolve notebook according to paper - Added code used in the paper - Wrote a first draft of instructions
1 parent 936507f commit 2db43e0

16 files changed

+2094
-113
lines changed

.github/workflows/notebook_ci.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,26 @@ jobs:
133133
# Download resources from qutip.github.io repository
134134
mkdir css
135135
cd css
136-
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/css/bootstrap.css
137136
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/css/site.css
138137
cd ..
139138
140139
mkdir _includes
141140
cd _includes
142-
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/footer.html
143-
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/header.html
141+
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/head.html
144142
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/navbar.html
143+
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/footer.html
144+
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/scripts.html
145145
cd ..
146146
147147
mkdir images
148148
cd images
149149
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/images/favicon.ico
150+
wget https://raw.githubusercontent.com/langhaarzombie/langhaarzombie.github.io/develop/images/logo_small.png
150151
cd ..
151152
152153
# build the website
153-
python create_index.py
154+
python create_index.py v5 html index.html
155+
python create_index.py v4 html index-v4.html
154156
bundle config path .gems
155157
bundle install
156158
bundle exec jekyll build
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
---
2+
jupyter:
3+
jupytext:
4+
text_representation:
5+
extension: .md
6+
format_name: markdown
7+
format_version: '1.3'
8+
jupytext_version: 1.17.0
9+
kernelspec:
10+
display_name: qiskit-stable8
11+
language: python
12+
name: python3
13+
---
14+
15+
### GRAPE calculation of control fields for cnot implementation
16+
17+
[This is an updated implementation based on the deprecated notebook of GRAPE CNOT implementation by Robert Johansson](https://nbviewer.org/github/qutip/qutip-notebooks/blob/master/examples/control-grape-cnot.ipynb)
18+
19+
```python
20+
import matplotlib.pyplot as plt
21+
import numpy as np
22+
import qutip as qt
23+
# the library for quantum control
24+
import qutip_qtrl.pulseoptim as cpo
25+
```
26+
27+
```python
28+
# total duration
29+
T = 2 * np.pi
30+
# number of time steps
31+
times = np.linspace(0, T, 500)
32+
```
33+
34+
```python
35+
U_0 = qt.operators.identity(4)
36+
U_target = qt.core.gates.cnot()
37+
```
38+
39+
### Starting Point
40+
41+
```python
42+
U_0
43+
```
44+
45+
### Target Operator
46+
47+
```python
48+
U_target
49+
```
50+
51+
```python
52+
# Drift Hamiltonian
53+
g = 0
54+
H_drift = g * (
55+
qt.tensor(qt.sigmax(), qt.sigmax()) + qt.tensor(qt.sigmay(), qt.sigmay())
56+
)
57+
```
58+
59+
```python
60+
H_ctrl = [
61+
qt.tensor(qt.sigmax(), qt.identity(2)),
62+
qt.tensor(qt.sigmay(), qt.identity(2)),
63+
qt.tensor(qt.sigmaz(), qt.identity(2)),
64+
qt.tensor(qt.identity(2), qt.sigmax()),
65+
qt.tensor(qt.identity(2), qt.sigmay()),
66+
qt.tensor(qt.identity(2), qt.sigmaz()),
67+
qt.tensor(qt.sigmax(), qt.sigmax()),
68+
qt.tensor(qt.sigmay(), qt.sigmay()),
69+
qt.tensor(qt.sigmaz(), qt.sigmaz()),
70+
]
71+
```
72+
73+
```python
74+
H_labels = [
75+
r"$u_{1x}$",
76+
r"$u_{1y}$",
77+
r"$u_{1z}$",
78+
r"$u_{2x}$",
79+
r"$u_{2y}$",
80+
r"$u_{2z}$",
81+
r"$u_{xx}$",
82+
r"$u_{yy}$",
83+
r"$u_{zz}$",
84+
]
85+
```
86+
87+
## GRAPE
88+
89+
```python
90+
result = cpo.optimize_pulse_unitary(
91+
H_drift,
92+
H_ctrl,
93+
U_0,
94+
U_target,
95+
num_tslots=500,
96+
evo_time=(2 * np.pi),
97+
# this attribute is crucial for convergence!!
98+
amp_lbound=-(2 * np.pi * 0.05),
99+
amp_ubound=(2 * np.pi * 0.05),
100+
fid_err_targ=1e-9,
101+
max_iter=500,
102+
max_wall_time=60,
103+
alg="GRAPE",
104+
optim_method="FMIN_L_BFGS_B",
105+
method_params={
106+
"disp": True,
107+
"maxiter": 1000,
108+
},
109+
)
110+
```
111+
112+
```python
113+
for attr in dir(result):
114+
if not attr.startswith("_"):
115+
print(f"{attr}: {getattr(result, attr)}")
116+
117+
print(np.shape(result.final_amps))
118+
```
119+
120+
## Plot control fields for cnot gate in the presense of single-qubit tunnelling
121+
122+
```python
123+
def plot_control_amplitudes(times, final_amps, labels):
124+
num_controls = final_amps.shape[1]
125+
126+
y_max = 0.1 # Fixed y-axis scale
127+
y_min = -0.1
128+
129+
for i in range(num_controls):
130+
fig, ax = plt.subplots(figsize=(8, 3))
131+
132+
for j in range(num_controls):
133+
# Highlight the current control
134+
color = "black" if i == j else "gray"
135+
alpha = 1.0 if i == j else 0.1
136+
ax.plot(
137+
times,
138+
final_amps[:, j],
139+
label=labels[j],
140+
color=color,
141+
alpha=alpha
142+
)
143+
ax.set_title(f"Control Fields Highlighting: {labels[i]}")
144+
ax.set_xlabel("Time")
145+
ax.set_ylabel(labels[i])
146+
ax.set_ylim(y_min, y_max) # Set fixed y-axis limits
147+
ax.grid(True)
148+
ax.legend()
149+
plt.tight_layout()
150+
plt.show()
151+
152+
153+
plot_control_amplitudes(times, result.final_amps / (2 * np.pi), H_labels)
154+
```
155+
156+
## Fidelity/overlap
157+
158+
```python
159+
U_target
160+
```
161+
162+
```python
163+
U_f = result.evo_full_final
164+
U_f.dims = [[2, 2], [2, 2]]
165+
```
166+
167+
```python
168+
U_f
169+
```
170+
171+
```python
172+
print(f"Fidelity: {qt.process_fidelity(U_f, U_target)}")
173+
```
174+
175+
## Proceess tomography
176+
177+
178+
Quantum Process Tomography (QPT) is a technique used to characterize an unknown quantum operation by reconstructing its process matrix (also called the χ (chi) matrix). This matrix describes how an input quantum state is transformed by the operation.
179+
180+
181+
Defines the basis operators
182+
{
183+
𝐼
184+
,
185+
𝑋
186+
,
187+
𝑌
188+
,
189+
𝑍
190+
}
191+
for the two-qubit system.
192+
193+
These operators form a complete basis to describe any quantum operation in the Pauli basis.
194+
195+
196+
### Ideal cnot gate
197+
198+
```python
199+
op_basis = [[qt.qeye(2), qt.sigmax(), qt.sigmay(), qt.sigmaz()]] * 2
200+
op_label = [["i", "x", "y", "z"]] * 2
201+
```
202+
203+
U_target is the ideal CNOT gate.
204+
205+
qt.to_super(U_target) converts it into superoperator form, which is necessary for QPT.
206+
207+
qt.qpt(U_i_s, op_basis) computes the χ matrix for the ideal gate.
208+
209+
```python
210+
fig = plt.figure(figsize=(12, 6))
211+
212+
U_i_s = qt.to_super(U_target)
213+
214+
chi = qt.qpt(U_i_s, op_basis)
215+
216+
fig = qt.qpt_plot_combined(chi, op_label, fig=fig, threshold=0.001)
217+
```
218+
219+
```python
220+
op_basis = [[qt.qeye(2), qt.sigmax(), qt.sigmay(), qt.sigmaz()]] * 2
221+
op_label = [["i", "x", "y", "z"]] * 2
222+
```
223+
224+
```python
225+
fig = plt.figure(figsize=(12, 6))
226+
227+
U_f_s = qt.to_super(U_f)
228+
229+
chi = qt.qpt(U_f_s, op_basis)
230+
231+
fig = qt.qpt_plot_combined(chi, op_label, fig=fig, threshold=0.01)
232+
```
233+
234+
## Versions
235+
236+
237+
```python
238+
qt.about()
239+
```

0 commit comments

Comments
 (0)