RouteMeander#

class RouteMeander(design, name: str | None = None, options: Dict | None = None, type: str = 'CPW', **kwargs)[source]#

Implements a simple CPW, with a single meander. The base CPW meandered class.

Inherits QRoute class

QRoute Default Options:
  • pin_inputs: Dict
    • start_pin: Dict – Component and pin string pair. Define which pin to start from
      • component: ‘’ – Name of component to start from, which has a pin

      • pin: ‘’ – Name of pin used for pin_start

    • end_pin=Dict – Component and pin string pair. Define which pin to start from
      • component: ‘’ – Name of component to end on, which has a pin

      • pin: ‘’ – Name of pin used for pin_end

  • fillet: ‘0’

  • lead: Dict
    • start_straight: ‘0mm’ – Lead-in, defined as the straight segment extension from start_pin. Defaults to 0.1um.

    • end_straight: ‘0mm’ – Lead-out, defined as the straight segment extension from end_pin. Defaults to 0.1um.

    • start_jogged_extension: ‘’ – Lead-in, jogged extension of lead-in. Described as list of tuples

    • end_jogged_extension: ‘’ – Lead-out, jogged extension of lead-out. Described as list of tuples

  • total_length: ‘7mm’

  • trace_width: ‘cpw_width’ – Defines the width of the line. Defaults to ‘cpw_width’.

Default Options:
  • meander: Dict
    • spacing: ‘200um’ – Minimum spacing between adjacent meander curves. Defaults to 200um.

    • asymmetry=’0um’ – offset between the center-line of the meander and the center-line that stretches from the tip of lead-in to the x (or y) coordinate of the tip of the lead-out. Defaults to ‘0um’.

  • snap: ‘true’

  • prevent_short_edges: ‘true’

Initializes all Routes.

Calls the QComponent __init__() to create a new Metal component. Before that, it adds the variables that are needed to support routing.

Parameters:
  • design (QDesign) – The parent design.

  • name (str) – Name of the component. Auto-named if possible.

  • options (dict) – User options that will override the defaults. Defaults to None.

  • type (string) – Supports Route (single layer trace) and CPW (adds the gap around it). Defaults to “CPW”.

Attributes

TOOLTIP = 'Implements a simple CPW, with a single meander.'#
class_name#

the full module name with the class name. e.g., qiskit_metal.qlibrary.qubits.TransmonPocket.

Returns:

Class name

Return type:

str

Type:

Return the full name of the class

component_metadata = {'short_name': 'cpw'}#

Component metadata

default_options = {'meander': {'asymmetry': '0um', 'spacing': '200um'}, 'prevent_short_edges': 'true', 'snap': 'true'}#

Default options

design#

Return a reference to the parent design object.

Returns:

design

Return type:

QDesign

id#

The unique id of component within a design.

Returns:

Component id

Return type:

int

length#

Sum of all segments length, including the head.

Returns:

Full point_array length

Return type:

length (float)

logger#

The Qiskit Metal Logger.

Returns:

Logger

Return type:

logging.Logger

name#

Name of the component.

options = {}#

A dictionary of the component-designer-defined options. These options are used in the make function to create the QGeometry and QPins. All options should have string keys and preferrable string values.

pin_names#

The names of the pins.

Returns:

Set of pin names

Return type:

set

qgeometry_types#

Get a list of the names of the element tables.

Returns:

Name of element table or type; e.g., ‘poly’ and ‘path’

Return type:

List[str]

pins#

Dictionary of pins. Populated by component designer in make function using add_pin.

metadata#

Metadata allows a designer to store extra information or analysis results.

status#

Stores the latest status of the component. Values include: Initialization Successful, Build Failed, etc.

Methods

add_dependency(parent: str, child: str)#

Add a dependency between one component and another. Calls parent design.

Parameters:
  • parent (str) – The component on which the child depends

  • child (str) – The child cannot live without the parent.

add_pin(name: str, points: ndarray, width: float, input_as_norm: bool = False, chip: str | None = None, gap: float | None = None)#

Adds a pin from two points which are normal/tangent to the intended plane of the pin. The normal should ‘point’ in the direction of intended connection. Adds the new pin as a subdictionary to parent component’s pins dictionary.

