3. First- and second-order meshes of an Xmon

3.1. Requirements

3.1.1. Software components

  • QTCAD®

  • Gmsh

  • KLayout (optional, for layout inspection)

3.1.2. Python script

  • qtcad/examples/tutorials/builder_xmon.py

3.1.3. Layout file

  • qtcad/examples/tutorials/layouts/xmon.oas

3.1.4. References

3.2. Briefing

In this tutorial, we use Builder to generate first- and second-order meshes of an Xmon device, starting from an OASIS layout file. Second-order meshes allow simulations to reach a better precision than first-order meshes. The design of the device is based on Barends et al. [BKM+13], and consists of the Xmon cross, coupled to an XY control line, a readout line, and a quantum bus.

The first-order mesh generated here is used in the tutorial Capacitance matrix extraction for an Xmon qubit to extract the capacitance matrix of the device. The legacy tutorial Capacitance matrix extraction for an Xmon qubit (Legacy) uses a similar device, whose geometry is generated with the Gmsh Python API.

The layout in the OASIS file is shown below:

../../../_images/builder_xmon_klayout.png

Fig. 3.2.2 Layout file opened in KLayout.

Layer 1 contains the superconducting (SC) sheets: the Xmon cross (xmon_cross), the XY control line (xy_ctrl), the readout line (readout), the quantum bus (qbus), and the ground plane (gnd). Layer 10 contains the rectangle representing the Josephson junction (jj). This tutorial uses the unit of length of the layout file, 1 μm.

Several of the steps found in this tutorial are similar to the ones found in the tutorial Coupled Xmons and will not be discussed in detail here. This tutorial will focus on the generation of second-order meshes.

3.3. Setup

3.3.2. Geometric parameters

We define the thickness of the substrate, the padding of the air box, and the characteristic length of the mesh (all in micrometers). The superconducting sheets are represented as 2D surfaces.

# Thickness of the substrate (μm).
thickness_substrate = 280

# Padding to add when enveloping the whole device in an air box (μm).
airbox_padding_lateral = 200
airbox_padding_vertical = 300

# Characteristic length of the mesh (μm).
mesh_size = 300

The characteristic length is intentionally set to a very large value. In Capacitance matrix extraction for an Xmon qubit, the resulting coarse mesh is then refined adaptively to achieve target accuracy while minimizing required computational resources.

3.4. Building the geometry

We load the layout and build the geometry using the same steps as in the tutorial Coupled Xmons. With adopt_units=True, load_layout makes Builder adopt the same units as the layout file in all subsequent operations. The superconducting sheets and the Josephson junction are added from layers 1 and 10 (see Fig. 3.2.2). The substrate is created below the superconducting sheets, and the whole device is then wrapped in an air box.

# Instantiate Builder and load the layout file, adopting its unit of length (μm).
builder = Builder(name="xmon")
builder.load_layout(layout_dir / "xmon.oas", cell_name="TOP", adopt_units=True)
builder.set_mesh_size(mesh_size)
builder.print_mask_tree()

# New entities inherit existing physical groups at intersections, and are assigned
# to a physical group named after their source shape.
builder.fill_mode()
builder.group_from_shape()

# Add the SC sheets and the junction as surfaces at z=0.
builder.use_mask("layer_1").set_z(0).add_surface()
builder.use_mask("layer_10").set_z(0).add_surface()

# Extrude the bounding box of layer 1 (SC sheets) to create the substrate.
builder.set_z(0)
builder.set_group_name("substrate")
builder.extrude_mask_bbox(height=-thickness_substrate, mask="layer_1")

# Envelop the whole device in an air box.
builder.set_group_name("air")
builder.wrap_in_bbox(
    padding=(airbox_padding_lateral, airbox_padding_lateral, airbox_padding_vertical)
)

The mask tree printed by print_mask_tree shows the polygons found in each layer, with their number of vertices in parentheses. As expected from Fig. 3.2.2, layer 1 contains the five superconducting sheets and layer 10 contains the junction.

Layout
├── Mask 1 "layer_1"
│   ├── 0  Polygon  "xmon_cross" (12)
│   ├── 1  Polygon  "xy_ctrl" (4)
│   ├── 2  Polygon  "qbus" (12)
│   ├── 3  Polygon  "readout" (12)
│   └── 4  Polygon  "gnd" (45)
└── Mask 10 "layer_10"
    └── 0  Polygon  "jj" (4)

We also export the geometry as an XAO file, which is needed for simulations with adaptive-mesh refinement. The XAO file contains only the geometry, so the same file can be used with first- and second-order meshes.

# Export the geometry as an XAO file.
builder.write(mesh_dir / "builder_xmon.xao")

3.5. Generating first- and second-order meshes

The order of the mesh elements is set with the order argument of mesh. A second-order tetrahedron has 10 nodes: one at each vertex and one at the middle of each edge (see Finite elements). Builder places the additional nodes at the middle of the straight edges, as currently required by QTCAD, rather than on curved boundaries of the geometry. Since the Xmon geometry has no curved boundaries, this choice does not affect this tutorial.

We first generate the first-order mesh, which is the default.

# Generate the first-order mesh and save it.
builder.mesh(3, algorithm3d=MeshAlgorithm3D.HXT, order=1)
builder.write(mesh_dir / "builder_xmon_order1.msh")

Each call to mesh generates the mesh from scratch. Hence, we can generate the second-order mesh from the same geometry by calling mesh again with order=2.

# Generate the second-order mesh and save it.
builder.mesh(3, algorithm3d=MeshAlgorithm3D.HXT, order=2)
builder.write(mesh_dir / "builder_xmon_order2.msh")

3.6. Loading and visualizing the meshes

