kqcircuits.util.node

class kqcircuits.util.node.Node(position: DPoint, element: Type[Element] | None = None, inst_name: str | None = None, align: tuple = (), angle: float | None = None, length_before: float | None = None, length_increment: float | None = None, meander_direction: int = 1, **params)[source]

Bases: object

Specifies a single node of a composite waveguide.

Node is as a position and optionally other parameters. The element argument sets an Element type that gets inserted in the waveguide. Typically this is an Airbridge, but any element with port_a and port_b is supported.

Parameters:
  • position – The location of the Node. Represented as a DPoint object.

  • element – The Element type that gets inserted in the waveguide. None by default.

  • inst_name – If an instance name is supplied, the element refpoints will be exposed with that name. Default None.

  • align – Tuple with two refpoint names that correspond the input and output point of element, respectively Default value (None) uses ('port_a', 'port_b')

  • angle – Angle of waveguide direction in degrees

  • length_before – Length of the waveguide segment before this node

  • length_increment – Waveguide length increment produced by meander before this node

  • **params – Other optional parameters for the inserted element

Returns:

A Node.

position: DPoint
element: Type[Element] | None
align: Tuple
inst_name: str | None
angle: float | None
length_before: float | None
length_increment: float | None
meander_direction: int
classmethod deserialize(serialized_node: tuple[float, float] | tuple[float, float, str | None | dict] | tuple[float, float, str | None, dict])[source]

Create a Node object from a serialized form, such that from_serialized(ast.literal_eval(str(node_object))) returns an equivalent copy of node_obj.

Parameters:
  • serialized_node – serialized node, consisting of a tuple (x, y, element_name, params), where x and

  • optional. (y are the node coordinates. The string element_name and dict params are) –

Returns: a Node

static nodes_from_string(nodes: list[str] | str) list[Node][source]

Converts the human-readable text representation of Nodes to an actual Node object list.

Needed for storage in KLayout parameters. The string has to conform to a specific format: (x, y, class_str, parameter_dict). For example (0, 500, ‘Airbridge’, {‘n_bridges’: 2}), see also the Node.__str__ method. Empty class_str or parameter_dict may be omitted.

Returns:

list of Node objects

../_images/kqcircuits.util.node.png