{
"cells": [
{
"cell_type": "markdown",
"id": "e8596ea3",
"metadata": {},
"source": [
"# 4.05 New LOM and Two Coupled Transmon Example with sequence"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9a97f615-d5a9-4167-a19a-99d1cfda80ae",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"import numpy as np\n",
"\n",
"from qiskit_metal.analyses.quantization.lumped_capacitive import (\n",
" load_q3d_capacitance_matrix,\n",
")\n",
"from qiskit_metal.analyses.quantization.lom_core_analysis import (\n",
" CompositeSystem,\n",
" Cell,\n",
" Subsystem,\n",
")\n",
"\n",
"from scipy.constants import speed_of_light as c_light\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"id": "a2a49da4",
"metadata": {},
"source": [
"> 💡 **Using this tutorial without the Qt GUI**\n",
"> \n",
"> This tutorial uses the desktop `MetalGUI`. To follow along on Colab, Binder, JupyterHub, or any environment where Qt isn't available, **replace any `gui.rebuild()` / `gui.screenshot()` call with `qm.view(design)`** — it renders the design to a matplotlib `Figure` you can display inline or save with `fig.savefig(...)`.\n",
"> \n",
"> See [1.4 Headless quick view](../1-Overview/1.4-Headless-quick-view-%28no-Qt-GUI%29.ipynb) for a complete runnable walkthrough and [`docs/headless-usage.rst`](../../../docs/headless-usage.rst) for the full reference."
]
},
{
"cell_type": "markdown",
"id": "32717ec8-f907-4902-bc2c-f5a17a7516bc",
"metadata": {},
"source": [
"## Example: two transmons coupled by a direct coupler\n",
"this part is identical to tutorial 4.05; please reference it for more detailed comments"
]
},
{
"cell_type": "markdown",
"id": "772a4f4a-0881-499f-a370-3e69494a817a",
"metadata": {},
"source": [
"### load transmon cell Q3d simulation results"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "b4b1be2d-19f7-410d-a0ca-ed273907a630",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Imported capacitance matrix with UNITS: [fF] now converted to USER UNITS:[fF] from file:\n",
"\t./Q1_TwoTransmon_CapMatrix.txt\n"
]
},
{
"data": {
"text/html": [
"\n",
"
\n",
" \n",
" \n",
" | | \n",
" coupler_connector_pad_Q1 | \n",
" ground_main_plane | \n",
" pad_bot_Q1 | \n",
" pad_top_Q1 | \n",
" readout_connector_pad_Q1 | \n",
"
\n",
" \n",
" \n",
" \n",
" | coupler_connector_pad_Q1 | \n",
" 59.20 | \n",
" -37.28 | \n",
" -2.01 | \n",
" -19.11 | \n",
" -0.23 | \n",
"
\n",
" \n",
" | ground_main_plane | \n",
" -37.28 | \n",
" 246.33 | \n",
" -39.79 | \n",
" -39.86 | \n",
" -37.30 | \n",
"
\n",
" \n",
" | pad_bot_Q1 | \n",
" -2.01 | \n",
" -39.79 | \n",
" 93.05 | \n",
" -30.61 | \n",
" -19.22 | \n",
"
\n",
" \n",
" | pad_top_Q1 | \n",
" -19.11 | \n",
" -39.86 | \n",
" -30.61 | \n",
" 92.99 | \n",
" -2.01 | \n",
"
\n",
" \n",
" | readout_connector_pad_Q1 | \n",
" -0.23 | \n",
" -37.30 | \n",
" -19.22 | \n",
" -2.01 | \n",
" 59.33 | \n",
"
\n",
" \n",
"
\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"path1 = \"./Q1_TwoTransmon_CapMatrix.txt\"\n",
"ta_mat, _, _, _ = load_q3d_capacitance_matrix(path1)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "4256eb88-ef19-4bbb-a5d3-b9cb8c0e968e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Imported capacitance matrix with UNITS: [fF] now converted to USER UNITS:[fF] from file:\n",
"\t./Q2_TwoTransmon_CapMatrix.txt\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
" \n",
" \n",
" | | \n",
" coupler_connector_pad_Q2 | \n",
" ground_main_plane | \n",
" pad_bot_Q2 | \n",
" pad_top_Q2 | \n",
" readout_connector_pad_Q2 | \n",
"
\n",
" \n",
" \n",
" \n",
" | coupler_connector_pad_Q2 | \n",
" 64.52 | \n",
" -38.63 | \n",
" -2.18 | \n",
" -22.93 | \n",
" -0.22 | \n",
"
\n",
" \n",
" | ground_main_plane | \n",
" -38.63 | \n",
" 267.40 | \n",
" -49.28 | \n",
" -49.30 | \n",
" -38.67 | \n",
"
\n",
" \n",
" | pad_bot_Q2 | \n",
" -2.18 | \n",
" -49.28 | \n",
" 121.38 | \n",
" -45.24 | \n",
" -23.06 | \n",
"
\n",
" \n",
" | pad_top_Q2 | \n",
" -22.93 | \n",
" -49.30 | \n",
" -45.24 | \n",
" 121.24 | \n",
" -2.18 | \n",
"
\n",
" \n",
" | readout_connector_pad_Q2 | \n",
" -0.22 | \n",
" -38.67 | \n",
" -23.06 | \n",
" -2.18 | \n",
" 64.70 | \n",
"
\n",
" \n",
"
\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"path2 = \"./Q2_TwoTransmon_CapMatrix.txt\"\n",
"tb_mat, _, _, _ = load_q3d_capacitance_matrix(path2)"
]
},