Parameters:
  • name (*) – name of the pin

  • points (*) – [[x1,y1],[x2,y2]] for the normal/tangent line

  • width (*) – the width of the intended connection (eg. qubit bus pad arm)

  • input_as_norm (*) – Indicates if the points are tangent or normal to the pin plane. Defaults to False.. Make True for normal.

  • parent (*) – The id of the parent component.

  • chip (*) – the name of the chip the pin is located on. Defaults to None, which is

  • self.options.chip. (converted to) –

  • gap (*) – the dielectric gap of the pin for the purpose of representing as a port for simulations. Defaults to None which is converted to 0.6 * width.

Dictionary containing pins information:
  • points (numpy.ndarray) - two (x,y) points which represent the edge of the pin for another component to attach to (eg. the edge of a CPW TL)

  • middle (numpy.ndarray) - an (x,y) which represents the middle of the points above, where the pin is represented.

  • normal (numpy.ndarray) - the normal vector of the pin, pointing in direction of intended connection

  • tangent (numpy.ndarray) - 90 degree rotation of normal vector

  • width (float) - the width of the pin

  • chip (str) - the chip the pin is on

  • parent_name - the id of the parent component

  • net_id - net_id of the pin if connected to another pin. Defaults to 0, indicates not connected))

* = pin
. = outline of component

—> = the list being passed in as ‘points’ [[x1,y1],[x2,y2]]

normal vector

..........
         .
--------->*
         .
..........

tangent vector

..........^
         .|
         .*
         .|
..........|
add_qgeometry(kind: str, geometry: dict, subtract: bool = False, helper: bool = False, layer: int | str | None = None, chip: str | None = None, **kwargs)#

Add QGeometry.

Takes any additional options in options.

Parameters:
  • kind (str) – The kind of QGeometry, such as ‘path’, ‘poly’, etc. All geometry in the dictionary should have the same kind, such as Polygon or LineString.

  • geometry (Dict[BaseGeometry]) – Key-value pairs of name of the geometry you want to add and the value should be a shapely geometry object, such as a Polygon or a LineString.

  • subtract (bool) – Subtract from the layer. Defaults to False.

  • helper (bool) – Is this a helper object. If true, subtract must be false Defaults to False.

  • layer (int, str) – The layer to which the set of QGeometry will belong Defaults to None, which is converted to self.options.chip.

  • chip (str) – Chip name. Defaults to None, which is converted to

  • self.options.chip.

  • kwargs (dict) – Parameters dictionary

Assumptions:
  • Assumes all geometry in the geometry argument are homogeneous in kind; i.e., all lines or polys etc.

adjust_length(delta_length, pts, start_pt: QRoutePoint, end_pt: QRoutePoint) ndarray[source]#

Edits meander points to redistribute the length slacks accrued with the various local adjustments It should be run after self.pts_intermediate is completely defined Inputs are however specific to the one meander segment Assumption is that pts is always a sequence of paired points, each corresponds to one meander 180deg curve The pts is typically an odd count since the last point is typically used to anchor the left-over length, therefore this code supports both odd and even cases, separately. For even it assumes all points are in paired.

Parameters:
  • delta_length (delta_length) – slack/excess length to distribute on the pts

  • pts (np.array) – intermediate points of meander. pairs, except last point (2,2,…,2,1)

  • start_pt (QRoutePoint) – QRoutePoint of the start

  • end_pt (QRoutePoint) – QRoutePoint of the end

Returns:

Array of points

Return type:

np.ndarray

assign_direction_to_anchor(ref_pt: QRoutePoint, anchor_pt: QRoutePoint)#

Method to assign a direction to a point. Currently assigned as the max(x,y projection) of the direct path between the reference point and the anchor. Method directly modifies the anchor_pt.direction, thus there is no return value.

Parameters:
  • ref_pt (QRoutePoint) – Reference point

  • anchor_pt (QRoutePoint) – Anchor point. if it already has a direction, the method will not overwrite it

connect_components_already_in_design(pin_name_self: str, comp2_id: int, pin2_name: str) int#
WARNING: Do NOT use this method during generation of component instance.

This method is expecting self to be added to design._components dict. More importantly, the unique id of self component needs to be in design._components dict.

Parameters:
  • pin_name_self (str) – Name of pin within the component.

  • comp2_id (int) – Component within design, but not self.

  • pin2_name (str) – The pin of comp2_id that pin_name_self will connect to.

Returns:

A unique net_id for the connection.

Return type:

int

connect_meandered(start_pt: QRoutePoint, end_pt: QRoutePoint) ndarray[source]#

Meanders using a fixed length and fixed spacing.

Parameters:
Returns:

