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.
Files changed (272) hide show
  1. quantcore_circuits/__init__.py +57 -0
  2. quantcore_circuits/analysis/__init__.py +12 -0
  3. quantcore_circuits/analysis/_metal.py +70 -0
  4. quantcore_circuits/analysis/amplifiers.py +263 -0
  5. quantcore_circuits/analysis/circuits.py +117 -0
  6. quantcore_circuits/analysis/epr.py +231 -0
  7. quantcore_circuits/analysis/epr_lumped.py +372 -0
  8. quantcore_circuits/analysis/extract.py +119 -0
  9. quantcore_circuits/analysis/lom.py +80 -0
  10. quantcore_circuits/analysis/results.py +549 -0
  11. quantcore_circuits/analysis/store.py +81 -0
  12. quantcore_circuits/analysis/synthesis.py +118 -0
  13. quantcore_circuits/analysis/transmon.py +126 -0
  14. quantcore_circuits/assembly/__init__.py +17 -0
  15. quantcore_circuits/assembly/builder.py +127 -0
  16. quantcore_circuits/assembly/drc.py +683 -0
  17. quantcore_circuits/assembly/last_good.py +137 -0
  18. quantcore_circuits/assembly/netlist.py +174 -0
  19. quantcore_circuits/assembly/plan.py +605 -0
  20. quantcore_circuits/assembly/sidecar.py +270 -0
  21. quantcore_circuits/autotrack.py +605 -0
  22. quantcore_circuits/cards.py +878 -0
  23. quantcore_circuits/circuit/__init__.py +14 -0
  24. quantcore_circuits/circuit/adapters.py +305 -0
  25. quantcore_circuits/circuit/bridges.py +353 -0
  26. quantcore_circuits/circuit/consensus.py +158 -0
  27. quantcore_circuits/circuit/derive.py +28 -0
  28. quantcore_circuits/circuit/draw.py +198 -0
  29. quantcore_circuits/circuit/fill.py +828 -0
  30. quantcore_circuits/circuit/hamiltonian.py +193 -0
  31. quantcore_circuits/circuit/kinetic.py +102 -0
  32. quantcore_circuits/circuit/schema.py +139 -0
  33. quantcore_circuits/cli.py +1085 -0
  34. quantcore_circuits/codesign.py +1038 -0
  35. quantcore_circuits/data/selftest_q1_r1.json +44 -0
  36. quantcore_circuits/design/__init__.py +44 -0
  37. quantcore_circuits/design/io.py +98 -0
  38. quantcore_circuits/design/pyscript.py +395 -0
  39. quantcore_circuits/design/schema.py +398 -0
  40. quantcore_circuits/designer.py +625 -0
  41. quantcore_circuits/guiflow.py +991 -0
  42. quantcore_circuits/kqc_files.py +208 -0
  43. quantcore_circuits/layouts/__init__.py +118 -0
  44. quantcore_circuits/layouts/catalog.py +520 -0
  45. quantcore_circuits/layouts/chips/__init__.py +0 -0
  46. quantcore_circuits/layouts/chips/design_chip.py +325 -0
  47. quantcore_circuits/layouts/chips/frame.py +235 -0
  48. quantcore_circuits/layouts/junctions/__init__.py +0 -0
  49. quantcore_circuits/layouts/junctions/jj_fingers.py +99 -0
  50. quantcore_circuits/layouts/junctions/legacy_junctions.py +237 -0
  51. quantcore_circuits/layouts/junctions/sim_gap.py +48 -0
  52. quantcore_circuits/layouts/junctions/trilayer.py +541 -0
  53. quantcore_circuits/layouts/metal/__init__.py +105 -0
  54. quantcore_circuits/layouts/metal/component.py +332 -0
  55. quantcore_circuits/layouts/metal/geometry.py +462 -0
  56. quantcore_circuits/layouts/others/__init__.py +0 -0
  57. quantcore_circuits/layouts/others/amplifiers.py +1139 -0
  58. quantcore_circuits/layouts/others/bond_pad.py +119 -0
  59. quantcore_circuits/layouts/others/connector_pads.py +190 -0
  60. quantcore_circuits/layouts/others/couplers.py +21 -0
  61. quantcore_circuits/layouts/others/cpw_segment.py +131 -0
  62. quantcore_circuits/layouts/others/cpwe.py +661 -0
  63. quantcore_circuits/layouts/others/keepout.py +66 -0
  64. quantcore_circuits/layouts/others/legacy_resonators.py +645 -0
  65. quantcore_circuits/layouts/others/markers.py +201 -0
  66. quantcore_circuits/layouts/others/qpdk_cells.py +263 -0
  67. quantcore_circuits/layouts/others/shapes.py +114 -0
  68. quantcore_circuits/layouts/others/spirals.py +140 -0
  69. quantcore_circuits/layouts/others/sqdmetal_cells.py +90 -0
  70. quantcore_circuits/layouts/others/test_pads.py +461 -0
  71. quantcore_circuits/layouts/ports.py +119 -0
  72. quantcore_circuits/layouts/qubits/__init__.py +0 -0
  73. quantcore_circuits/layouts/qubits/legacy_transmon.py +124 -0
  74. quantcore_circuits/layouts/qubits/qpdk_cells.py +374 -0
  75. quantcore_circuits/layouts/qubits/sqdmetal_cells.py +376 -0
  76. quantcore_circuits/layouts/qubits/trilayer_concentric.py +65 -0
  77. quantcore_circuits/layouts/qubits/xmon.py +375 -0
  78. quantcore_circuits/layouts/registry.py +418 -0
  79. quantcore_circuits/layouts/wafers/__init__.py +0 -0
  80. quantcore_circuits/layouts/wafers/fab_export.py +454 -0
  81. quantcore_circuits/layouts/wafers/legacy_wafer.py +111 -0
  82. quantcore_circuits/layouts/wafers/wafer.py +469 -0
  83. quantcore_circuits/live/__init__.py +6 -0
  84. quantcore_circuits/live/klayout.py +225 -0
  85. quantcore_circuits/live/klive.py +61 -0
  86. quantcore_circuits/live/snapshot.py +185 -0
  87. quantcore_circuits/live/watch.py +93 -0
  88. quantcore_circuits/lom/__init__.py +15 -0
  89. quantcore_circuits/lom/builder.py +932 -0
  90. quantcore_circuits/lom/calibration.py +82 -0
  91. quantcore_circuits/lom/estimates.py +235 -0
  92. quantcore_circuits/lom/fragment.py +421 -0
  93. quantcore_circuits/lom/kqc_models.py +734 -0
  94. quantcore_circuits/lom/metal_models.py +917 -0
  95. quantcore_circuits/lom/quantcore_models.py +784 -0
  96. quantcore_circuits/lom/simulate.py +636 -0
  97. quantcore_circuits/lom/synthesize.py +189 -0
  98. quantcore_circuits/loop.py +610 -0
  99. quantcore_circuits/optimise.py +423 -0
  100. quantcore_circuits/pdk/__init__.py +451 -0
  101. quantcore_circuits/plots.py +876 -0
  102. quantcore_circuits/plugins.py +69 -0
  103. quantcore_circuits/review/__init__.py +57 -0
  104. quantcore_circuits/review/server.py +251 -0
  105. quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  106. quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  107. quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  108. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  109. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  110. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  111. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  112. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  113. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  114. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  115. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  116. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  117. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  118. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  119. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  120. quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  121. quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  122. quantcore_circuits/review/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  123. quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  124. quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  125. quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  126. quantcore_circuits/review/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  127. quantcore_circuits/review/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  128. quantcore_circuits/review/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  129. quantcore_circuits/review/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  130. quantcore_circuits/review/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  131. quantcore_circuits/review/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  132. quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  133. quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  134. quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  135. quantcore_circuits/review/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  136. quantcore_circuits/review/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  137. quantcore_circuits/review/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  138. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  139. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  140. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  141. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  142. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  143. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  144. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  145. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  146. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  147. quantcore_circuits/review/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  148. quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  149. quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  150. quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  151. quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  152. quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  153. quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  154. quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  155. quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  156. quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  157. quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  158. quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  159. quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  160. quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  161. quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  162. quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  163. quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  164. quantcore_circuits/review/static/assets/index-CDHdrFyA.css +1 -0
  165. quantcore_circuits/review/static/assets/index-CSx05Og4.js +409 -0
  166. quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-HOLc17fK.woff +0 -0
  167. quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-obahsSVq.woff2 +0 -0
  168. quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-BasfLYem.woff2 +0 -0
  169. quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-CxZf_p3X.woff +0 -0
  170. quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-4D_pXhcN.woff +0 -0
  171. quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-CWCymEST.woff2 +0 -0
  172. quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-CjBOestx.woff2 +0 -0
  173. quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-DrXBdSj3.woff +0 -0
  174. quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-BQZuk6qB.woff2 +0 -0
  175. quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-DQukG94-.woff +0 -0
  176. quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-B0yAr1jD.woff2 +0 -0
  177. quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-BmqWE9Dz.woff +0 -0
  178. quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Bcila6Z-.woff +0 -0
  179. quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Dfes3d0z.woff2 +0 -0
  180. quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-BjwYoWNd.woff2 +0 -0
  181. quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-LO58E6JB.woff +0 -0
  182. quantcore_circuits/review/static/assets/inter-greek-400-normal-B4URO6DV.woff2 +0 -0
  183. quantcore_circuits/review/static/assets/inter-greek-400-normal-q2sYcFCs.woff +0 -0
  184. quantcore_circuits/review/static/assets/inter-greek-500-normal-BIZE56-Y.woff2 +0 -0
  185. quantcore_circuits/review/static/assets/inter-greek-500-normal-Xzm54t5V.woff +0 -0
  186. quantcore_circuits/review/static/assets/inter-greek-600-normal-BZpKdvQh.woff +0 -0
  187. quantcore_circuits/review/static/assets/inter-greek-600-normal-plRanbMR.woff2 +0 -0
  188. quantcore_circuits/review/static/assets/inter-greek-700-normal-BUv2fZ6O.woff +0 -0
  189. quantcore_circuits/review/static/assets/inter-greek-700-normal-C3JjAnD8.woff2 +0 -0
  190. quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-DGGRlc-M.woff2 +0 -0
  191. quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-KugGGMne.woff +0 -0
  192. quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-2j5mBUwD.woff +0 -0
  193. quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-C4iEst2y.woff2 +0 -0
  194. quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-B8X0CLgF.woff +0 -0
  195. quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-DRtmH8MT.woff2 +0 -0
  196. quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-BoQ6DsYi.woff +0 -0
  197. quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-qfdV9bQt.woff2 +0 -0
  198. quantcore_circuits/review/static/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
  199. quantcore_circuits/review/static/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
  200. quantcore_circuits/review/static/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
  201. quantcore_circuits/review/static/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
  202. quantcore_circuits/review/static/assets/inter-latin-600-normal-CiBQ2DWP.woff +0 -0
  203. quantcore_circuits/review/static/assets/inter-latin-600-normal-LgqL8muc.woff2 +0 -0
  204. quantcore_circuits/review/static/assets/inter-latin-700-normal-BLAVimhd.woff +0 -0
  205. quantcore_circuits/review/static/assets/inter-latin-700-normal-Yt3aPRUw.woff2 +0 -0
  206. quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-77YHD8bZ.woff +0 -0
  207. quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-C1nco2VV.woff2 +0 -0
  208. quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-BxGbmqWO.woff +0 -0
  209. quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-CV4jyFjo.woff2 +0 -0
  210. quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-CIVaiw4L.woff +0 -0
  211. quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-D2bJ5OIk.woff2 +0 -0
  212. quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-Ca8adRJv.woff2 +0 -0
  213. quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-TidjK2hL.woff +0 -0
  214. quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-Bbgyi5SW.woff +0 -0
  215. quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-DMkecbls.woff2 +0 -0
  216. quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-DOriooB6.woff2 +0 -0
  217. quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-mJboJaSs.woff +0 -0
  218. quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-BuLX-rYi.woff +0 -0
  219. quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-Cc8MFFhd.woff2 +0 -0
  220. quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-BZaoP0fm.woff +0 -0
  221. quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-DlLaEgI2.woff2 +0 -0
  222. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  223. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  224. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
  225. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
  226. quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  227. quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  228. quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
  229. quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
  230. quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  231. quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  232. quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  233. quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
  234. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  235. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  236. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
  237. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
  238. quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  239. quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
  240. quantcore_circuits/review/static/index.html +14 -0
  241. quantcore_circuits/review/static/logo-quantcore-black.png +0 -0
  242. quantcore_circuits/review/static/logo-quantcore-white.png +0 -0
  243. quantcore_circuits/review/static/sample/chip.png +0 -0
  244. quantcore_circuits/review/static/sample/chip_rev1.png +0 -0
  245. quantcore_circuits/review/static/sample/q1.png +0 -0
  246. quantcore_circuits/review/static/sample/q2.png +0 -0
  247. quantcore_circuits/review/static/sample-state.json +3747 -0
  248. quantcore_circuits/route/__init__.py +5 -0
  249. quantcore_circuits/route/router.py +694 -0
  250. quantcore_circuits/route/waveguide.py +187 -0
  251. quantcore_circuits/selftest.py +224 -0
  252. quantcore_circuits/sim_tools/__init__.py +6 -0
  253. quantcore_circuits/sim_tools/aedt_attach.py +66 -0
  254. quantcore_circuits/sim_tools/aedt_progress.py +224 -0
  255. quantcore_circuits/sim_tools/aedt_project.py +302 -0
  256. quantcore_circuits/sim_tools/aedt_scripts.py +397 -0
  257. quantcore_circuits/sim_tools/aedt_session.py +275 -0
  258. quantcore_circuits/sim_tools/ansys.py +90 -0
  259. quantcore_circuits/sim_tools/builder.py +1690 -0
  260. quantcore_circuits/sim_tools/export.py +470 -0
  261. quantcore_circuits/sim_tools/geometry_check.py +342 -0
  262. quantcore_circuits/sim_tools/hfss.py +583 -0
  263. quantcore_circuits/sim_tools/palace.py +197 -0
  264. quantcore_circuits/sim_tools/runner.py +179 -0
  265. quantcore_circuits/sim_tools/subset.py +364 -0
  266. quantcore_circuits/track.py +671 -0
  267. quantcore_circuits-0.0.1.dist-info/METADATA +204 -0
  268. quantcore_circuits-0.0.1.dist-info/RECORD +272 -0
  269. quantcore_circuits-0.0.1.dist-info/WHEEL +5 -0
  270. quantcore_circuits-0.0.1.dist-info/entry_points.txt +2 -0
  271. quantcore_circuits-0.0.1.dist-info/licenses/LICENSE +674 -0
  272. quantcore_circuits-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,610 @@
