{ "cells": [ { "cell_type": "markdown", "id": "dcef2e75", "metadata": {}, "source": [ "# Demo Notebook Demonstrating How to Test for Component/CPW Overlap" ] }, { "cell_type": "markdown", "id": "b209b605", "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": "94731f0b", "metadata": {}, "source": [ "This tutorial notebook demonstrates how to use the QDesign_Check class to test for overlap and/or collisions between componenets in a design. Let's start by importing the relevant modules and opening up the GUI:" ] }, { "cell_type": "code", "execution_count": null, "id": "22967b0b", "metadata": { "scrolled": true }, "outputs": [], "source": [ "import qiskit_metal as metal\n", "from qiskit_metal import designs, draw\n", "from qiskit_metal import MetalGUI, Dict, open_docs\n", "from qiskit_metal.qlibrary.qubits.transmon_pocket_6 import TransmonPocket6\n", "\n", "design = metal.designs.DesignPlanar()\n", "gui = metal.MetalGUI(design)\n", "design.overwrite_enabled = True\n", "design.chips.main" ] }, { "cell_type": "markdown", "id": "c28cd919", "metadata": {}, "source": [ "## Design #1: CPW/Qubit Collision" ] }, { "cell_type": "markdown", "id": "23c220f1", "metadata": {}, "source": [ "Let's create a design with three qubits in a straight line. Then we'll connect the outer two qubits with a CPW which (intentionally) intersects the middle qubit. " ] }, { "cell_type": "code", "execution_count": null, "id": "256688de", "metadata": {}, "outputs": [], "source": [ "Q1 = TransmonPocket6(\n", " design,\n", " \"Q1\",\n", " options=dict(\n", " pos_x=\"-2mm\",\n", " pos_y=\"0mm\",\n", " pad_width=\"425 um\",\n", " pocket_height=\"650um\",\n", " connection_pads=dict(\n", " readout=dict(loc_W=1, loc_H=-1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " bus_01=dict(loc_W=1, loc_H=1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " ),\n", " ),\n", ")\n", "\n", "Q2 = TransmonPocket6(\n", " design,\n", " \"Q2\",\n", " options=dict(\n", " pos_x=\"2mm\",\n", " pos_y=\"0mm\",\n", " orientation=0,\n", " pad_width=\"425 um\",\n", " pocket_height=\"650um\",\n", " connection_pads=dict(\n", " readout=dict(loc_W=-1, loc_H=-1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " bus_01=dict(loc_W=-1, loc_H=1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " ),\n", " ),\n", ")\n", "\n", "Q3 = TransmonPocket6(\n", " design,\n", " \"Q3\",\n", " options=dict(\n", " pos_x=\"0mm\",\n", " pos_y=\"0mm\",\n", " orientation=0,\n", " pad_width=\"425 um\",\n", " pocket_height=\"650um\",\n", " connection_pads=dict(\n", " readout=dict(loc_W=-1, loc_H=-1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " bus_01=dict(loc_W=-1, loc_H=1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " ),\n", " ),\n", ")\n", "\n", "gui.rebuild()\n", "gui.autoscale()" ] }, { "cell_type": "code", "execution_count": null, "id": "b9c074a8", "metadata": {}, "outputs": [], "source": [ "from qiskit_metal.qlibrary.tlines.meandered import RouteMeander\n", "from qiskit_metal.qlibrary.tlines.pathfinder import RoutePathfinder\n", "from qiskit_metal.qlibrary.tlines.anchored_path import RouteAnchors\n", "from qiskit_metal.qlibrary.tlines.straight_path import RouteStraight\n", "\n", "bus1 = RoutePathfinder(\n", " design,\n", " \"coupler1\",\n", " Dict(\n", " pin_inputs=Dict(\n", " start_pin=Dict(component=\"Q1\", pin=\"readout\"),\n", " end_pin=Dict(component=\"Q2\", pin=\"readout\"),\n", " ),\n", " ),\n", ")\n", "\n", "gui.rebuild()\n", "gui.autoscale()" ] }, { "cell_type": "markdown", "id": "3646c57f", "metadata": {}, "source": [ "Let's look at a screenshot to see that there is in fact a CPW/qubit collision:" ] }, { "cell_type": "code", "execution_count": null, "id": "c4911e5d", "metadata": {}, "outputs": [], "source": [ "gui.screenshot()" ] }, { "cell_type": "markdown", "id": "ceeef7fa", "metadata": {}, "source": [ "Indeed we can see the CPW being routed straight through the middle qubit. We can use the \"overlap_tester\" function in the QDesign_Check class to verify that this is caught:" ] }, { "cell_type": "markdown", "id": "4e4eec09", "metadata": {}, "source": [ "Let's now import the QDesign_Check class, which contains several useful functions to test for overlap and collisions among design components:" ] }, { "cell_type": "code", "execution_count": null, "id": "9b6ac4ae", "metadata": { "tags": [] }, "outputs": [], "source": [ "from qiskit_metal.qlibrary.core.design_check import QDesignCheck\n", "\n", "a_tester = QDesignCheck(design)" ] }, { "cell_type": "markdown", "id": "cbf104c0", "metadata": {}, "source": [ "And now we'll test the design for any overlap or collision errors:" ] }, { "cell_type": "code", "execution_count": null, "id": "978fa503", "metadata": { "tags": [] }, "outputs": [], "source": [ "a_tester.overlap_tester()" ] }, { "cell_type": "markdown", "id": "338c44aa", "metadata": {}, "source": [ "This function tells us that there is a collision between component 3 (the middle qubit) and component 4 (the CPW.)" ] }, { "cell_type": "markdown", "id": "cff5162a", "metadata": {}, "source": [ "## Design #2: CPW/CPW Collision" ] }, { "cell_type": "markdown", "id": "bf2a9bf0", "metadata": {}, "source": [ "Now let's modify the existing design to create a scenario where two CPW resonators intersect with one another. We can do this by shifting the middle qubit up and adding another qubit below it:" ] }, { "cell_type": "code", "execution_count": null, "id": "8472cb04", "metadata": {}, "outputs": [], "source": [ "Q3.options.pos_y = \"2.0 mm\"\n", "Q3.options.orientation = \"90\"" ] }, { "cell_type": "code", "execution_count": null, "id": "defbe27e", "metadata": {}, "outputs": [], "source": [ "Q4 = TransmonPocket6(\n", " design,\n", " \"Q4\",\n", " options=dict(\n", " pos_x=\"0mm\",\n", " pos_y=\"-2mm\",\n", " orientation=270,\n", " pad_width=\"425 um\",\n", " pocket_height=\"650um\",\n", " connection_pads=dict(\n", " readout=dict(loc_W=-1, loc_H=-1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " bus_01=dict(loc_W=-1, loc_H=1, pad_width=\"100um\", pad_gap=\"50um\"),\n", " ),\n", " ),\n", ")\n", "\n", "gui.rebuild()\n", "gui.autoscale()" ] }, { "cell_type": "code", "execution_count": null, "id": "68e435b0", "metadata": {}, "outputs": [], "source": [ "from qiskit_metal.qlibrary.tlines.meandered import RouteMeander\n", "from qiskit_metal.qlibrary.tlines.pathfinder import RoutePathfinder\n", "from qiskit_metal.qlibrary.tlines.anchored_path import RouteAnchors\n", "from qiskit_metal.qlibrary.tlines.straight_path import RouteStraight\n", "\n", "bus1 = RouteStraight(\n", " design,\n", " \"coupler2\",\n", " Dict(\n", " pin_inputs=Dict(\n", " start_pin=Dict(component=\"Q3\", pin=\"readout\"),\n", " end_pin=Dict(component=\"Q4\", pin=\"readout\"),\n", " ),\n", " ),\n", ")\n", "\n", "gui.rebuild()\n", "gui.autoscale()" ] }, { "cell_type": "code", "execution_count": null, "id": "18628536", "metadata": {}, "outputs": [], "source": [ "gui.screenshot()" ] }, { "cell_type": "markdown", "id": "e27d462d", "metadata": {}, "source": [ "Indeed we can see that the two CPWs are crossing one another. Let's see if the overlap_tester catches this:" ] }, { "cell_type": "code", "execution_count": null, "id": "911b76ac", "metadata": {}, "outputs": [], "source": [ "a_tester.update_design(design)\n", "a_tester.overlap_tester()" ] }, { "cell_type": "markdown", "id": "c82348aa", "metadata": {}, "source": [ "We see that the collision is detected between component 4 (the horizontal CPW) and component 5 (the vertical CPW). " ] }, { "cell_type": "markdown", "id": "1c524e30", "metadata": {}, "source": [ "## Design #3: Qubit/Qubit Overlap" ] }, { "cell_type": "markdown", "id": "93e5c103", "metadata": {}, "source": [ "Let's modify the existing design to remove the CPWs and move one of the qubits so that it's partially overlapping with another:" ] }, { "cell_type": "code", "execution_count": null, "id": "ee081ac0", "metadata": {}, "outputs": [], "source": [ "design.delete_component(\"coupler1\")\n", "design.delete_component(\"coupler2\")\n", "Q4.options.pos_y = \"1.5 mm\"\n", "gui.rebuild()\n", "gui.autoscale()" ] }, { "cell_type": "code", "execution_count": null, "id": "f324b0b7", "metadata": {}, "outputs": [], "source": [ "gui.screenshot()" ] }, { "cell_type": "code", "execution_count": null, "id": "a457d167", "metadata": {}, "outputs": [], "source": [ "a_tester.update_design(design)\n", "a_tester.overlap_tester()" ] }, { "cell_type": "markdown", "id": "6688e572", "metadata": {}, "source": [ "Here we see that program correctly identified a collision between qubits 3 and 5. " ] } ], "metadata": { "kernelspec": { "display_name": "metal_qamp_v2", "language": "python", "name": "metal_qamp_v2" }, "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.10.5" } }, "nbformat": 4, "nbformat_minor": 5 }