quantcore_circuits.cli ====================== .. py:module:: quantcore_circuits.cli .. autoapi-nested-parse:: ``qcc`` command line. Attributes ---------- .. autoapisummary:: quantcore_circuits.cli.LABEL_HEIGHT_HELP quantcore_circuits.cli.app quantcore_circuits.cli.circuit_app quantcore_circuits.cli.design_app quantcore_circuits.cli.hfss_app quantcore_circuits.cli.results_app quantcore_circuits.cli.runner_app quantcore_circuits.cli.sim_app Functions --------- .. autoapisummary:: quantcore_circuits.cli.analyse quantcore_circuits.cli.build quantcore_circuits.cli.circuit_export quantcore_circuits.cli.circuit_layout quantcore_circuits.cli.circuit_simulate quantcore_circuits.cli.components quantcore_circuits.cli.dashboard quantcore_circuits.cli.design_drc quantcore_circuits.cli.design_hash_cmd quantcore_circuits.cli.design_junctions quantcore_circuits.cli.design_netlist quantcore_circuits.cli.design_placement_junction quantcore_circuits.cli.design_ports quantcore_circuits.cli.design_to_python_cmd quantcore_circuits.cli.design_validate quantcore_circuits.cli.hfss_check quantcore_circuits.cli.hfss_collect quantcore_circuits.cli.hfss_render quantcore_circuits.cli.hfss_solve quantcore_circuits.cli.kqc_files quantcore_circuits.cli.main quantcore_circuits.cli.mask quantcore_circuits.cli.results_apply_cmd quantcore_circuits.cli.results_collect quantcore_circuits.cli.results_extract quantcore_circuits.cli.results_import_cmd quantcore_circuits.cli.results_propose_cmd quantcore_circuits.cli.results_show quantcore_circuits.cli.results_template_cmd quantcore_circuits.cli.review quantcore_circuits.cli.runner_serve quantcore_circuits.cli.runner_status quantcore_circuits.cli.selftest quantcore_circuits.cli.sim_auto_cmd quantcore_circuits.cli.sim_build quantcore_circuits.cli.sim_preview_cmd quantcore_circuits.cli.sim_run quantcore_circuits.cli.sim_submit quantcore_circuits.cli.sim_subset_cmd quantcore_circuits.cli.synth quantcore_circuits.cli.watch Module Contents --------------- .. py:function:: analyse(design: pathlib.Path, job: pathlib.Path, group: str = typer.Option(None, '--group', '-g', help="Sim group (default: the job's)"), run_dir: pathlib.Path = typer.Option(None, help='Dashboard run directory (default build/)'), readout: bool = typer.Option(True, help='Simulate the readout (χ from transmission) with QuTiP'), propose: bool = typer.Option(False, '--feedback', help='Also propose the next design revision (surrogate)')) Job results → circuit.json → Metal LOM / QuCat / SQcircuit / scqubits / QuTiP → consensus vs targets. .. py:function:: build(design: pathlib.Path, out: pathlib.Path = typer.Option(None, '-o', help='Output .oas/.gds (default build/.oas)'), show: bool = typer.Option(False, help='Send to KLayout via klive'), keep_going: bool = typer.Option(False, '--keep-going', help="A route that cannot be built is left out (named in the sidecar's failed_routes, its last good route kept in .last_good_routes.json) instead of failing the build. The default is strict."), label_height: float = typer.Option(None, '--label-height', help=LABEL_HEIGHT_HELP)) Build DESIGN (.json/.py) into a KQC chip and write it. .. py:function:: circuit_export(design: pathlib.Path, group: str = typer.Option('chip', '--group', '-g', help="'chip' (all) or a sim_groups name"), out: pathlib.Path = typer.Option(None, '-o', help='Output circuit.json (default build/.circuit.json)')) Layout → LOM netlist: components' lumped models joined along routes/snaps (values = component estimates). .. py:function:: circuit_layout(circuit: pathlib.Path, out: pathlib.Path = typer.Option(..., '-o', help='Output design.json'), live: bool = typer.Option(False, help='Lay it out live in KLayout')) LOM -> layout: transmon + lambda/4 pairs with targets -> knobs -> a laid-out feedline chip. .. py:function:: circuit_simulate(source: pathlib.Path = typer.Argument(..., help='circuit.json, or a design (its layout LOM is used)'), job: pathlib.Path = typer.Option(None, help='Fill capacitances from this simulation job (design input only)'), group: str = typer.Option('chip', '--group', '-g'), json_out: pathlib.Path = typer.Option(None, '--json', help='Also write the result (modes, params, netlist values) as JSON'), png: pathlib.Path = typer.Option(None, '--png', help='Also draw the circuit schematic (matplotlib) to this PNG')) LOM simulation: QuCat normal modes + kappa, QuTiP dressed spectrum -> f_q, alpha, f_r, chi, kappa. .. py:function:: components(cell: str = typer.Argument(None, help='Show ports of this cell (name, dotted path or metal:)'), category: str = typer.Option(None, '--category', '-c', help='Only this category (qubit, coupler, launcher, ...)'), source: str = typer.Option(None, '--source', '-s', help='Only this source: quantcore, kqc or metal'), as_json: bool = typer.Option(False, '--json', help='Machine-readable: refs (or ports with CELL)'), details: bool = typer.Option(False, '--details', help='With --json: full catalog records instead of refs'), show_all: bool = typer.Option(False, '--all', help='Include whole KQC chips and Metal routes (not cells)'), outline: bool = typer.Option(False, '--outline', help='With CELL --json: also its bbox and a simplified outline (the KLayout placement ghost)'), params: str = typer.Option('{}', '--params', help='With CELL: PCell parameters as JSON'), schema: bool = typer.Option(False, '--schema', help='With CELL: its editable parameters and defaults (JSON)'), schemas: bool = typer.Option(False, '--schemas', help="Every listed cell's editable parameters in one JSON (the KLayout PCell library)"), oas: pathlib.Path = typer.Option(None, '--oas', help='With CELL: write its geometry (a static cell) to this OASIS file'), design: pathlib.Path = typer.Option(None, '--design', help='With CELL --oas: build it as in this design (chip-inherited parameters, PDK junction)')) List available components (Quantcore, KQC, Quantum Metal) by category, or the ports of one. .. py:function:: dashboard(run: str = typer.Argument(None, help='Run name (build/); default: follow the run with the latest activity'), port: int = 8765, open_browser: bool = True, root: pathlib.Path = typer.Option(None, help='Folder with the run directories (default: /build)')) Live dashboard that follows the notebooks' tracked runs (``track.start(...)`` / ``QCC_TRACK=1``). .. py:function:: design_drc(design: pathlib.Path, netlist: bool = typer.Option(True, help='Also run the KQC netlist check'), keep_going: bool = typer.Option(False, '--keep-going', help='Report a route that cannot be built (route_failed) and check the rest, instead of stopping at it')) Connectivity DRC: dangling ports, components without LOM, outside chip, overlaps, crossings, opens/shorts. .. py:function:: design_hash_cmd(design: pathlib.Path) .. py:function:: design_junctions(design: pathlib.Path, names: list[str] = typer.Argument(None, help='Only these instances (default: every component with a junction)'), as_json: bool = typer.Option(False, '--json'), default: bool = typer.Option(False, '--default', help='No names: the qubits of the default simulation subset')) Each junction as the LOM and the eigenmode / driven exports take it: L_J0, C_J, flux Φ/Φ0, asymmetry d, L at that flux and the source (design or drawn trilayer junction, PDK rule). Exit 1 when one has no L_J. .. py:function:: design_netlist(design: pathlib.Path) M3 netlist check: declared connections vs. the KQC geometric netlist (opens/shorts with coordinates). .. py:function:: design_placement_junction(cell: str, params: str = typer.Option('{}', '--params', help='Cell parameters as JSON')) JSON of the junction values a new CELL gets when placed (``{"Lj_nH", "Cj_fF", "source"}``: the drawn trilayer junction's PDK value, else the PDK nominal SQUID), or ``null`` for a component without a junction. .. py:function:: design_ports(design: pathlib.Path, as_json: bool = typer.Option(False, '--json')) All resolved ports of a design (absolute positions), e.g. for the KLayout plugin's connect dialog. .. py:function:: design_to_python_cmd(design: pathlib.Path, out: pathlib.Path = typer.Option(None, '-o', help='Output script (default: .py next to the design)'), check: bool = typer.Option(True, help='Run the script here and require the same design hash (default on)')) Write a readable Python script (the Designer API) that rebuilds DESIGN: the GUI prototype continues as code. The script writes the design.json again (``python design.py``); the round trip is checked (same ``qcc design hash``). Entries the Designer calls cannot say are written as plain data with a comment. .. py:function:: design_validate(design: pathlib.Path) .. py:function:: hfss_check(job: pathlib.Path) Read JOB's rendered .aedt back: stack, metal sheets, ports / terminations, nets and every solver setting. .. py:function:: hfss_collect(job: pathlib.Path, aedt: str = typer.Option('batch', '--aedt', help='batch (a new non-graphical AEDT, default) | gui (a new window)')) Re-export a solved job from its saved project as it is now (no solve), e.g. after you changed the setup in AEDT and solved there; then ``qcc results import DESIGN JOB``. Close the project in your own AEDT first, or run ``scripts/qcc_collect.py`` in that AEDT (Tools > Run Script) instead. .. py:function:: hfss_render(design: pathlib.Path, group: str = typer.Option('chip', '--group', '-g', help="'chip' (whole chip) or a sim_groups name"), analysis: str = typer.Option('eigenmode_epr', '--analysis', '-a', help='eigenmode_epr (default) | hfss_eigenmode | q3d_cmatrix | hfss_driven'), out: pathlib.Path = typer.Option(None, '-o', help='Job directory (default build/jobs/)'), solve: bool = typer.Option(False, help='Also solve (qcc_solve.py in a new non-graphical AEDT) and collect results'), settings: list[str] = typer.Option(None, '--set', help='Solver setting key=value (JSON value), repeatable, e.g. --set percent_error=1 --set mesh_size={"1t1_gap":10}'), airbridges: bool = typer.Option(None, '--airbridges/--no-airbridges', help="Keep airbridges in the simulated geometry (default: the group's setting, else dropped)"), timeout: float = typer.Option(None, help='Seconds before qcc kills the AEDT process tree it started'), open_gui: bool = typer.Option(False, '--open', help='Open the rendered project in a new AEDT GUI'), graphical: bool = typer.Option(False, help='Run the render with the AEDT window instead of -ng'), aedt: str = typer.Option(None, '--aedt', help='batch (new -ng AEDT, default) | gui (new AEDT window, left open) | attach (the open AEDT)'), show: bool = typer.Option(False, help='Also send the chip to KLayout via klive'), dry_run: bool = typer.Option(False, help='Export the job and print the AEDT command only')) Render DESIGN (whole chip or a sim group) into an AEDT project: geometry, stack, ports, Lj boundaries. .. py:function:: hfss_solve(job: pathlib.Path, timeout: float = typer.Option(None, help='Seconds before qcc kills the AEDT process tree it started'), graphical: bool = typer.Option(False, help='Run with the AEDT window instead of -ng'), aedt: str = typer.Option(None, '--aedt', help='batch (new -ng AEDT, default) | gui (new AEDT window, left open) | attach (the open AEDT)')) Solve an exported Ansys JOB directory (new batch AEDT, a new window or the open AEDT) and collect results. .. py:function:: kqc_files(version: str = typer.Option(None, '--version', help='kqcircuits version (default: the installed one).'), source: pathlib.Path = typer.Option(None, '--source', help='A KQCircuits checkout or a source zip, instead of the download.'), force: bool = typer.Option(False, '--force', help='Fetch again even when the cache has them.')) Fetch the KQCircuits files its PyPI package lacks: the simulation scripts and the label font. Downloads them for the installed kqcircuits release from github.com/iqm-finland/KQCircuits into the user cache (the HFSS / Q3D / Elmer export and KQC's chip-frame labels need them). Nothing to do for a KQCircuits checkout. .. py:function:: main(version: bool = typer.Option(False, '--version', callback=_version, is_eager=True, help='Show version.')) Quantcore circuits CLI. .. py:function:: mask(design: pathlib.Path, out: pathlib.Path = typer.Option(None, '-o'), positive: list[str] = typer.Option(None), cheese: bool = typer.Option(True, help="Cheese: the build's (PDK band or the original design's own); --no-cheese writes none"), round_corners: bool = typer.Option(True, '--round/--no-round', help='PDK corner rounding (r ∝ shortest dim.)'), grid: bool = typer.Option(False, help="KQC's whole-area ground grid (with_grid) instead of the PDK band")) Fab export with the PDK fab rules: layers 1/0–4/0, 50–53/0, 100/0, 300/301, 700, 800+, 1000/0+; --positive M1 inverts a layer. Corner rounding is on by default; the cheese is the build's own (the PDK band unless the design has its own cheese, which wins). Simulation exports never get either. .. py:function:: results_apply_cmd(design: pathlib.Path, proposal: pathlib.Path = typer.Argument(..., help='proposal.json from `qcc results propose -o`'), out: pathlib.Path = typer.Option(None, '-o', help='Write the new design here (default: overwrite DESIGN)')) DESIGN with the proposal's knobs set (refuses when the design changed since the proposal). .. py:function:: results_collect(job: pathlib.Path) Parse solver outputs in JOB into results/results.json. .. py:function:: results_extract(design: pathlib.Path, job: pathlib.Path, store: pathlib.Path = typer.Option(None, help='Results store (sqlite)')) Extract Hamiltonian parameters from JOB results and compare with design targets. .. py:function:: results_import_cmd(design: pathlib.Path, sources: list[pathlib.Path] = typer.Argument(..., help='Solved job folder(s) or results.json file(s)'), group: str = typer.Option(None, '--group', '-g', help='Sim group the results belong to (default: from the job)')) Read solved results back (a job folder, its results/ folder or a results.json: format in `qcc results template --format`), check them against the design and analyse them (the KLayout Results tab shows the outcome). .. py:function:: results_propose_cmd(design: pathlib.Path, job: list[pathlib.Path] = typer.Option(None, '--job', help="Job folder(s) to analyse (default: the last run's, else the layout estimates)"), out: pathlib.Path = typer.Option(None, '-o', help='Write the proposal (JSON) here')) Propose the next design revision (loop.feedback: every qubit with a LOM model and a lambda/4 or lambda/2 readout) as old -> new knob values; nothing is written to the design. ``qcc results apply`` sets them. .. py:function:: results_show(design: pathlib.Path, store: pathlib.Path = typer.Option(Path('results.sqlite'))) .. py:function:: results_template_cmd(design: pathlib.Path, out: pathlib.Path = typer.Option(None, '-o', help='Write the skeleton here (default: print it)'), group: str = typer.Option('chip', '--group', '-g'), analysis: str = typer.Option('q3d_cmatrix', '--analysis', '-a'), show_format: bool = typer.Option(False, '--format', help='Print the results.json format description instead')) A results.json skeleton with this design's net names (with --format: the format description). .. py:function:: review(design: pathlib.Path, port: int = 8765, open_browser: bool = True, run_dir: pathlib.Path = typer.Option(None, help='Run directory (default build/)')) Open the live dashboard for DESIGN: steps, goal, plots, circuit, Hamiltonian, jobs, screenshots. .. py:function:: runner_serve(queue: pathlib.Path, poll: float = 5.0, once: bool = False) Process the filesystem queue (run on the lab server). .. py:function:: runner_status(queue: pathlib.Path) .. py:function:: selftest(allow_missing: bool = typer.Option(False, '--allow-missing', help='A missing extra (analysis, sim, notebook) is skipped instead of failing.'), as_json: bool = typer.Option(False, '--json', help='Print the checks as JSON.')) Check this install: imports of every extra, a Q1 + R1 chip (build, DRC, LOM, job export), ansysedt lookup. .. py:function:: sim_auto_cmd(design: pathlib.Path, instances: str = typer.Option('', '--instances', '-i', help='Qubits and/or readout routes, comma separated'), default: bool = typer.Option(False, '--default', help='No --instances: the first qubit with its readout'), whole: bool = typer.Option(False, '--whole', help='The whole chip (slow, memory hungry)'), analysis: str = typer.Option('q3d_cmatrix', '--analysis', '-a'), aedt: str = typer.Option('batch', '--aedt', help='batch (a new non-graphical AEDT, default) | gui (a new window)'), fast: bool = typer.Option(True, '--fast/--full', help='Fast solver settings (default)'), margin: float = typer.Option(300.0, help='Margin (um) around the selection'), name: str = typer.Option('gui_sim', help='Name of the sim group(s) written into the design'), timeout: float = typer.Option(3600.0, help='Seconds per solve before qcc stops the AEDT it started'), status: pathlib.Path = typer.Option(None, help='Status file (JSON) the KLayout plugin polls'), set_: list[str] = typer.Option(None, '--set', help='Solver setting key=value, repeatable (with --full: on top of the analysis defaults), e.g. --set maximum_passes=12 --set percent_error=1')) Automatic simulation: subset -> export -> solve in a NEW AEDT (never the one you have open) -> analyse. Fills the LOM of the simulated components; ``qcc analyse`` / the KLayout Results tab show it against the targets. .. py:function:: sim_build(design: pathlib.Path, group: str = typer.Option(..., '--group', '-g'), analysis: str = typer.Option(..., '--analysis', '-a', help='q3d_cmatrix | hfss_eigenmode | eigenmode_epr | elmer_cap | palace_cap | palace_eig'), out: pathlib.Path = typer.Option(None, '-o', help='Job directory'), overwrite: bool = False) Create a simulation job directory for a sim group. .. py:function:: sim_preview_cmd(design: pathlib.Path, instances: str = typer.Option('', '--instances', '-i', help='Components, as for `qcc sim subset`'), default: bool = typer.Option(False, '--default', help='No --instances: the first qubit with its readout'), whole: bool = typer.Option(False, '--whole', help='The whole chip'), group: str = typer.Option(None, '--group', '-g', help='A saved sim_groups entry, as it is'), analysis: str = typer.Option(None, '--analysis', '-a', help="Default q3d_cmatrix; with --group the group's first"), margin: float = typer.Option(300.0, help='Margin (um) around the selection'), name: str = typer.Option('gui_sim', help='Name of the sim group(s) the export would write')) Print as JSON what `qcc sim subset` would render (no file is written): the box, the components and routes in it and every port (50 ohm edge ports, cut stubs, junction ports) with its position. The KLayout plugin draws it. .. py:function:: sim_run(job: pathlib.Path, dry_run: bool = typer.Option(False, help='Only print the command')) Run a job locally (AEDT / Elmer / Palace) and collect results. .. py:function:: sim_submit(job: pathlib.Path, queue: pathlib.Path = typer.Option(..., help='Queue directory')) .. py:function:: sim_subset_cmd(design: pathlib.Path, instances: str = typer.Option('', '--instances', '-i', help="Components to simulate, comma separated. q3d_cmatrix: qubits and/or their readout routes (Q1,R1), resonators cut to a stub port; eigenmode / driven: exactly these components (plus the routes joining them and the pads at a selected line's ends), lines leaving the box end in 50 ohm"), default: bool = typer.Option(False, '--default', help='No --instances: the first qubit with its readout'), whole: bool = typer.Option(False, '--whole', help='The whole chip (slow, memory hungry)'), out: pathlib.Path = typer.Option(None, '-o', help='Job folder (one box) or the folder that holds one job per box'), analysis: str = typer.Option('q3d_cmatrix', '--analysis', '-a', help='q3d_cmatrix (cheap, fills the LOM) | eigenmode_epr | hfss_eigenmode | hfss_driven'), fast: bool = typer.Option(True, '--fast/--full', help='Fast solver settings (default) or the analysis defaults'), margin: float = typer.Option(300.0, help='Margin (um) around the selection'), name: str = typer.Option('gui_sim', help='Name of the sim group(s) written into the design'), write_group: bool = typer.Option(True, '--write-group/--no-write-group', help='Store the sim group in the design'), group: str = typer.Option(None, '--group', '-g', help='Export a saved sim_groups entry as it is (writes nothing)'), set_: list[str] = typer.Option(None, '--set', help='Solver setting key=value, repeatable (with --full: on top of the analysis defaults), e.g. --set maximum_passes=12 --set percent_error=1')) Export the job folder of a subset (no solve): geometry, AEDT scripts, job.json, README.md (what to run and what to bring back) and results_template.json. Solve it by hand or elsewhere; read it back with ``qcc results import``. .. py:function:: synth(f_q: float = typer.Option(..., help='Qubit f01 [GHz]'), alpha: float = typer.Option(..., help='α [MHz]'), f_r: float = typer.Option(..., help='Resonator [GHz]'), g: float = typer.Option(..., help='g [MHz]'), a: float = 10.0, b: float = 6.0) LOM-first synthesis: targets → Lj, C_Σ, Cg, λ/4 length. .. py:function:: watch(design: pathlib.Path, out: pathlib.Path = typer.Option(None, '-o'), klive: bool = typer.Option(True, help='Use klive'), extra: list[pathlib.Path] = typer.Option(None, help='More files to watch (e.g. imported modules)'), label_height: float = typer.Option(None, '--label-height', help=LABEL_HEIGHT_HELP)) Rebuild on every save and reload KLayout (klive). .. py:data:: LABEL_HEIGHT_HELP :value: "Height of the instance name labels in µm (capital letters; 0 = none). Default: KQC's 280. An... .. py:data:: app .. py:data:: circuit_app .. py:data:: design_app .. py:data:: hfss_app .. py:data:: results_app .. py:data:: runner_app .. py:data:: sim_app