
{
"cell_type": "markdown",
"id": "4ed9aaaf-2b6d-4371-a853-0a2f22e2b421",
"metadata": {},
"source": [
"### Create LOM cells from capacitance matrices"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "c1fd4755-9160-4895-b722-23ba6eaa8eb3",
"metadata": {},
"outputs": [],
"source": [
"# cell 1: transmon Alice cell\n",
"\n",
"opt1 = dict(\n",
" node_rename={\n",
" \"coupler_connector_pad_Q1\": \"coupling\",\n",
" \"readout_connector_pad_Q1\": \"readout_alice\",\n",
" },\n",
" cap_mat=ta_mat,\n",
" ind_dict={(\"pad_top_Q1\", \"pad_bot_Q1\"): 10}, # junction inductance in nH\n",
" jj_dict={(\"pad_top_Q1\", \"pad_bot_Q1\"): \"j1\"},\n",
" cj_dict={(\"pad_top_Q1\", \"pad_bot_Q1\"): 2}, # junction capacitance in fF\n",
")\n",
"cell_1 = Cell(opt1)\n",
"\n",
"\n",
"# cell 2: transmon Bob cell\n",
"opt2 = dict(\n",
" node_rename={\n",
" \"coupler_connector_pad_Q2\": \"coupling\",\n",
" \"readout_connector_pad_Q2\": \"readout_bob\",\n",
" },\n",
" cap_mat=tb_mat,\n",
" ind_dict={(\"pad_top_Q2\", \"pad_bot_Q2\"): 12}, # junction inductance in nH\n",
" jj_dict={(\"pad_top_Q2\", \"pad_bot_Q2\"): \"j2\"},\n",
" cj_dict={(\"pad_top_Q2\", \"pad_bot_Q2\"): 2}, # junction capacitance in fF\n",
")\n",
"cell_2 = Cell(opt2)"
]
},