kqcircuits.elements.element

kqcircuits.elements.element.get_refpoints(layer, cell, cell_transf=r0 0, 0, rec_levels=None)[source]

Returns Refpoints object for extracting reference points from given layer and cell.

Parameters
  • layer – layer specification for source of refpoints

  • cell – cell containing the refpoints

  • cell_transf – transform for converting refpoints into target coordinate system

  • rec_levels – recursion level when looking for refpoints from subcells. Set to 0 to disable recursion.

Returns

Refpoints object, which behaves like dictionary, where keys are refpoints names, values are DPoints.

kqcircuits.elements.element.insert_cell_into(target_cell, cell, trans=None, inst_name=None, label_trans=None, align_to=None, align=None, rec_levels=0, **parameters)[source]

Inserts a subcell into a given target cell.

Note: This general method is useful to insert cells or elements into a static cell. To insert cells into an Element, use the elements’ insert_cell method, which has additional features such as parameter inheritance.

It will use the given cell object or if cell is an Element class’ name then directly take the provided keyword arguments to first create the cell object.

If inst_name given, a label inst_name is added to labels layer at the base refpoint and label_trans transformation.

Parameters
  • target_cell – Cell object to insert into

  • cell – cell object or Element class name

  • trans – used transformation for placement. None by default, which places the subcell into the coordinate origin of the parent cell. If align and align_to arguments are used, trans is applied to the cell before alignment transform which allows for example rotation of the cell before placement.

  • inst_name – possible instance name inserted into subcell properties under id. Default is None

  • label_trans – relative transformation for the instance name label

  • align_toDPoint or DVector location in parent cell coordinates for alignment of cell. Default is None

  • align – name of the cell refpoint aligned to argument align_to. Default is None

  • rec_levels – recursion level when looking for refpoints from subcells. Set to 0 to disable recursion.

  • **parameters – PCell parameters for the element, as keyword argument

Returns

tuple of placed cell instance and reference points with the same transformation

class kqcircuits.elements.element.Element[source]

Bases: klayout.db.pcell_declaration_helper._PCellDeclarationHelper

Element PCell declaration.

PCell parameters for an element are defined as class attributes of Param type. Elements have ports.

LIBRARY_NAME = 'Element Library'
LIBRARY_DESCRIPTION = 'Superconducting quantum circuit library for elements.'
LIBRARY_PATH = 'elements'
static create_cell_from_shape(layout, name)[source]
classmethod create(layout, library=None, **parameters) klayout.dbcore.Cell[source]

Create cell for this element in layout.

Parameters
  • layout – pya.Layout object where this cell is created

  • library – LIBRARY_NAME of the calling PCell instance

  • **parameters – PCell parameters for the element as keyword arguments

classmethod create_subtype(layout, library=None, subtype=None, **parameters)[source]

Create cell from an abstract class using the specified sub-class type.

This is to be called from the create() function of abstract classes. It takes care of creating a code generated or a file based cell.

Parameters
  • layout – pya.Layout object where this cell is created

  • library – LIBRARY_NAME of the calling PCell instance

  • subtype – name (str) of the desired sub-class of cls

  • **parameters – PCell parameters for the element as keyword arguments

Returns

tuple of the cell instance and a boolean indicating code generated cell

classmethod create_with_refpoints(layout, library=None, refpoint_transform=r0 0, 0, rec_levels=None, **parameters)[source]

Convenience function to create cell and return refpoints too.

Parameters
  • layout – pya.Layout object where this cell is created

  • library – LIBRARY_NAME of the calling PCell instance

  • refpoint_transform – transform for converting refpoints into target coordinate system

  • rec_levels – recursion level when looking for refpoints from subcells. Set to 0 to disable recursion.

  • **parameters – PCell parameters for the element, as keyword argument

add_element(cls, **parameters)[source]

Create a new cell for the given element in this layout.

Parameters
  • cls – Element subclass to be created

  • **parameters – PCell parameters for the element as keyword arguments

Returns

the created cell

insert_cell(cell, trans=None, inst_name=None, label_trans=None, align_to=None, align=None, rec_levels=0, **parameters)[source]

Inserts a subcell into the present cell.

It will use the given cell object or if cell is an Element class’ name then directly take the provided keyword arguments to first create the cell object.

