quantcore-circuits 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantcore_circuits/__init__.py +57 -0
- quantcore_circuits/analysis/__init__.py +12 -0
- quantcore_circuits/analysis/_metal.py +70 -0
- quantcore_circuits/analysis/amplifiers.py +263 -0
- quantcore_circuits/analysis/circuits.py +117 -0
- quantcore_circuits/analysis/epr.py +231 -0
- quantcore_circuits/analysis/epr_lumped.py +372 -0
- quantcore_circuits/analysis/extract.py +119 -0
- quantcore_circuits/analysis/lom.py +80 -0
- quantcore_circuits/analysis/results.py +549 -0
- quantcore_circuits/analysis/store.py +81 -0
- quantcore_circuits/analysis/synthesis.py +118 -0
- quantcore_circuits/analysis/transmon.py +126 -0
- quantcore_circuits/assembly/__init__.py +17 -0
- quantcore_circuits/assembly/builder.py +127 -0
- quantcore_circuits/assembly/drc.py +683 -0
- quantcore_circuits/assembly/last_good.py +137 -0
- quantcore_circuits/assembly/netlist.py +174 -0
- quantcore_circuits/assembly/plan.py +605 -0
- quantcore_circuits/assembly/sidecar.py +270 -0
- quantcore_circuits/autotrack.py +605 -0
- quantcore_circuits/cards.py +878 -0
- quantcore_circuits/circuit/__init__.py +14 -0
- quantcore_circuits/circuit/adapters.py +305 -0
- quantcore_circuits/circuit/bridges.py +353 -0
- quantcore_circuits/circuit/consensus.py +158 -0
- quantcore_circuits/circuit/derive.py +28 -0
- quantcore_circuits/circuit/draw.py +198 -0
- quantcore_circuits/circuit/fill.py +828 -0
- quantcore_circuits/circuit/hamiltonian.py +193 -0
- quantcore_circuits/circuit/kinetic.py +102 -0
- quantcore_circuits/circuit/schema.py +139 -0
- quantcore_circuits/cli.py +1085 -0
- quantcore_circuits/codesign.py +1038 -0
- quantcore_circuits/data/selftest_q1_r1.json +44 -0
- quantcore_circuits/design/__init__.py +44 -0
- quantcore_circuits/design/io.py +98 -0
- quantcore_circuits/design/pyscript.py +395 -0
- quantcore_circuits/design/schema.py +398 -0
- quantcore_circuits/designer.py +625 -0
- quantcore_circuits/guiflow.py +991 -0
- quantcore_circuits/kqc_files.py +208 -0
- quantcore_circuits/layouts/__init__.py +118 -0
- quantcore_circuits/layouts/catalog.py +520 -0
- quantcore_circuits/layouts/chips/__init__.py +0 -0
- quantcore_circuits/layouts/chips/design_chip.py +325 -0
- quantcore_circuits/layouts/chips/frame.py +235 -0
- quantcore_circuits/layouts/junctions/__init__.py +0 -0
- quantcore_circuits/layouts/junctions/jj_fingers.py +99 -0
- quantcore_circuits/layouts/junctions/legacy_junctions.py +237 -0
- quantcore_circuits/layouts/junctions/sim_gap.py +48 -0
- quantcore_circuits/layouts/junctions/trilayer.py +541 -0
- quantcore_circuits/layouts/metal/__init__.py +105 -0
- quantcore_circuits/layouts/metal/component.py +332 -0
- quantcore_circuits/layouts/metal/geometry.py +462 -0
- quantcore_circuits/layouts/others/__init__.py +0 -0
- quantcore_circuits/layouts/others/amplifiers.py +1139 -0
- quantcore_circuits/layouts/others/bond_pad.py +119 -0
- quantcore_circuits/layouts/others/connector_pads.py +190 -0
- quantcore_circuits/layouts/others/couplers.py +21 -0
- quantcore_circuits/layouts/others/cpw_segment.py +131 -0
- quantcore_circuits/layouts/others/cpwe.py +661 -0
- quantcore_circuits/layouts/others/keepout.py +66 -0
- quantcore_circuits/layouts/others/legacy_resonators.py +645 -0
- quantcore_circuits/layouts/others/markers.py +201 -0
- quantcore_circuits/layouts/others/qpdk_cells.py +263 -0
- quantcore_circuits/layouts/others/shapes.py +114 -0
- quantcore_circuits/layouts/others/spirals.py +140 -0
- quantcore_circuits/layouts/others/sqdmetal_cells.py +90 -0
- quantcore_circuits/layouts/others/test_pads.py +461 -0
- quantcore_circuits/layouts/ports.py +119 -0
- quantcore_circuits/layouts/qubits/__init__.py +0 -0
- quantcore_circuits/layouts/qubits/legacy_transmon.py +124 -0
- quantcore_circuits/layouts/qubits/qpdk_cells.py +374 -0
- quantcore_circuits/layouts/qubits/sqdmetal_cells.py +376 -0
- quantcore_circuits/layouts/qubits/trilayer_concentric.py +65 -0
- quantcore_circuits/layouts/qubits/xmon.py +375 -0
- quantcore_circuits/layouts/registry.py +418 -0
- quantcore_circuits/layouts/wafers/__init__.py +0 -0
- quantcore_circuits/layouts/wafers/fab_export.py +454 -0
- quantcore_circuits/layouts/wafers/legacy_wafer.py +111 -0
- quantcore_circuits/layouts/wafers/wafer.py +469 -0
- quantcore_circuits/live/__init__.py +6 -0
- quantcore_circuits/live/klayout.py +225 -0
- quantcore_circuits/live/klive.py +61 -0
- quantcore_circuits/live/snapshot.py +185 -0
- quantcore_circuits/live/watch.py +93 -0
- quantcore_circuits/lom/__init__.py +15 -0
- quantcore_circuits/lom/builder.py +932 -0
- quantcore_circuits/lom/calibration.py +82 -0
- quantcore_circuits/lom/estimates.py +235 -0
- quantcore_circuits/lom/fragment.py +421 -0
- quantcore_circuits/lom/kqc_models.py +734 -0
- quantcore_circuits/lom/metal_models.py +917 -0
- quantcore_circuits/lom/quantcore_models.py +784 -0
- quantcore_circuits/lom/simulate.py +636 -0
- quantcore_circuits/lom/synthesize.py +189 -0
- quantcore_circuits/loop.py +610 -0
- quantcore_circuits/optimise.py +423 -0
- quantcore_circuits/pdk/__init__.py +451 -0
- quantcore_circuits/plots.py +876 -0
- quantcore_circuits/plugins.py +69 -0
- quantcore_circuits/review/__init__.py +57 -0
- quantcore_circuits/review/server.py +251 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- quantcore_circuits/review/static/assets/index-CDHdrFyA.css +1 -0
- quantcore_circuits/review/static/assets/index-CSx05Og4.js +409 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-HOLc17fK.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-obahsSVq.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-BasfLYem.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-CxZf_p3X.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-4D_pXhcN.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-CWCymEST.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-CjBOestx.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-DrXBdSj3.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-BQZuk6qB.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-DQukG94-.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-B0yAr1jD.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-BmqWE9Dz.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Bcila6Z-.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Dfes3d0z.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-BjwYoWNd.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-LO58E6JB.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-400-normal-B4URO6DV.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-400-normal-q2sYcFCs.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-500-normal-BIZE56-Y.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-500-normal-Xzm54t5V.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-600-normal-BZpKdvQh.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-600-normal-plRanbMR.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-700-normal-BUv2fZ6O.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-700-normal-C3JjAnD8.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-DGGRlc-M.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-KugGGMne.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-2j5mBUwD.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-C4iEst2y.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-B8X0CLgF.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-DRtmH8MT.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-BoQ6DsYi.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-qfdV9bQt.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-600-normal-CiBQ2DWP.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-600-normal-LgqL8muc.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-700-normal-BLAVimhd.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-700-normal-Yt3aPRUw.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-77YHD8bZ.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-C1nco2VV.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-BxGbmqWO.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-CV4jyFjo.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-CIVaiw4L.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-D2bJ5OIk.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-Ca8adRJv.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-TidjK2hL.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-Bbgyi5SW.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-DMkecbls.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-DOriooB6.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-mJboJaSs.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-BuLX-rYi.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-Cc8MFFhd.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-BZaoP0fm.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-DlLaEgI2.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
- quantcore_circuits/review/static/index.html +14 -0
- quantcore_circuits/review/static/logo-quantcore-black.png +0 -0
- quantcore_circuits/review/static/logo-quantcore-white.png +0 -0
- quantcore_circuits/review/static/sample/chip.png +0 -0
- quantcore_circuits/review/static/sample/chip_rev1.png +0 -0
- quantcore_circuits/review/static/sample/q1.png +0 -0
- quantcore_circuits/review/static/sample/q2.png +0 -0
- quantcore_circuits/review/static/sample-state.json +3747 -0
- quantcore_circuits/route/__init__.py +5 -0
- quantcore_circuits/route/router.py +694 -0
- quantcore_circuits/route/waveguide.py +187 -0
- quantcore_circuits/selftest.py +224 -0
- quantcore_circuits/sim_tools/__init__.py +6 -0
- quantcore_circuits/sim_tools/aedt_attach.py +66 -0
- quantcore_circuits/sim_tools/aedt_progress.py +224 -0
- quantcore_circuits/sim_tools/aedt_project.py +302 -0
- quantcore_circuits/sim_tools/aedt_scripts.py +397 -0
- quantcore_circuits/sim_tools/aedt_session.py +275 -0
- quantcore_circuits/sim_tools/ansys.py +90 -0
- quantcore_circuits/sim_tools/builder.py +1690 -0
- quantcore_circuits/sim_tools/export.py +470 -0
- quantcore_circuits/sim_tools/geometry_check.py +342 -0
- quantcore_circuits/sim_tools/hfss.py +583 -0
- quantcore_circuits/sim_tools/palace.py +197 -0
- quantcore_circuits/sim_tools/runner.py +179 -0
- quantcore_circuits/sim_tools/subset.py +364 -0
- quantcore_circuits/track.py +671 -0
- quantcore_circuits-0.0.1.dist-info/METADATA +204 -0
- quantcore_circuits-0.0.1.dist-info/RECORD +272 -0
- quantcore_circuits-0.0.1.dist-info/WHEEL +5 -0
- quantcore_circuits-0.0.1.dist-info/entry_points.txt +2 -0
- quantcore_circuits-0.0.1.dist-info/licenses/LICENSE +674 -0
- quantcore_circuits-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
"""Code-first chip design (Metal-style), drawn live in KLayout as you type.
|
|
2
|
+
|
|
3
|
+
>>> d = Designer("q1_r1", box=(0, 0, 7500, 7500), chip={"name_chip": "Q1R1"}, live=True) # opens KLayout
|
|
4
|
+
>>> pw = d.add("PAD_W", "BondPad", at=(1125, 3750), rot=270)
|
|
5
|
+
>>> pe = d.add("PAD_E", "BondPad", at=(6375, 3750), rot=90)
|
|
6
|
+
>>> fl = d.route("FL", pw.a, pe.a) # ports are attributes
|
|
7
|
+
>>> q1 = d.add("Q1", "Xmon", at=(2975, 2200), cross_length=300, junction={"Lj_nH": 12, "Cj_fF": 2})
|
|
8
|
+
>>> d.route("R1", q1.claw_n, fl.hanger(s=2000, length=300, side="right"), meander=4200)
|
|
9
|
+
>>> d.save("examples/my_chip.json"); d.lom().model # design.json and its lumped circuit
|
|
10
|
+
|
|
11
|
+
Every ``add``/``route``/``set`` validates immediately (unknown cells, parameters or ports raise with the list of
|
|
12
|
+
valid ones) and, with ``live=True``, rebuilds the chip (≈0.1 s warm), writes ``build/<name>.oas`` + sidecar and
|
|
13
|
+
reloads KLayout through klive. A change that cannot be routed yet (e.g. a route to a component not placed yet) keeps
|
|
14
|
+
the last good layout and prints why. ``with d.batch():`` groups changes into one rebuild. The result is an ordinary
|
|
15
|
+
``design.json``, so the KLayout plugin, ``qcc watch``, simulation and analysis all work on it unchanged.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import contextlib
|
|
21
|
+
import copy
|
|
22
|
+
import json
|
|
23
|
+
import time
|
|
24
|
+
from functools import lru_cache
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
from quantcore_circuits.pdk import DEFAULT_PDK
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class PortRef(str):
|
|
31
|
+
"""``"Q1.claw_n"`` with the port's geometry attached (``.pos``, ``.dir``, ``.a``, ``.b`` in the local frame)."""
|
|
32
|
+
|
|
33
|
+
def __new__(cls, ref: str, port=None):
|
|
34
|
+
obj = super().__new__(cls, ref)
|
|
35
|
+
obj.port = port
|
|
36
|
+
return obj
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@lru_cache(maxsize=256)
|
|
40
|
+
def _ports(cell: str, params_json: str) -> dict:
|
|
41
|
+
from quantcore_circuits.assembly.plan import pcell_params # pylint: disable=C0415
|
|
42
|
+
from quantcore_circuits.layouts.registry import element_ports, resolve_cell # pylint: disable=C0415
|
|
43
|
+
|
|
44
|
+
if cell.startswith("static:"):
|
|
45
|
+
return {}
|
|
46
|
+
cls = resolve_cell(cell)
|
|
47
|
+
return element_ports(cls, **pcell_params(cls, json.loads(params_json)))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class InstanceHandle:
|
|
51
|
+
def __init__(self, designer: Designer, name: str):
|
|
52
|
+
self._d, self.name = designer, name
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def spec(self) -> dict:
|
|
56
|
+
return self._d.data["instances"][self.name]
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def ports(self) -> dict:
|
|
60
|
+
return _ports(self.spec["cell"], json.dumps(self.spec.get("params", {}), sort_keys=True))
|
|
61
|
+
|
|
62
|
+
def __getattr__(self, port: str) -> PortRef:
|
|
63
|
+
if port.startswith("_"):
|
|
64
|
+
raise AttributeError(port)
|
|
65
|
+
ports = self.ports
|
|
66
|
+
if port not in ports:
|
|
67
|
+
raise AttributeError(f"{self.name} ({self.spec['cell']}) has no port {port!r}; ports: {sorted(ports)}")
|
|
68
|
+
return PortRef(f"{self.name}.{port}", ports[port])
|
|
69
|
+
|
|
70
|
+
def __getitem__(self, port: str) -> PortRef:
|
|
71
|
+
return self.__getattr__(port)
|
|
72
|
+
|
|
73
|
+
def set(self, **params) -> InstanceHandle:
|
|
74
|
+
"""Change cell parameters (``at=`` / ``rot=`` are accepted too; ``junction=`` replaces the junction dict,
|
|
75
|
+
e.g. ``{"Lj_nH": 7.0, "flux_phi0": 0.2, "asym": 0.1}``)."""
|
|
76
|
+
with self._d._change(f"set {self.name}"):
|
|
77
|
+
spec = self.spec
|
|
78
|
+
place = spec["place"]
|
|
79
|
+
for k in ("at", "rot", "mirror", "edge"):
|
|
80
|
+
if k in params:
|
|
81
|
+
place.pop("snap", None)
|
|
82
|
+
place.pop("to", None)
|
|
83
|
+
place[k] = list(params.pop(k)) if k == "at" else params.pop(k)
|
|
84
|
+
if "junction" in params:
|
|
85
|
+
spec["junction"] = dict(params.pop("junction"))
|
|
86
|
+
spec.setdefault("params", {}).update(params)
|
|
87
|
+
return self
|
|
88
|
+
|
|
89
|
+
def move(self, at=None, rot=None, edge: str | None = None) -> InstanceHandle:
|
|
90
|
+
"""Move / rotate; ``edge`` ("n"/"s"/"e"/"w"/"auto") puts the outer edge of the etch at the PDK pad distance
|
|
91
|
+
(``frame.pad_edge``, 100 µm) from that die edge."""
|
|
92
|
+
kw = {k: v for k, v in (("at", at), ("rot", rot), ("edge", edge)) if v is not None}
|
|
93
|
+
return self.set(**kw)
|
|
94
|
+
|
|
95
|
+
def __repr__(self) -> str:
|
|
96
|
+
return f"<{self.spec['cell']} {self.name} ports={sorted(self.ports)}>"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class RouteHandle:
|
|
100
|
+
def __init__(self, designer: Designer, name: str):
|
|
101
|
+
self._d, self.name = designer, name
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def spec(self) -> dict:
|
|
105
|
+
return self._d.data["routes"][self.name]
|
|
106
|
+
|
|
107
|
+
def hanger(
|
|
108
|
+
self,
|
|
109
|
+
s: float | None = None,
|
|
110
|
+
length: float = 300.0,
|
|
111
|
+
side: str = "left",
|
|
112
|
+
ground_gap: float = 6.0,
|
|
113
|
+
direction: str = "forward",
|
|
114
|
+
end: str = "short",
|
|
115
|
+
open_gap: float = 6.0,
|
|
116
|
+
bend: bool = True,
|
|
117
|
+
near=None,
|
|
118
|
+
coupler_gap: float | None = None,
|
|
119
|
+
line_gap: float | None = None,
|
|
120
|
+
) -> dict:
|
|
121
|
+
"""End spec for a λ/4 coupler running along this route (use as another route's ``end``). ``bend=False``
|
|
122
|
+
enters the coupler straight instead of with a 90° bend; ``direction`` flips which end is terminated.
|
|
123
|
+
``near=(x, y)`` instead of ``s`` centres the coupler at the point of this route nearest to (x, y).
|
|
124
|
+
``coupler_gap`` / ``line_gap`` narrow the two facing gaps along the coupler (closer, stronger coupling)."""
|
|
125
|
+
spec = {
|
|
126
|
+
"hanger": self.name,
|
|
127
|
+
"s": s,
|
|
128
|
+
"length": length,
|
|
129
|
+
"side": side,
|
|
130
|
+
"ground_gap": ground_gap,
|
|
131
|
+
"direction": direction,
|
|
132
|
+
"end": end,
|
|
133
|
+
"open_gap": open_gap,
|
|
134
|
+
"bend": bend,
|
|
135
|
+
}
|
|
136
|
+
for key, value in (("coupler_gap", coupler_gap), ("line_gap", line_gap)):
|
|
137
|
+
if value is not None:
|
|
138
|
+
spec[key] = value
|
|
139
|
+
if near is not None:
|
|
140
|
+
spec["near"] = list(near)
|
|
141
|
+
spec.pop("s")
|
|
142
|
+
elif s is None:
|
|
143
|
+
raise ValueError("hanger(...) needs s= (arclength along this route) or near=(x, y)")
|
|
144
|
+
return spec
|
|
145
|
+
|
|
146
|
+
def set(self, **kw) -> RouteHandle:
|
|
147
|
+
with self._d._change(f"set {self.name}"):
|
|
148
|
+
for k, v in kw.items():
|
|
149
|
+
if v is None:
|
|
150
|
+
self.spec.pop(k, None)
|
|
151
|
+
else:
|
|
152
|
+
self.spec["length" if k == "meander" else k] = v
|
|
153
|
+
if "meander" in kw:
|
|
154
|
+
self.spec["type"] = "meander"
|
|
155
|
+
return self
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def length(self) -> float | None:
|
|
159
|
+
r = self._d.result
|
|
160
|
+
return r.route_lengths().get(self.name) if r else None
|
|
161
|
+
|
|
162
|
+
def __repr__(self) -> str:
|
|
163
|
+
return f"<route {self.name}: {self.spec['from']} → {self.spec['to']}>"
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class Designer:
|
|
167
|
+
def __init__(
|
|
168
|
+
self,
|
|
169
|
+
name: str,
|
|
170
|
+
box=(0.0, 0.0, 10000.0, 10000.0),
|
|
171
|
+
pdk: str = DEFAULT_PDK,
|
|
172
|
+
chip: dict | None = None,
|
|
173
|
+
launchers: str | dict | None = None,
|
|
174
|
+
live: bool = False,
|
|
175
|
+
out: str | Path | None = None,
|
|
176
|
+
delay: float = 0.0,
|
|
177
|
+
open_klayout: bool | None = None,
|
|
178
|
+
verbose: bool = True,
|
|
179
|
+
):
|
|
180
|
+
"""``live=True``: every change is rebuilt and redrawn in KLayout (klive). ``open_klayout`` (default: the
|
|
181
|
+
``QCC_KLAYOUT_GUI`` switch, on) starts KLayout when it is not running — also again after its window was
|
|
182
|
+
closed — and raises its window on the first build; False only redraws a KLayout that is already open."""
|
|
183
|
+
self.data: dict = {
|
|
184
|
+
"schema": "qcc/0.1",
|
|
185
|
+
"name": name,
|
|
186
|
+
"pdk": pdk,
|
|
187
|
+
"chip": {"box": list(box), "launchers": launchers, "params": {"with_grid": False, **(chip or {})}},
|
|
188
|
+
"instances": {},
|
|
189
|
+
"routes": {},
|
|
190
|
+
"targets": {},
|
|
191
|
+
"sim_groups": {},
|
|
192
|
+
"couplings": {},
|
|
193
|
+
}
|
|
194
|
+
self.live, self.delay, self.verbose = live, delay, verbose
|
|
195
|
+
self.out = Path(out) if out else Path("build") / f"{name}.oas"
|
|
196
|
+
self.result = None
|
|
197
|
+
self.history: list[str] = []
|
|
198
|
+
self._batch = 0
|
|
199
|
+
self._dirty = False
|
|
200
|
+
self._open = open_klayout # None: QCC_KLAYOUT_GUI decides at each build
|
|
201
|
+
self._front = True # raise the KLayout window on the first live build
|
|
202
|
+
self._kl_pid: int | None = None # the KLayout this designer started
|
|
203
|
+
self._kl_hint = False
|
|
204
|
+
self._autosave = True # only Designer.load sets a path; see load()
|
|
205
|
+
self.path: Path | None = None
|
|
206
|
+
|
|
207
|
+
# ---- construction ------------------------------------------------------------------------------------------
|
|
208
|
+
@classmethod
|
|
209
|
+
def load(cls, source, autosave: bool | None = None, **kw) -> Designer:
|
|
210
|
+
"""Open a saved design. ``autosave`` (default: the ``live`` setting) writes every rebuild back to ``source``:
|
|
211
|
+
on in a live KLayout session, so the plugin and ``qcc watch`` see your edits; off in scripts, tests and
|
|
212
|
+
``QCC_LIVE=0`` notebooks, so loading a design never rewrites it by accident (``d.save(path)`` still does)."""
|
|
213
|
+
from quantcore_circuits.design import load_design # pylint: disable=import-outside-toplevel
|
|
214
|
+
|
|
215
|
+
design = load_design(source)
|
|
216
|
+
d = cls(design.name, **kw)
|
|
217
|
+
d._autosave = d.live if autosave is None else bool(autosave)
|
|
218
|
+
d.data = design.to_json_dict()
|
|
219
|
+
for key in ("instances", "routes", "targets", "sim_groups", "couplings"): # omitted when empty on disk
|
|
220
|
+
d.data.setdefault(key, {})
|
|
221
|
+
d.path = Path(source) if isinstance(source, (str, Path)) else None
|
|
222
|
+
if d.live:
|
|
223
|
+
d.show()
|
|
224
|
+
return d
|
|
225
|
+
|
|
226
|
+
def add(
|
|
227
|
+
self,
|
|
228
|
+
name: str,
|
|
229
|
+
cell,
|
|
230
|
+
at=None,
|
|
231
|
+
rot: float = 0.0,
|
|
232
|
+
mirror: bool = False,
|
|
233
|
+
snap: str | None = None,
|
|
234
|
+
to: str | None = None,
|
|
235
|
+
snap_gap: float = 0.0,
|
|
236
|
+
junction: dict | None = None,
|
|
237
|
+
edge: str | None = None,
|
|
238
|
+
**params,
|
|
239
|
+
) -> InstanceHandle:
|
|
240
|
+
"""Place a component: ``cell`` is a class (``Xmon``) or name; ``params`` are its PCell parameters.
|
|
241
|
+
|
|
242
|
+
Absolute placement with ``at``/``rot``, or port snap with ``snap="port"`` (own port) and ``to=`` another
|
|
243
|
+
instance's port (``q1.claw_n``, optional ``snap_gap``); the rebuild solves the rotation. ``edge`` ("n", "s",
|
|
244
|
+
"e", "w" or "auto") applies the Quantcore pad rule to an absolute placement: the instance slides
|
|
245
|
+
perpendicular to that die edge until the outer edge of its etch is the PDK pad distance (PDK
|
|
246
|
+
``frame.pad_edge``, 100 µm) from it. ``junction`` holds the lumped junction values for the LOM and the
|
|
247
|
+
simulations: ``{"Lj_nH", "Cj_fF", "flux_phi0", "asym"}`` (L_J at zero flux, C_J, a SQUID's flux Φ/Φ0 and
|
|
248
|
+
asymmetry d; without ``Lj_nH`` the drawn trilayer junction's PDK value is used). All other keyword arguments
|
|
249
|
+
are cell parameters (e.g. the Xmon's ``gap``).
|
|
250
|
+
"""
|
|
251
|
+
cell_name = cell if isinstance(cell, str) else cell.__name__
|
|
252
|
+
self._check_cell(cell_name, params)
|
|
253
|
+
if name in self.data["instances"] or name in self.data["routes"]:
|
|
254
|
+
raise ValueError(f"{name!r} already exists")
|
|
255
|
+
if to is not None:
|
|
256
|
+
place = {"snap": snap if snap and "." in snap else f"{name}.{snap or 'a'}", "to": str(to)}
|
|
257
|
+
if snap_gap:
|
|
258
|
+
place["gap"] = snap_gap
|
|
259
|
+
if mirror: # applied before the snap rotation is solved (see design.schema.Place)
|
|
260
|
+
place["mirror"] = True
|
|
261
|
+
else:
|
|
262
|
+
place = {"at": list(at or (0.0, 0.0)), "rot": rot}
|
|
263
|
+
if mirror:
|
|
264
|
+
place["mirror"] = True
|
|
265
|
+
if edge:
|
|
266
|
+
place["edge"] = edge
|
|
267
|
+
spec = {"cell": cell_name, "params": params, "place": place}
|
|
268
|
+
if junction:
|
|
269
|
+
spec["junction"] = dict(junction)
|
|
270
|
+
with self._change(f"add {name} ({cell_name})"):
|
|
271
|
+
self.data["instances"][name] = spec
|
|
272
|
+
return InstanceHandle(self, name)
|
|
273
|
+
|
|
274
|
+
def array(
|
|
275
|
+
self,
|
|
276
|
+
name: str,
|
|
277
|
+
cell,
|
|
278
|
+
origin=(0.0, 0.0),
|
|
279
|
+
pitch=(100.0, 100.0),
|
|
280
|
+
shape=(1, 1),
|
|
281
|
+
rot: float = 0.0,
|
|
282
|
+
vary: dict | None = None,
|
|
283
|
+
**params,
|
|
284
|
+
) -> list[InstanceHandle]:
|
|
285
|
+
"""Place ``shape = (columns, rows)`` copies of a cell on a grid (test-pad and junction arrays).
|
|
286
|
+
|
|
287
|
+
Instances are named ``<name>_<col>_<row>``. ``vary`` maps a parameter to one value per copy (column-major,
|
|
288
|
+
e.g. a junction-width sweep); the other ``params`` are shared.
|
|
289
|
+
"""
|
|
290
|
+
(nx, ny), (px, py) = shape, pitch
|
|
291
|
+
handles = []
|
|
292
|
+
with self.batch():
|
|
293
|
+
for i in range(nx):
|
|
294
|
+
for j in range(ny):
|
|
295
|
+
k = i * ny + j
|
|
296
|
+
own = dict(params) | {p: v[k] for p, v in (vary or {}).items()}
|
|
297
|
+
at = (origin[0] + i * px, origin[1] + j * py)
|
|
298
|
+
handles.append(self.add(f"{name}_{i}_{j}", cell, at=at, rot=rot, **own))
|
|
299
|
+
return handles
|
|
300
|
+
|
|
301
|
+
@property
|
|
302
|
+
def chip_ports(self) -> dict:
|
|
303
|
+
"""Chip-level (launcher) ports, referenced as ``"chip.<name>"``."""
|
|
304
|
+
if not self.data["chip"].get("launchers"):
|
|
305
|
+
return {}
|
|
306
|
+
from quantcore_circuits.assembly.plan import _launcher_ports, chip_parameters # pylint: disable=C0415
|
|
307
|
+
|
|
308
|
+
design = self.design # validated: preset defaults filled in
|
|
309
|
+
return _launcher_ports(design.chip.launchers, chip_parameters(design))
|
|
310
|
+
|
|
311
|
+
def route(
|
|
312
|
+
self,
|
|
313
|
+
name: str,
|
|
314
|
+
start,
|
|
315
|
+
end,
|
|
316
|
+
meander: float | None = None,
|
|
317
|
+
type: str | None = None, # noqa: A002
|
|
318
|
+
nodes=None,
|
|
319
|
+
a: float | None = None,
|
|
320
|
+
b: float | None = None,
|
|
321
|
+
r: float | None = None,
|
|
322
|
+
airbridges=None,
|
|
323
|
+
meander_direction: int | None = None,
|
|
324
|
+
**params,
|
|
325
|
+
) -> RouteHandle:
|
|
326
|
+
"""Connect two ports with a CPW (``meander=length`` for a fixed-length meander). ``end`` may be a port,
|
|
327
|
+
``other_route.hanger(...)`` or ``Designer.free_end(...)``; ``nodes`` are waypoints (tuples or
|
|
328
|
+
:meth:`waypoint`). ``meander_direction=-1`` mirrors the meander (its first turn goes the other way)."""
|
|
329
|
+
for p in (start, end):
|
|
330
|
+
if isinstance(p, str):
|
|
331
|
+
self._check_port(p)
|
|
332
|
+
spec: dict = {
|
|
333
|
+
"from": str(start) if isinstance(start, str) else start,
|
|
334
|
+
"to": str(end) if isinstance(end, str) else end,
|
|
335
|
+
}
|
|
336
|
+
if meander is not None:
|
|
337
|
+
spec.update(type="meander", length=float(meander))
|
|
338
|
+
elif type:
|
|
339
|
+
spec["type"] = type
|
|
340
|
+
if nodes:
|
|
341
|
+
spec["nodes"] = [list(n) if isinstance(n, tuple) else n for n in nodes]
|
|
342
|
+
for k, v in (
|
|
343
|
+
("a", a),
|
|
344
|
+
("b", b),
|
|
345
|
+
("r", r),
|
|
346
|
+
("airbridges", airbridges),
|
|
347
|
+
("meander_direction", meander_direction),
|
|
348
|
+
):
|
|
349
|
+
if v is not None:
|
|
350
|
+
spec[k] = v
|
|
351
|
+
if params:
|
|
352
|
+
spec["params"] = params
|
|
353
|
+
with self._change(f"route {name}"):
|
|
354
|
+
self.data["routes"][name] = spec
|
|
355
|
+
return RouteHandle(self, name)
|
|
356
|
+
|
|
357
|
+
@staticmethod
|
|
358
|
+
def waypoint(at, a: float | None = None, b: float | None = None, airbridge: bool = False, **params) -> dict:
|
|
359
|
+
w = {"at": list(at)}
|
|
360
|
+
if a is not None:
|
|
361
|
+
w["a"] = a
|
|
362
|
+
if b is not None:
|
|
363
|
+
w["b"] = b
|
|
364
|
+
if airbridge:
|
|
365
|
+
w["airbridge"] = True
|
|
366
|
+
if params:
|
|
367
|
+
w["params"] = params
|
|
368
|
+
return w
|
|
369
|
+
|
|
370
|
+
@staticmethod
|
|
371
|
+
def free_end(at, dir: float | None = None, term: float = 0.0) -> dict: # noqa: A002
|
|
372
|
+
return {"at": list(at), "dir": dir, "term": term}
|
|
373
|
+
|
|
374
|
+
def remove(self, name: str) -> None:
|
|
375
|
+
with self._change(f"remove {name}"):
|
|
376
|
+
if name in self.data["instances"]:
|
|
377
|
+
del self.data["instances"][name]
|
|
378
|
+
for rname, rt in list(self.data["routes"].items()):
|
|
379
|
+
ends = [e for e in (rt["from"], rt["to"]) if isinstance(e, str)]
|
|
380
|
+
if any(e.split(".", 1)[0] == name for e in ends):
|
|
381
|
+
del self.data["routes"][rname]
|
|
382
|
+
else:
|
|
383
|
+
self.data["routes"].pop(name, None)
|
|
384
|
+
|
|
385
|
+
def couple(
|
|
386
|
+
self,
|
|
387
|
+
name: str,
|
|
388
|
+
a: str,
|
|
389
|
+
b: str,
|
|
390
|
+
C_fF: float | None = None,
|
|
391
|
+
L_nH: float | None = None,
|
|
392
|
+
note: str = "",
|
|
393
|
+
wire: bool = False,
|
|
394
|
+
) -> None:
|
|
395
|
+
"""Declare a lumped coupling no route or snap carries (e.g. qubit arms facing each other).
|
|
396
|
+
|
|
397
|
+
``a``/``b`` are ``"Q1"`` (main island), ``"Q1.<port>"``, ``"Q1.<LOM node>"`` or a route name (its conductor,
|
|
398
|
+
e.g. a hanger against a routed feedline: ``d.couple("K_R1", "R1", "FL")``); give ``C_fF`` (default C,
|
|
399
|
+
value optional: a C-matrix fills it by island name) or ``L_nH``. ``wire=True`` declares a galvanic join of two
|
|
400
|
+
*ports* instead (no element, no geometry): for overlapping metal, e.g. a legacy resonator end drawn inside a
|
|
401
|
+
claw tail.
|
|
402
|
+
"""
|
|
403
|
+
for end in (a, b):
|
|
404
|
+
head = end.split(".", 1)[0]
|
|
405
|
+
if head not in self.data["instances"] and not (not wire and str(end) in self.data["routes"]):
|
|
406
|
+
raise ValueError(f"coupling {name}: no instance or route {head!r}")
|
|
407
|
+
if wire:
|
|
408
|
+
if C_fF is not None or L_nH is not None:
|
|
409
|
+
raise ValueError(f"coupling {name}: a wire takes no value")
|
|
410
|
+
for end in (a, b):
|
|
411
|
+
self._check_port(str(end))
|
|
412
|
+
kind, value = "wire", None
|
|
413
|
+
else:
|
|
414
|
+
kind, value = ("L", L_nH) if L_nH is not None else ("C", C_fF)
|
|
415
|
+
with self._change(f"couple {name}", rebuild=False):
|
|
416
|
+
self.data["couplings"][name] = {"between": [str(a), str(b)], "type": kind, "value": value, "note": note}
|
|
417
|
+
|
|
418
|
+
def targets(self, **per_instance) -> None:
|
|
419
|
+
with self._change("targets", rebuild=False):
|
|
420
|
+
self.data["targets"].update(per_instance)
|
|
421
|
+
|
|
422
|
+
def sim_group(
|
|
423
|
+
self,
|
|
424
|
+
name: str,
|
|
425
|
+
select: list[str],
|
|
426
|
+
margin_um: float = 300.0,
|
|
427
|
+
analyses=("eigenmode_epr", "q3d_cmatrix"), # decision #31: eigenmode/EPR first (the default analysis)
|
|
428
|
+
ports: dict[str, str] | None = None,
|
|
429
|
+
settings: dict | None = None,
|
|
430
|
+
) -> None:
|
|
431
|
+
"""A FEM sub-problem. ``ports`` maps a selected route to ``"keep"`` (not cut for capacitance analyses),
|
|
432
|
+
``"edge"`` or ``"internal"``; ``"edge"`` on a grounded line the box cuts (e.g. a qubit's λ/4 readout when only
|
|
433
|
+
the qubit is selected) terminates it in 50 Ω there for eigenmode / driven runs. ``settings`` are passed to the
|
|
434
|
+
simulation (solver options)."""
|
|
435
|
+
spec = {"select": list(select), "margin_um": margin_um, "analyses": list(analyses)}
|
|
436
|
+
if ports:
|
|
437
|
+
spec["ports"] = dict(ports)
|
|
438
|
+
if settings:
|
|
439
|
+
spec["settings"] = dict(settings)
|
|
440
|
+
with self._change(f"sim group {name}", rebuild=False):
|
|
441
|
+
self.data["sim_groups"][name] = spec
|
|
442
|
+
|
|
443
|
+
def sim_subset(
|
|
444
|
+
self,
|
|
445
|
+
name: str,
|
|
446
|
+
pairs=None,
|
|
447
|
+
qubits=None,
|
|
448
|
+
margin_um: float = 300.0,
|
|
449
|
+
analyses=("eigenmode_epr", "q3d_cmatrix"),
|
|
450
|
+
settings: dict | None = None,
|
|
451
|
+
split: str = "auto",
|
|
452
|
+
verbose: bool = False,
|
|
453
|
+
readouts: bool = True,
|
|
454
|
+
) -> list[str]:
|
|
455
|
+
"""Simulate a subset of the chip (:mod:`quantcore_circuits.sim_tools.subset`): ``pairs=[("Q3", "R3"), ("Q5",
|
|
456
|
+
"R5")]`` (resonator None → the qubit's readout) or ``qubits=["Q3", "Q5"]``. Each chosen qubit comes with its
|
|
457
|
+
readout chain; the feedline is always in the box and cut into 50 Ω ports by it; a bus between two chosen qubits
|
|
458
|
+
comes in, a bus to a qubit outside the subset is cut (``ports={bus: "cut"}``: a 50 Ω stub at the chosen
|
|
459
|
+
qubit's pad). Disjoint pairs get one box each (``split="auto"``; ``"one"``: one box). Adds one sim group per
|
|
460
|
+
box and returns their names (``name`` itself when there is one box, else ``<name>_<qubits>``). The netlist is
|
|
461
|
+
not touched: ``fill(whole_chip_model, design, [jobs])`` fills only these components. ``readouts=False``: the
|
|
462
|
+
qubits alone (the box cuts their readouts into 50 Ω lines; an eigenmode box that fits a workstation)."""
|
|
463
|
+
from quantcore_circuits.sim_tools.subset import describe, plan_subset # pylint: disable=C0415
|
|
464
|
+
|
|
465
|
+
groups = plan_subset(self.design, name, pairs=pairs, qubits=qubits, split=split, readouts=readouts)
|
|
466
|
+
for sg in groups:
|
|
467
|
+
spec = sg.spec(margin_um, analyses, settings)
|
|
468
|
+
self.sim_group(sg.name, spec["select"], margin_um, analyses, spec.get("ports"), settings)
|
|
469
|
+
self.subset_plan = groups
|
|
470
|
+
if verbose:
|
|
471
|
+
print(describe(groups))
|
|
472
|
+
return [sg.name for sg in groups]
|
|
473
|
+
|
|
474
|
+
def __getitem__(self, name: str):
|
|
475
|
+
if name in self.data["instances"]:
|
|
476
|
+
return InstanceHandle(self, name)
|
|
477
|
+
if name in self.data["routes"]:
|
|
478
|
+
return RouteHandle(self, name)
|
|
479
|
+
raise KeyError(name)
|
|
480
|
+
|
|
481
|
+
# ---- live --------------------------------------------------------------------------------------------------
|
|
482
|
+
@contextlib.contextmanager
|
|
483
|
+
def batch(self):
|
|
484
|
+
"""Group several changes into one rebuild."""
|
|
485
|
+
self._batch += 1
|
|
486
|
+
try:
|
|
487
|
+
yield self
|
|
488
|
+
finally:
|
|
489
|
+
self._batch -= 1
|
|
490
|
+
if self._batch == 0 and self._dirty and self.live:
|
|
491
|
+
self.show()
|
|
492
|
+
|
|
493
|
+
@contextlib.contextmanager
|
|
494
|
+
def _change(self, what: str, rebuild: bool = True):
|
|
495
|
+
backup = copy.deepcopy(self.data)
|
|
496
|
+
try:
|
|
497
|
+
yield
|
|
498
|
+
self.design # noqa: B018 (validate now: bad specs raise here, with the old state restored)
|
|
499
|
+
except Exception:
|
|
500
|
+
self.data = backup
|
|
501
|
+
raise
|
|
502
|
+
self.history.append(what)
|
|
503
|
+
self._dirty = True
|
|
504
|
+
if rebuild and self.live and self._batch == 0:
|
|
505
|
+
self.show(quiet_errors=True)
|
|
506
|
+
if self.delay:
|
|
507
|
+
time.sleep(self.delay)
|
|
508
|
+
|
|
509
|
+
def show(self, quiet_errors: bool = False):
|
|
510
|
+
"""Build, write ``build/<name>.oas`` (+ sidecar) and reload KLayout (starting it if needed)."""
|
|
511
|
+
from quantcore_circuits.assembly import build, write_layout # pylint: disable=import-outside-toplevel
|
|
512
|
+
from quantcore_circuits.live import klive_available, send_to_klive # pylint: disable=import-outside-toplevel
|
|
513
|
+
|
|
514
|
+
t0 = time.perf_counter()
|
|
515
|
+
try:
|
|
516
|
+
result = build(self.design)
|
|
517
|
+
except Exception as e: # noqa: BLE001
|
|
518
|
+
if not quiet_errors:
|
|
519
|
+
raise
|
|
520
|
+
if self.verbose:
|
|
521
|
+
print(f"[qcc] {self.history[-1] if self.history else 'build'}: not built yet — {type(e).__name__}: {e}")
|
|
522
|
+
return self.result
|
|
523
|
+
self.result = result
|
|
524
|
+
write_layout(result, self.out)
|
|
525
|
+
if self.path and self._autosave:
|
|
526
|
+
self.save(self.path)
|
|
527
|
+
if self.live:
|
|
528
|
+
self._live_klayout(klive_available, send_to_klive)
|
|
529
|
+
self._dirty = False
|
|
530
|
+
if self.verbose and self.live:
|
|
531
|
+
last = self.history[-1] if self.history else "build"
|
|
532
|
+
print(f"[qcc] {last}: built in {time.perf_counter() - t0:.2f} s → {self.out}")
|
|
533
|
+
return result
|
|
534
|
+
|
|
535
|
+
def _live_klayout(self, klive_available, send_to_klive) -> None:
|
|
536
|
+
"""Redraw in KLayout: start it when klive is not listening (unless switched off, or the KLayout this designer
|
|
537
|
+
started is still coming up), send the layout, raise the window on the first build / after a start."""
|
|
538
|
+
from quantcore_circuits.live import klayout as kl # pylint: disable=import-outside-toplevel
|
|
539
|
+
|
|
540
|
+
may_open = kl.gui_enabled() if self._open is None else bool(self._open)
|
|
541
|
+
started = False
|
|
542
|
+
if not klive_available() and may_open:
|
|
543
|
+
if self._kl_pid and self._kl_pid in kl.klayout_pids():
|
|
544
|
+
if self.verbose and not self._kl_hint: # ours is open but klive never came up: do not start more
|
|
545
|
+
print(f"[qcc] KLayout pid {self._kl_pid} is open but klive is not listening on localhost:8082")
|
|
546
|
+
self._kl_hint = True
|
|
547
|
+
else:
|
|
548
|
+
try:
|
|
549
|
+
info = kl.open_klayout(self.out, front=False)
|
|
550
|
+
except FileNotFoundError as e: # no KLayout installed: stay headless (layouts are still written)
|
|
551
|
+
info = {"started": False, "klive": False, "hint": str(e)}
|
|
552
|
+
self._open = False
|
|
553
|
+
started = bool(info.get("started"))
|
|
554
|
+
self._kl_pid = info.get("pid") or self._kl_pid
|
|
555
|
+
if self.verbose:
|
|
556
|
+
print(f"[qcc] KLayout: {info}")
|
|
557
|
+
sent = klive_available()
|
|
558
|
+
if sent:
|
|
559
|
+
send_to_klive(self.out)
|
|
560
|
+
if may_open and (started or (sent and self._front)): # only a window that shows this layout
|
|
561
|
+
kl.bring_to_front(self._kl_pid if started else None, self.out)
|
|
562
|
+
self._front = False
|
|
563
|
+
|
|
564
|
+
# ---- outputs -----------------------------------------------------------------------------------------------
|
|
565
|
+
@property
|
|
566
|
+
def design(self):
|
|
567
|
+
from quantcore_circuits.design import load_design # pylint: disable=import-outside-toplevel
|
|
568
|
+
|
|
569
|
+
return load_design(copy.deepcopy(self.data))
|
|
570
|
+
|
|
571
|
+
def save(self, path: str | Path) -> Path:
|
|
572
|
+
path = Path(path)
|
|
573
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
574
|
+
path.write_text(json.dumps(self.design.to_json_dict(), indent=2) + "\n", encoding="utf-8")
|
|
575
|
+
self.path = path
|
|
576
|
+
return path
|
|
577
|
+
|
|
578
|
+
def lom(self, select: list[str] | None = None):
|
|
579
|
+
"""Lumped circuit of this layout (component estimates; see :mod:`quantcore_circuits.lom`)."""
|
|
580
|
+
from quantcore_circuits.lom import lom_from_design # pylint: disable=import-outside-toplevel
|
|
581
|
+
|
|
582
|
+
return lom_from_design(self.design, select)
|
|
583
|
+
|
|
584
|
+
def drc(self):
|
|
585
|
+
from quantcore_circuits.assembly.drc import check # pylint: disable=import-outside-toplevel
|
|
586
|
+
|
|
587
|
+
return check(self.result or self.design)
|
|
588
|
+
|
|
589
|
+
# ---- validation ----------------------------------------------------------------------------------------------
|
|
590
|
+
@staticmethod
|
|
591
|
+
def _check_cell(cell: str, params: dict) -> None:
|
|
592
|
+
if cell.startswith("static:"):
|
|
593
|
+
return
|
|
594
|
+
from quantcore_circuits.layouts.registry import list_components, resolve_cell # pylint: disable=C0415
|
|
595
|
+
|
|
596
|
+
try:
|
|
597
|
+
cls = resolve_cell(cell)
|
|
598
|
+
except Exception as e: # noqa: BLE001
|
|
599
|
+
raise ValueError(f"unknown cell {cell!r}; available: {sorted(list_components())}") from e
|
|
600
|
+
if hasattr(cls, "qcc_params"): # wrapper cell: it validates its own parameters
|
|
601
|
+
cls.qcc_params(dict(params))
|
|
602
|
+
return
|
|
603
|
+
schema = cls.get_schema()
|
|
604
|
+
unknown = sorted(set(params) - set(schema))
|
|
605
|
+
if unknown:
|
|
606
|
+
close = sorted(n for n in schema if not n.startswith("_"))
|
|
607
|
+
raise ValueError(f"{cell}: unknown parameter(s) {unknown}; parameters: {close}")
|
|
608
|
+
|
|
609
|
+
def _check_port(self, ref: str) -> None:
|
|
610
|
+
inst, _, port = ref.partition(".")
|
|
611
|
+
if inst == "chip" and inst not in self.data["instances"]:
|
|
612
|
+
if port not in self.chip_ports:
|
|
613
|
+
raise ValueError(f"{ref!r}: chip launchers are {sorted(self.chip_ports)}")
|
|
614
|
+
return
|
|
615
|
+
if inst not in self.data["instances"]:
|
|
616
|
+
raise ValueError(f"{ref!r}: no instance {inst!r} (placed: {sorted(self.data['instances'])})")
|
|
617
|
+
h = InstanceHandle(self, inst)
|
|
618
|
+
if port not in h.ports:
|
|
619
|
+
raise ValueError(f"{ref!r}: {inst} has ports {sorted(h.ports)}")
|
|
620
|
+
|
|
621
|
+
def __repr__(self) -> str:
|
|
622
|
+
return (
|
|
623
|
+
f"<Designer {self.data['name']}: {len(self.data['instances'])} instances, "
|
|
624
|
+
f"{len(self.data['routes'])} routes, live={self.live}>"
|
|
625
|
+
)
|