
{
"cell_type": "markdown",
"id": "4ceffcfc-6cc1-444e-9a92-2fe022b2385a",
"metadata": {},
"source": [
"### Make subsystems"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b2ec34e2-3a7e-4946-88c2-e497fc8d5836",
"metadata": {},
"outputs": [],
"source": [
"# subsystem 1: transmon Alice\n",
"transmon_alice = Subsystem(name=\"transmon_alice\", sys_type=\"TRANSMON\", nodes=[\"j1\"])\n",
"\n",
"\n",
"# subsystem 2: transmon Bob\n",
"transmon_bob = Subsystem(name=\"transmon_bob\", sys_type=\"TRANSMON\", nodes=[\"j2\"])\n",
"\n",
"\n",
"# subsystem 3: Alice readout resonator\n",
"q_opts = dict(\n",
" f_res=8, # resonator dressed frequency in GHz\n",
" Z0=50, # characteristic impedance in Ohm\n",
" vp=0.404314 * c_light, # phase velocity\n",
")\n",
"res_alice = Subsystem(\n",
" name=\"readout_alice\",\n",
" sys_type=\"TL_RESONATOR\",\n",
" nodes=[\"readout_alice\"],\n",
" q_opts=q_opts,\n",
")\n",
"\n",
"\n",
"# subsystem 4: Bob readout resonator\n",
"q_opts = dict(\n",
" f_res=7.6, # resonator dressed frequency in GHz\n",
" Z0=50, # characteristic impedance in Ohm\n",
" vp=0.404314 * c_light, # phase velocity\n",
")\n",
"res_bob = Subsystem(\n",
" name=\"readout_bob\", sys_type=\"TL_RESONATOR\", nodes=[\"readout_bob\"], q_opts=q_opts\n",
")"
]
},
{
"cell_type": "markdown",
"id": "fee92273-fbdb-46cf-9b5b-950cb4516146",
"metadata": {},
"source": [
"### Creat the composite system from the cells and the subsystems"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "0666953a-c1e4-49b2-8c8e-998edf97a070",
"metadata": {},
"outputs": [],
"source": [
"composite_sys = CompositeSystem(\n",
" subsystems=[transmon_alice, transmon_bob, res_alice, res_bob],\n",
" cells=[cell_1, cell_2],\n",
" grd_node=\"ground_main_plane\",\n",
" nodes_force_keep=[\"readout_alice\", \"readout_bob\"],\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "7021dfb3-62e0-484f-8c67-b1d81f07a5ec",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"node_jj_basis:\n",
"-------------\n",
"\n",
"['j1', 'pad_bot_Q1', 'j2', 'pad_bot_Q2', 'readout_alice', 'readout_bob', 'coupling']\n",
"\n",
"nodes_keep:\n",
"-------------\n",
"\n",
"['j1', 'j2', 'readout_alice', 'readout_bob']\n",
"\n",
"\n",
"L_inv_k (reduced inverse inductance matrix):\n",
"-------------\n",
"\n",
" j1 j2 readout_alice readout_bob\n",
"j1 0.1 0.000000 0.0 0.0\n",
"j2 0.0 0.083333 0.0 0.0\n",
"readout_alice 0.0 0.000000 0.0 0.0\n",
"readout_bob 0.0 0.000000 0.0 0.0\n",
"\n",
"C_k (reduced capacitance matrix):\n",
"-------------\n",
"\n",
" j1 j2 readout_alice readout_bob\n",
"j1 63.185549 -0.766012 8.318893 -0.323188\n",
"j2 -0.766012 84.343548 -0.342145 10.039921\n",
"readout_alice 8.318893 -0.342145 55.591197 -0.144354\n",
"readout_bob -0.323188 10.039921 -0.144354 60.347427\n",
"\n",
"\n"
]
}
],
"source": [
"cg = composite_sys.circuitGraph()\n",
"print(cg)"
]
},