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,470 @@
1
+ """Export a :class:`SimSetup` to a self-contained job directory using KQC's exporters.
2
+
3
+ Job directory = KQC export (``scripts/``, ``<sim>.gds``, ``<sim>.json``) + ``job.json``
4
+ (qcc metadata: design hash, group, analysis, solver settings, port → net labels) + ``simulation.oas``. Ansys jobs
5
+ also get ``scripts/qcc_render.py`` / ``qcc_solve.py`` (:mod:`.aedt_scripts`) and ``simulation.bat`` / ``simulation.sh``
6
+ that run ``qcc_solve.py`` in a new non-graphical AEDT and collect ``results/results.json``.
7
+
8
+ Analyses:
9
+
10
+ ================== ==========================================================================================
11
+ ``q3d_cmatrix`` Ansys Q3D Maxwell capacitance matrix (KQC ``AnsysQ3dSolution``)
12
+ ``hfss_eigenmode`` Ansys HFSS eigenmode with Lj/Cj lumped RLC on junctions (``AnsysEigenmodeSolution``)
13
+ ``eigenmode_epr`` as above + KQC ``pyepr`` flag (junction lines); ``qcc_solve.py`` evaluates pyEPR's field
14
+ integrals in its own AEDT, :mod:`..analysis.epr` turns them into p_mj, χ, α (not KQC's
15
+ ``run_pyepr_t1_estimate.py``: it attaches to a running AEDT over COM and quits it)
16
+ ``elmer_cap`` Elmer electrostatics capacitance matrix (``ElmerCapacitanceSolution``)
17
+ ``palace_cap`` Palace electrostatic C-matrix (KQC gmsh mesh → Palace config, see :mod:`.palace`)
18
+ ``palace_eig`` Palace eigenmode with junction LumpedPort L=Lj (see :mod:`.palace`)
19
+ ``hfss_driven`` Ansys HFSS driven modal S-parameters (``AnsysHfssSolution``): wave ports where lines leave
20
+ the box, junctions as lumped L/C; e.g. a hanger's S21 → κ to calibrate the LOM coupling
21
+ ================== ==========================================================================================
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ import json
27
+ import os
28
+ import shutil
29
+ import sys
30
+ from datetime import UTC, datetime
31
+ from pathlib import Path
32
+
33
+ from kqcircuits.simulations.export.simulation_export import export_simulation_oas
34
+ from kqcircuits.simulations.post_process import PostProcess
35
+
36
+ from quantcore_circuits.design.io import design_hash, group_hash, tool_versions
37
+ from quantcore_circuits.pdk import get_pdk
38
+ from quantcore_circuits.sim_tools.builder import SimSetup
39
+
40
+ JOB_SCHEMA = "qcc-job/0.1"
41
+ MAX_SWEEP_POINTS = 25000 # AEDT: "A sweep can not have over 25000 points"
42
+
43
+ DEFAULT_SETTINGS = {
44
+ "q3d_cmatrix": {"percent_error": 0.5, "maximum_passes": 18, "minimum_passes": 2, "minimum_converged_passes": 2},
45
+ "hfss_eigenmode": {
46
+ "n_modes": 2,
47
+ "min_frequency": 3.0,
48
+ "max_delta_f": 0.1,
49
+ "maximum_passes": 17,
50
+ "minimum_passes": 1,
51
+ "minimum_converged_passes": 2,
52
+ "percent_refinement": 30,
53
+ "integrate_energies": False,
54
+ },
55
+ "elmer_cap": {"p_element_order": 3, "maximum_passes": 1},
56
+ "palace_cap": {"order": 2, "mesh_global_max": 100.0, "mesh_edge": 4.0},
57
+ "palace_eig": {"order": 2, "n_modes": 2, "target_GHz": 3.0, "mesh_global_max": 100.0, "mesh_edge": 4.0},
58
+ }
59
+ DEFAULT_SETTINGS["eigenmode_epr"] = {**DEFAULT_SETTINGS["hfss_eigenmode"], "n_modes": 2}
60
+ DEFAULT_SETTINGS["hfss_driven"] = {
61
+ "frequency": 6.0, # GHz, adaptive-mesh frequency (put it near the resonance of interest)
62
+ "max_delta_s": 0.02,
63
+ "maximum_passes": 20,
64
+ "minimum_passes": 2,
65
+ "minimum_converged_passes": 2,
66
+ "percent_refinement": 30,
67
+ "sweep_enabled": True,
68
+ "sweep_start": 4.0,
69
+ "sweep_end": 9.0,
70
+ "sweep_count": 1001,
71
+ "sweep_type": "interpolating",
72
+ }
73
+
74
+ # "Fast FEM" (2026-11-13): whole-chip *test* runs that finish in minutes on a workstation. The values are not
75
+ # accurate (the mesh is not converged); they move with the design, so the whole loop (render → solve → save → read
76
+ # back → fill → feedback → re-solve) can be exercised before anyone fine-tunes the settings. Criteria are loosened to
77
+ # at least these values, pass counts capped at them; mesh seeds (``mesh_size``) are coarsened by FAST_MESH_FACTOR and a
78
+ # sweep capped at FAST_SWEEP_POINTS. Switch: ``export_job(..., fast=True)``, :func:`set_fem_fast` or
79
+ # ``QCC_FEM_FAST=1``.
80
+ FAST_SETTINGS = {
81
+ "q3d_cmatrix": {"percent_error": 2.0, "maximum_passes": 8, "minimum_passes": 1, "minimum_converged_passes": 1},
82
+ # eigenmode: memory, not time, is the limit here (31 GB): tutorial 04's two-qubit box needed 20 GB for hf3d at
83
+ # pass 3 (265 k tets) and pass 4 would not have fitted, so 3 passes on a 40 µm gap seed (≈ 15 GB at most)
84
+ "hfss_eigenmode": {"max_delta_f": 1.0, "maximum_passes": 3, "minimum_passes": 1, "minimum_converged_passes": 1},
85
+ "hfss_driven": {"max_delta_s": 0.05, "maximum_passes": 6, "minimum_passes": 1, "minimum_converged_passes": 1},
86
+ }
87
+ FAST_SETTINGS["eigenmode_epr"] = FAST_SETTINGS["hfss_eigenmode"]
88
+ # HFSS starts from a mesh too coarse to resolve the junction gap and the CPW gaps: unseeded, the first ~6 eigenmode
89
+ # passes show the qubit and the readout at the wrong frequencies (the 2026-11-03 fixture: 10–14 GHz until pass 7,
90
+ # then 3.2 → 5.2 GHz), and a driven S21 stays flat. So a fast run without a seed of its own gets one on the gaps.
91
+ # Tutorial 00 with 20 µm: qubit / readout 5.23 / 6.65 GHz at pass 1, 5.32 / 6.96 at pass 3, 5.35 / 7.00 at pass 4;
92
+ # tutorial 04 with 30 µm: both qubits and both readouts at pass 1 (158 k tets).
93
+ FAST_MESH_SEED = {"hfss_eigenmode": {"1t1_gap": 40.0}, "eigenmode_epr": {"1t1_gap": 40.0},
94
+ "hfss_driven": {"1t1_gap": 30.0}}
95
+ FAST_MESH_FACTOR = 3.0
96
+ # … and the junction islands (the nets of the junction ports, KQC layer ``<face>_signal_<n>``) a fine seed of their own:
97
+ # with the gap seed alone a qubit-only box (tutorial 01 ``Q1_q``, 0.8 × 1 mm) got 18 k tets and no qubit mode
98
+ # (10.3 / 11.6 GHz). The islands are small, so this costs little.
99
+ FAST_ISLAND_SEED = 10.0
100
+ FAST_SWEEP_POINTS = 10001
101
+ _LOOSER = ("percent_error", "max_delta_f", "max_delta_s") # larger = looser
102
+ _FEWER = ("maximum_passes", "minimum_passes", "minimum_converged_passes") # smaller = faster
103
+ _FAST: bool | None = None
104
+
105
+
106
+ def set_fem_fast(flag: bool | None) -> None:
107
+ """Process-wide default for ``export_job(fast=None)`` (None: ``QCC_FEM_FAST``, else off)."""
108
+ global _FAST # noqa: PLW0603
109
+ _FAST = flag
110
+
111
+
112
+ def fem_fast(fast: bool | None = None) -> bool:
113
+ """Whether jobs are exported with :data:`FAST_SETTINGS`: ``fast`` if given, else :func:`set_fem_fast`'s value,
114
+ else ``QCC_FEM_FAST`` (``1`` / ``true``)."""
115
+ if fast is not None:
116
+ return bool(fast)
117
+ if _FAST is not None:
118
+ return _FAST
119
+ return os.environ.get("QCC_FEM_FAST", "").strip().lower() in ("1", "true", "yes", "on")
120
+
121
+
122
+ def fast_settings(analysis: str, settings: dict, islands: list[int] | tuple = ()) -> dict:
123
+ """``settings`` for a fast whole-chip test run of ``analysis`` (see :data:`FAST_SETTINGS`): each convergence
124
+ criterion at least the fast value, each pass count at most the fast value, ``mesh_size`` seeds × FAST_MESH_FACTOR
125
+ (no seed given: :data:`FAST_MESH_SEED` for eigenmode / driven), ``sweep_count`` ≤ FAST_SWEEP_POINTS. Other keys
126
+ (frequencies, modes, sweep band) are kept. Analyses without fast
127
+ values (Elmer, Palace, plugins) are returned unchanged. ``islands``: KQC excitation numbers of the junction
128
+ islands; eigenmode / driven runs seed each with :data:`FAST_ISLAND_SEED`."""
129
+ fast = FAST_SETTINGS.get(analysis)
130
+ out = dict(settings)
131
+ if not fast:
132
+ return out
133
+ for k, v in fast.items():
134
+ if k in _LOOSER:
135
+ out[k] = max(float(out.get(k, v)), v)
136
+ elif k in _FEWER:
137
+ out[k] = min(int(out.get(k, v)), v)
138
+ if "minimum_passes" in out and "maximum_passes" in out:
139
+ out["minimum_passes"] = min(out["minimum_passes"], out["maximum_passes"])
140
+ if isinstance(out.get("mesh_size"), dict) and out["mesh_size"]:
141
+ out["mesh_size"] = {k: v * FAST_MESH_FACTOR for k, v in out["mesh_size"].items()}
142
+ elif analysis in FAST_MESH_SEED:
143
+ out["mesh_size"] = dict(FAST_MESH_SEED[analysis])
144
+ if analysis in FAST_MESH_SEED:
145
+ for n in islands:
146
+ out["mesh_size"].setdefault(f"*_signal_{int(n)}", FAST_ISLAND_SEED)
147
+ if int(out.get("sweep_count", 0)) > FAST_SWEEP_POINTS:
148
+ out["sweep_count"] = FAST_SWEEP_POINTS
149
+ return out
150
+
151
+
152
+ def tighter_or_equal(old: dict, new: dict) -> bool:
153
+ """Whether solver settings ``old`` are at least as tight as ``new``: the same keys and values except that each
154
+ convergence criterion of ``old`` is ≤ ``new``'s, each pass count ≥ and each mesh seed ≤ (e.g. a full solve vs the
155
+ fast settings of the same job: its results can stand in for a fast re-run)."""
156
+ for k in set(old) | set(new):
157
+ a, b = old.get(k), new.get(k)
158
+ if a == b:
159
+ continue
160
+ if a is None or b is None: # e.g. an unseeded run vs a seeded one: not comparable (unseeded early passes
161
+ # can miss the qubit entirely), so it does not stand in
162
+ return False
163
+ if k in _LOOSER:
164
+ ok = float(a) <= float(b)
165
+ elif k in _FEWER:
166
+ ok = int(a) >= int(b)
167
+ elif k == "mesh_size" and isinstance(a, dict) and isinstance(b, dict):
168
+ ok = set(a) == set(b) and all(a[x] <= b[x] for x in a)
169
+ elif k == "sweep_count":
170
+ ok = int(a) >= int(b)
171
+ else:
172
+ ok = False
173
+ if not ok:
174
+ return False
175
+ return True
176
+
177
+
178
+ # pyEPR post-process defaults (KQC run_pyepr_t1_estimate.py inputs)
179
+ PYEPR_DEFAULTS = {
180
+ "substrate_loss_tangent": 1e-6,
181
+ "dielectric_surfaces": {
182
+ "layerMA": {"tan_delta_surf": 1e-3, "th": 3e-9, "eps_r": 10},
183
+ "layerMS": {"tan_delta_surf": 1e-3, "th": 3e-9, "eps_r": 10},
184
+ "layerSA": {"tan_delta_surf": 1e-3, "th": 3e-9, "eps_r": 10},
185
+ },
186
+ }
187
+
188
+
189
+ def solver_of(analysis: str) -> str:
190
+ builtin = {"q3d": "ansys", "hfs": "ansys", "eig": "ansys", "elm": "elmer", "pal": "palace"}
191
+ if analysis in DEFAULT_SETTINGS:
192
+ return builtin[analysis[:3]]
193
+ from quantcore_circuits.plugins import analysis_plugins # pylint: disable=import-outside-toplevel
194
+
195
+ return analysis_plugins()[analysis].solver
196
+
197
+
198
+ def export_job(setup: SimSetup, job_dir: str | Path, overwrite: bool = False, fast: bool | None = None,
199
+ **settings) -> Path:
200
+ """Write the job directory for ``setup`` (:func:`_export_job`); marks the dashboard's Render step running → done /
201
+ failed with the job name (nested inside :func:`hfss.render`, only the outer render marks it)."""
202
+ from quantcore_circuits import track as _track # pylint: disable=import-outside-toplevel
203
+
204
+ with _track.stage("render", f"export {Path(job_dir).name}") as st:
205
+ out = _export_job(setup, job_dir, overwrite, fast, **settings)
206
+ st.note = "job exported"
207
+ return out
208
+
209
+
210
+ def _export_job(setup: SimSetup, job_dir: str | Path, overwrite: bool = False, fast: bool | None = None,
211
+ **settings) -> Path:
212
+ """Write the job directory for ``setup``. ``settings`` override :data:`DEFAULT_SETTINGS` for the analysis.
213
+ ``fast`` (None: :func:`fem_fast`): loosen the result to :func:`fast_settings` (a whole-chip test run; recorded
214
+ as ``"fem_fast": true`` in ``job.json``)."""
215
+ job_dir = Path(job_dir)
216
+ if job_dir.exists():
217
+ if not overwrite:
218
+ raise FileExistsError(f"{job_dir} exists; pass overwrite=True to replace it")
219
+ shutil.rmtree(job_dir)
220
+ job_dir.mkdir(parents=True)
221
+ analysis = setup.analysis
222
+ plugin = None
223
+ if analysis not in DEFAULT_SETTINGS:
224
+ from quantcore_circuits.plugins import analysis_plugins # pylint: disable=import-outside-toplevel
225
+
226
+ plugin = analysis_plugins()[analysis]
227
+ defaults = plugin.defaults if plugin else DEFAULT_SETTINGS[analysis]
228
+ cfg = {**defaults, **group_settings(setup, defaults), **settings}
229
+ is_fast = fem_fast(fast) and analysis in FAST_SETTINGS
230
+ if is_fast:
231
+ cfg = fast_settings(analysis, cfg, _junction_islands(setup))
232
+ # mesh seeds by name (the KLayout Simulate dialog): "gap_seed" µm on the CPW gaps, "island_seed" µm on the
233
+ # junction islands (what a fast run seeds by itself); None / 0 = no seed
234
+ gap_seed, island_seed = cfg.pop("gap_seed", None), cfg.pop("island_seed", None)
235
+ if gap_seed or island_seed:
236
+ seeds = dict(cfg.get("mesh_size") or {})
237
+ if gap_seed:
238
+ seeds[f"{get_pdk(setup.design.pdk).face}_gap"] = float(gap_seed)
239
+ if island_seed:
240
+ for n in _junction_islands(setup):
241
+ seeds[f"*_signal_{int(n)}"] = float(island_seed)
242
+ cfg["mesh_size"] = seeds
243
+ ansys_exe = cfg.pop("ansys_executable", None)
244
+ sim = setup.simulation
245
+ if plugin is None and solver_of(analysis) in ("ansys", "elmer"):
246
+ from quantcore_circuits.kqc_files import ensure_kqc_scripts # pylint: disable=C0415
247
+
248
+ ensure_kqc_scripts() # a pip-installed kqcircuits ships no scripts/ folder (qcc kqc-files)
249
+ if solver_of(analysis) == "ansys":
250
+ from quantcore_circuits.sim_tools.ansys import configure_kqc_ansys # pylint: disable=C0415
251
+
252
+ configure_kqc_ansys(ansys_exe)
253
+
254
+ if plugin is not None:
255
+ plugin.export(setup, job_dir, **cfg)
256
+ elif analysis == "q3d_cmatrix":
257
+ from kqcircuits.simulations.export.ansys.ansys_export import export_ansys # pylint: disable=C0415
258
+
259
+ export_ansys(
260
+ [sim],
261
+ path=job_dir,
262
+ ansys_tool="q3d",
263
+ exit_after_run=True,
264
+ post_process=PostProcess("produce_cmatrix_table.py", command=_python()),
265
+ **cfg,
266
+ )
267
+ elif analysis in ("hfss_eigenmode", "eigenmode_epr"):
268
+ from kqcircuits.simulations.export.ansys.ansys_export import export_ansys # pylint: disable=C0415
269
+
270
+ extra = {}
271
+ if analysis == "eigenmode_epr":
272
+ # "pyepr" makes KQC draw a Junction<n> line over each junction (line voltage → EPR). KQC's own post-process
273
+ # (run_pyepr_t1_estimate.py) is NOT used: it attaches to any running AEDT over COM and quits it at the
274
+ # end. qcc_solve.py evaluates pyEPR's field integrals in its own batch AEDT instead (aedt_scripts).
275
+ epr_options = {**PYEPR_DEFAULTS, **cfg.pop("pyepr", {})}
276
+ extra = {"simulation_flags": ["pyepr"]}
277
+ export_ansys([sim], path=job_dir, ansys_tool="eigenmode", exit_after_run=True, **extra, **cfg)
278
+ elif analysis == "hfss_driven":
279
+ from kqcircuits.simulations.export.ansys.ansys_export import export_ansys # pylint: disable=C0415
280
+
281
+ if int(cfg.get("sweep_count", 0)) > MAX_SWEEP_POINTS: # AEDT refuses the sweep (seen on 2024 R1)
282
+ raise ValueError(f"sweep_count {cfg['sweep_count']} > {MAX_SWEEP_POINTS}: AEDT allows at most 25000 points")
283
+ export_ansys([sim], path=job_dir, ansys_tool="hfss", exit_after_run=True, **cfg)
284
+ elif analysis == "elmer_cap":
285
+ from kqcircuits.simulations.export.elmer.elmer_export import export_elmer # pylint: disable=C0415
286
+ from kqcircuits.simulations.export.elmer.mesh_size_helpers import refine_metal_edges # pylint: disable=C0415
287
+
288
+ workflow = {"python_executable": _python(), "n_workers": 1, "elmer_n_processes": -1, "gmsh_n_threads": -1}
289
+ export_elmer(
290
+ [sim],
291
+ path=job_dir,
292
+ tool="capacitance",
293
+ workflow=workflow,
294
+ mesh_size={"global_max": 100.0, **refine_metal_edges(4.0)},
295
+ **cfg,
296
+ )
297
+ elif analysis in ("palace_cap", "palace_eig"):
298
+ from quantcore_circuits.sim_tools.palace import export_palace # pylint: disable=C0415
299
+
300
+ export_palace(setup, job_dir, **cfg)
301
+ else: # pragma: no cover - guarded by builder
302
+ raise ValueError(analysis)
303
+
304
+ if solver_of(analysis) == "ansys":
305
+ _add_tool_key(job_dir, sim.name)
306
+ _ansys_launchers(job_dir, sim.name, ansys_exe)
307
+ if analysis != "q3d_cmatrix": # Q3D: AutoIdentifyNets makes each overlapping piece its own net (AEDT 2024 R1)
308
+ _split_gds_records(setup, job_dir / f"{sim.name}.gds")
309
+ if not (job_dir / "simulation.oas").exists():
310
+ export_simulation_oas([sim], job_dir)
311
+ if analysis == "eigenmode_epr":
312
+ cfg = {**cfg, "pyepr": epr_options}
313
+ write_job_json(setup, job_dir, cfg)
314
+ if is_fast:
315
+ update_job(job_dir, fem_fast=True)
316
+ return job_dir
317
+
318
+
319
+ def _split_gds_records(setup: SimSetup, gds: Path) -> None:
320
+ """HFSS jobs: GDS polygons above the XY record limit (C8; after the builder's bend simplification only holes are
321
+ left, e.g. flux-trap rows) → overlapping pieces of one conductor (:func:`~.builder.split_large_gds_polygons`);
322
+ recorded in ``geometry.gds_polygons_split`` and a note. HFSS makes every metal sheet PEC, so the pieces act as one
323
+ conductor (rendered in AEDT 2024 R1: imported, PerfE on all pieces). Not for Q3D: its ``AutoIdentifyNets`` keeps
324
+ overlapping pieces as separate nets (same render), so a Q3D job keeps such a polygon whole (checker warning)."""
325
+ from quantcore_circuits.sim_tools.builder import GDS_MAX_POINTS, split_large_gds_polygons # pylint: disable=C0415
326
+
327
+ if not gds.exists():
328
+ return
329
+ n = split_large_gds_polygons(gds)
330
+ if n:
331
+ setup.geometry["gds_polygons_split"] = n
332
+ note = (f"{n} polygon(s) still above {GDS_MAX_POINTS} points (holes, not bends: e.g. flux-trap holes) written "
333
+ "to the GDS as overlapping pieces of the same conductor (outline unchanged)")
334
+ if note not in setup.notes:
335
+ setup.notes.append(note)
336
+
337
+
338
+ def _junction_islands(setup: SimSetup) -> list[int]:
339
+ """KQC excitation numbers of the nets the junction ports connect (the qubit islands)."""
340
+ by_name = {v: k for k, v in setup.nets.items()}
341
+ out = []
342
+ for p in setup.ports:
343
+ if p.kind == "junction" and (p.excitation or "") in by_name:
344
+ out.append(int(by_name[p.excitation]))
345
+ return sorted(set(out))
346
+
347
+
348
+ def group_settings(setup: SimSetup, defaults: dict) -> dict:
349
+ """Solver settings from the sim group's ``settings``: keys of the analysis defaults (plus ``mesh_size``,
350
+ ``pyepr``), and a nested ``{"<analysis>": {...}}`` dict for that analysis only. Builder options (``airbridges``)
351
+ and settings of other analyses are left out."""
352
+ from quantcore_circuits.sim_tools.builder import group_spec # pylint: disable=import-outside-toplevel
353
+
354
+ try:
355
+ raw = dict(group_spec(setup.design, setup.group).settings or {})
356
+ except ValueError:
357
+ return {}
358
+ allowed = set(defaults)
359
+ if solver_of(setup.analysis) == "ansys":
360
+ allowed.add("mesh_size") # KQC AnsysSolution: {layer pattern: max element length µm}
361
+ if setup.analysis == "eigenmode_epr":
362
+ allowed.add("pyepr")
363
+ out = {k: v for k, v in raw.items() if k in allowed}
364
+ nested = raw.get(setup.analysis)
365
+ if isinstance(nested, dict):
366
+ out.update(nested)
367
+ return out
368
+
369
+
370
+ def _group_select(setup: SimSetup) -> list[str] | None:
371
+ """The group's selection (None for the built-in whole-chip ``chip`` group)."""
372
+ from quantcore_circuits.sim_tools.builder import CHIP_GROUP, group_spec # pylint: disable=import-outside-toplevel
373
+
374
+ if setup.group == CHIP_GROUP and setup.group not in setup.design.sim_groups:
375
+ return None
376
+ return list(group_spec(setup.design, setup.group).select)
377
+
378
+
379
+ def write_job_json(setup: SimSetup, job_dir: Path, settings: dict) -> Path:
380
+ box = setup.box
381
+ data = {
382
+ "schema": JOB_SCHEMA,
383
+ "created": datetime.now(UTC).isoformat(timespec="seconds"),
384
+ "design": setup.design.name,
385
+ "design_hash": design_hash(setup.design),
386
+ "group": setup.group,
387
+ # subset read-back (additive): this group's own hash, what it selected, which routes stayed in the geometry
388
+ "group_hash": group_hash(setup.design, setup.group),
389
+ "select": _group_select(setup),
390
+ "routes_in_sim": list(getattr(setup, "routes", []) or []),
391
+ "analysis": setup.analysis,
392
+ "solver": solver_of(setup.analysis),
393
+ "simulation_name": setup.simulation.name,
394
+ "settings": settings,
395
+ "box_um": [box.left, box.bottom, box.right, box.top] if box else None,
396
+ "ports": [vars(p) for p in setup.ports],
397
+ "nets": {str(k): v for k, v in sorted(setup.nets.items())},
398
+ "waveguide_length_um": setup.waveguide_length,
399
+ "geometry": getattr(setup, "geometry", {}),
400
+ "notes": getattr(setup, "notes", []),
401
+ "versions": tool_versions(setup.design.pdk),
402
+ "status": "exported",
403
+ }
404
+ path = job_dir / "job.json"
405
+ path.write_text(json.dumps(data, indent=2, default=str) + "\n", encoding="utf-8")
406
+ return path
407
+
408
+
409
+ def read_job(job_dir: str | Path) -> dict:
410
+ return json.loads((Path(job_dir) / "job.json").read_text(encoding="utf-8"))
411
+
412
+
413
+ def update_job(job_dir: str | Path, **fields) -> dict:
414
+ data = read_job(job_dir)
415
+ data.update(fields)
416
+ (Path(job_dir) / "job.json").write_text(json.dumps(data, indent=2, default=str) + "\n", encoding="utf-8")
417
+ return data
418
+
419
+
420
+ def _add_tool_key(job_dir: Path, sim_name: str) -> None:
421
+ """KQC main's ``produce_cmatrix_table.py`` reads ``data["tool"]`` but ``export_ansys`` writes ``ansys_tool``."""
422
+ path = job_dir / f"{sim_name}.json"
423
+ if path.exists():
424
+ data = json.loads(path.read_text(encoding="utf-8"))
425
+ if "tool" not in data and "ansys_tool" in data:
426
+ data["tool"] = data["ansys_tool"]
427
+ path.write_text(json.dumps(data, indent=4), encoding="utf-8")
428
+
429
+
430
+ def _ansys_launchers(job_dir: Path, sim_name: str, executable=None) -> None:
431
+ """qcc AEDT scripts + launchers that solve in a *new* non-graphical AEDT (never one that is already open) and
432
+ collect the results: ``simulation.bat`` (replaces KQC's, which ran AEDT with its GUI and, for pyEPR jobs, a
433
+ post-process that quits whatever AEDT it attached to) and ``simulation.sh`` (Linux server)."""
434
+ from quantcore_circuits.sim_tools.aedt_scripts import SOLVE_SCRIPT, write_scripts # pylint: disable=C0415
435
+ from quantcore_circuits.sim_tools.ansys import default_executable, find_ansys_executable # pylint: disable=C0415
436
+
437
+ write_scripts(job_dir)
438
+ exe = Path(executable) if executable else (find_ansys_executable() or default_executable())
439
+ flag = "SF6694_NON_GRAPHICAL_COMMAND_EXECUTION"
440
+ collect = "from quantcore_circuits.analysis.results import collect_results; collect_results('.')"
441
+ run = f'-ng -features={flag} -RunScriptAndExit "scripts/{SOLVE_SCRIPT}" -ScriptArgs "{sim_name}.json"'
442
+ bat = [
443
+ "@echo off",
444
+ "rem qcc: solve in a separate non-graphical AEDT, then collect results/results.json",
445
+ f"set ANSYSEM_FEATURE_{flag}_ENABLE=1",
446
+ f'"{exe}" {run}',
447
+ f'{_python()} -c "{collect}"',
448
+ ]
449
+ (job_dir / "simulation.bat").write_text("\r\n".join(bat) + "\r\n", encoding="utf-8", newline="")
450
+ linux_exe = exe if os.name != "nt" else default_executable_linux()
451
+ sh = [
452
+ "#!/bin/bash",
453
+ "# qcc: solve in a separate non-graphical AEDT, then collect results/results.json",
454
+ 'cd "$(dirname "$0")"',
455
+ f"export ANSYSEM_FEATURE_{flag}_ENABLE=1",
456
+ f'"${{QCC_ANSYS_EXECUTABLE:-{linux_exe}}}" {run}',
457
+ f'"${{QCC_PYTHON:-python3}}" -c "{collect}"',
458
+ ]
459
+ (job_dir / "simulation.sh").write_text("\n".join(sh) + "\n", encoding="utf-8", newline="")
460
+
461
+
462
+ def default_executable_linux(version: int | None = None) -> str:
463
+ from quantcore_circuits.sim_tools.ansys import TARGET_VERSION # pylint: disable=import-outside-toplevel
464
+
465
+ return f"/ansys_inc/v{version or TARGET_VERSION}/AnsysEM/ansysedt"
466
+
467
+
468
+ def _python() -> str:
469
+ """Python used by post-process steps inside the job (this environment, so pyEPR/pandas are available)."""
470
+ return f'"{sys.executable}"'