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,14 @@
1
+ """Circuit IR (``circuit.json``), extraction bridges, estimator adapters, consensus and Hamiltonian models (M8–M10).
2
+
3
+ * :mod:`.schema` — pydantic ``circuit.json`` with topology validation, ``to_networkx``
4
+ * :mod:`.derive` — default circuit for a sim group from the design
5
+ * :mod:`.bridges` — C-matrix → branches, λ/4 → LC, Rn ↔ Ic ↔ Lj, SQUID EJ(Φ)
6
+ * :mod:`.fill` — fill a circuit from job results (design and extracted values side by side)
7
+ * :mod:`.adapters` — Metal LOM, QuCat, SQcircuit, scqubits: ``solve(filled) -> ParamSet``
8
+ * :mod:`.consensus` — per-parameter estimator table, spread, choice, residual to target
9
+ * :mod:`.hamiltonian` — QuTiP Hamiltonian, dressed levels, simulated readout (χ), flux curve, Purcell T1
10
+ """
11
+
12
+ from quantcore_circuits.circuit.schema import CircuitModel, load_circuit, save_circuit
13
+
14
+ __all__ = ["CircuitModel", "load_circuit", "save_circuit"]
@@ -0,0 +1,305 @@
1
+ """Estimator adapters (M9): ``solve(filled) -> ParamSet`` with Metal LOM, QuCat, SQcircuit and scqubits.
2
+
3
+ A ``ParamSet`` is a flat dict keyed like the design targets: ``"<Q>.f_q_GHz"``, ``"<Q>.alpha_MHz"``, ``"<Q>.EJ_GHz"``,
4
+ ``"<Q>.EC_GHz"``, ``"<R>.f_GHz"`` (dressed resonator), ``"<R>.g_MHz"``, ``"<R>.chi_MHz"`` (χ = E11 − E10 − E01 + E00)
5
+ and ``"<R>.kappa_MHz"`` when a feedline coupling is known. Every adapter sees the same filled circuit (same
6
+ C-matrix, Lj, λ/4 LC) and quantises it its own way:
7
+
8
+ * ``metal_lom`` — Quantum Metal LOM 2.0: TRANSMON + TL_RESONATOR subsystems on the Maxwell matrix
9
+ * ``qucat`` — QuCat lumped network (C-matrix branches + JJ + λ/4 parallel LC): its circuit Hamiltonian (junction
10
+ Taylor-expanded) diagonalised with QuTiP
11
+ * ``sqcircuit`` — SQcircuit exact diagonalisation of the 2-node circuit (charge × harmonic basis)
12
+ * ``scqubits`` — scqubits Transmon + Oscillator HilbertSpace with the analytic loaded coupling
13
+ * ``pyepr`` — not a LOM: pyEPR's Hamiltonian from an eigenmode job's junction participations (``eigenmode_epr``);
14
+ it runs only when the filled circuit carries EPR results (``filled.results["epr"]``)
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import contextlib
20
+ import io
21
+ import warnings
22
+
23
+ import numpy as np
24
+
25
+ from quantcore_circuits.circuit.fill import FilledCircuit, TransmonReadout, two_node_model
26
+
27
+ ParamSet = dict[str, float]
28
+
29
+
30
+ def _keys(p: TransmonReadout, out: dict) -> ParamSet:
31
+ q, r = p.qubit, p.resonator
32
+ mapping = {
33
+ "f_q_GHz": f"{q}.f_q_GHz",
34
+ "alpha_MHz": f"{q}.alpha_MHz",
35
+ "EJ_GHz": f"{q}.EJ_GHz",
36
+ "EC_GHz": f"{q}.EC_GHz",
37
+ "f_r_GHz": f"{r}.f_GHz",
38
+ "g_MHz": f"{r}.g_MHz",
39
+ "chi_MHz": f"{r}.chi_MHz",
40
+ "kappa_MHz": f"{r}.kappa_MHz",
41
+ }
42
+ return {mapping[k]: float(v) for k, v in out.items() if k in mapping and v is not None and np.isfinite(v)}
43
+
44
+
45
+ def metal_lom(filled: FilledCircuit) -> ParamSet:
46
+ from quantcore_circuits.analysis.lom import lom_transmon_resonator # pylint: disable=import-outside-toplevel
47
+
48
+ out: ParamSet = {}
49
+ for p in filled.pairs:
50
+ if getattr(p, "kind", "lambda/4") != "lambda/4":
51
+ continue # Metal's lom_transmon_resonator models a λ/4 line; a λ/2 readout would get the wrong g
52
+ with contextlib.redirect_stdout(io.StringIO()), warnings.catch_warnings():
53
+ warnings.simplefilter("ignore")
54
+ # Metal's TL_RESONATOR takes the resonator frequency as given: pass the claw-loaded λ/4 frequency
55
+ f_r = two_node_model(p)["f_r_loaded_GHz"]
56
+ res = lom_transmon_resonator(
57
+ p.cmatrix_fF, p.labels, p.labels[0], p.labels[1], p.lj_nH, f_r, p.cj_fF, z0=p.z0_ohm
58
+ )
59
+ out.update(_keys(p, res))
60
+ return out
61
+
62
+
63
+ def _qucat_network(p: TransmonReadout):
64
+ from qucat import C, J, L, Network # pylint: disable=import-outside-toplevel
65
+
66
+ tn = two_node_model(p)
67
+ comps = [
68
+ C(0, 1, p.c_island_fF * 1e-15),
69
+ J(0, 1, "Lj"),
70
+ C(1, 2, p.cg_fF * 1e-15),
71
+ C(0, 2, (p.c_coupler_fF + tn["C_r_fF"]) * 1e-15),
72
+ L(0, 2, tn["L_r_nH"] * 1e-9),
73
+ ]
74
+ with contextlib.redirect_stdout(io.StringIO()), warnings.catch_warnings():
75
+ warnings.simplefilter("ignore")
76
+ return Network(comps), tn
77
+
78
+
79
+ def qucat(filled: FilledCircuit, taylor: int = 8, excitations: tuple[int, int] = (10, 10)) -> ParamSet:
80
+ """QuCat: normal modes + the circuit Hamiltonian (junction cosine Taylor-expanded to ``taylor``), diagonalised
81
+ with QuTiP. States are identified by overlap with the bare Fock states of the (qubit, resonator) modes.
82
+
83
+ ``excitations`` per mode: 10 resonator levels (not 6) keep α converged for strongly anharmonic qubits (a Metal
84
+ TransmonPocket with α ≈ −460 MHz: −416 MHz with 6 levels, −457.5 with 10, SQcircuit −459.2)."""
85
+ import qutip as qt # pylint: disable=import-outside-toplevel
86
+
87
+ out: ParamSet = {}
88
+ for p in filled.pairs:
89
+ net, tn = _qucat_network(p)
90
+ lj = p.lj_nH * 1e-9
91
+ with contextlib.redirect_stdout(io.StringIO()), warnings.catch_warnings():
92
+ warnings.simplefilter("ignore")
93
+ f, _, a, _ = (np.real(x) for x in net.f_k_A_chi(Lj=lj))
94
+ h = net.hamiltonian(modes="all", taylor=taylor, excitations=list(excitations), Lj=lj)
95
+ qm = int(np.argmax(a)) # modes are ordered by frequency; the qubit is the most anharmonic one
96
+ rm = 1 - qm
97
+ evals, evecs = h.eigenstates()
98
+ evals = np.real(evals) / 1e9
99
+ dims = list(excitations)
100
+
101
+ def level(nq, nr, qm=qm, rm=rm, dims=dims, evals=evals, evecs=evecs):
102
+ occ = [0, 0]
103
+ occ[qm], occ[rm] = nq, nr
104
+ bare = qt.tensor(qt.basis(dims[0], occ[0]), qt.basis(dims[1], occ[1]))
105
+ return float(evals[int(np.argmax([abs(bare.overlap(v)) for v in evecs]))])
106
+
107
+ e00, e10, e01, e20, e11 = level(0, 0), level(1, 0), level(0, 1), level(2, 0), level(1, 1)
108
+ entry = {
109
+ "f_q_GHz": e10 - e00,
110
+ "alpha_MHz": (e20 - 2 * e10 + e00) * 1e3,
111
+ "f_r_GHz": e01 - e00,
112
+ "chi_MHz": (e11 - e10 - e01 + e00) * 1e3,
113
+ "EJ_GHz": tn["EJ_GHz"],
114
+ "EC_GHz": tn["EC_GHz"],
115
+ }
116
+ out.update(_keys(p, entry))
117
+ out[f"{p.qubit}.f_linear_GHz"] = float(f[qm] / 1e9)
118
+ return out
119
+
120
+
121
+ def _sq_levels(p: TransmonReadout, n_levels: int = 14):
122
+ import SQcircuit as sq # pylint: disable=import-outside-toplevel
123
+
124
+ tn = two_node_model(p)
125
+ sq.set_unit_freq("GHz")
126
+ c1 = sq.Capacitor(p.c_island_fF, "fF")
127
+ cg = sq.Capacitor(p.cg_fF, "fF")
128
+ c2 = sq.Capacitor(p.c_coupler_fF + tn["C_r_fF"], "fF")
129
+ lr = sq.Inductor(tn["L_r_nH"], "nH")
130
+ jj = sq.Junction(tn["EJ_GHz"], "GHz")
131
+ with contextlib.redirect_stdout(io.StringIO()), warnings.catch_warnings():
132
+ warnings.simplefilter("ignore")
133
+ cr = sq.Circuit({(0, 1): [c1, jj], (1, 2): [cg], (0, 2): [c2, lr]})
134
+ cr.set_trunc_nums([12 if w > 0 else 30 for w in np.atleast_1d(cr.omega)])
135
+ efreqs, _ = cr.diag(n_levels)
136
+ ev = np.sort(np.real(np.asarray(efreqs, dtype=float)))
137
+ return ev - ev[0], tn
138
+
139
+
140
+ def sqcircuit(filled: FilledCircuit) -> ParamSet:
141
+ from quantcore_circuits.analysis.transmon import transmon_spectrum # pylint: disable=import-outside-toplevel
142
+
143
+ out: ParamSet = {}
144
+ for p in filled.pairs:
145
+ ev, tn = _sq_levels(p)
146
+ fq0, a0 = transmon_spectrum(tn["EJ_GHz"], tn["EC_GHz"])
147
+ fr0 = tn["f_r_loaded_GHz"]
148
+ used: set[int] = {0}
149
+
150
+ def take(guess, ev=ev, used=used):
151
+ i = min((k for k in range(len(ev)) if k not in used), key=lambda k: abs(ev[k] - guess))
152
+ used.add(i)
153
+ return ev[i]
154
+
155
+ e10 = take(fq0)
156
+ e01 = take(fr0)
157
+ e20 = take(2 * fq0 + a0 / 1e3)
158
+ e11 = take(fq0 + fr0)
159
+ out.update(
160
+ _keys(
161
+ p,
162
+ {
163
+ "f_q_GHz": e10,
164
+ "alpha_MHz": (e20 - 2 * e10) * 1e3,
165
+ "f_r_GHz": e01,
166
+ "chi_MHz": (e11 - e10 - e01) * 1e3,
167
+ "EJ_GHz": tn["EJ_GHz"],
168
+ "EC_GHz": tn["EC_GHz"],
169
+ },
170
+ )
171
+ )
172
+ return out
173
+
174
+
175
+ def scqubits(filled: FilledCircuit) -> ParamSet:
176
+ from quantcore_circuits.analysis.transmon import dressed_transmon_resonator # pylint: disable=C0415
177
+
178
+ out: ParamSet = {}
179
+ for p in filled.pairs:
180
+ tn = two_node_model(p)
181
+ with warnings.catch_warnings():
182
+ warnings.simplefilter("ignore")
183
+ res = dressed_transmon_resonator(tn["EJ_GHz"], tn["EC_GHz"], tn["f_r_loaded_GHz"], tn["g_MHz"])
184
+ out.update(_keys(p, {**res, "g_MHz": tn["g_MHz"], "EJ_GHz": tn["EJ_GHz"], "EC_GHz": tn["EC_GHz"]}))
185
+ return out
186
+
187
+
188
+ def _epr_results(filled: FilledCircuit) -> list[dict]:
189
+ """Every EPR result the filled circuit carries: ``filled.results`` and, for a subset fill with several eigenmode
190
+ jobs, each job's own (``filled.jobs``), once each."""
191
+ out, seen = [], set()
192
+ for res in [filled.results or {}] + [j.get("results") or {} for j in getattr(filled, "jobs", [])]:
193
+ if (res.get("epr") or {}).get("p_mj") and id(res) not in seen:
194
+ seen.add(id(res))
195
+ out.append(res)
196
+ return out
197
+
198
+
199
+ def epr_modes(filled: FilledCircuit, results: dict | None = None) -> dict[str, dict]:
200
+ """Qubit and resonator mode of each pair in the job's EPR result (``filled.results["epr"]``, or ``results``).
201
+
202
+ The qubit mode is the one with the largest participation of the qubit's junction; the resonator mode is the
203
+ remaining mode closest to the pair's claw-loaded λ/4 (LOM) frequency. Returns qubit → {"qm", "rm", "junction"}.
204
+ A pair whose qubit has no junction in this result (a subset job without it) is left out.
205
+ """
206
+ epr = ((filled.results if results is None else results) or {}).get("epr") or {}
207
+ if "p_mj" not in epr:
208
+ return {}
209
+ p = np.asarray(epr["p_mj"], dtype=float) # modes × junctions
210
+ names = epr.get("junction_names") or [f"junction_{j}" for j in epr["junctions"]]
211
+ f_lin = np.asarray(epr["f_linear_GHz"], dtype=float)
212
+ out = {}
213
+ for pair in filled.pairs:
214
+ j = next((k for k, n in enumerate(names) if n.split(".", 1)[0] == pair.qubit), None)
215
+ if j is None:
216
+ continue
217
+ qm = int(np.argmax(p[:, j]))
218
+ f_guess = two_node_model(pair)["f_r_loaded_GHz"]
219
+ rest = [m for m in range(len(f_lin)) if m != qm]
220
+ rm = min(rest, key=lambda m: abs(f_lin[m] - f_guess)) if rest else None
221
+ out[pair.qubit] = {"qm": qm, "rm": rm, "junction": j, "resonator": pair.resonator}
222
+ return out
223
+
224
+
225
+ def _epr_plausible(f_linear: float, f_dressed: float, alpha_MHz: float) -> bool:
226
+ """A pyEPR mode is usable when its dressed frequency stays within 30 % of the linear eigenfrequency and |α| is
227
+ below a quarter of f (a transmon's α is a few % of f_q; the Lamb / Kerr shifts are far below 30 %)."""
228
+ try:
229
+ f_linear, f_dressed, alpha_MHz = float(f_linear), float(f_dressed), float(alpha_MHz)
230
+ except (TypeError, ValueError):
231
+ return False
232
+ if not all(np.isfinite([f_linear, f_dressed, alpha_MHz])) or f_linear <= 0:
233
+ return False
234
+ return abs(f_dressed - f_linear) <= 0.3 * f_linear and abs(alpha_MHz) <= 250.0 * f_linear
235
+
236
+
237
+ def pyepr(filled: FilledCircuit) -> ParamSet:
238
+ """pyEPR on eigenmode data (``eigenmode_epr`` job): dressed f_q, α, f_r and χ from the EPR Hamiltonian
239
+ (pyEPR numerical diagonalisation of the junction participations, :func:`quantcore_circuits.analysis.epr.
240
+ epr_analysis`), κ = f/Q of the resonator mode (50 Ω-terminated feedline). Empty without EPR results."""
241
+ out: ParamSet = {}
242
+ for res in _epr_results(filled) or [filled.results or {}]:
243
+ for k, v in _pyepr_one(filled, res).items():
244
+ out.setdefault(k, v) # a qubit in two subset jobs: the first job's values
245
+ return out
246
+
247
+
248
+ def _pyepr_one(filled: FilledCircuit, results: dict) -> ParamSet:
249
+ epr = (results or {}).get("epr") or {}
250
+ out: ParamSet = {}
251
+ chi = np.asarray(epr.get("chi_MHz", []), dtype=float)
252
+ f_nd = epr.get("f_GHz") or []
253
+ q = epr.get("Q") or []
254
+ f_lin = epr.get("f_linear_GHz") or []
255
+ for qubit, m in epr_modes(filled, results).items():
256
+ qm, rm = m["qm"], m["rm"]
257
+ if not _epr_plausible(f_lin[qm], f_nd[qm], chi[qm, qm]):
258
+ # an unconverged mesh (e.g. a capped fast run) can leave the junction resonating on its own (p_J ≈ 1 at
259
+ # 1/2π√(L_J C_J)) and the diagonalisation then returns nonsense: never let that win the consensus
260
+ warnings.warn(f"pyepr: {qubit} mode {qm + 1} dropped (linear {f_lin[qm]:.3f} GHz, dressed {f_nd[qm]:.3f} "
261
+ f"GHz, α {chi[qm, qm]:.4g} MHz: not a transmon; mesh not converged?)", stacklevel=2)
262
+ continue
263
+ if rm is not None and not _epr_plausible(f_lin[rm], f_nd[rm], 0.0):
264
+ rm = None
265
+ out[f"{qubit}.f_q_GHz"] = float(f_nd[qm])
266
+ out[f"{qubit}.alpha_MHz"] = float(chi[qm, qm])
267
+ out[f"{qubit}.f_linear_GHz"] = float(epr["f_linear_GHz"][qm])
268
+ out[f"{qubit}.p_junction"] = float(epr["p_mj"][qm][m["junction"]])
269
+ if rm is not None:
270
+ r = m["resonator"]
271
+ out[f"{r}.f_GHz"] = float(f_nd[rm])
272
+ out[f"{r}.chi_MHz"] = float(chi[qm, rm])
273
+ out[f"{r}.f_linear_GHz"] = float(epr["f_linear_GHz"][rm])
274
+ hv = filled.values.get(f"K_{r}")
275
+ if hv is not None and hv.extracted is not None: # FEM κ_ext of the hanger (driven fit preferred, fill)
276
+ out[f"{r}.kappa_MHz"] = float(hv.extracted)
277
+ elif len(q) > rm and q[rm]: # κ_ext: the 50 Ω feedline load only (bulk-dielectric loss removed)
278
+ qd = (epr.get("Q_dielectric") or [None] * len(q))[rm]
279
+ q_ext = 1 / (1 / q[rm] - 1 / qd) if qd and 1 / q[rm] > 1 / qd else q[rm]
280
+ out[f"{r}.kappa_MHz"] = float(epr["f_linear_GHz"][rm] / q_ext * 1e3)
281
+ if len(q) > qm and q[qm]:
282
+ out[f"{qubit}.Q"] = float(q[qm])
283
+ return out
284
+
285
+
286
+ ADAPTERS = {"metal_lom": metal_lom, "qucat": qucat, "sqcircuit": sqcircuit, "scqubits": scqubits, "pyepr": pyepr}
287
+
288
+
289
+ def solve_all(filled: FilledCircuit, names: list[str] | None = None) -> dict[str, ParamSet]:
290
+ """Run each adapter; a failing estimator is reported as ``{"error": message}`` instead of aborting the rest.
291
+
292
+ ``pyepr`` joins the model's estimators automatically when the filled circuit carries EPR results."""
293
+ out: dict[str, ParamSet] = {}
294
+ names = list(names or filled.model.estimators)
295
+ if "pyepr" not in names and _epr_results(filled):
296
+ names.append("pyepr")
297
+ for name in names:
298
+ fn = ADAPTERS.get(name)
299
+ if fn is None:
300
+ continue
301
+ try:
302
+ out[name] = fn(filled)
303
+ except Exception as e: # noqa: BLE001 pylint: disable=broad-except
304
+ out[name] = {"error": f"{type(e).__name__}: {e}"}
305
+ return out
@@ -0,0 +1,353 @@
1
+ """Mathematical bridges from simulation results to circuit element values.
2
+
3
+ 1. Maxwell C-matrix → branch capacitances: C_ij = −C_ij(Maxwell) (i ≠ j), C_i0 = Σ_j C_ij(Maxwell).
4
+ 2. Distributed λ/4 resonator → LC at its open end: C_r = π/(4 ω_r Z0), L_r = 4 Z0/(π ω_r); v_ph and Z0 from Metal's
5
+ CPW formulas on the PDK stack (:func:`quantcore_circuits.analysis.synthesis.cpw_properties`).
6
+ 3. Junction: Rn ↔ Ic (Ambegaokar–Baratoff at T = 0: Ic·Rn = πΔ/2e) ↔ Lj = Φ0/(2π Ic); area → Rn through the PDK
7
+ specific resistance; SQUID → EJ(Φ) = EJΣ |cos πΦ| √(1 + d² tan² πΦ). The Quantcore trilayer rule
8
+ (:class:`quantcore_circuits.pdk.JunctionProcess`: Δ = 1.4 meV, R_n 40–50 kΩ, f_q 4–8 GHz) sizes junctions:
9
+ :func:`size_junction` (target f_q and C_Σ → E_J, L_J, R_n, area, finger widths), :func:`junction_from_fingers`
10
+ (drawn fingers → R_n, I_c, L_J, E_J, C_J), :func:`fingers_for_lj` (what the junction cells use).
11
+ 4. Ports: a 50 Ω resistor on feedline nodes (κ in QuCat).
12
+ 5. Participations → ϕ_zpf: :mod:`quantcore_circuits.analysis.epr`.
13
+
14
+ Units: fF, nH, Ω, µm, GHz.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import math
20
+ from dataclasses import asdict, dataclass, field
21
+
22
+ import numpy as np
23
+
24
+ E = 1.602176634e-19
25
+ H = 6.62607015e-34
26
+ PHI0 = 2.067833848e-15
27
+ DELTA_NB_MEV = 1.40 # Nb gap (trilayer Nb/AlOx/Nb junctions); pass delta_meV for Al (≈ 0.18–0.20)
28
+
29
+
30
+ def branch_capacitances(maxwell_fF, labels: list[str], ground: str = "ground") -> dict[tuple[str, str], float]:
31
+ """Maxwell matrix (signal nets only, as Q3D/Elmer/Palace export it) → branch capacitances in fF.
32
+
33
+ Keys are ``(net, ground)`` for capacitance to ground and ``(net_i, net_j)`` (i < j in ``labels`` order).
34
+ """
35
+ c = np.asarray(maxwell_fF, dtype=float)
36
+ out: dict[tuple[str, str], float] = {}
37
+ for i, a in enumerate(labels):
38
+ out[(a, ground)] = float(c[i].sum())
39
+ for j in range(i + 1, len(labels)):
40
+ out[(a, labels[j])] = float(-c[i, j])
41
+ return out
42
+
43
+
44
+ def maxwell_from_branches(branches: dict[tuple[str, str], float], labels: list[str], ground: str = "ground"):
45
+ """Inverse of :func:`branch_capacitances` (for tests and for building Maxwell matrices from a circuit)."""
46
+ n = len(labels)
47
+ idx = {lab: i for i, lab in enumerate(labels)}
48
+ c = np.zeros((n, n))
49
+ for (a, b), v in branches.items():
50
+ if b == ground:
51
+ c[idx[a], idx[a]] += v
52
+ elif a == ground:
53
+ c[idx[b], idx[b]] += v
54
+ else:
55
+ i, j = idx[a], idx[b]
56
+ c[i, i] += v
57
+ c[j, j] += v
58
+ c[i, j] -= v
59
+ c[j, i] -= v
60
+ return c
61
+
62
+
63
+ def quarter_wave_lc(f_r_GHz: float, z0: float = 50.0) -> tuple[float, float]:
64
+ """(C fF, L nH) of a λ/4 resonator near resonance seen from its open end."""
65
+ w = 2 * math.pi * f_r_GHz * 1e9
66
+ c = math.pi / (4 * w * z0)
67
+ return c / 1e-15, 4 * z0 / (math.pi * w) / 1e-9
68
+
69
+
70
+ def tl_resonator(length_um: float, a_um: float, b_um: float, pdk_name: str | None = None, guess_GHz: float = 7.0):
71
+ """λ/4 CPW resonator of ``length_um`` → {f_GHz, Z0_ohm, vp_m_s, eps_eff, C_fF, L_nH, + L_geo/L_k/alpha_k} (fixed
72
+ point on f). The film's kinetic inductance (``pdk.kinetic``, decision #45) is in v_p and Z0: f = f_geo/√(1+L_k/L_geo);
73
+ ``alpha_k`` = L_k/(L_k+L_geo) of the line and ``f_geo_GHz`` the purely geometric frequency are reported."""
74
+ from quantcore_circuits.analysis.synthesis import cpw_properties # pylint: disable=import-outside-toplevel
75
+ from quantcore_circuits.pdk import DEFAULT_PDK # pylint: disable=import-outside-toplevel
76
+
77
+ pdk_name = pdk_name or DEFAULT_PDK
78
+ f = guess_GHz
79
+ props = {}
80
+ for _ in range(4):
81
+ props = cpw_properties(f, a_um, b_um, pdk_name)
82
+ f = props["vp_m_s"] / (4 * length_um * 1e-6) / 1e9
83
+ c, ind = quarter_wave_lc(f, props["Z0_ohm"])
84
+ keys = ("Z0_ohm", "vp_m_s", "eps_eff", "L_geo_nH_per_m", "L_k_nH_per_m", "alpha_k")
85
+ return {
86
+ "f_GHz": f,
87
+ **{k: props[k] for k in keys},
88
+ "f_geo_GHz": f * math.sqrt(1.0 + props["L_k_nH_per_m"] / props["L_geo_nH_per_m"]),
89
+ "C_fF": c,
90
+ "L_nH": ind,
91
+ }
92
+
93
+
94
+ def ic_from_rn(rn_ohm: float, delta_meV: float = DELTA_NB_MEV) -> float:
95
+ """Ambegaokar–Baratoff critical current (A) at T = 0."""
96
+ return math.pi * delta_meV * 1e-3 / (2 * rn_ohm) # πΔ/(2 e Rn), Δ in eV
97
+
98
+
99
+ def rn_from_ic(ic_A: float, delta_meV: float = DELTA_NB_MEV) -> float:
100
+ return math.pi * delta_meV * 1e-3 / (2 * ic_A)
101
+
102
+
103
+ def lj_from_ic(ic_A: float) -> float:
104
+ """Josephson inductance (nH)."""
105
+ return PHI0 / (2 * math.pi * ic_A) / 1e-9
106
+
107
+
108
+ def ic_from_lj(lj_nH: float) -> float:
109
+ return PHI0 / (2 * math.pi * lj_nH * 1e-9)
110
+
111
+
112
+ def rn_from_area(area_um2: float, rn_area_ohm_um2: float) -> float:
113
+ """Normal-state resistance from junction area and the PDK specific resistance Rn·A (Ω·µm²)."""
114
+ return rn_area_ohm_um2 / area_um2
115
+
116
+
117
+ def lj_from_area(area_um2: float, rn_area_ohm_um2: float, delta_meV: float = DELTA_NB_MEV) -> float:
118
+ return lj_from_ic(ic_from_rn(rn_from_area(area_um2, rn_area_ohm_um2), delta_meV))
119
+
120
+
121
+ def area_from_rn(rn_ohm: float, rn_area_ohm_um2: float) -> float:
122
+ """Junction area (µm²) for a normal-state resistance, from the specific resistance Rn·A (Ω·µm²)."""
123
+ return rn_area_ohm_um2 / rn_ohm
124
+
125
+
126
+ def lj_from_rn(rn_ohm: float, delta_meV: float = DELTA_NB_MEV) -> float:
127
+ """Josephson inductance (nH) of a junction of normal-state resistance ``rn_ohm`` (Ambegaokar–Baratoff, T = 0)."""
128
+ return lj_from_ic(ic_from_rn(rn_ohm, delta_meV))
129
+
130
+
131
+ def rn_from_lj(lj_nH: float, delta_meV: float = DELTA_NB_MEV) -> float:
132
+ return rn_from_ic(ic_from_lj(lj_nH), delta_meV)
133
+
134
+
135
+ def ej_from_lj(lj_nH: float) -> float:
136
+ """E_J/h (GHz) = (Φ0/2π)² / L_J / h."""
137
+ return (PHI0 / (2 * math.pi)) ** 2 / (lj_nH * 1e-9) / H / 1e9
138
+
139
+
140
+ def lj_from_ej(ej_GHz: float) -> float:
141
+ return (PHI0 / (2 * math.pi)) ** 2 / (ej_GHz * 1e9 * H) / 1e-9
142
+
143
+
144
+ def ec_from_c(c_fF: float) -> float:
145
+ """E_C/h (GHz) = e² / (2 C) / h."""
146
+ return E**2 / (2 * c_fF * 1e-15) / H / 1e9
147
+
148
+
149
+ def c_from_ec(ec_GHz: float) -> float:
150
+ return E**2 / (2 * ec_GHz * 1e9 * H) / 1e-15
151
+
152
+
153
+ def transmon_f01(ej_GHz: float, ec_GHz: float) -> float:
154
+ """Transmon 0→1 frequency (GHz), asymptotic √(8 E_J E_C) − E_C (E_J/E_C ≫ 1)."""
155
+ return math.sqrt(8 * ej_GHz * ec_GHz) - ec_GHz
156
+
157
+
158
+ def ej_for_f01(f01_GHz: float, ec_GHz: float) -> float:
159
+ """E_J/h (GHz) that gives ``f01_GHz`` at ``ec_GHz`` (inverse of :func:`transmon_f01`)."""
160
+ return (f01_GHz + ec_GHz) ** 2 / (8 * ec_GHz)
161
+
162
+
163
+ def junction_process(pdk=None):
164
+ """The :class:`~quantcore_circuits.pdk.JunctionProcess` of a PDK (name, ``Pdk`` or None = default PDK); a
165
+ ``JunctionProcess`` passes through."""
166
+ from quantcore_circuits.pdk import JunctionProcess, Pdk, get_pdk # pylint: disable=import-outside-toplevel
167
+
168
+ if isinstance(pdk, JunctionProcess):
169
+ return pdk
170
+ if isinstance(pdk, Pdk):
171
+ return pdk.junction
172
+ return get_pdk(pdk).junction if pdk else get_pdk().junction
173
+
174
+
175
+ @dataclass
176
+ class JunctionValues:
177
+ """Electrical values of ``n`` identical trilayer cross junctions in parallel (n = 2: a symmetric SQUID at zero
178
+ flux). Per-junction values carry ``_each``; ``rn_kohm``, ``lj_nH``, ``ej_GHz``, ``cj_fF`` are the device totals."""
179
+
180
+ straight_um: float
181
+ bent_um: float
182
+ n: int
183
+ area_each_um2: float
184
+ rn_each_kohm: float
185
+ ic_each_nA: float
186
+ rn_kohm: float
187
+ lj_nH: float
188
+ ej_GHz: float
189
+ cj_fF: float
190
+ rn_in_window: bool
191
+
192
+ def as_dict(self) -> dict:
193
+ return asdict(self)
194
+
195
+
196
+ def junction_from_fingers(straight_um: float, bent_um: float | None = None, n: int = 1, pdk=None) -> JunctionValues:
197
+ """Drawn cross junction(s) → R_n, I_c, L_J, E_J, C_J on the PDK junction rule (``bent_um`` None or 0: same as
198
+ the straight finger, as the trilayer cells' ``second_finger_width = 0``)."""
199
+ proc = junction_process(pdk)
200
+ bent = bent_um or straight_um
201
+ area = straight_um * bent
202
+ rn = rn_from_area(area, proc.rn_area_ohm_um2)
203
+ ic = ic_from_rn(rn, proc.gap_meV)
204
+ lj_total = lj_from_ic(ic) / n
205
+ lo, hi = proc.rn_target_kohm
206
+ return JunctionValues(
207
+ straight_um=straight_um,
208
+ bent_um=bent,
209
+ n=n,
210
+ area_each_um2=area,
211
+ rn_each_kohm=rn / 1e3,
212
+ ic_each_nA=ic * 1e9,
213
+ rn_kohm=rn / n / 1e3,
214
+ lj_nH=lj_total,
215
+ ej_GHz=ej_from_lj(lj_total),
216
+ cj_fF=proc.cj_fF_per_um2 * area * n,
217
+ rn_in_window=lo <= rn / n / 1e3 <= hi,
218
+ )
219
+
220
+
221
+ def _grid(x: float, step: float) -> float:
222
+ return round(round(x / step) * step, 6) if step > 0 else x
223
+
224
+
225
+ def fingers_for_lj(lj_nH: float, n: int = 1, pdk=None, bent_um: float | None = None) -> tuple[float, float, list[str]]:
226
+ """(straight µm, bent µm, notes) of ``n`` parallel junctions with total L_J ``lj_nH`` on the PDK rule.
227
+
228
+ The bent finger stays at ``bent_um`` (default the PDK's ``bent_finger_um``); the straight finger gives the area,
229
+ rounded to ``finger_grid_um``. Below ``finger_range_um[0]`` the straight finger is held at the minimum and the
230
+ bent finger takes the area; above the maximum it is clipped (notes say so)."""
231
+ proc = junction_process(pdk)
232
+ lo, hi = proc.finger_range_um
233
+ bent = bent_um or proc.bent_finger_um
234
+ area = area_from_rn(rn_from_lj(lj_nH * n, proc.gap_meV), proc.rn_area_ohm_um2)
235
+ straight = _grid(area / bent, proc.finger_grid_um)
236
+ notes = []
237
+ if straight < lo:
238
+ straight = lo
239
+ bent = max(lo, _grid(area / lo, proc.finger_grid_um))
240
+ notes.append(f"straight finger at the minimum {lo:g} µm; bent finger {bent:g} µm carries the area")
241
+ elif straight > hi:
242
+ notes.append(f"straight finger {straight:g} µm clipped to the maximum {hi:g} µm (L_J will be higher)")
243
+ straight = hi
244
+ return straight, bent, notes
245
+
246
+
247
+ @dataclass
248
+ class JunctionSizing:
249
+ """Result of :func:`size_junction`: the target, the ideal junction, and the junction as drawn (fingers on the
250
+ PDK grid), with window checks (R_n 40–50 kΩ and f_q 4–8 GHz on the default rule)."""
251
+
252
+ f_q_GHz: float
253
+ c_sigma_fF: float
254
+ ec_GHz: float
255
+ ej_GHz: float
256
+ lj_nH: float
257
+ rn_kohm: float
258
+ n: int
259
+ drawn: JunctionValues
260
+ f_q_drawn_GHz: float
261
+ rn_in_window: bool
262
+ f_in_window: bool
263
+ notes: list[str] = field(default_factory=list)
264
+
265
+ @property
266
+ def finger_width(self) -> float:
267
+ return self.drawn.straight_um
268
+
269
+ @property
270
+ def second_finger_width(self) -> float:
271
+ return self.drawn.bent_um
272
+
273
+ def junction_params(self) -> dict:
274
+ """Parameters for the trilayer junction cells (``junction_params`` of an Xmon, a ``Quantcore*`` cell)."""
275
+ return {"finger_width": self.drawn.straight_um, "second_finger_width": self.drawn.bent_um}
276
+
277
+ def design_junction(self) -> dict:
278
+ """``design.json`` instance ``junction`` values of the drawn junction (L_J total, C_J total)."""
279
+ return {"Lj_nH": round(self.drawn.lj_nH, 4), "Cj_fF": round(self.drawn.cj_fF, 3)}
280
+
281
+ def as_dict(self) -> dict:
282
+ return asdict(self)
283
+
284
+
285
+ def size_junction(
286
+ f_q_GHz: float, c_sigma_fF: float, pdk=None, n: int = 1, c_includes_junction: bool = True
287
+ ) -> JunctionSizing:
288
+ """Size a Quantcore trilayer junction for a transmon frequency.
289
+
290
+ ``c_sigma_fF`` is the total shunt capacitance (``c_includes_junction=False``: without the junction's own C_J,
291
+ which is then added from the sized area, iterated to convergence). E_C = e²/2C_Σ, E_J = (f_q + E_C)²/(8 E_C)
292
+ (inverse of the asymptotic transmon f01), L_J = (Φ0/2π)²/E_J; each of the ``n`` parallel junctions (n = 2: a
293
+ symmetric SQUID at zero flux) gets n·L_J → R_n (Ambegaokar–Baratoff, Δ of the PDK) → area = R_n·A / R_n →
294
+ fingers (:func:`fingers_for_lj`). The drawn junction (fingers on the grid) is re-evaluated; ``rn_in_window``
295
+ checks the device R_n (per junction / n) against ``rn_target_kohm`` and ``f_in_window`` the drawn f_q against
296
+ ``f_q_range_GHz``; ``notes`` say what is outside.
297
+ """
298
+ proc = junction_process(pdk)
299
+ c_total = c_sigma_fF
300
+ lj = 0.0
301
+ for _ in range(50 if not c_includes_junction else 1):
302
+ ec = ec_from_c(c_total)
303
+ ej = ej_for_f01(f_q_GHz, ec)
304
+ lj = lj_from_ej(ej)
305
+ if c_includes_junction:
306
+ break
307
+ cj = proc.cj_fF_per_um2 * area_from_rn(rn_from_lj(lj * n, proc.gap_meV), proc.rn_area_ohm_um2) * n
308
+ if abs(c_sigma_fF + cj - c_total) < 1e-9:
309
+ break
310
+ c_total = c_sigma_fF + cj
311
+ ec = ec_from_c(c_total)
312
+ ej = ej_for_f01(f_q_GHz, ec)
313
+ rn_total = rn_from_lj(lj, proc.gap_meV)
314
+ straight, bent, notes = fingers_for_lj(lj, n, proc)
315
+ drawn = junction_from_fingers(straight, bent, n, proc)
316
+ c_drawn = c_total if c_includes_junction else c_sigma_fF + drawn.cj_fF
317
+ f_drawn = transmon_f01(drawn.ej_GHz, ec_from_c(c_drawn))
318
+ lo, hi = proc.rn_target_kohm
319
+ flo, fhi = proc.f_q_range_GHz
320
+ rn_ok = lo <= rn_total / 1e3 <= hi
321
+ f_ok = flo <= f_drawn <= fhi
322
+ if not rn_ok:
323
+ notes.append(
324
+ f"R_n {rn_total / 1e3:.1f} kΩ is outside the process window {lo:g}–{hi:g} kΩ "
325
+ f"(f_q {f_q_GHz:g} GHz with C_Σ {c_total:.1f} fF needs E_J/h {ej:.1f} GHz)"
326
+ )
327
+ if not f_ok:
328
+ notes.append(f"drawn f_q {f_drawn:.2f} GHz is outside {flo:g}–{fhi:g} GHz")
329
+ return JunctionSizing(
330
+ f_q_GHz=f_q_GHz,
331
+ c_sigma_fF=c_total,
332
+ ec_GHz=ec,
333
+ ej_GHz=ej,
334
+ lj_nH=lj,
335
+ rn_kohm=rn_total / 1e3,
336
+ n=n,
337
+ drawn=drawn,
338
+ f_q_drawn_GHz=f_drawn,
339
+ rn_in_window=rn_ok,
340
+ f_in_window=f_ok,
341
+ notes=notes,
342
+ )
343
+
344
+
345
+ def squid_ej(ej_sum_GHz: float, asym: float, flux_phi0: float) -> float:
346
+ """Effective EJ of an asymmetric DC SQUID (d = (EJ1 − EJ2)/(EJ1 + EJ2)) at flux Φ/Φ0."""
347
+ x = math.pi * flux_phi0
348
+ return ej_sum_GHz * abs(math.cos(x)) * math.sqrt(1 + asym**2 * math.tan(x) ** 2)
349
+
350
+
351
+ def stack_capacitance_scale(eps_from: float, eps_to: float) -> float:
352
+ """Approximate rescaling of planar (CPW-like) capacitances between substrates: C ∝ (εr + 1)/2."""
353
+ return (eps_to + 1) / (eps_from + 1)