
{
"cell_type": "markdown",
"id": "26229dbe-9842-425a-b2fd-946e17b5f29b",
"metadata": {},
"source": [
"### Generate the hilberspace from the composite system, leveraging the scqubits package"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "ef9ca844-eb2b-47ef-b7d8-9b9e4670738c",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"Quantum object: dims = [[10, 10, 3, 3], [10, 10, 3, 3]], shape = (900, 900), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}-2.438\\times10^{+04} & 0.108j & 0.0 & 0.127j & -0.436 & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\-0.108j & -1.678\\times10^{+04} & 0.153j & 0.436 & 0.127j & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\0.0 & -0.153j & -9.184\\times10^{+03} & 0.0 & 0.617 & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\-0.127j & 0.436 & 0.0 & -1.638\\times10^{+04} & 0.108j & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\-0.436 & -0.127j & 0.617 & -0.108j & -8.784\\times10^{+03} & \\cdots & -1.839\\times10^{-08} & 0.0 & 0.0 & 0.0 & 0.0\\\\\\vdots & \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\vdots & \\vdots & \\vdots\\\\0.0 & 0.0 & 0.0 & 0.0 & -1.839\\times10^{-08} & \\cdots & 7.287\\times10^{+04} & 706.553j & 0.617 & 862.863j & -0.872\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & -706.553j & 8.047\\times10^{+04} & 0.0 & 0.872 & 862.863j\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & 0.617 & 0.0 & 7.327\\times10^{+04} & 499.608j & 0.0\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & -862.863j & 0.872 & -499.608j & 8.087\\times10^{+04} & 706.553j\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & -0.872 & -862.863j & 0.0 & -706.553j & 8.847\\times10^{+04}\\\\\\end{array}\\right)\\end{equation*}"
],
"text/plain": [
"Quantum object: dims = [[10, 10, 3, 3], [10, 10, 3, 3]], shape = (900, 900), type = oper, isherm = True\n",
"Qobj data =\n",
"[[-24384.00898603+0.00000000e+00j 0. +1.08232559e-01j\n",
" 0. +0.00000000e+00j ... 0. +0.00000000e+00j\n",
" 0. +0.00000000e+00j 0. +0.00000000e+00j]\n",
" [ 0. -1.08232559e-01j -16784.00898603+0.00000000e+00j\n",
" 0. +1.53063953e-01j ... 0. +0.00000000e+00j\n",
" 0. +0.00000000e+00j 0. +0.00000000e+00j]\n",
" [ 0. +0.00000000e+00j 0. -1.53063953e-01j\n",
" -9184.00898603+0.00000000e+00j ... 0. +0.00000000e+00j\n",
" 0. +0.00000000e+00j 0. +0.00000000e+00j]\n",
" ...\n",
" [ 0. +0.00000000e+00j 0. +0.00000000e+00j\n",
" 0. +0.00000000e+00j ... 73269.11342615+0.00000000e+00j\n",
" 0. +4.99608155e+02j 0. +0.00000000e+00j]\n",
" [ 0. +0.00000000e+00j 0. +0.00000000e+00j\n",
" 0. +0.00000000e+00j ... 0. -4.99608155e+02j\n",
" 80869.11342615+0.00000000e+00j 0. +7.06552629e+02j]\n",
" [ 0. +0.00000000e+00j 0. +0.00000000e+00j\n",
" 0. +0.00000000e+00j ... 0. +0.00000000e+00j\n",
" 0. -7.06552629e+02j 88469.11342615+0.00000000e+00j]]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hilbertspace = composite_sys.create_hilbertspace()\n",
"hilbertspace = composite_sys.add_interaction()\n",
"hilbertspace.hamiltonian()"
]
},