{ "cells": [ { "cell_type": "markdown", "id": "e6fb3f52-c8e0-42e8-bc5f-bbc1b7edc443", "metadata": {}, "source": [ "# 3.5 Render your design to Gmsh\n", "\n", "This notebook demonstrates the open-source rendering capabilities of Qiskit Metal\n", "using [Gmsh](https://gmsh.info) for mesh generation. By the end you will be able to:\n", "\n", "1. Render a full or selective design (with open pins, skip junctions)\n", "2. Generate a basic mesh, a customised mesh, and an Intelli-mesh\n", "3. Export the mesh to a `.msh` file for downstream FEM solvers\n", "\n", "**Contents:** creating a design → rendering (wireframe + selective + open/short pins +\n", "skip junctions) → meshing (basic + customised + Intelli-mesh + custom function) → export\n", "\n", "> **Gmsh required.** Install with `pip install gmsh` or `conda install -c conda-forge gmsh`.\n", "> The import check in the next section will tell you if it is missing." ] }, { "cell_type": "markdown", "id": "e04834b0", "metadata": {}, "source": [ "> ⚠️ **`launch_gui()` blocks the kernel**\n", ">\n", "> Every cell that calls `gmsh_renderer.launch_gui()` opens the Gmsh FLTK window\n", "> and **pauses execution** until you close that window. This is expected — Gmsh's\n", "> event loop is synchronous. Close the window to continue to the next cell.\n", ">\n", "> If you are running headlessly (Colab, JupyterHub, CI), remove the\n", "> `launch_gui()` calls — everything else (render, mesh, export) works without a display." ] }, { "cell_type": "markdown", "id": "53155980-d117-4a08-a59c-052eb4b389aa", "metadata": {}, "source": [ "### Imports and Gmsh availability check" ] }, { "cell_type": "code", "execution_count": 1, "id": "fd940c56", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gmsh 4.15.0 is available.\n" ] } ], "source": [ "try:\n", " import gmsh\n", "\n", " print(f\"Gmsh {gmsh.__version__} is available.\")\n", "except ImportError:\n", " raise ImportError(\n", " \"Gmsh is not installed. \"\n", " \"Install it with: pip install gmsh\\n\"\n", " \"or: conda install -c conda-forge gmsh\"\n", " )" ] }, { "cell_type": "code", "execution_count": 3, "id": "127ebb29-7a7b-43ba-a342-c8ccb44a26b8", "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", "from qiskit_metal import MetalGUI, designs\n", "from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket\n", "from qiskit_metal.qlibrary.tlines.meandered import RouteMeander\n", "from qiskit_metal.qlibrary.terminations.open_to_ground import OpenToGround" ] }, { "cell_type": "code", "execution_count": 4, "id": "2e9f81bb-dcbc-461d-ad04-7095069152a6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "