Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display ports in simulation export Klayout dialog #52

Open
qpavsmi opened this issue Apr 28, 2023 · 0 comments
Open

Display ports in simulation export Klayout dialog #52

qpavsmi opened this issue Apr 28, 2023 · 0 comments
Labels
enhancement New feature or request FEM Finite Element simulations GUI

Comments

@qpavsmi
Copy link
Contributor

qpavsmi commented Apr 28, 2023

Prerequisites

KQCircuits, GUI and standalone installations

Issue description

When exporting files to be used by an external FEM simulation software, KQCircuits will usually show a preview of the geometry files that will be used for simulations in KLayout to review that the correct geometry is placed in correct layers. We also export some coordinates within geometry as "ports" in separate json files to be used by the simulation software. These ports do not show up in KLayout, and it's inconvenient to look them up from a separate file to see how the coordinates match with the design geometry. During the preview it would be good to have the port coordinates be outlined as text objects in KLayout.

How to get started

Go to root of the KQCircuits source code folder and run:
python klayout_package/python/scripts/simulations/xs1_full_chip_sim.py

This will cause a KLayout window to pop up, showing geometry of an example chip for which a simulation can be run (remove some clutter double-clicking the refpoints layer to hide it). The python script will also generate the tmp subfolder if not present already, with a folder tmp/xs1_full_chip_sim_output inside. Inside that folder there is simulation.oas design file, which is exactly what the pop up window shows.

Review the contents of the tmp/xs1_full_chip_sim_output/Simulation.json file. Look through the "ports" list. You will see that ports numbered 1-8 are of type EdgePort, and the rest of the ports are of type InternalPort. These are the two classes of ports that are used in KQCircuits. EdgePorts are placed at the edge of the simulation region and InternalPorts are placed inside the region. Every port is defined by signal_location 2D coordinate, InternalPorts may additionally have a ground_location 2D coordinate.

You can compare the port locations as exported to tmp/xs1_full_chip_sim_output/Simulation.json with how we define the ports in single_xmons_full_chip_sim.py. There are two calls of self.ports.append, EdgePorts are placed for the launchers and InternalPorts are added for the SQUID parts of qubits, signal locations located at the edge of qubits' inner metal part and ground locations located outside of qubits. See below charts.

image

internalports

These would be good to illustrate by placing text objects similar to what we currently do in the refpoints layer. We already place some visualisation elements during simulation preview using the function visualise_region. Currently we do that with taking XSections and defining PartitionRegions.

Using visualise_region you can set the name of the layer drawing shapes for visualisation purposes, let's call it simulation_ports. You can also specify the label of the text object. The label should specify the port index and type, for example edge_port_1, internal_port_signal_2, internal_port_ground_3. So a way to place a single text object as a point could be:

# port is some EdgePort
self.visualise_region(pya.Region(), "edge_port_1", "simulation_ports", port.signal_location)

Since EdgePorts are always placed at edges of the simulation box, you can infer the direction of the port based on which edge of the box the port is placed in. It would be nice if the port would be visualised as a line segment that starts from port location and extends for some length outside of the box, as presented in first illustration. See the first argument pya.Region() in the example call of visualise_region. This constructs an "empty" region, which means that only the text object is placed, and no polygons. You might consider visualising the ports as 2D shapes in the case of EdgePorts

Suppose we want to place a vertical line of width w from 2D point (x,y1) to (x,y2). We can just draw it using a box: pya.Region(pya.DBox(x-w, y1, x+w, y2).to_itype(self.layout.dbu)). Here pya.DBox is defined in domain specific units (in this case microns), but pya.Region only accepts KLayout's internal integer measurements. Therefore we need to convert the pya.DBox to integer units using .to_itype(self.layout.dbu). You could also set w=0 if you'd prefer infinitely thin lines, these still get rendered in the KLayout window.

For InternalPorts you might also draw a line from signal_location to ground_location. Notice that the line might have some angled direction, in which case using a pya.DBox might not look correct, so you could instead use a pya.DPolygon with four points. Notice also that ground_location is an optional property, so if it is not defined, just placing a text point is enough.

The port visualisation code should run as last call in Simulation.__init__ function. You should have access to all ports from Simulation.ports attribute, which gets populated after build call.

Definition of done

  • All ports exported to simulation json files should be visible in simulation.oas in a separate layer. Ports should convey their location, index and type of port as defined in the json files.
  • If the simulation script creates a sweep of simulations (e.g. double_pads_sim.py), the ports should be separated to each appropriate simulation sweep
  • No tests needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request FEM Finite Element simulations GUI
Projects
None yet
Development

No branches or pull requests

1 participant