
{
"cell_type": "markdown",
"id": "d5e863ce-26e3-41da-a503-7691f55585c3",
"metadata": {},
"source": [
"### Print the results"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "7b826d90-0b97-4caf-9f33-19212b763cbc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Finished eigensystem. \n",
"\n",
"system frequencies in GHz:\n",
"--------------------------\n",
"{'transmon_alice': 6.053360688806868, 'transmon_bob': 4.7989883222888094, 'readout_alice': 8.009054820710865, 'readout_bob': 7.604412010766995}\n",
"\n",
"Chi matrices in MHz\n",
"--------------------------\n",
" transmon_alice transmon_bob readout_alice readout_bob\n",
"transmon_alice -353.239816 -0.542895 -4.132854 -0.003120\n",
"transmon_bob -0.542895 -263.940098 -0.001154 -1.460416\n",
"readout_alice -4.132854 -0.001154 4.283111 -0.000017\n",
"readout_bob -0.003120 -1.460416 -0.000017 3.829744\n"
]
}
],
"source": [
"hamiltonian_results = composite_sys.hamiltonian_results(hilbertspace, evals_count=30)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "5138689d-3384-4763-aeef-ad9a7d481ae8",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" transmon_alice | \n",
" transmon_bob | \n",
" readout_alice | \n",
" readout_bob | \n",
"
\n",
" \n",
" \n",
" \n",
" | transmon_alice | \n",
" -353.239816 | \n",
" -0.542895 | \n",
" -4.132854 | \n",
" -0.003120 | \n",
"
\n",
" \n",
" | transmon_bob | \n",
" -0.542895 | \n",
" -263.940098 | \n",
" -0.001154 | \n",
" -1.460416 | \n",
"
\n",
" \n",
" | readout_alice | \n",
" -4.132854 | \n",
" -0.001154 | \n",
" 4.283111 | \n",
" -0.000017 | \n",
"
\n",
" \n",
" | readout_bob | \n",
" -0.003120 | \n",
" -1.460416 | \n",
" -0.000017 | \n",
" 3.829744 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" transmon_alice transmon_bob readout_alice readout_bob\n",
"transmon_alice -353.239816 -0.542895 -4.132854 -0.003120\n",
"transmon_bob -0.542895 -263.940098 -0.001154 -1.460416\n",
"readout_alice -4.132854 -0.001154 4.283111 -0.000017\n",
"readout_bob -0.003120 -1.460416 -0.000017 3.829744"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hamiltonian_results[\"chi_in_MHz\"].to_dataframe()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "c9411ae7-3b22-4d57-b37a-03c43939a6c7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" transmon_alice transmon_bob readout_alice readout_bob\n",
"transmon_alice 0.000000 20.115410 -129.897537 3.275638\n",
"transmon_bob 20.115410 0.000000 2.678608 -111.508230\n",
"readout_alice -129.897537 2.678608 0.000000 0.436190\n",
"readout_bob 3.275638 -111.508230 0.436190 0.000000"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"composite_sys.compute_gs()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "fb26d9ba-73bb-41ab-a9fc-02d6def23f31",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'EJ': 16346.15128067812,\n",
" 'EC': 312.756868730393,\n",
" 'Q_zpf': 3.204353268e-19,\n",
" 'default_charge_op': Operator(op=array([[-22, 0, 0, ..., 0, 0, 0],\n",
" [ 0, -21, 0, ..., 0, 0, 0],\n",
" [ 0, 0, -20, ..., 0, 0, 0],\n",
" ...,\n",
" [ 0, 0, 0, ..., 20, 0, 0],\n",
" [ 0, 0, 0, ..., 0, 21, 0],\n",
" [ 0, 0, 0, ..., 0, 0, 22]]), add_hc=False)}"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"transmon_alice.h_params"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "e23dff63-4823-46dd-8eb3-51f45a87b0b3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'EJ': 13621.792733898432,\n",
" 'EC': 234.32409269967633,\n",
" 'Q_zpf': 3.204353268e-19,\n",
" 'default_charge_op': Operator(op=array([[-22, 0, 0, ..., 0, 0, 0],\n",
" [ 0, -21, 0, ..., 0, 0, 0],\n",
" [ 0, 0, -20, ..., 0, 0, 0],\n",
" ...,\n",
" [ 0, 0, 0, ..., 20, 0, 0],\n",
" [ 0, 0, 0, ..., 0, 21, 0],\n",
" [ 0, 0, 0, ..., 0, 0, 22]]), add_hc=False)}"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"transmon_bob.h_params"
]
},
{
"cell_type": "markdown",
"id": "05d75379-50b0-4f64-920c-43dd12a482f0",
"metadata": {},
"source": [
"### ***********"
]
},