Array of points

Return type:

np.ndarray

Adjusts the width of the meander:
  • Includes the start but not the given end point

  • If it cannot meander just returns the initial start point

del_colinear_points(inarray)#

Delete colinear points from the given array.

Parameters:

inarray (list) – List of points

Returns:

List of points without colinear points

Return type:

list

delete()#

Delete the QComponent.

Removes QGeometry, QPins, etc. from the design.

static get_index_for_side1_meander(num_root_pts: int)[source]#

Get the indices.

Parameters:

num_root_pts (list) – List of points

Returns:

Tuple of indices

Return type:

tuple

get_pin(name: str) Dict#

Interface for components to get pin data.

Parameters:

name (str) – Name of the desired pin.

Returns:

Returns the data of the pin, see make_pin() for what those values are.

Return type:

dict

get_points() ndarray#

Assembles the list of points for the route by concatenating: head_pts + intermediate_pts, tail_pts.

Returns:

((H+N+T)x2) all points (x,y) of the CPW

Return type:

np.ndarray

classmethod get_template_options(design: QDesign, component_template: Dict = None, logger_: Logger = None, template_key: str = None) Dict#

Creates template options for the Metal Component class required for the class to function, based on the design template; i.e., be created, made, and rendered. Provides the blank option structure required.

The options can be extended by plugins, such as renderers.

Parameters:
  • design (QDesign) – Design class. Should be the class, not the instance.

  • component_template (Dict) – Template options to overwrite the class ones (default: None)

  • logger (logging.Logger) – A logger for errors. Defaults to None.

  • template_key (str) – The template key identifier. If None, then uses cls._get_unique_class_name(). Defaults to None.

Returns:

dictionary of default options based on design template.

Return type:

Dict

get_tip() QRoutePoint#

Access the last element in the QRouteLead.

Returns:

Last point in the QRouteLead The values are numpy arrays with two float points each.

Return type:

QRoutePoint

get_unit_vectors(start: QRoutePoint, end: QRoutePoint, snap: bool = False) Tuple#

Return the unit and target vector in which the CPW should process as its coordinate sys.

Parameters:
  • start (QRoutePoint) – Reference start point (direction from here)

  • end (QRoutePoint) – Reference end point (direction to here)

  • snap (bool) – True to snap to grid. Defaults to False.

Returns:

straight and 90 deg CCW rotated vecs 2D (array([1., 0.]), array([0., 1.]))

Return type:

array

issideways(point, seg_point_a, seg_point_b)[source]#
length_excess_corner_rounding(points) float#

Computes how much length to deduce for compensating the fillet settings.

Parameters:

points (list or array) – List of vertices that will be receiving the corner rounding radius

Returns:

Corner rounding radius excess multiplied by the number of points

Return type:

length_excess (float)

make()[source]#

The make function implements the logic that creates the geometry (poly, path, etc.) from the qcomponent.options dictionary of parameters, and the adds them to the design, using qcomponent.add_qgeometry(…), adding in extra needed information, such as layer, subtract, etc.

make_elements(pts: ndarray)#

Turns the CPW points into design elements, and add them to the design object.

Parameters:

pts (np.ndarray) – Array of points

parse_options(options: Dict | None = None) Dict#

Parse the options, converting string into interpreted values. Parses units, variables, strings, lists, and dictionaries. Explained by example below.

Parameters:

options (dict) – If left None, then self.options is used. Defaults to None.

Returns:

Parsed value

Return type:

dict

Calls self.design.parse_options.

See self.parse_value for more information.

parse_value(value: Any | List | Dict | Iterable) Any | List | Dict | Iterable#

Parse a string, mappable (dict, Dict), iterable (list, tuple) to account for units conversion, some basic arithmetic, and design variables. This is the main parsing function of Qiskit Metal.

Parameters:
  • value (str) – String to parse or

  • variable_dict (dict) – dict pointer of variables

Returns:

Parse value

Return type:

str, float, list, tuple, or ast eval

Handled Inputs:
Strings:
Strings of numbers, numbers with units; e.g., ‘1’, ‘1nm’, ‘1 um’

Converts to int or float. Some basic arithmetic is possible, see below.

Strings of variables ‘variable1’.

