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.

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)[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 a base class using the specified sub-class type.

This is to be called from the create() function of base classes of other elements. 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_index=0)[source]

Returns the face dictionary corresponding to self.face_ids[face_index].

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

Parameters

face_index – index of the face_id in self.face_ids, 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 – index of the face id, 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)[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.

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 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 – index of the face id, 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, opposite_face_id=1)[source]

Add ground grid protection shape

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

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

  • opposite_face_id – opposite face index, will be used if protect_opposite_face is True, default=1

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) - Add opposite face protection too, default=False

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