Finally, we load both meshes with the Mesh class. The scale of the meshes is the unit of length adopted by Builder, in meters. Builder stores this unit as the base-10 exponent length_unit_exponent, so the scale is 10**length_unit_exponent, here 1e-06.

# Scale of the meshes, in meters, from the unit of length adopted by Builder.
scale = 10.0**builder.length_unit_exponent
print("Scale of the meshes (m):", scale)

# Load the first- and second-order meshes.
mesh_order1 = Mesh(scale, mesh_dir / "builder_xmon_order1.msh")
mesh_order2 = Mesh(scale, mesh_dir / "builder_xmon_order2.msh")

When loading each mesh, QTCAD prints its statistics. In this run, the output for the first-order mesh is

================================================================================
3D MESH STATISTICS
--------------------------------------------------------------------------------
Total number of elements      1584
Triangular elements           510
Tetrahedral elements          1074
Total number of nodes         259
Boundary physical names       xy_ctrl, xmon_cross, qbus, readout, gnd, jj, substrate_bottom, substrate_side, substrate_top, air_side, air_bottom, air_top,
Region physical names         substrate, air,
================================================================================

and for the second-order mesh, it is

================================================================================
3D MESH STATISTICS
--------------------------------------------------------------------------------
Total number of elements      1586
Triangular elements           510
Tetrahedral elements          1076
Total number of nodes         1705
Boundary physical names       xy_ctrl, xmon_cross, qbus, readout, gnd, jj, substrate_bottom, substrate_side, substrate_top, air_side, air_bottom, air_top,
Region physical names         substrate, air,
================================================================================

The two meshes have roughly the same number of tetrahedra, 1074 and 1076. However, the second-order mesh has 1705 nodes, while the first-order mesh has 259 nodes, since each edge of the second-order mesh carries an additional node.

We then visualize the first-order mesh. The faces of the substrate and of the air box are hidden, and the substrate and the air are made partly transparent, so that the superconducting sheets are visible. These settings can also be changed interactively in the right-hand panel of the QTCAD visualizer (see Poisson and Schrödinger simulation of a nanowire quantum dot).

# Visualize the first-order mesh. Hide the faces of the substrate and of the air box,
# and make the substrate and the air partly transparent.
hidden = [
    "substrate_bottom",
    "substrate_side",
    "substrate_top",
    "air_bottom",
    "air_side",
    "air_top",
]
mesh_order1.show(
    config={
        "visibility": {name: False for name in hidden},
        "opacity": {"substrate": 0.3, "air": 0.3},
    }
)
../../../_images/builder_xmon_mesh_order1.png

Fig. 3.6.2 First-order mesh of the device.

The generated geometry and mesh files can then be used to simulate this device with QTCAD, for example to extract its capacitance matrix (see Capacitance matrix extraction for an Xmon qubit).

3.7. Full code

__copyright__ = "Copyright 2022-2026, Nanoacademic Technologies Inc."

from pathlib import Path
from qtcad.builder import Builder, MeshAlgorithm3D
from qtcad.device.mesh3d import Mesh

script_dir = Path(__file__).parent.resolve()
layout_dir = script_dir / "layouts"
mesh_dir = script_dir / "meshes"

# Thickness of the substrate (μm).
thickness_substrate = 280

# Padding to add when enveloping the whole device in an air box (μm).
airbox_padding_lateral = 200
airbox_padding_vertical = 300

# Characteristic length of the mesh (μm).
mesh_size = 300

# Instantiate Builder and load the layout file, adopting its unit of length (μm).
builder = Builder(name="xmon")
builder.load_layout(layout_dir / "xmon.oas", cell_name="TOP", adopt_units=True)
builder.set_mesh_size(mesh_size)
builder.print_mask_tree()

# New entities inherit existing physical groups at intersections, and are assigned
# to a physical group named after their source shape.
builder.fill_mode()
builder.group_from_shape()

# Add the SC sheets and the junction as surfaces at z=0.
builder.use_mask("layer_1").set_z(0).add_surface()
builder.use_mask("layer_10").set_z(0).add_surface()

# Extrude the bounding box of layer 1 (SC sheets) to create the substrate.
builder.set_z(0)
builder.set_group_name("substrate")
builder.extrude_mask_bbox(height=-thickness_substrate, mask="layer_1")

# Envelop the whole device in an air box.
builder.set_group_name("air")
builder.wrap_in_bbox(
    padding=(airbox_padding_lateral, airbox_padding_lateral, airbox_padding_vertical)
)

# Export the geometry as an XAO file.
builder.write(mesh_dir / "builder_xmon.xao")

# Generate the first-order mesh and save it.
builder.mesh(3, algorithm3d=MeshAlgorithm3D.HXT, order=1)
builder.write(mesh_dir / "builder_xmon_order1.msh")

# Generate the second-order mesh and save it.
builder.mesh(3, algorithm3d=MeshAlgorithm3D.HXT, order=2)
builder.write(mesh_dir / "builder_xmon_order2.msh")

# Scale of the meshes, in meters, from the unit of length adopted by Builder.
scale = 10.0**builder.length_unit_exponent
print("Scale of the meshes (m):", scale)

# Load the first- and second-order meshes.
mesh_order1 = Mesh(scale, mesh_dir / "builder_xmon_order1.msh")
mesh_order2 = Mesh(scale, mesh_dir / "builder_xmon_order2.msh")

# Visualize the first-order mesh. Hide the faces of the substrate and of the air box,
# and make the substrate and the air partly transparent.
hidden = [
    "substrate_bottom",
    "substrate_side",
    "substrate_top",
    "air_bottom",
    "air_side",
    "air_top",
]
mesh_order1.show(
    config={
        "visibility": {name: False for name in hidden},
        "opacity": {"substrate": 0.3, "air": 0.3},
    }
)