quantcore_circuits.designer =========================== .. py:module:: quantcore_circuits.designer .. autoapi-nested-parse:: Code-first chip design (Metal-style), drawn live in KLayout as you type. >>> d = Designer("q1_r1", box=(0, 0, 7500, 7500), chip={"name_chip": "Q1R1"}, live=True) # opens KLayout >>> pw = d.add("PAD_W", "BondPad", at=(1125, 3750), rot=270) >>> pe = d.add("PAD_E", "BondPad", at=(6375, 3750), rot=90) >>> fl = d.route("FL", pw.a, pe.a) # ports are attributes >>> q1 = d.add("Q1", "Xmon", at=(2975, 2200), cross_length=300, junction={"Lj_nH": 12, "Cj_fF": 2}) >>> d.route("R1", q1.claw_n, fl.hanger(s=2000, length=300, side="right"), meander=4200) >>> d.save("examples/my_chip.json"); d.lom().model # design.json and its lumped circuit Every ``add``/``route``/``set`` validates immediately (unknown cells, parameters or ports raise with the list of valid ones) and, with ``live=True``, rebuilds the chip (≈0.1 s warm), writes ``build/.oas`` + sidecar and reloads KLayout through klive. A change that cannot be routed yet (e.g. a route to a component not placed yet) keeps the last good layout and prints why. ``with d.batch():`` groups changes into one rebuild. The result is an ordinary ``design.json``, so the KLayout plugin, ``qcc watch``, simulation and analysis all work on it unchanged. Classes ------- .. autoapisummary:: quantcore_circuits.designer.Designer quantcore_circuits.designer.InstanceHandle quantcore_circuits.designer.PortRef quantcore_circuits.designer.RouteHandle Module Contents --------------- .. py:class:: Designer(name: str, box=(0.0, 0.0, 10000.0, 10000.0), pdk: str = DEFAULT_PDK, chip: dict | None = None, launchers: str | dict | None = None, live: bool = False, out: str | pathlib.Path | None = None, delay: float = 0.0, open_klayout: bool | None = None, verbose: bool = True) .. py:method:: add(name: str, cell, at=None, rot: float = 0.0, mirror: bool = False, snap: str | None = None, to: str | None = None, snap_gap: float = 0.0, junction: dict | None = None, edge: str | None = None, **params) -> InstanceHandle Place a component: ``cell`` is a class (``Xmon``) or name; ``params`` are its PCell parameters. Absolute placement with ``at``/``rot``, or port snap with ``snap="port"`` (own port) and ``to=`` another instance's port (``q1.claw_n``, optional ``snap_gap``); the rebuild solves the rotation. ``edge`` ("n", "s", "e", "w" or "auto") applies the Quantcore pad rule to an absolute placement: the instance slides perpendicular to that die edge until the outer edge of its etch is the PDK pad distance (PDK ``frame.pad_edge``, 100 µm) from it. ``junction`` holds the lumped junction values for the LOM and the simulations: ``{"Lj_nH", "Cj_fF", "flux_phi0", "asym"}`` (L_J at zero flux, C_J, a SQUID's flux Φ/Φ0 and asymmetry d; without ``Lj_nH`` the drawn trilayer junction's PDK value is used). All other keyword arguments are cell parameters (e.g. the Xmon's ``gap``). .. py:method:: array(name: str, cell, origin=(0.0, 0.0), pitch=(100.0, 100.0), shape=(1, 1), rot: float = 0.0, vary: dict | None = None, **params) -> list[InstanceHandle] Place ``shape = (columns, rows)`` copies of a cell on a grid (test-pad and junction arrays). Instances are named ``__``. ``vary`` maps a parameter to one value per copy (column-major, e.g. a junction-width sweep); the other ``params`` are shared. .. py:method:: batch() Group several changes into one rebuild. .. py:method:: couple(name: str, a: str, b: str, C_fF: float | None = None, L_nH: float | None = None, note: str = '', wire: bool = False) -> None Declare a lumped coupling no route or snap carries (e.g. qubit arms facing each other). ``a``/``b`` are ``"Q1"`` (main island), ``"Q1."``, ``"Q1."`` or a route name (its conductor, e.g. a hanger against a routed feedline: ``d.couple("K_R1", "R1", "FL")``); give ``C_fF`` (default C, value optional: a C-matrix fills it by island name) or ``L_nH``. ``wire=True`` declares a galvanic join of two *ports* instead (no element, no geometry): for overlapping metal, e.g. a legacy resonator end drawn inside a claw tail. .. py:method:: drc() .. py:method:: free_end(at, dir: float | None = None, term: float = 0.0) -> dict :staticmethod: .. py:method:: load(source, autosave: bool | None = None, **kw) -> Designer :classmethod: Open a saved design. ``autosave`` (default: the ``live`` setting) writes every rebuild back to ``source``: on in a live KLayout session, so the plugin and ``qcc watch`` see your edits; off in scripts, tests and ``QCC_LIVE=0`` notebooks, so loading a design never rewrites it by accident (``d.save(path)`` still does). .. py:method:: lom(select: list[str] | None = None) Lumped circuit of this layout (component estimates; see :mod:`quantcore_circuits.lom`). .. py:method:: remove(name: str) -> None .. py:method:: route(name: str, start, end, meander: float | None = None, type: str | None = None, nodes=None, a: float | None = None, b: float | None = None, r: float | None = None, airbridges=None, meander_direction: int | None = None, **params) -> RouteHandle Connect two ports with a CPW (``meander=length`` for a fixed-length meander). ``end`` may be a port, ``other_route.hanger(...)`` or ``Designer.free_end(...)``; ``nodes`` are waypoints (tuples or :meth:`waypoint`). ``meander_direction=-1`` mirrors the meander (its first turn goes the other way). .. py:method:: save(path: str | pathlib.Path) -> pathlib.Path .. py:method:: show(quiet_errors: bool = False) Build, write ``build/.oas`` (+ sidecar) and reload KLayout (starting it if needed). .. py:method:: sim_group(name: str, select: list[str], margin_um: float = 300.0, analyses=('eigenmode_epr', 'q3d_cmatrix'), ports: dict[str, str] | None = None, settings: dict | None = None) -> None A FEM sub-problem. ``ports`` maps a selected route to ``"keep"`` (not cut for capacitance analyses), ``"edge"`` or ``"internal"``; ``"edge"`` on a grounded line the box cuts (e.g. a qubit's λ/4 readout when only the qubit is selected) terminates it in 50 Ω there for eigenmode / driven runs. ``settings`` are passed to the simulation (solver options). .. py:method:: sim_subset(name: str, pairs=None, qubits=None, margin_um: float = 300.0, analyses=('eigenmode_epr', 'q3d_cmatrix'), settings: dict | None = None, split: str = 'auto', verbose: bool = False, readouts: bool = True) -> list[str] Simulate a subset of the chip (:mod:`quantcore_circuits.sim_tools.subset`): ``pairs=[("Q3", "R3"), ("Q5", "R5")]`` (resonator None → the qubit's readout) or ``qubits=["Q3", "Q5"]``. Each chosen qubit comes with its readout chain; the feedline is always in the box and cut into 50 Ω ports by it; a bus between two chosen qubits comes in, a bus to a qubit outside the subset is cut (``ports={bus: "cut"}``: a 50 Ω stub at the chosen qubit's pad). Disjoint pairs get one box each (``split="auto"``; ``"one"``: one box). Adds one sim group per box and returns their names (``name`` itself when there is one box, else ``_``). The netlist is not touched: ``fill(whole_chip_model, design, [jobs])`` fills only these components. ``readouts=False``: the qubits alone (the box cuts their readouts into 50 Ω lines; an eigenmode box that fits a workstation). .. py:method:: targets(**per_instance) -> None .. py:method:: waypoint(at, a: float | None = None, b: float | None = None, airbridge: bool = False, **params) -> dict :staticmethod: .. py:property:: chip_ports :type: dict Chip-level (launcher) ports, referenced as ``"chip."``. .. py:attribute:: data :type: dict .. py:property:: design .. py:attribute:: history :type: list[str] :value: [] .. py:attribute:: out .. py:attribute:: path :type: pathlib.Path | None :value: None .. py:attribute:: result :value: None .. py:class:: InstanceHandle(designer: Designer, name: str) .. py:method:: move(at=None, rot=None, edge: str | None = None) -> InstanceHandle Move / rotate; ``edge`` ("n"/"s"/"e"/"w"/"auto") puts the outer edge of the etch at the PDK pad distance (``frame.pad_edge``, 100 µm) from that die edge. .. py:method:: set(**params) -> InstanceHandle Change cell parameters (``at=`` / ``rot=`` are accepted too; ``junction=`` replaces the junction dict, e.g. ``{"Lj_nH": 7.0, "flux_phi0": 0.2, "asym": 0.1}``). .. py:property:: ports :type: dict .. py:property:: spec :type: dict .. py:class:: PortRef Bases: :py:obj:`str` ``"Q1.claw_n"`` with the port's geometry attached (``.pos``, ``.dir``, ``.a``, ``.b`` in the local frame). .. py:class:: RouteHandle(designer: Designer, name: str) .. py:method:: hanger(s: float | None = None, length: float = 300.0, side: str = 'left', ground_gap: float = 6.0, direction: str = 'forward', end: str = 'short', open_gap: float = 6.0, bend: bool = True, near=None, coupler_gap: float | None = None, line_gap: float | None = None) -> dict End spec for a λ/4 coupler running along this route (use as another route's ``end``). ``bend=False`` enters the coupler straight instead of with a 90° bend; ``direction`` flips which end is terminated. ``near=(x, y)`` instead of ``s`` centres the coupler at the point of this route nearest to (x, y). ``coupler_gap`` / ``line_gap`` narrow the two facing gaps along the coupler (closer, stronger coupling). .. py:method:: set(**kw) -> RouteHandle .. py:property:: length :type: float | None .. py:property:: spec :type: dict