Variable interpretation will use string method isidentifier ‘variable1’.isidentifier()`

Dictionaries:

Returns ordered Dict with same key-value mappings, where the values have been subjected to parse_value.

Itterables(list, tuple, …):

Returns same kind and calls itself parse_value on each element.

Numbers:

Returns the number as is. Int to int, etc.

Arithemetic:

Some basic arithmetic can be handled as well, such as ‘-2 * 1e5 nm’ will yield float(-0.2) when the default units are set to mm.

Default units:

User units can be set in the design. The design will set config.DEFAULT.units

Examples

See the docstring for this module.

>> ?qiskit_metal.toolbox_metal.parsing

populate_to_track_table_usage() None#

Use the element_handler to get a list of all the table names used in QGeometry.

The dict qgeometry_able_usage should get updated by add_qgeometry(). This dict is used to get a summary tables used for this component.

qgeometry_bounds() Tuple#

Fetched the component bound dict_value.

Returns:

containing (minx, miny, maxx, maxy) bound values for the bounds of the component as a whole.

Return type:

tuple

Uses:

design.qgeometry.get_component_bounds

qgeometry_dict(element_type: str) Dict[str, BaseGeometry]#

Returns a dict of element qgeometry (shapely geometry) of the component as a python dict, where the dict keys are the names of the qgeometry and the corresponding values are the shapely geometries.

Parameters:

element_type (str) – Name of element table or type; e.g., ‘poly’ and ‘path’

Returns:

Geometry diction or None if an error in the name of the element type (ie. table)

Return type:

List[BaseGeometry]

qgeometry_list(element_type: str = 'all') List[BaseGeometry]#

Returns a list of element qgeometry (shapely geometry) of the component as a python list of shapely geometries.

Parameters:

element_type (str) – Name of element table or type; e.g., ‘poly’ and ‘path’. Can also specify all

Returns:

Geometry list or None if an error in the name of the element type (ie. table)

Return type:

List[BaseGeometry]

qgeometry_plot(ax: matplotlib.axes.Axes = None, plot_kw: dict = None) List#

Draw all the qgeometry of the component (polys and path etc.)

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axis to draw on. Defaults to None. When None, it gets the current axis.

  • plot_kw (dict) – Parameters dictionary.

Returns:

The list of qgeometry draw

Return type:

List

Example use:

Suppose you had a component called q1:

fig, ax = draw.mpl.figure_spawn() q1.qgeometry_plot(ax)

qgeometry_table(element_type: str) DataFrame#

Returns the entire element table for the component.

Parameters:

element_type (str) – Name of element table or type; e.g., ‘poly’ and ‘path’

Returns:

Element table for the component or None if an error in the name of the element type (ie. table)

Return type:

pd.DataFrame

rebuild()#

Builds the QComponent.

This is the main action function of a QComponent, call it qc. It converts the qc.options into QGeometry with all of the required options, such as the geometry points, layer number, materials, etc. needed to render.

The build clears the existing QGeometry and QPins and then calls the qc.make function, which is written by the component developer to implement the logic (using the metal. draw module) to convert the qc.options into the QGeometry.

Build status: The function also sets the build status of the component. It sets to failed when the component is created, and then it sets to good when it is done with no errors. The user can also set other statuses, which can appear if the code fails to reach the final line of the build, where the build status is set to good.

Raises:

Exception – Component build failure

set_lead(name: str) QRoutePoint#

Defines the lead_extension by adding a point to the self.head/tail.

Parameters:

name – String (supported pin names are: start, end)

Returns:

Last point in the QRouteLead (self.head/tail)

Return type:

QRoutePoint

Raises:

Exception – Ping name is not supported

set_lead_extension(name: str) QRoutePoint#

Defines the jogged lead_extension by adding a series of turns to the self.head/tail.

Parameters:

name – String (supported pin names are: start, end)

Returns:

Last point in the QRouteLead (self.head/tail)

Return type:

QRoutePoint

Raises:
  • Exception – Ping name is not supported

  • Exception – Dictionary error

set_pin(name: str) QRoutePoint#

Defines the CPW pins and returns the pin coordinates and normal direction vector.

Parameters:

name – String (supported pin names are: start, end)

Returns:

Last point (for now the single point) in the QRouteLead

Return type:

QRoutePoint

Raises:

Exception – Ping name is not supported

to_script(thin: bool = False, is_part_of_chip: bool = False) Tuple#
Parameters:
  • thin – If true then any key in the QComponent’s options whose value is the same value as the default will not be included in the body

  • is_part_of_chip – If true, body will not include header code

Returns: Code that if copy-pasted into a .py file would generate an instance of this class with the same properties as the instance calling this function