
{
"cell_type": "markdown",
"id": "56293cba-fe08-4fe6-88c4-281dfed02ec4",
"metadata": {},
"source": [
"## Time evolution simulation with Sequencing https://sequencing.readthedocs.io/en/latest/index.html"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "65fc2e48-9de6-4e2b-9c34-67033d7a3c48",
"metadata": {},
"outputs": [],
"source": [
"%config InlineBackend.figure_formats = ['svg']\n",
"\n",
"import qutip\n",
"from tqdm import tqdm\n",
"\n",
"from sequencing import get_sequence, sync\n",
"from sequencing.calibration import tune_rabi\n",
"\n",
"from qiskit_metal.analyses.quantization.lom_time_evolution_sim import (\n",
" lom_composite_sys_to_seq_sys,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "75294219-86b2-434a-84d5-ac6e6fca9bd8",
"metadata": {
"tags": []
},
"source": [
"### A simple example: selective qubit pulse in the strong dispersive regime\n",
"\n",
"*(Illustration `number_splitting.png` not in repo — see [Schuster thesis](https://rsl.yale.edu/sites/default/files/files/RSL_Theses/SchusterThesis.pdf) for the original figure.)*\n",
"\n",
"\\* *Dave Schuster's thesis* https://rsl.yale.edu/sites/default/files/files/RSL_Theses/SchusterThesis.pdf"
]
},
{
"cell_type": "markdown",
"id": "6b6835a4-49b0-42b5-aea6-c50ed10153b1",
"metadata": {
"tags": []
},
"source": [
"## LOM composite system to Sequencing system\n",
"\n",
"*(Illustration `sequencing_h.png` not in repo — see the [Sequencing documentation](https://sequencing.readthedocs.io/en/latest/notebooks/introduction.html) for the original figure.)*\n",
"\n",
"\\* Sequencing documentation, https://sequencing.readthedocs.io/en/latest/notebooks/introduction.html\n",
"\n",
"In this part of the demo, we essentially **reproduce the exact same example as demonstrated in the Sequencing tutorial**, \"Controlling a Transmon coupled to Cavity\", https://sequencing.readthedocs.io/en/latest/notebooks/06-transmon-cavity-control.html, by generating a Sequencing system converted from a LOM composite system. Hence please follow the Sequencing tutorial for more detailed explanations on the pulse construction, calibration and ultimately simulation."
]
},
{
"cell_type": "markdown",
"id": "f0058dfc",
"metadata": {},
"source": [
"### Convert Metal LOM system to Sequencing system\n",
"A Qiskit Metal LOM subsystem corresponds to a 'mode' in Sequencing system. The diagonal elements in `hamiltonian_results['chi_in_MHz']` (anharmonicity) are the self-Kerr's and the off-diagonal elements the cross-Kerr's in Sequencing's Hamiltonian screenshot above.\n",
"\n",
"For more details on modes in Sequencing system, please check out the Sequencing package's documentation. The `levels` parameter specifies the number of energy levels to keep for each mode in the Sequencing system. If not specified, i.e., None, they default to LOM subsystem's respective dimensions as represented by the LOM composite system's hilberspace (`hilbertspace.subsystem_dims`)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "73c072aa-c80c-46ed-ae2d-beaa89f5903a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Finished eigensystem. \n"
]
}
],
"source": [
"system = lom_composite_sys_to_seq_sys(\n",
" composite_sys, hilbertspace, levels=[3, 3, 10, 10]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "ea5dfec0-8504-4c3f-98a4-94b0a987c09c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Transmon(name='transmon_alice', cls='sequencing.modes.Transmon', levels=3, t1=inf, t2=inf, thermal_population=0.0, df=0.0, kerr=-0.3532398157382704, pulses={'smoothed_constant_pulse': SmoothedConstantPulse(name='smoothed_constant_pulse', cls='sequencing.pulses.SmoothedConstantPulse', amp=1.0, detune=0.0, phase=0.0, noise_sigma=0.0, noise_alpha=0.0, scale_noise=False, length=100, sigma=0, shape='tanh'), 'gaussian_pulse': GaussianPulse(name='gaussian_pulse', cls='sequencing.pulses.GaussianPulse', amp=1.0, detune=0.0, phase=0.0, noise_sigma=0.0, noise_alpha=0.0, scale_noise=False, sigma=10, chop=4, drag=0.0)}, default_pulse='gaussian_pulse')\n",
"Cavity(name='readout_alice', cls='sequencing.modes.Cavity', levels=10, t1=inf, t2=inf, thermal_population=0.0, df=0.0, kerr=0.004283110746677267, pulses={'smoothed_constant_pulse': SmoothedConstantPulse(name='smoothed_constant_pulse', cls='sequencing.pulses.SmoothedConstantPulse', amp=1.0, detune=0.0, phase=0.0, noise_sigma=0.0, noise_alpha=0.0, scale_noise=False, length=100, sigma=0, shape='tanh'), 'gaussian_pulse': GaussianPulse(name='gaussian_pulse', cls='sequencing.pulses.GaussianPulse', amp=1.0, detune=0.0, phase=0.0, noise_sigma=0.0, noise_alpha=0.0, scale_noise=False, sigma=10, chop=4, drag=0.0)}, default_pulse='gaussian_pulse')\n"
]
}
],
"source": [
"alice = system.modes[1]\n",
"readout_alice = system.modes[-1]\n",
"print(alice)\n",
"print(readout_alice)"
]
},