qcc_kplugin.flow ================ .. py:module:: qcc_kplugin.flow .. autoapi-nested-parse:: Simulate, Results and Fab: the last three steps of the Quantcore Flow strip (G4 – G6). ``ACTIONS`` fills the menu's Simulate / Results / Fab submenus; ``simulate`` / ``results`` / ``fab`` are what the panel's Flow buttons call. * **Simulate** (automatic): the components selected in KLayout are the subset (nothing selected: asks for the default subset or the whole chip). ``qcc sim auto`` runs in the background — subset, export, solve in a *new* non-graphical AEDT (never the one you have open), analyse — and the status bar shows its progress. KLayout stays usable; when it ends the layout is rebuilt so the Results tab shows the values. * **Simulate** (manual): the Simulate dialog's *Export the job only* button (``export_job``) writes the job folder with a README (what to run, what to bring back); *Import results…* (a menu item) reads a solved job folder or a results.json back (format: ``qcc results template --format``). * **Results** shows the latest values against the targets; *Propose next revision* previews old → new knob values (``loop.feedback``; 21 qubit classes with λ/4 or λ/2 readouts, through the generic surrogate in ``codesign.py``; what it cannot tune is listed as *Not tuned*), and *Apply* writes them to design.json through the session (undo works) and rebuilds. * **Fab** writes the fab mask (``qcc mask``), the netlist (``circuit.json``), ``design.py`` (the drawn chip as a Designer script) and a PNG into one folder. Everything slow runs as a ``qcc`` subprocess through :mod:`qcc_kplugin.jobs` (never in KLayout's UI thread, never a modal dialog from a timer). The functions take ``wait=True`` for tests, which blocks until the job ended. Attributes ---------- .. autoapisummary:: qcc_kplugin.flow.ACTIONS qcc_kplugin.flow.AEDT_PATH_LIMIT qcc_kplugin.flow.CFG_AEDT_WINDOW qcc_kplugin.flow.CFG_SIM qcc_kplugin.flow.DEFAULT_LAYOUT_CHOICES qcc_kplugin.flow.DIALOGS qcc_kplugin.flow.PORT_LAYERS qcc_kplugin.flow.SIMLAYOUT_PREFIX Classes ------- .. autoapisummary:: qcc_kplugin.flow.FlowJob qcc_kplugin.flow.ProposalWindow qcc_kplugin.flow.ResultsDialog qcc_kplugin.flow.SimJob Functions --------- .. autoapisummary:: qcc_kplugin.flow.aedt_path_too_long qcc_kplugin.flow.apply_proposal qcc_kplugin.flow.ask_dir qcc_kplugin.flow.ask_file qcc_kplugin.flow.choose qcc_kplugin.flow.export_job qcc_kplugin.flow.fab qcc_kplugin.flow.import_results qcc_kplugin.flow.info_window qcc_kplugin.flow.open_folder qcc_kplugin.flow.open_results_file qcc_kplugin.flow.open_sim_layout qcc_kplugin.flow.propose qcc_kplugin.flow.results qcc_kplugin.flow.results_dir qcc_kplugin.flow.resume_runs qcc_kplugin.flow.save_python qcc_kplugin.flow.selected_names qcc_kplugin.flow.show_sim_gds qcc_kplugin.flow.sim_layer_name qcc_kplugin.flow.sim_layout_args qcc_kplugin.flow.sim_layout_missing_lj qcc_kplugin.flow.sim_settings_saved qcc_kplugin.flow.simlayout_root qcc_kplugin.flow.simulate qcc_kplugin.flow.simulate_dialog Module Contents --------------- .. py:class:: FlowJob(steps, label, done, cwd=None, status_file=None) Bases: :py:obj:`qcc_kplugin.jobs.Job` A :class:`jobs.Job` that shows its own progress (a status file the ``qcc`` command writes plus the AEDT progress line in its output) and can be stopped (only the process tree it started). .. py:method:: cancel() -> None Stop the job: the ``qcc`` process and the AEDT it started (taskkill /T), nothing else. .. py:method:: poll() -> None .. py:method:: progress_line() -> str .. py:method:: status() -> dict .. py:attribute:: cancelled :value: False .. py:attribute:: last_step :value: '' .. py:attribute:: status_file .. py:class:: ProposalWindow(proposal: dict, path: pathlib.Path) Bases: :py:obj:`_Window` A non-modal window with a title, text and a Close button (results of background jobs: never modal from a timer). .. py:method:: apply() .. py:attribute:: table .. py:class:: ResultsDialog Bases: :py:obj:`_Window` Latest values against the targets (the sidecar's ``results``: the same rows as the panel's Results tab), plus the tune buttons. Refreshes itself when the layout is rebuilt. .. py:method:: refresh() -> None .. py:attribute:: header .. py:attribute:: tree .. py:class:: SimJob(steps, label, done, cwd=None, status_file=None, record=None) Bases: :py:obj:`FlowJob` ``qcc sim auto``, started detached so it outlives KLayout (see :mod:`simrun`). Its output goes to ``.flow/sim_run.log`` and the run record ``sim_run.json`` keeps its pid and outcome. With ``record`` (a run from an earlier KLayout session) nothing is started: the job watches that run's pid and ends when it does. .. py:attribute:: flow_dir .. py:attribute:: record :value: None .. py:function:: aedt_path_too_long(job_dir) -> bool AEDT fails on Windows when its ``*.aedtresults`` folders pass 260 characters; the job folder name is repeated in them (the same rule as ``quantcore_circuits.guiflow.aedt_path_too_long``). .. py:function:: apply_proposal(proposal: dict, path: pathlib.Path, wait: bool = False) Write a proposal's knobs to design.json through the session (one undo step) and rebuild. .. py:function:: ask_dir(title: str, start: str) -> str | None .. py:function:: ask_file(title: str, start: str, pattern: str = 'JSON (*.json)') -> str | None .. py:function:: choose(title: str, text: str, choices: list[str], checkbox: str | None = None) A small modal question: one button per choice and Cancel. Returns ``(index, checked)`` or None. (An auto-accepted dialog returns the first choice, which is how the GUI smoke test drives it.) .. py:function:: export_job(wait: bool = False, names=None, subset: str | None = None, folder: str | None = None, analysis: str | None = None, settings: dict | None = None) The Simulate dialog's *Export the job only* button: write the job folder (geometry, AEDT scripts, job.json, README.md with what to run and what to bring back, results_template.json) for the selected components, to solve by hand or elsewhere. .. py:function:: fab(wait: bool = False, folder: str | None = None, force: bool = False) Flow ▸ Fab: the fab mask (``qcc mask``, PDK fab layers, cheese and corner rounding), the netlist (circuit.json), ``design.py`` and a PNG, all into one folder. .. py:function:: import_results(wait: bool = False, source: str | None = None) Flow ▸ Simulate ▸ Import results…: a solved job folder or a results.json → analysed against the design; the Results tab and dialog show the outcome. .. py:function:: info_window(title: str, text: str, buttons: dict | None = None) -> _Window Read-only text in a non-modal window, with optional extra buttons ``{key: (label, function)}``. .. py:function:: open_folder(path) -> None .. py:function:: open_results_file(wait: bool = False, source: str | None = None) Flow ▸ Simulate ▸ Open results file…: pick a results file (e.g. the ``__results.json`` a run saved in ``build/``, or one solved by hand) and analyse it against the design, without the job-folder question. .. py:function:: open_sim_layout(wait: bool = False, names=None, subset: str | None = None, analysis: str | None = None, group: str | None = None) Simulate ▸ Open simulation layout…: export the job geometry of the selection, the default subset or a saved sim group (the same path as *Export the job only*, no AEDT) to a temporary folder and open the GDS that AEDT imports in a new layout tab, with readable layer names: the cut-out metal and gaps, the junction sheets and the port polygons. The design and its build are never touched. An eigenmode / driven layout with a qubit that has no L_J is not exported: a window names the qubit and offers the Q3D layout instead (:func:`sim_layout_missing_lj`). .. py:function:: propose(wait: bool = False) Flow ▸ Results ▸ Propose next revision…: ``loop.feedback`` in the background, then a preview of old → new knob values with Apply (writes them to design.json; Quantcore > Edit > Undo takes them back). .. py:function:: results(wait: bool = False, quiet: bool = False) Flow ▸ Results: the latest values against the targets in a window (and the panel's Results tab). ``quiet`` (called when a background job ends, i.e. from a timer): a failure goes to the status bar and the log, no dialog. .. py:function:: results_dir() -> pathlib.Path ``/build/``: where ``qcc sim auto`` saves ``__results.json`` (simsetup.run_dir; ``build/`` is also where convergence.json and the run state live). .. py:function:: resume_runs(force: bool = False) A ``qcc sim auto`` run of this design started in an earlier KLayout session: one that ended meanwhile is imported (its results are in the run state: the layout is rebuilt and the Results tab filled); one still going is watched and imported when it ends. Returns the watching job, or None. Called when a design is opened. .. py:function:: save_python(wait: bool = False, path: str | None = None) Quantcore ▸ Design ▸ Save as Python script…: ``qcc design to-python`` (the drawn chip as a Designer script, to continue it as code; the fab export puts the same script beside the mask). .. py:function:: selected_names() -> list[str] Instances and routes selected with KLayout's own select tool (their ``id`` property is the design name). .. py:function:: show_sim_gds(job_dir) -> str | None Open the GDS of the exported job folder in a new layout tab (not the design's view): layers get readable names and colours; the port polygons of ``.json`` are added as two extra layers in memory (the file is not changed). Returns the tab's title, or None when the folder holds no GDS. .. py:function:: sim_layer_name(name: str) -> str A readable name for a KQC simulation layer (``1t1_gap``, ``1t1_signal_2``, ``1t1_ground``). .. py:function:: sim_layout_args(design, target, subset: str, names, analysis: str, group: str | None = None) -> list ``qcc sim subset`` arguments of the simulation layout: the job export with nothing written to the design (and no AEDT): the selection, the default subset or a saved sim group, to ``target``. .. py:function:: sim_layout_missing_lj(subset: str, names, analysis: str, group: str | None, design_data: dict) -> str The Simulate dialog's pre-check, for Open simulation layout: an eigenmode / driven layout puts a lumped L‖C sheet on each junction, so a qubit without an L_J would fail the export. The warning that names them and says where to set the value, or "" (all set, or a capacitance analysis, which needs none). .. py:function:: sim_settings_saved() -> dict .. py:function:: simlayout_root() -> pathlib.Path .. py:function:: simulate(wait: bool = False, names=None, subset: str | None = None, window: bool | None = None, analysis: str | None = None, settings: dict | None = None) Flow ▸ Simulate: the Simulate dialog (:func:`simulate_dialog`: what is rendered, Q3D or eigenmode, the solver settings, the last run's convergence), then ``qcc sim auto`` in the background (or the job export). A run in progress is offered to stop instead. ``subset`` ("selection" \| "default" \| "whole") with ``names`` / ``window`` / ``analysis`` / ``settings`` skips the dialog (tests; no settings: the fast ones). .. py:function:: simulate_dialog(names: list[str]) What to simulate and how → ``{"scope": selection\|default\|whole, "analysis", "settings", "window", "action": run\|export\|layout}`` or None (cancelled). The analysis (Q3D capacitance or HFSS eigenmode; driven runs are for scripts) is preset from the selection (:func:`simsetup.recommend`). The solver settings (passes, convergence, modes, mesh seeds) are filled with the fast values and can be changed; the last values are kept. The last run's convergence (``convergence.json``) is shown. .. py:data:: ACTIONS .. py:data:: AEDT_PATH_LIMIT :value: 250 .. py:data:: CFG_AEDT_WINDOW :value: 'qcc-kplugin-aedt-window' .. py:data:: CFG_SIM :value: 'qcc-kplugin-sim-settings' .. py:data:: DEFAULT_LAYOUT_CHOICES .. py:data:: DIALOGS :type: list :value: [] .. py:data:: PORT_LAYERS .. py:data:: SIMLAYOUT_PREFIX :value: 'qcc_simlayout'