1
+ """The analysis half of the design loop, step by step, recording everything for the dashboard.
2
+
3
+ :func:`analyse` — job results → ``circuit.json`` (filled: design vs extracted values) → Metal LOM / QuCat /
4
+ SQcircuit / scqubits → QuTiP Hamiltonian (dressed levels, simulated readout χ, flux curve) → consensus vs targets.
5
+ The design is planned once for the circuit and its fill; with ``out_dir`` the four estimators' results are kept in
6
+ ``estimates_cache.json`` and reused while the circuit they read is the same (a second analysis of the same design and
7
+ jobs, e.g. Propose after Simulate or Import, skips them).
8
+ :func:`feedback` — a surrogate per qubit–readout pair anchored on that point (FEM or the layout's estimates; every
9
+ qubit class with a LOM model, λ/4 and λ/2 readouts, :mod:`quantcore_circuits.codesign`) → proposed knobs → design
10
+ revision (rebuilt and checked, or only written for a preview), with notes on what could not be tuned.
11
+
12
+ Both update a :class:`~quantcore_circuits.track.Run` (``build/<design>/state.json``) when given one, and return
13
+ plain data for notebooks and plots (:mod:`quantcore_circuits.plots`).
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ from dataclasses import dataclass, field
20
+ from pathlib import Path
21
+
22
+ from quantcore_circuits import plots as P
23
+ from quantcore_circuits import track as _track
24
+ from quantcore_circuits.autotrack import _fem_compare
25
+
26
+ BRANCH_TYPE = {"C": "C", "L": "L", "JJ": "JJ", "SQUID": "SQUID", "TLres": "TL", "R": "R", "HANGER": "HANGER"}
27
+ TARGET_LABEL = {
28
+ "f_q_GHz": "frequency",
29
+ "alpha_MHz": "anharmonicity",
30
+ "f_GHz": "frequency",
31
+ "g_MHz": "coupling",
32
+ "chi_MHz": "dispersive shift",
33
+ "kappa_MHz": "linewidth",
34
+ }
35
+
36
+
37
+ @dataclass
38
+ class Analysis:
39
+ model: object # CircuitModel
40
+ filled: object # FilledCircuit
41
+ estimates: dict
42
+ rows: list
43
+ goal: dict
44
+ hamiltonian: object | None = None # TransmonResonator
45
+ dressed: dict | None = None
46
+ readout: dict | None = None
47
+ flux: dict | None = None
48
+ plots: list[dict] = field(default_factory=list)
49
+ # every transmon–resonator pair solved in QuTiP: qubit → {resonator, hamiltonian, dressed, readout, flux};
50
+ # ``hamiltonian`` / ``dressed`` / ``readout`` / ``flux`` above are the first pair's (the Hamiltonian tab)
51
+ pair_results: dict[str, dict] = field(default_factory=dict)
52
+ plan: object | None = None # the design's build plan the circuit was derived from (feedback reuses it)
53
+
54
+
55
+ def pair_plot_id(kind: str, qubit: str, an: Analysis) -> str:
56
+ """Plot id of a per-pair plot (``levels``, ``readout``, ``flux``): bare for the first pair, ``<kind>_<qubit>``
57
+ for the others."""
58
+ first = next(iter(an.pair_results), None)
59
+ return kind if qubit == first else f"{kind}_{qubit}"
60
+
61
+
62
+ def dashboard_circuit(filled) -> dict:
63
+ model = filled.model
64
+ nodes = [n for n in model.nodes if not model.nodes[n].ground]
65
+ qubits = [
66
+ n
67
+ for n in nodes
68
+ if "." not in n and any(b.type in ("JJ", "SQUID") and n in b.nodes for b in model.branches.values())
69
+ ]
70
+ couplers = [n for n in nodes if "." in n]
71
+ others = [n for n in nodes if n not in qubits and n not in couplers]
72
+ order = qubits + couplers + others
73
+ pos = {n: [round((i + 1) / (len(order) + 1), 3), 0.35] for i, n in enumerate(order)}
74
+ out_nodes = [{"id": model.ground, "label": "ground", "ground": True, "pos": [0.5, 0.95]}]
75
+ for n in order:
76
+ isl = model.nodes[n].island
77
+ label = f"{n} island" if n in qubits else (f"{n.replace('.', ' ')}" if n in couplers else n)
78
+ out_nodes.append({"id": n, "label": label, "island": isl, "pos": pos[n]})
79
+ labels = {"C_": "C", "Cg_": "C_g", "Cc_": "C_c", "K_": "κ hanger", "J_": "L_J", "Port_": "port"}
80
+ branches = []
81
+ for name, v in filled.values.items():
82
+ b = model.branches[name]
83
+ label = next((lab for pre, lab in labels.items() if name.startswith(pre)), f"λ/4 {name}")
84
+ if name.startswith("C_"):
85
+ label = f"C_{name[2:]}"
86
+ branches.append(
87
+ {
88
+ "id": name,
89
+ "type": BRANCH_TYPE[b.type],
90
+ "nodes": list(b.nodes),
91
+ "value": v.value,
92
+ "designValue": v.design,
93
+ "unit": v.unit,
94
+ "label": label,
95
+ "source": f"{v.origin}: {v.source}",
96
+ }
97
+ )
98
+ return {"name": model.name, "nodes": out_nodes, "branches": branches}
99
+
100
+
101
+ def dashboard_targets(rows) -> list[dict]:
102
+ out = []
103
+ for r in rows:
104
+ if r.target is None:
105
+ continue
106
+ inst = r.param.split(".", 1)[0]
107
+ out.append(
108
+ {
109
+ "key": r.param,
110
+ "label": f"{inst} {TARGET_LABEL.get(r.quantity, r.quantity)}",
111
+ "symbol": r.symbol,
112
+ "unit": r.unit,
113
+ "target": r.target,
114
+ "tol": r.tol,
115
+ "value": r.chosen,
116
+ "source": r.chosen_by,
117
+ "status": r.status,
118
+ }
119
+ )
120
+ return out
121
+
122
+
123
+ def dashboard_consensus(rows) -> list[dict]:
124
+ return [
125
+ {
126
+ "param": r.param,
127
+ "label": r.symbol,
128
+ "unit": r.unit,
129
+ "target": r.target,
130
+ "values": r.values,
131
+ "chosen": r.chosen,
132
+ "chosenBy": r.chosen_by,
133
+ "spreadRel": r.spread_rel,
134
+ "flagged": r.flagged,
135
+ }
136
+ for r in rows
137
+ if r.quantity not in ("EJ_GHz", "EC_GHz")
138
+ ]
139
+
140
+
141
+ def analyse(
142
+ design,
143
+ job_dir=None,
144
+ group: str | None = None,
145
+ run=None,
146
+ readout: bool = True,
147
+ kappa_MHz: float | None = None,
148
+ out_dir: str | Path | None = None,
149
+ ) -> Analysis:
150
+ """Job → circuit → estimators → QuTiP → consensus (module docstring). ``run`` None: the dashboard tracking
151
+ session's run (:func:`quantcore_circuits.track.start`), if there is one."""
152
+ run = run or _track.run_for(design if not isinstance(design, dict) else None)
153
+ # this function records fill / LOM / targets itself; state.json is written per step, not per plot / note
154
+ with _track.quiet(), _deferred(run):
155
+ return _analyse(design, job_dir, group, run, readout, kappa_MHz, out_dir)
156
+
157
+
158
+ def _deferred(run):
159
+ """``run.deferred()`` (:meth:`quantcore_circuits.track.Run.deferred`), or nothing without a run."""
160
+ import contextlib # pylint: disable=import-outside-toplevel
161
+
162
+ fn = getattr(run, "deferred", None)
163
+ return fn() if callable(fn) else contextlib.nullcontext()
164
+
165
+
166
+ def _analyse(design, job_dir, group, run, readout, kappa_MHz, out_dir) -> Analysis:
167
+ from quantcore_circuits.circuit import hamiltonian as H # pylint: disable=import-outside-toplevel
168
+ from quantcore_circuits.circuit.adapters import solve_all # pylint: disable=import-outside-toplevel
169
+ from quantcore_circuits.circuit.consensus import ( # pylint: disable=import-outside-toplevel
170
+ consensus,
171
+ flag_near_resonance,
172
+ goal,
173
+ report_markdown,
174
+ save,
175
+ )
176
+ from quantcore_circuits.circuit.derive import circuit_from_design # pylint: disable=import-outside-toplevel
177
+ from quantcore_circuits.circuit.fill import fill, load_results # pylint: disable=import-outside-toplevel
178
+ from quantcore_circuits.circuit.schema import save_circuit # pylint: disable=import-outside-toplevel
179
+
180
+ # a list of jobs (subset jobs): the whole chip's netlist, each job filling its own components (circuit.fill)
181
+ many = isinstance(job_dir, (list, tuple))
182
+ first = (job_dir[0] if job_dir else None) if many else job_dir
183
+ results, job = load_results(first) if first is not None else ({}, None)
184
+ group = group or ("chip" if many else None) or results.get("group") or (job or {}).get("group") or "chip"
185
+ if run:
186
+ run.start("extract")
187
+ from quantcore_circuits.assembly.last_good import plan_for_lom # pylint: disable=import-outside-toplevel
188
+ from quantcore_circuits.design import load_design # pylint: disable=import-outside-toplevel
189
+
190
+ plan = plan_for_lom(load_design(design), design) # planned once: the circuit and its fill read the same plan
191
+ model = circuit_from_design(design, group, plan=plan)
192
+ # job_dir None: layout → LOM estimates only
193
+ filled = fill(model, design, list(job_dir) if many else job_dir, plan=plan)
194
+ if run:
195
+ for note in filled.notes:
196
+ run.log(note, "warn" if note.startswith("stack") else "info")
197
+ p0 = filled.pairs[0] if filled.pairs else None
198
+ summary = (
199
+ f"C_Σ {p0.c_island_fF + p0.cg_fF:.1f} fF · C_g {p0.cg_fF:.2f} fF · claw {p0.c_coupler_fF:.1f} fF"
200
+ if p0
201
+ else "no transmon–resonator pair in the C-matrix"
202
+ )
203
+ run.set(
204
+ circuit=dashboard_circuit(filled),
205
+ cmatrix={**filled.cmatrix, "unit": "fF", "job": filled.job} if filled.cmatrix else None,
206
+ femCompare=_fem_compare(filled) if filled.cmatrix else [],
207
+ )
208
+ run.done("extract", summary)
209
+ run.start("hamiltonian")
210
+ estimates = _solve_cached(filled, out_dir, solve_all)
211
+ an = Analysis(model, filled, estimates, [], {}, plan=plan)
212
+ qutip_est = {}
213
+ for pair in filled.pairs: # one QuTiP model per transmon–resonator pair (multi-qubit chips)
214
+ if pair.qubit in an.pair_results:
215
+ continue # a qubit with two resonators: the first (readout) pair defines its Hamiltonian
216
+ ham = H.from_pair(
217
+ pair, nq=model.truncation.get("qubit_levels", 8), nr=model.truncation.get("resonator_levels", 6)
218
+ )
219
+ dressed = H.dressed(ham)
220
+ qutip_est.update(
221
+ {
222
+ f"{pair.qubit}.f_q_GHz": dressed["f_q_GHz"],
223
+ f"{pair.qubit}.alpha_MHz": dressed["alpha_MHz"],
224
+ f"{pair.resonator}.f_GHz": dressed["f_r_GHz"],
225
+ f"{pair.resonator}.chi_MHz": dressed["chi_MHz"],
226
+ f"{pair.resonator}.g_MHz": dressed["g_MHz"],
227
+ }
228
+ )
229
+ kappa = kappa_MHz or getattr(pair, "kappa_MHz", None) or 1.0
230
+ an.pair_results[pair.qubit] = {
231
+ "resonator": pair.resonator,
232
+ "hamiltonian": ham,
233
+ "dressed": dressed,
234
+ "readout": H.readout(ham, kappa_MHz=kappa) if readout else None,
235
+ # the SQUID's curve from its zero-flux E_J (ham.EJ_GHz is at the design flux) and its asymmetry
236
+ "flux": H.flux_curve(ham.EJ_GHz * pair.ej_sum_ratio, ham.EC_GHz, pair.asym) if pair.squid else None,
237
+ }
238
+ if an.pair_results:
239
+ first = next(iter(an.pair_results.values()))
240
+ an.hamiltonian, an.dressed, an.readout, an.flux = (
241
+ first["hamiltonian"],
242
+ first["dressed"],
243
+ first["readout"],
244
+ first["flux"],
245
+ )
246
+ estimates["qutip"] = qutip_est
247
+ an.rows = consensus(estimates, model.targets)
248
+ for note in flag_near_resonance(an.rows, an.filled.pairs):
249
+ if run:
250
+ run.log(note, "warn")
251
+ an.goal = goal(an.rows)
252
+ an.plots = _plots(an)
253
+ if out_dir:
254
+ out = Path(out_dir)
255
+ save_circuit(model, out / "circuit.json")
256
+ save(an.rows, out / "consensus.json")
257
+ (out / "consensus.md").write_text(report_markdown(an.rows, f"Consensus — {model.name}"), encoding="utf-8")
258
+ (out / "estimates.json").write_text(json.dumps(estimates, indent=2, default=float), encoding="utf-8")
259
+ if run:
260
+ d = an.dressed or {}
261
+ tr = model.truncation
262
+ run.set(
263
+ hamiltonian=_dashboard_hamiltonian(an, tr),
264
+ consensus=dashboard_consensus(an.rows),
265
+ targets=dashboard_targets(an.rows),
266
+ goal=an.goal,
267
+ )
268
+ for spec in an.plots:
269
+ run.plot(spec)
270
+ chi_r = an.readout["chi_readout_MHz"] if an.readout else None
271
+ run.done(
272
+ "hamiltonian",
273
+ f"QuTiP {tr.get('qubit_levels', 8)}×{tr.get('resonator_levels', 6)}: f_q "
274
+ f"{d.get('f_q_GHz', 0):.4f} GHz · α {d.get('alpha_MHz', 0):.1f} MHz · χ {d.get('chi_MHz', 0):.3f} MHz"
275
+ + (f" (readout {chi_r:.3f})" if chi_r is not None else ""),
276
+ )
277
+ run.start("compare")
278
+ flagged = [r.param for r in an.rows if r.flagged]
279
+ if flagged:
280
+ run.log(f"estimator spread above tolerance (modelling, not design): {', '.join(flagged)}", "warn")
281
+ run.done("compare", an.goal["summary"])
282
+ update_cards(run, design, an)
283
+ return an
284
+
285
+
286
+ ESTIMATES_CACHE = "estimates_cache.json"
287
+
288
+
289
+ def _estimates_key(filled) -> str:
290
+ """What the estimators read — every pair's 2-node network, junction, line and κ, the EPR / eigenmode results and
291
+ the hanger values a FEM job filled — plus the estimators' own code (this package's ``circuit`` / ``analysis``
292
+ modules, the libraries' versions): equal keys give equal estimates."""
293
+ import hashlib # pylint: disable=import-outside-toplevel
294
+ from importlib import metadata # pylint: disable=import-outside-toplevel
295
+
296
+ import numpy as np # pylint: disable=import-outside-toplevel
297
+
298
+ pairs = [[p.qubit, p.resonator, list(p.labels), np.asarray(p.cmatrix_fF, dtype=float).tolist(), p.lj_nH, p.cj_fF,
299
+ p.f_r_GHz, p.z0_ohm, p.ck_fF, p.feedline, p.asym, p.flux_phi0, p.squid, p.kappa_MHz, p.kind]
300
+ for p in filled.pairs]
301
+ hangers = {n: [v.extracted, v.estimate] for n, v in filled.values.items() if v.type == "HANGER"}
302
+ fem = [filled.results or {}] + [j.get("results") or {} for j in getattr(filled, "jobs", [])]
303
+ fem = [{k: r[k] for k in ("epr", "eigenmodes", "sparams") if k in r} for r in fem]
304
+ pkg = Path(__file__).resolve().parent
305
+ code = max((f.stat().st_mtime_ns for d in ("circuit", "analysis") for f in (pkg / d).glob("*.py")), default=0)
306
+ libs = {}
307
+ for lib in ("SQcircuit", "qucat", "scqubits", "qiskit-metal", "qutip", "pyEPR-quantum", "numpy", "scipy"):
308
+ try:
309
+ libs[lib] = metadata.version(lib)
310
+ except metadata.PackageNotFoundError:
311
+ libs[lib] = None
312
+ payload = {"v": 1, "estimators": list(filled.model.estimators), "pairs": pairs, "hangers": hangers, "fem": fem,
313
+ "code": code, "libs": libs}
314
+ return hashlib.sha256(json.dumps(payload, sort_keys=True, default=str).encode("utf-8")).hexdigest()
315
+
316
+
317
+ def _solve_cached(filled, out_dir, solve_all):
318
+ """``solve_all(filled)``, or the estimates of an earlier analysis of the same circuit (``<out_dir>/
319
+ estimates_cache.json``, keyed by :func:`_estimates_key`): Propose after Simulate / Import, or a second Propose,
320
+ does not run the four estimators again. Without ``out_dir`` there is no cache."""
321
+ if not out_dir:
322
+ return solve_all(filled)
323
+ path = Path(out_dir) / ESTIMATES_CACHE
324
+ try:
325
+ key = _estimates_key(filled)
326
+ except Exception: # noqa: BLE001 (an unusual circuit: no cache)
327
+ return solve_all(filled)
328
+ try:
329
+ data = json.loads(path.read_text(encoding="utf-8"))
330
+ if data.get("key") == key:
331
+ return data["estimates"]
332
+ except (OSError, ValueError, KeyError):
333
+ pass
334
+ estimates = solve_all(filled)
335
+ try:
336
+ path.parent.mkdir(parents=True, exist_ok=True)
337
+ path.write_text(json.dumps({"key": key, "estimates": estimates}, default=float), encoding="utf-8")
338
+ except OSError:
339
+ pass
340
+ return estimates
341
+
342
+
343
+ def update_cards(run, design, an, proposal=None) -> None:
344
+ """Parameter cards + design summary for the dashboard (see :mod:`quantcore_circuits.cards`)."""
345
+ from quantcore_circuits import cards # pylint: disable=import-outside-toplevel
346
+ from quantcore_circuits.design import load_design # pylint: disable=import-outside-toplevel
347
+
348
+ run.set(**cards.build(load_design(design), an, proposal, run.state.get("jobs")))
349
+
350
+
351
+ def _dashboard_hamiltonian(an: Analysis, truncation: dict) -> dict | None:
352
+ if an.hamiltonian is None:
353
+ return None
354
+ import qutip # pylint: disable=import-outside-toplevel
355
+
356
+ ham, d = an.hamiltonian, an.dressed
357
+ terms = [
358
+ {"symbol": "E_J", "label": "Josephson energy", "value": ham.EJ_GHz, "unit": "GHz"},
359
+ {"symbol": "E_C", "label": "charging energy (loaded)", "value": ham.EC_GHz, "unit": "GHz"},
360
+ {"symbol": "E_J/E_C", "label": "transmon ratio", "value": ham.EJ_GHz / ham.EC_GHz, "unit": ""},
361
+ {"symbol": "f_r", "label": "λ/4 (claw-loaded, bare)", "value": ham.f_r_GHz, "unit": "GHz"},
362
+ {"symbol": "g_n", "label": "charge coupling", "value": ham.g_n_MHz, "unit": "MHz"},
363
+ {"symbol": "g", "label": "exchange coupling", "value": d["g_MHz"], "unit": "MHz"},
364
+ {"symbol": "f_{01}", "label": "dressed qubit", "value": d["f_q_GHz"], "unit": "GHz"},
365
+ {"symbol": "\\alpha", "label": "anharmonicity", "value": d["alpha_MHz"], "unit": "MHz"},
366
+ {"symbol": "\\chi", "label": "dispersive shift (eigen)", "value": d["chi_MHz"], "unit": "MHz"},
367
+ ]
368
+ if an.readout:
369
+ terms.append(
370
+ {
371
+ "symbol": "\\chi_{ro}",
372
+ "label": "dispersive shift (simulated readout)",
373
+ "value": an.readout["chi_readout_MHz"],
374
+ "unit": "MHz",
375
+ }
376
+ )
377
+ first_q = next(iter(an.pair_results), None)
378
+ return {
379
+ "pair": [first_q, an.pair_results[first_q]["resonator"]] if first_q else None,
380
+ "model": "Transmon (charge basis) + λ/4 resonator, charge coupling, no RWA",
381
+ "latex": ham.latex(),
382
+ "terms": terms,
383
+ "levels": [{"label": lv["label"], "energy": lv["energy"]} for lv in d["levels"][:8]],
384
+ "truncation": {"qubit": truncation.get("qubit_levels", 8), "resonator": truncation.get("resonator_levels", 6)},
385
+ "solver": f"QuTiP {qutip.__version__} eigenstates; readout: steady-state Lindblad",
386
+ }
387
+
388
+
389
+ def _plots(an: Analysis) -> list[dict]:
390
+ specs = []
391
+ if an.filled.cmatrix:
392
+ cm = an.filled.cmatrix
393
+ specs.append(
394
+ P.heatmap_spec(
395
+ "cmatrix",
396
+ "Maxwell C-matrix (as used)",
397
+ "simulation",
398
+ cm["labels"],
399
+ cm["labels"],
400
+ [[round(v, 3) for v in row] for row in cm["matrix"]],
401
+ "fF",
402
+ caption=f"{an.filled.job}; " + "; ".join(an.filled.notes)[:300],
403
+ )
404
+ )
405
+ multi = len(an.pair_results) > 1
406
+ for q, res in an.pair_results.items():
407
+ specs += _pair_plots(an, q, res, f" — {q}–{res['resonator']}" if multi else "")
408
+ specs += _estimator_plots(an)
409
+ # the solved jobs' convergence per adaptive pass, S21 notch fits and EPR (plots.fem_specs): Plots tab
410
+ specs += P.fem_specs(an.filled.jobs or ([{"results": an.filled.results}] if an.filled.results else []))
411
+ return specs
412
+
413
+
414
+ def _pair_plots(an: Analysis, q: str, res: dict, suffix: str) -> list[dict]:
415
+ specs = []
416
+ if res["dressed"]:
417
+ specs.append(
418
+ P.levels_spec(
419
+ pair_plot_id("levels", q, an),
420
+ "Dressed spectrum" + suffix,
421
+ "hamiltonian",
422
+ [
423
+ {"label": lv["label"], "energy": round(lv["energy"], 5), "group": "dressed"}
424
+ for lv in res["dressed"]["levels"][:8]
425
+ ],
426
+ caption="QuTiP, charge-basis transmon + λ/4",
427
+ )
428
+ )
429
+ if res["readout"]:
430
+ r = res["readout"]
431
+ x = [round((f - r["peak_g_GHz"]) * 1e3, 5) for f in r["f_GHz"]]
432
+ specs.append(
433
+ P.xy_spec(
434
+ pair_plot_id("readout", q, an),
435
+ "Simulated readout: transmission vs qubit state" + suffix,
436
+ "hamiltonian",
437
+ [
438
+ {"name": "qubit |g⟩", "x": x, "y": r["T_g"]},
439
+ {"name": "qubit |e⟩", "x": x, "y": r["T_e"], "dashed": True},
440
+ ],
441
+ "Probe detuning (MHz)",
442
+ "|⟨a⟩|² (norm.)",
443
+ [
444
+ {"axis": "x", "value": 0.0, "label": "g"},
445
+ {"axis": "x", "value": round(r["chi_readout_MHz"], 4), "label": "e"},
446
+ ],
447
+ caption=f"χ readout {r['chi_readout_MHz']:.3f} MHz vs eigen {r['chi_eigen_MHz']:.3f} MHz "
448
+ f"(κ {r['kappa_MHz']} MHz)",
449
+ )
450
+ )
451
+ if res["flux"]:
452
+ fl = res["flux"]
453
+ specs.append(
454
+ P.xy_spec(
455
+ pair_plot_id("flux", q, an),
456
+ "Qubit spectrum vs flux (symmetric SQUID)" + suffix,
457
+ "hamiltonian",
458
+ [
459
+ {"name": "f01", "x": fl["phi"], "y": fl["f01_GHz"]},
460
+ {"name": "f12", "x": fl["phi"], "y": fl["f12_GHz"], "dashed": True},
461
+ ],
462
+ "Flux Φ/Φ0",
463
+ "Frequency (GHz)",
464
+ caption="EJ(Φ) = EJΣ|cos πΦ/Φ0|",
465
+ )
466
+ )
467
+ return specs
468
+
469
+
470
+ def _estimator_plots(an: Analysis) -> list[dict]:
471
+ specs = []
472
+ est = {n: v for n, v in an.estimates.items() if "error" not in v}
473
+ bars = []
474
+ for r in an.rows:
475
+ if r.quantity in ("f_q_GHz", "alpha_MHz", "chi_MHz", "f_GHz", "g_MHz"):
476
+ bars.append(
477
+ {
478
+ "label": f"{r.param.split('.')[0]} {r.symbol} ({r.unit})",
479
+ "values": {n: est[n].get(r.param) for n in est},
480
+ }
481
+ )
482
+ if bars:
483
+ specs.append(P.bar_spec("estimators", "Estimator values per parameter", "plots", bars, "value"))
484
+ devs = []
485
+ for r in an.rows:
486
+ if r.chosen and r.values and r.quantity not in ("EJ_GHz", "EC_GHz"):
487
+ devs.append(
488
+ {
489
+ "label": f"{r.param.split('.')[0]} {r.symbol}",
490
+ "values": {n: round(100 * (v - r.chosen) / abs(r.chosen), 4) for n, v in r.values.items()},
491
+ }
492
+ )
493
+ specs.append(
494
+ P.bar_spec(
495
+ "estimator_spread",
496
+ "Deviation from chosen value",
497
+ "plots",
498
+ devs,
499
+ "deviation (%)",
500
+ caption="0 % = the policy's chosen estimator; spread above tolerance is flagged",
501
+ )
502
+ )
503
+ return specs
504
+
505
+
506
+ def feedback(an: Analysis, run=None, design_source=None, iteration: int = 1, bounds=None, build_revision: bool = True):
507
+ """Surrogate from this FEM point → knobs → revision ``iteration`` (built + netlist-checked). Returns
508
+ ``(proposal, revision_path, build_result)``.
509
+
510
+ Every transmon–readout pair of the circuit gets a surrogate (:func:`quantcore_circuits.codesign.
511
+ surrogate_from_fill`: any qubit class with a LOM model, λ/4 and λ/2 readouts); what cannot be tuned (no pair, no
512
+ clean knob, a drawn junction) is listed in ``proposal.notes``. ``build_revision=False`` (a preview, e.g. ``qcc
513
+ results propose``) writes the revision without building it: ``build_result`` is then None."""
514
+ run = run or _track.run_for(an.filled.design)
515
+ with _deferred(run):
516
+ return _feedback(an, run, design_source, iteration, bounds, build_revision)
517
+
518
+
519
+ def _feedback(an: Analysis, run, design_source, iteration: int, bounds, build_revision: bool):
520
+ from quantcore_circuits import codesign as cd # pylint: disable=import-outside-toplevel
521
+
522
+ if run:
523
+ run.start("feedback")
524
+ run.state["history"] = [h for h in run.state["history"] if h.get("kind") != "lom"] # (FEM rows follow)
525
+ notes = cd.unpaired_notes(an.filled)
526
+ surrogates = cd.surrogates_from_fill(an.filled, notes) # one per qubit–resonator pair
527
+ b = {**an.model.knobs, **(bounds or {})}
528
+ for s in surrogates:
529
+ if s.cg.knob:
530
+ b.setdefault(s.cg.knob, (s.cg.k0 * 0.4, s.cg.k0 * 2.2) if s.cg.p >= 0 else (s.cg.k0 * 0.5, s.cg.k0 * 2.5))
531
+ measured = {r.param: r.chosen for r in an.rows if r.chosen is not None} # what the consensus reports
532
+ prop = cd.propose_all(surrogates, an.model.targets, b, anchor=measured)
533
+ prop.notes = list(dict.fromkeys(notes + prop.notes))
534
+ same = design_source is None or getattr(an, "plan", None) is not None and _same_design(design_source, an)
535
+ design = cd.apply(design_source or an.filled.design, prop.knobs, plan=an.plan if same else None)
536
+ run_dir = run.dir if run else Path("build") / design.name
537
+ rev = cd.write_revision(design, run_dir, iteration)
538
+ result = net = None
539
+ if build_revision:
540
+ from quantcore_circuits.assembly import build # pylint: disable=import-outside-toplevel
541
+ from quantcore_circuits.assembly.netlist import check_netlist # pylint: disable=import-outside-toplevel
542
+
543
+ result = build(rev)
544
+ net = check_netlist(result)
545
+ if run:
546
+ measured = {r.param: r.residual for r in an.rows if r.residual is not None}
547
+ run.iteration(
548
+ {
549
+ "iteration": iteration - 1,
550
+ "objective": _norm(measured),
551
+ "residuals": measured,
552
+ "knobs": prop.start_knobs,
553
+ "accepted": True,
554
+ }
555
+ )
556
+ run.iteration(
557
+ {
558
+ "iteration": iteration,
559
+ "objective": prop.objective,
560
+ "residuals": prop.residuals,
561
+ "knobs": prop.knobs,
562
+ "accepted": False,
563
+ }
564
+ )
565
+ hist = run.state["history"]
566
+ run.plot(
567
+ P.xy_spec(
568
+ "residual",
569
+ "Residual vs iteration",
570
+ "history",
571
+ [
572
+ {
573
+ "name": "‖r‖ (tolerances)",
574
+ "x": [h["iteration"] for h in hist],
575
+ "y": [max(h["objective"], 1e-3) for h in hist],
576
+ "kind": "line",
577
+ }
578
+ ],
579
+ "Iteration",
580
+ "‖r‖ (tolerances)",
581
+ [{"axis": "y", "value": 1.0, "label": "tolerance"}],
582
+ log_y=True,
583
+ caption="filled: FEM-extracted; last point: surrogate prediction, awaiting FEM",
584
+ )
585
+ )
586
+ changes = ", ".join(f"{k} {prop.start_knobs[k]:g}→{v:g}" for k, v in prop.knobs.items())
587
+ if prop.at_bounds:
588
+ run.log(
589
+ f"feedback: knob(s) at their bound: {', '.join(prop.at_bounds)} — widen the bounds or add knobs", "warn"
590
+ )
591
+ for note in prop.notes:
592
+ run.log(f"feedback: {note}", "info")
593
+ checked = "not built (preview)" if net is None else ("netlist OK" if net.ok else "netlist FAILED")
594
+ run.done("feedback", f"rev{iteration}: {changes} · predicted ‖r‖ {prop.objective:.2g} · {checked}")
595
+ update_cards(run, design_source or an.filled.design, an, prop)
596
+ return prop, rev, result
597
+
598
+
599
+ def _same_design(source, an: Analysis) -> bool:
600
+ """Whether ``source`` is the design ``an`` analysed (then its plan holds the ports :func:`codesign.apply` needs)."""
601
+ from quantcore_circuits.design import design_hash, load_design # pylint: disable=import-outside-toplevel
602
+
603
+ try:
604
+ return design_hash(load_design(source)) == design_hash(an.filled.design)
605
+ except Exception: # noqa: BLE001
606
+ return False
607
+
608
+
609
+ def _norm(res: dict) -> float:
610
+ return float(sum(v * v for v in res.values()) ** 0.5)