If inst_name given, the refpoints of the cell are added to the self.refpoints with inst_name as a prefix, and also adds a label inst_name to “`”labels layer” at the base refpoint and label_trans transformation.

Parameters
  • cell – cell object or Element class name

  • trans – used transformation for placement. None by default, which places the subcell into the coordinate origin of the parent cell. If align and align_to arguments are used, trans is applied to the cell before alignment transform which allows for example rotation of the cell before placement.

  • inst_name – possible instance name inserted into subcell properties under id. Default is None

  • label_trans – relative transformation for the instance name label

  • align_to – location in parent cell coordinates for alignment of cell. Can be either string indicating the parent refpoint name, DPoint or DVector. Default is None

  • align – name of the cell refpoint aligned to argument align_to. Default is None

  • rec_levels – recursion level when looking for refpoints from subcells. Set to 0 to disable recursion.

  • **parameters – PCell parameters for the element, as keyword argument

Returns

tuple of placed cell instance and reference points with the same transformation

face(face_id=0)[source]

Returns the face dictionary corresponding to face_id.

The face dictionary contains key “id” for the face ID and keys for all the available layers in that face.

Parameters

face_id – name or index of the face, default=0

pcell_params_by_name(cls=None, **parameters)[source]

Give PCell parameters as a dictionary.

Parameters
  • cls – Return only parameters present in this class. All by default.

  • **parameters – Optionally update with other keyword arguments

Returns

A dictionary of all PCell parameter names and corresponding current values.

add_port(name, pos, direction=None, face_id=0)[source]

Add a port location to the list of reference points as well as ports layer for netlist extraction

Parameters
  • name – name for the port. Will be “decorated” for annotation layer, left as is for port layer. If evaluates to False, it will be replaced with port

  • pos – pya.DVector or pya.DPoint marking the position of the port in the Element base

  • direction – direction of the signal going _to_ the port to determine the location of the “corner” reference point which is used for waveguide direction. If evaluates to False as is the default, no corner point is added.

  • face_id – name or index of the face, default=0

copy_port(name, cell_inst, new_name=None)[source]

Copy a port definition from a different cell and instance; typically used to expose a specific subcell port.

Parameters
  • name – Name of the port as it was specified to add_port

  • cell_inst – Instance of the cell, used to transform the port location correctly.

  • new_name – Optionally rename the port

classmethod get_schema(noparents=False, abstract_class=None)[source]

Returns the combined parameters of the class “cls” and all its ancestor classes.

Parameters
  • noparents – If True then only return the parameters of “cls”, not including ancestors.

  • abstract_class – Return parameters up to this abstract class if specified.

produce_impl()[source]

This method builds the PCell.

Adds all refpoints to user properties and draws their names to the annotation layer.

build()[source]

Child classes re-define this method to build the PCell.

post_build()[source]

Child classes may re-define this method for post-build operations.

display_text_impl()[source]

default implementation

get_refpoints(cell, cell_transf=r0 0, 0, rec_levels=None)[source]

See get_refpoints.

get_layer(layer_name, face_id=0)[source]

Returns the specified Layer object.

Parameters
  • layer_name – layer name text

  • face_id – Name or index of the face to use, default=0

raise_error_on_cell(error_msg, position=0, 0)[source]

Replaces cell with error text in the annotation layer, and raises ValueError with the same error message.

Parameters
  • error_msg – the error message

  • position – location of the text center (optional)

add_protection(shape, face_id=0)[source]

Add ground grid avoidance shape on given face (and on opposing face if self.protect_opposite_face is True). Use this function to protect signal carrying elements that typically include some metal between gaps. Do not use this function with pure flip-chip connectors, TSVs, or airbridges that doesn’t include metal gaps.

Parameters
  • shape – The shape (Region, DPolygon, etc.) to add to ground_grid_avoidance layer

  • face_id – Name or index of the primary face of ground_grid_avoidance layer, default=0

sync_parameters(abc)[source]

Syncronise the calling class’ parameters with a JSON representation.

This is called several times from coerce_parameters_impl() while using the PCell editor GUI. Particularly, each time a parameter of abc’s sub-class is changed by the user. It figures out which parameter is changed and updates the *_parameters JSON strings accordingly, or the other way around.

For example, if abc is Fluxline and the fluxline_width parameter is changed in GUI then the fluxline_parameters JSON string will be updated with this value. Or if fluxline_parameters string is changed then the corresponding fluxline parameter of the calling pcell is updated.

Parameters

abc – An abstract class. Only consider parameters of this class’ descendants

classmethod get_sim_ports(simulation)[source]

List of RefpointToSimPort objects defining which refpoints should be turned to simulation ports for the given element class

Returns empty list if not implemented for Element subclass. When implementing this method, the best practice is for this method to have no “side effects”, that is all code contained within this method should only serve to derive the list of RefpointToSimPort objects and nothing else: no change in element’s geometry or parameter values.

Parameters
  • cls – Element class, this is a class method

  • simulation – Simulation object where a cell of this element class is placed. Use this argument if you need to decide certain arguments for RefpointToSimPort objects based on simulation’s parameters

Returns

List of RefpointToSimPort objects, empty list by default

static left_and_right_waveguides(simulation)[source]

A common implementation of get_sim_ports that adds left and right waveguides to port_a and port_b respectively. The a and b values of right waveguide can be adjusted separately.

static face_changer_waveguides(simulation)[source]

A common implementation of get_sim_ports that adds waveguides on both sides of a face-changing element. The port names are ‘{face_ids[0]}_port’ and ‘{face_ids[1]}_port’. The first port points to left and the second port orientation is determined by output_rotation parameter. The a and b values of the second waveguide are adjusted by a2 and b2 parameters.

PCell parameters:

  • a (Double) - Width of center conductor, default=10, unit=μm

  • b (Double) - Width of gap, default=6, unit=μm

  • n (Int) - Number of points on turns, default=64

  • r (Double) - Turn radius, default=100, unit=μm

  • margin (Double) - Margin of the protection layer, default=5, unit=μm

  • face_ids (List) - Chip face IDs list, default=['1t1', '2b1', '1b1', '2t1']

  • display_name (String) - Name displayed in GUI (empty for default), default=

  • protect_opposite_face (Boolean) - This applies only on signal carrying elements that typically include some metal between gaps., default=False

  • opposing_face_id_groups (List) - Opposing face ID groups (list of lists), default=[['1t1', '2b1']]

  • etch_opposite_face (Boolean) - Etch avoidance shaped gap on the opposite face too, default=False

  • etch_opposite_face_margin (Double) - Margin of the opposite face etch shape, default=5, unit=μm

../_images/kqcircuits.elements.element.png