
{
"cell_type": "markdown",
"id": "9e096ff0-3914-4b5b-a323-20a5b42fe65a",
"metadata": {},
"source": [
"### Are there zero photon in the cavity?\n",
"\n",
"## Tune the amplitude of a pulse on Alice using an amplitude-Rabi sequence"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "651035a6-fb1c-4f3a-8843-df50c794ce43",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 51/51 [00:01<00:00, 35.27it/s]\n"
]
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"selective_sigma = 100 # ns\n",
"\n",
"# tune selective qubit pulse using Rabi\n",
"with system.use_modes([alice]):\n",
" with alice.temporarily_set(gaussian_pulse__sigma=selective_sigma):\n",
" _, _, selective_qubit_amp = tune_rabi(\n",
" system,\n",
" system.fock(\n",
" transmon_alice=0, transmon_bob=0, readout_alice=0, readout_bob=0\n",
" ),\n",
" mode_name=alice.name,\n",
" update=False,\n",
" plot=True,\n",
" verify=False,\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "e8eb9f61-0a25-43fa-953d-3f221fcce152",
"metadata": {},
"outputs": [],
"source": [
"def selective_rotation(qubit, angle, phase=0, detune=0, sigma=selective_sigma):\n",
" with qubit.gaussian_pulse.temporarily_set(sigma=sigma, amp=selective_qubit_amp):\n",
" qubit.rotate(np.pi, phase, detune=detune)"
]
},
{
"cell_type": "markdown",
"id": "4b5c7ba2-2c5e-4738-b689-c62176a23994",
"metadata": {},
"source": [
"## Populate alice readout cavity with 0, 1, 2, 3 photons respectively"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "17eff66f-9ab4-4d99-ad69-4a1708b636dc",
"metadata": {},
"outputs": [],
"source": [
"init_states = [\n",
" (f\"$|g{n}\\\\rangle$\", system.fock(transmon_alice=0, readout_alice=n))\n",
" for n in range(4)\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "be02a327-6020-4642-927c-fe11e4ccfcaf",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Initial states: 100%|██████████| 4/4 [00:00<00:00, 5.31it/s]\n"
]
}
],
"source": [
"# Apply a selective pi pulse that is resonant\n",
"# with the qubit when the cavity is in |0>.\n",
"results = {}\n",
"\n",
"seq = get_sequence(system)\n",
"selective_rotation(alice, np.pi)\n",
"\n",
"for label, state in tqdm(init_states, desc=\"Initial states\"):\n",
" result = seq.run(state)\n",
" results[label] = result"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "f3d68c83-03ed-4b0d-a697-7cf336acb3da",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(1, 1)\n",
"for label, result in results.items():\n",
" # trace over the cavity\n",
" qubit_states = [state.ptrace(alice.index) for state in result.states]\n",
" e_pops = qutip.expect(alice.fock_dm(1, full_space=False), qubit_states)\n",
" ax.plot(result.times, e_pops, label=label)\n",
" ax.grid(True)\n",
" ax.legend(loc=0)\n",
"ax.set_xlabel(\"Time [ns]\")\n",
"ax.set_ylabel(r\"$P(|e\\rangle)$\")\n",
"_ = ax.set_title(\"Transmon trajectory vs. initial cavity state\")"
]
},