Skip to content

Commit f76a9f9

Browse files
committed
Doc
1 parent 7e661ab commit f76a9f9

File tree

1 file changed

+72
-4
lines changed

1 file changed

+72
-4
lines changed

doc/source/examples/advanced_concatenation.ipynb

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@
239239
" for i in range(3):\n",
240240
" for j in range(3):\n",
241241
" t = ax[i, j].get_title()[7:]\n",
242-
" ax[i, j].set_title('$F^{(' + pulses[i] + pulses[j] + t)"
242+
" ax[i, j].set_title('$F^{(' + pulses[i] + pulses[j] + t)\n",
243+
" fig.suptitle(f'{gate_type} gates')\n",
244+
" fig.tight_layout()"
243245
]
244246
},
245247
{
@@ -254,12 +256,78 @@
254256
"\n",
255257
"While the imaginary part cancels out when calculating fidelities, $\\mathcal{I}\\propto\\sum_{ij} \\int\\mathrm{d}\\omega S(\\omega)F^{(ij)}(\\omega)$, the real part does not and the offdiagonals therefore lead to corrections in the total fidelity of a composite pulse, $\\mathcal{I}_\\text{tot}\\neq\\sum_g\\mathcal{I}^{(g)}$ with $\\mathcal{I}^{(g)}$ the infidelities of the individual pulses. These corrections can thus in principle also be negative, leading to improved fidelities for composite pulses."
256258
]
259+
},
260+
{
261+
"cell_type": "markdown",
262+
"metadata": {},
263+
"source": [
264+
"## Second-order filter functions\n",
265+
"We can also compute the second-order filter function as the concatenation of individual pulses. Although the calculation is not completely independent of the internal dynamics of the individual pulses as in the first-order case due to the nested time integral, a significant chunk can still be obtained from previously computed quantities. \n",
266+
"\n",
267+
"To do this, we need to make sure that some intermediate results are cached when computing the first- and second-order filter functions of the individual pulses, setting the `cache_intermediates` flag. We then just set the `calc_second_order_FF` argument to `True`."
268+
]
269+
},
270+
{
271+
"cell_type": "code",
272+
"execution_count": null,
273+
"metadata": {},
274+
"outputs": [],
275+
"source": [
276+
"# Clean up from before to have a clean slate for demonstration purposes\n",
277+
"from itertools import chain\n",
278+
"for key, pulse in chain(X2.items(), Y2.items()):\n",
279+
" pulse.cleanup('frequency dependent')\n",
280+
" pulse.cache_filter_function(omega[key], cache_intermediates=True,\n",
281+
" order=1)\n",
282+
" pulse.cache_filter_function(omega[key], cache_intermediates=True,\n",
283+
" order=2)\n",
284+
"\n",
285+
"H = {key: ff.concatenate((Y2, X2, X2), calc_second_order_FF=True, which='generalized')\n",
286+
" for (key, X2), (key, Y2) in zip(X2.items(), Y2.items())}"
287+
]
288+
},
289+
{
290+
"cell_type": "markdown",
291+
"metadata": {},
292+
"source": [
293+
"Visualize the FFs:"
294+
]
295+
},
296+
{
297+
"cell_type": "code",
298+
"execution_count": null,
299+
"metadata": {},
300+
"outputs": [],
301+
"source": [
302+
"for key, pulse in H.items():\n",
303+
" fig, axes = plt.subplots(3, 3, sharex=True, sharey=False,\n",
304+
" figsize=(9, 6))\n",
305+
" for i in range(1, 4):\n",
306+
" for j in range(1, 4):\n",
307+
" FF1 = pulse.get_filter_function(omega[key], order=1,\n",
308+
" which='generalized')\n",
309+
" FF2 = pulse.get_filter_function(omega[key], order=2,\n",
310+
" which='generalized')\n",
311+
" axes[i-1, j-1].semilogx(omega[key], FF1[0,0,i,j].real,\n",
312+
" color='tab:blue', ls='-')\n",
313+
" axes[i-1, j-1].semilogx(omega[key], FF1[0,0,i,j].imag,\n",
314+
" color='tab:blue', ls='--')\n",
315+
" axes[i-1, j-1].semilogx(omega[key], FF2[0,0,i,j].real,\n",
316+
" color='tab:orange', ls='-')\n",
317+
" axes[i-1, j-1].semilogx(omega[key], FF2[0,0,i,j].imag,\n",
318+
" color='tab:orange', ls='--')\n",
319+
" axes[i-1, j-1].margins(x=0)\n",
320+
" fig.suptitle(f'{key} gates')\n",
321+
" fig.supxlabel(r'$\\omega$')\n",
322+
" fig.supylabel(r'$\\mathcal{F}(\\omega)$')\n",
323+
" fig.tight_layout()"
324+
]
257325
}
258326
],
259327
"metadata": {
260328
"kernelspec": {
261-
"display_name": "Python 3 (Spyder)",
262-
"language": "python3",
329+
"display_name": "Python 3 (ipykernel)",
330+
"language": "python",
263331
"name": "python3"
264332
},
265333
"language_info": {
@@ -272,7 +340,7 @@
272340
"name": "python",
273341
"nbconvert_exporter": "python",
274342
"pygments_lexer": "ipython3",
275-
"version": "3.12.3"
343+
"version": "3.13.5"
276344
},
277345
"widgets": {
278346
"application/vnd.jupyter.widget-state+json": {

0 commit comments

Comments
 (0)