
{
"cell_type": "markdown",
"id": "c7dcdc38-a784-423e-8f5f-b9ecb6f5fc98",
"metadata": {},
"source": [
"## Use the qubit to measure the cavity: how many photons are there?"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "32910d82-9205-4d19-a3cb-e8fbcd022c0b",
"metadata": {},
"outputs": [],
"source": [
"def rotate_qubit_on_n(\n",
" system, n, angle, qubit_name=\"transmon_alice\", cavity_name=\"readout_alice\"\n",
"):\n",
" \"\"\"Rotate the qubit state iff the cavity is in state |n> by detuning\n",
" the selective qubit pulse by n * chi.\n",
" \"\"\"\n",
" qubit = system.get_mode(qubit_name)\n",
" cavity = system.get_mode(cavity_name)\n",
" chi = system.cross_kerrs[frozenset([qubit.name, cavity.name])]\n",
" selective_rotation(qubit, angle, detune=n * chi)"
]
},
{
"cell_type": "markdown",
"id": "fcbee62b-724c-48c2-bd05-2f91fe484869",
"metadata": {},
"source": [
"### Displace the cavity and then apply selective pulse on alice"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "e90f17c9-367f-4407-953d-75a49fcf2a1a",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Disp. amp. (measure n=0): 100%|██████████| 21/21 [00:07<00:00, 2.76it/s]\n",
"Disp. amp. (measure n=1): 100%|██████████| 21/21 [00:07<00:00, 2.77it/s]\n",
"Disp. amp. (measure n=2): 100%|██████████| 21/21 [00:07<00:00, 2.80it/s]\n",
"Disp. amp. (measure n=3): 100%|██████████| 21/21 [00:07<00:00, 2.71it/s]\n"
]
}
],
"source": [
"max_n = 4\n",
"\n",
"init_state = system.ground_state()\n",
"# qubit in |e> after selective pi pulse means cavity in |n>\n",
"e_op = alice.fock_dm(1, full_space=False)\n",
"disp_amps = np.linspace(0.01, 3, 21)\n",
"e_pops = []\n",
"\n",
"for n in range(max_n):\n",
" e_pops.append([])\n",
" for amp in tqdm(disp_amps, desc=f\"Disp. amp. (measure n={n})\"):\n",
" seq = get_sequence(system)\n",
"\n",
" readout_alice.displace(amp)\n",
" sync()\n",
" rotate_qubit_on_n(system, n, np.pi)\n",
" result = seq.run(init_state)\n",
" # trace over the cavity\n",
" transmon_state = result.states[-1].ptrace(alice.index)\n",
" e_pops[-1].append(qutip.expect(e_op, transmon_state))"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "ee44f4fd-175b-4f62-a6a2-e64cc57b55a6",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots()\n",
"for n, es in enumerate(e_pops):\n",
" ax.plot(disp_amps, es, \".-\", label=f\"measure n = {n}\")\n",
"ax.legend(loc=0)\n",
"ax.grid(True)\n",
"ax.set_xlabel(\"Displacement amplitude\")\n",
"ax.set_ylabel(r\"$P(|e\\rangle)$\")\n",
"_ = ax.set_title(r\"Displacement sequence with selective $\\pi$ pulse\")"
]
}
],
"metadata": {
"interpreter": {
"hash": "487fc71460a2c3509d052c1ab59d4d4ee7aa0fe9ce9e1b164929d34b719b0588"
},
"kernelspec": {
"display_name": "metal",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}