setupEM 0.17.0__tar.gz → 0.18.0__tar.gz

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 (53) hide show
  1. {setupem-0.17.0/src/setupEM.egg-info → setupem-0.18.0}/PKG-INFO +19 -13
  2. {setupem-0.17.0 → setupem-0.18.0}/README_pypi.md +17 -11
  3. {setupem-0.17.0 → setupem-0.18.0}/pyproject.toml +1 -1
  4. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/__init__.py +1 -1
  5. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/data/SG13CMOS5L_200um.xml +5 -0
  6. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_FEM_200um.xml +5 -0
  7. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_FEM_200um_passi3D.xml +5 -0
  8. setupem-0.18.0/src/setupEM/join_pieces.py +197 -0
  9. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/layout_preview.py +388 -1
  10. setupem-0.18.0/src/setupEM/piece_set.py +509 -0
  11. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/result_viewer.py +62 -3
  12. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/run_with_overrides.py +10 -1
  13. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/setupEM.py +902 -114
  14. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/setupThermal.py +33 -4
  15. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/setup_common.py +566 -29
  16. {setupem-0.17.0 → setupem-0.18.0/src/setupEM.egg-info}/PKG-INFO +19 -13
  17. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM.egg-info/SOURCES.txt +8 -0
  18. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM.egg-info/requires.txt +1 -1
  19. setupem-0.18.0/tests/test_deembedded_view.py +71 -0
  20. setupem-0.18.0/tests/test_join_pieces.py +132 -0
  21. setupem-0.18.0/tests/test_margin_per_side.py +346 -0
  22. setupem-0.18.0/tests/test_piece_set.py +420 -0
  23. setupem-0.18.0/tests/test_port_walls.py +440 -0
  24. setupem-0.18.0/tests/test_qt_platform_noise.py +23 -0
  25. {setupem-0.17.0 → setupem-0.18.0}/tests/test_run_with_overrides.py +52 -0
  26. {setupem-0.17.0 → setupem-0.18.0}/LICENSE +0 -0
  27. {setupem-0.17.0 → setupem-0.18.0}/README.md +0 -0
  28. {setupem-0.17.0 → setupem-0.18.0}/setup.cfg +0 -0
  29. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/__main__.py +0 -0
  30. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/config_update.py +0 -0
  31. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_100um.xml +0 -0
  32. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_200um.xml +0 -0
  33. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_nosub.xml +0 -0
  34. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/field_viewer.py +0 -0
  35. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/gds_hierarchy_scan.py +0 -0
  36. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/momentum_import.py +0 -0
  37. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/palace_results.py +0 -0
  38. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/script_model.py +0 -0
  39. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/script_probe.py +0 -0
  40. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/simplify_gds.py +0 -0
  41. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/stackupEditor.py +0 -0
  42. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/stackup_writer.py +0 -0
  43. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM/thermal_results.py +0 -0
  44. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM.egg-info/dependency_links.txt +0 -0
  45. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM.egg-info/entry_points.txt +0 -0
  46. {setupem-0.17.0 → setupem-0.18.0}/src/setupEM.egg-info/top_level.txt +0 -0
  47. {setupem-0.17.0 → setupem-0.18.0}/tests/test_config_update.py +0 -0
  48. {setupem-0.17.0 → setupem-0.18.0}/tests/test_config_update_gui.py +0 -0
  49. {setupem-0.17.0 → setupem-0.18.0}/tests/test_script_model.py +0 -0
  50. {setupem-0.17.0 → setupem-0.18.0}/tests/test_script_probe.py +0 -0
  51. {setupem-0.17.0 → setupem-0.18.0}/tests/test_table_rows.py +0 -0
  52. {setupem-0.17.0 → setupem-0.18.0}/tests/test_thermal_powers.py +0 -0
  53. {setupem-0.17.0 → setupem-0.18.0}/tests/test_thermal_results.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: setupEM
3
- Version: 0.17.0
3
+ Version: 0.18.0
4
4
  Summary: Python tool for configuration of gds2palace workflow with GUI.
5
5
  Author-email: Volker Muehlhaus <volker@muehlhaus.com>
6
6
  License-Expression: GPL-3.0-or-later
@@ -10,7 +10,7 @@ Project-URL: Changelog, https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc
10
10
  Requires-Python: >=3.9
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
- Requires-Dist: gds2palace>=0.9.4
13
+ Requires-Dist: gds2palace>=0.10.0
14
14
  Requires-Dist: gds_prepare_for_EM>=1.6.0
15
15
  Requires-Dist: PySide6
16
16
  Requires-Dist: shiboken6
@@ -40,6 +40,22 @@ https://github.com/VolkerMuehlhaus/setupEM
40
40
 
41
41
  ## Recent changes
42
42
 
43
+ # What's New - November 10, 2026 (setupEM 0.18.0)
44
+
45
+ **De-embedded results shown**: View S-Parameters lists the `_deembedded` files from the start and opens with the raw result and its `_deembedded` result together. Model Fit fits the calibrated result (`_dc_deembedded`, else `_deembedded`) of a model with port walls or a moved reference plane; the raw result still holds the uncalibrated gap ports.
46
+
47
+ **Port wall fixes:** a model script edited in place now gives back its port wall extension, reference plane shift and de-embedding length (they were written but not read, so the next session started with 0). Two port walls no longer make 0 the default oversize and air (the other sides became overrides and the default fields changed nothing); a default field that sets no side any more is greyed out. The status line under the log names the solve of a port wall run (calibration standard k/n, reused, or the model). The Port walls status says OK or the warnings only; the layout preview draws an extended feed and its length, a symbol per box side, and labels without the side names.
48
+
49
+ **Split regions**: a `.simcfg` from the KLayout plug-in's Export All of a split region (several EM region boxes) opens as a set of pieces. The Models list shows the pieces (and an unticked full check model). The settings (frequencies, mesh, solver, boundaries) are those of the whole region, shared by all pieces; a piece's box sides follow from the region's (a cut is a port wall, a stretch of a port wall without the piece's ports is PEC at the layout edge) and are locked; a piece can have its own mesh settings (Mesh tab, "Own mesh settings for p2"). Start Simulation runs the pieces without a gmsh window and does not mesh a piece again whose mesh is current; View S-Parameters shows the joined result first, and Model Fit fits it. The port wall extension and reference plane shift are the region's, on its outer sides only (none on a cut). An export written on another machine opens with its model folders, layouts and stackup found here. Start Simulation creates and runs the ticked pieces one after another and joins their results at the cuts (`join_pieces.py`, also `python -m setupEM.join_pieces <name>.simcfg`) into `<name>_deembedded.sNp` of the whole region. A piece whose layout fingerprint, settings and gds2palace version are unchanged since its last run is reused (`piece.key` in its model folder); **Run unchanged pieces too** overrides. Create Model keeps a settings file's own keys of the layout tool (piece name, fingerprint) when it rewrites the file.
50
+
51
+ The calibration standards of a port wall are no longer listed as models of their own in **Models** on the Create Model tab (they share the model's `_data` folder and its `run_sim` solves them before the model); Start Simulation ran `run_sim` once per listed row, and **Preview** stopped after the first standard with the model itself unbuilt. For a script that creates several models, the question about results of a previous simulation is now asked once before the first model starts, not between two models.
52
+
53
+ **Port walls**: calibrated ports at the layout edge (needs gds2palace 0.10.0). **Mesh and Boundaries > Advanced...** offers **Port wall** for xmin, xmax, ymin and ymax: PEC at the layout edge, oversize and air 0 and locked, written as `'PORTWALL'` in `settings['boundary']`. The Ports tab gets a **De-embedding** column (calibrated at a port wall, or the estimated port inductance), locks the direction of ports on a port wall, and a **Port walls** group with **Check port walls** (reads the layout, no meshing): per port wall its ports, ground at the cut, D, the standards' lengths, the valid frequency range, warnings or the error, and the **Reference plane shift** (`settings['reference_plane_shift']`). A port on an edge that is not a port wall gets the question whether to make that side one. Create Model runs the check when a port wall is set and stops on an error. An **Extension (µm)** per port wall (`auto` or a length, `settings['port_wall_extension']`) moves the port wall outward. The Ports tab runs the check by itself when a port wall has no result yet; the panel splits with the port list by a divider; warnings show with an icon and the start of their text. The layout preview shows the reference plane, where the uniform feed ends, and an extension, and fits the view to the layout and its box. setupEM and setupThermal keep the window's size and position (and the Ports tab's divider) from one session to the next. A via port on a port wall is listed as "via port used as a gap port on <line metal>" (gds2palace converts it when writing the model). The layout preview draws the simulation box: one frame, not to scale, with a label per side (a click opens the box sides dialog), a port wall as a white line. `combine_extend_snp.py` in `src/scripts` is synced with gds2palace.
54
+
55
+ The dielectric oversize can be set per side (xmin, xmax, ymin, ymax): in setupEM with **Advanced...** next to **Boundary conditions**, in setupThermal with **Advanced...** next to the oversize. It is written to the model script as a list `settings['margin'] = [xmin, xmax, ymin, ymax]`, and read from there and from settings files. Needs gds2palace 0.10.0. A negative oversize is no longer accepted.
56
+
57
+ Bundled IHP stackups (from gds2palace 0.10.0): heat source target layers `HEAT_TRANSISTOR` and `HEAT_RESISTOR`, for thermal models. Nothing is drawn on them, so EM models are unchanged.
58
+
43
59
  # What's New - November 5, 2026 (setupEM 0.17.0)
44
60
 
45
61
  setupThermal works with the thermal export of the KLayout plug-in klayout_em_export (one heat source per transistor and resistor, with the schematic instance names from LVS in `<layout>_thermalmap.json`):
@@ -73,23 +89,13 @@ setupEM 0.16.0 needs gds2palace 0.9.3 or later: a layout with several shapes on
73
89
  - An incomplete port (direction and layers that don't fit, e.g. from a `.simcfg` written by another tool) gives a warning in the Ports tab. Before, gds2palace exited and setupEM closed. A lowercase `z` counts as a via port too.
74
90
  - `combine_extend_snp` (Touchstone output after a Palace run) handles ports with several elements (several shapes on one port layer, gds2palace 0.9.3): one Z0 per port in the option line, and the elements' port inductances combined in parallel for de-embedding. Before, the last element overwrote the others.
75
91
 
76
- # What's New - October 29, 2026
77
-
78
- **File > Edit \*.py model in place** (new, setupEM and setupThermal): edits a gds2palace model script directly, e.g. one from the gds2palace MCP server, an example or your own code. Create Model and **File > Save** write only the values you change; the script's loops, comments and custom code stay. Settings the script computes itself are greyed out. A script that builds several models (a parameter sweep) lists them on the Create Model tab, and Start Simulation runs the ticked ones. After importing a script that setupEM didn't write, a bar below the menu offers **Edit in place instead**.
79
-
80
- **File > Import from \*.py model** now runs a gds2palace script to read it, without reading the GDSII file and without meshing. The run stops where the script builds the model, so its solver start never runs. The import now gets exactly what gds2palace would get, also values and ports the script computes. Before, ports made in a loop (as in many gds2palace MCP scripts) were left out, and the imported model was missing them. The script's own code before building the model does run, e.g. a script that generates its GDSII file writes it. If the run fails, the import reads the script text as before, and the bar below the menu says why.
81
-
82
- **File menu:** the three Recent submenus are now one **Open Recent** submenu, with sections for configs, imported \*.py models and \*.py models edited in place. A file reopens the way it was opened. The menu is grouped as open, recent, save, preferences. **Load Default Config** and **Save as Default Config** are removed: defaults for new models are set in **File > Preferences**. An existing `default.simcfg` / `default.tsimcfg` in your home directory still opens with **Load Config**, and **Save Config** can write it.
83
-
84
- Import and edit in place now read a stackup given as `utilities.get_stackup_path("SG13G2_FEM_200um.xml")`, the way the gds2palace MCP server writes it (needs gds2palace 0.9.1 or later). Before, an imported model using that syntax had no stackup file.
85
-
86
92
  Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)
87
93
 
88
94
  ---
89
95
 
90
96
  **Note:** the `setupEM` PyPI package itself requires:
91
97
 
92
- - gds2palace>=0.9.4
98
+ - gds2palace>=0.10.0
93
99
  - gds_prepare_for_EM>=1.6.0
94
100
  - PySide6
95
101
  - shiboken6
@@ -11,6 +11,22 @@ https://github.com/VolkerMuehlhaus/setupEM
11
11
 
12
12
  ## Recent changes
13
13
 
14
+ # What's New - November 10, 2026 (setupEM 0.18.0)
15
+
16
+ **De-embedded results shown**: View S-Parameters lists the `_deembedded` files from the start and opens with the raw result and its `_deembedded` result together. Model Fit fits the calibrated result (`_dc_deembedded`, else `_deembedded`) of a model with port walls or a moved reference plane; the raw result still holds the uncalibrated gap ports.
17
+
18
+ **Port wall fixes:** a model script edited in place now gives back its port wall extension, reference plane shift and de-embedding length (they were written but not read, so the next session started with 0). Two port walls no longer make 0 the default oversize and air (the other sides became overrides and the default fields changed nothing); a default field that sets no side any more is greyed out. The status line under the log names the solve of a port wall run (calibration standard k/n, reused, or the model). The Port walls status says OK or the warnings only; the layout preview draws an extended feed and its length, a symbol per box side, and labels without the side names.
19
+
20
+ **Split regions**: a `.simcfg` from the KLayout plug-in's Export All of a split region (several EM region boxes) opens as a set of pieces. The Models list shows the pieces (and an unticked full check model). The settings (frequencies, mesh, solver, boundaries) are those of the whole region, shared by all pieces; a piece's box sides follow from the region's (a cut is a port wall, a stretch of a port wall without the piece's ports is PEC at the layout edge) and are locked; a piece can have its own mesh settings (Mesh tab, "Own mesh settings for p2"). Start Simulation runs the pieces without a gmsh window and does not mesh a piece again whose mesh is current; View S-Parameters shows the joined result first, and Model Fit fits it. The port wall extension and reference plane shift are the region's, on its outer sides only (none on a cut). An export written on another machine opens with its model folders, layouts and stackup found here. Start Simulation creates and runs the ticked pieces one after another and joins their results at the cuts (`join_pieces.py`, also `python -m setupEM.join_pieces <name>.simcfg`) into `<name>_deembedded.sNp` of the whole region. A piece whose layout fingerprint, settings and gds2palace version are unchanged since its last run is reused (`piece.key` in its model folder); **Run unchanged pieces too** overrides. Create Model keeps a settings file's own keys of the layout tool (piece name, fingerprint) when it rewrites the file.
21
+
22
+ The calibration standards of a port wall are no longer listed as models of their own in **Models** on the Create Model tab (they share the model's `_data` folder and its `run_sim` solves them before the model); Start Simulation ran `run_sim` once per listed row, and **Preview** stopped after the first standard with the model itself unbuilt. For a script that creates several models, the question about results of a previous simulation is now asked once before the first model starts, not between two models.
23
+
24
+ **Port walls**: calibrated ports at the layout edge (needs gds2palace 0.10.0). **Mesh and Boundaries > Advanced...** offers **Port wall** for xmin, xmax, ymin and ymax: PEC at the layout edge, oversize and air 0 and locked, written as `'PORTWALL'` in `settings['boundary']`. The Ports tab gets a **De-embedding** column (calibrated at a port wall, or the estimated port inductance), locks the direction of ports on a port wall, and a **Port walls** group with **Check port walls** (reads the layout, no meshing): per port wall its ports, ground at the cut, D, the standards' lengths, the valid frequency range, warnings or the error, and the **Reference plane shift** (`settings['reference_plane_shift']`). A port on an edge that is not a port wall gets the question whether to make that side one. Create Model runs the check when a port wall is set and stops on an error. An **Extension (µm)** per port wall (`auto` or a length, `settings['port_wall_extension']`) moves the port wall outward. The Ports tab runs the check by itself when a port wall has no result yet; the panel splits with the port list by a divider; warnings show with an icon and the start of their text. The layout preview shows the reference plane, where the uniform feed ends, and an extension, and fits the view to the layout and its box. setupEM and setupThermal keep the window's size and position (and the Ports tab's divider) from one session to the next. A via port on a port wall is listed as "via port used as a gap port on <line metal>" (gds2palace converts it when writing the model). The layout preview draws the simulation box: one frame, not to scale, with a label per side (a click opens the box sides dialog), a port wall as a white line. `combine_extend_snp.py` in `src/scripts` is synced with gds2palace.
25
+
26
+ The dielectric oversize can be set per side (xmin, xmax, ymin, ymax): in setupEM with **Advanced...** next to **Boundary conditions**, in setupThermal with **Advanced...** next to the oversize. It is written to the model script as a list `settings['margin'] = [xmin, xmax, ymin, ymax]`, and read from there and from settings files. Needs gds2palace 0.10.0. A negative oversize is no longer accepted.
27
+
28
+ Bundled IHP stackups (from gds2palace 0.10.0): heat source target layers `HEAT_TRANSISTOR` and `HEAT_RESISTOR`, for thermal models. Nothing is drawn on them, so EM models are unchanged.
29
+
14
30
  # What's New - November 5, 2026 (setupEM 0.17.0)
15
31
 
16
32
  setupThermal works with the thermal export of the KLayout plug-in klayout_em_export (one heat source per transistor and resistor, with the schematic instance names from LVS in `<layout>_thermalmap.json`):
@@ -44,23 +60,13 @@ setupEM 0.16.0 needs gds2palace 0.9.3 or later: a layout with several shapes on
44
60
  - An incomplete port (direction and layers that don't fit, e.g. from a `.simcfg` written by another tool) gives a warning in the Ports tab. Before, gds2palace exited and setupEM closed. A lowercase `z` counts as a via port too.
45
61
  - `combine_extend_snp` (Touchstone output after a Palace run) handles ports with several elements (several shapes on one port layer, gds2palace 0.9.3): one Z0 per port in the option line, and the elements' port inductances combined in parallel for de-embedding. Before, the last element overwrote the others.
46
62
 
47
- # What's New - October 29, 2026
48
-
49
- **File > Edit \*.py model in place** (new, setupEM and setupThermal): edits a gds2palace model script directly, e.g. one from the gds2palace MCP server, an example or your own code. Create Model and **File > Save** write only the values you change; the script's loops, comments and custom code stay. Settings the script computes itself are greyed out. A script that builds several models (a parameter sweep) lists them on the Create Model tab, and Start Simulation runs the ticked ones. After importing a script that setupEM didn't write, a bar below the menu offers **Edit in place instead**.
50
-
51
- **File > Import from \*.py model** now runs a gds2palace script to read it, without reading the GDSII file and without meshing. The run stops where the script builds the model, so its solver start never runs. The import now gets exactly what gds2palace would get, also values and ports the script computes. Before, ports made in a loop (as in many gds2palace MCP scripts) were left out, and the imported model was missing them. The script's own code before building the model does run, e.g. a script that generates its GDSII file writes it. If the run fails, the import reads the script text as before, and the bar below the menu says why.
52
-
53
- **File menu:** the three Recent submenus are now one **Open Recent** submenu, with sections for configs, imported \*.py models and \*.py models edited in place. A file reopens the way it was opened. The menu is grouped as open, recent, save, preferences. **Load Default Config** and **Save as Default Config** are removed: defaults for new models are set in **File > Preferences**. An existing `default.simcfg` / `default.tsimcfg` in your home directory still opens with **Load Config**, and **Save Config** can write it.
54
-
55
- Import and edit in place now read a stackup given as `utilities.get_stackup_path("SG13G2_FEM_200um.xml")`, the way the gds2palace MCP server writes it (needs gds2palace 0.9.1 or later). Before, an imported model using that syntax had no stackup file.
56
-
57
63
  Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)
58
64
 
59
65
  ---
60
66
 
61
67
  **Note:** the `setupEM` PyPI package itself requires:
62
68
 
63
- - gds2palace>=0.9.4
69
+ - gds2palace>=0.10.0
64
70
  - gds_prepare_for_EM>=1.6.0
65
71
  - PySide6
66
72
  - shiboken6
@@ -12,7 +12,7 @@ authors = [
12
12
  { name = "Volker Muehlhaus", email = "volker@muehlhaus.com" }
13
13
  ]
14
14
  dependencies = [
15
- "gds2palace>=0.9.4",
15
+ "gds2palace>=0.10.0",
16
16
  "gds_prepare_for_EM>=1.6.0",
17
17
  "PySide6",
18
18
  "shiboken6",
@@ -24,4 +24,4 @@ A Python tool for EM setup using gds2palace.
24
24
  from .setupEM import main
25
25
 
26
26
  __all__ = ["main"]
27
- __version__ = "0.17.0"
27
+ __version__ = "0.18.0"
@@ -30,6 +30,7 @@
30
30
  <Material Name="RSIL" Type="Resistor" Rs="7" Color="d0d0d0" />
31
31
  <Material Name="RPPD" Type="Resistor" Rs="260" Color="d0d0d0" />
32
32
  <Material Name="RHIGH" Type="Resistor" Rs="1360" Color="d0d0d0" />
33
+ <Material Name="PolyRes" Type="Conductor" ThermalConductivity="20" Color="c08040" />
33
34
  </Materials>
34
35
  <ELayers LengthUnit="um">
35
36
  <Dielectrics>
@@ -57,6 +58,10 @@
57
58
  <Layer Name="RSIL" Type="sheet" Reference="Activ" ReferenceEdge="Top" Material="RSIL" Layer="314" Zmin="0.0000" Zmax="0.0000" />
58
59
  <Layer Name="REF_FOR_TRANSISTOR" Type="sheet" Reference="SiO2" ReferenceEdge="Bottom" Material="PEC" Layer="300" Zmin="0.4" Zmax="0.4" />
59
60
  <Layer Name="Activ" Type="conductor" Reference="SiO2" ReferenceEdge="Bottom" Material="Activ" Layer="1" Zmin="0.0000" Zmax="0.4000" />
61
+ <!-- Heat source targets for thermal models: z range and material of a heat source. Nothing is drawn on
62
+ these GDS layers, so they add no geometry to EM models. -->
63
+ <Layer Name="HEAT_TRANSISTOR" Type="conductor" Reference="Activ" ReferenceEdge="Top" Material="Activ" Layer="320" Zmin="-0.0400" Zmax="0.0000" />
64
+ <Layer Name="HEAT_RESISTOR" Type="conductor" Reference="Activ" ReferenceEdge="Top" Material="PolyRes" Layer="321" Zmin="0.0000" Zmax="0.1600" />
60
65
  <Layer Name="SUBGND" Type="sheet" Reference="EPI" ReferenceEdge="Top" Material="PEC" Layer="250" Zmin="0.0000" Zmax="0" />
61
66
  <Layer Name="LBE" Type="dielectric" Reference="Substrate" ReferenceEdge="Bottom" Material="AIR" Layer="157" Zmin="0.0000" Zmax="=bulk_thickness + 3.7500" />
62
67
  <Layer Name="BACKSIDEGND" Type="sheet" Reference="Substrate" ReferenceEdge="Bottom" Material="PEC" Layer="251" Zmin="0" Zmax="0" />
@@ -37,6 +37,7 @@
37
37
  <Material Name="RSIL" Type="Resistor" Rs="7" Color="d0d0d0" />
38
38
  <Material Name="RPPD" Type="Resistor" Rs="260" Color="d0d0d0" />
39
39
  <Material Name="RHIGH" Type="Resistor" Rs="1360" Color="d0d0d0" />
40
+ <Material Name="PolyRes" Type="Conductor" ThermalConductivity="20" Color="c08040" />
40
41
  </Materials>
41
42
  <ELayers LengthUnit="um">
42
43
  <Dielectrics>
@@ -71,6 +72,10 @@
71
72
  <Layer Name="RSIL" Type="sheet" Reference="Activ" ReferenceEdge="Top" Material="RSIL" Layer="314" Zmin="0.0000" Zmax="0.0000" />
72
73
  <Layer Name="REF_FOR_TRANSISTOR" Type="sheet" Reference="SiO2" ReferenceEdge="Bottom" Material="PEC" Layer="300" Zmin="0.4" Zmax="0.4" />
73
74
  <Layer Name="Activ" Type="conductor" Reference="SiO2" ReferenceEdge="Bottom" Material="Activ" Layer="1" Zmin="0.0000" Zmax="0.4000" />
75
+ <!-- Heat source targets for thermal models: z range and material of a heat source. Nothing is drawn on
76
+ these GDS layers, so they add no geometry to EM models. -->
77
+ <Layer Name="HEAT_TRANSISTOR" Type="conductor" Reference="Activ" ReferenceEdge="Top" Material="Activ" Layer="320" Zmin="-0.0400" Zmax="0.0000" />
78
+ <Layer Name="HEAT_RESISTOR" Type="conductor" Reference="Activ" ReferenceEdge="Top" Material="PolyRes" Layer="321" Zmin="0.0000" Zmax="0.1600" />
74
79
  <Layer Name="SUBGND" Type="sheet" Reference="EPI" ReferenceEdge="Top" Material="PEC" Layer="250" Zmin="0.0000" Zmax="0" />
75
80
  <Layer Name="LBE" Type="dielectric" Reference="Substrate" ReferenceEdge="Bottom" Material="AIR" Layer="157" Zmin="0.0000" Zmax="=bulk_thickness + 3.7500" />
76
81
  <Layer Name="BACKSIDEGND" Type="sheet" Reference="Substrate" ReferenceEdge="Bottom" Material="PEC" Layer="251" Zmin="0" Zmax="0.0000" />
@@ -36,6 +36,7 @@
36
36
  <Material Name="RSIL" Type="Resistor" Rs="7" Color="d0d0d0" />
37
37
  <Material Name="RPPD" Type="Resistor" Rs="260" Color="d0d0d0" />
38
38
  <Material Name="RHIGH" Type="Resistor" Rs="1360" Color="d0d0d0" />
39
+ <Material Name="PolyRes" Type="Conductor" ThermalConductivity="20" Color="c08040" />
39
40
  </Materials>
40
41
  <ELayers LengthUnit="um">
41
42
  <Dielectrics>
@@ -71,6 +72,10 @@
71
72
  <Layer Name="RSIL" Type="sheet" Reference="Activ" ReferenceEdge="Top" Material="RSIL" Layer="314" Zmin="0" Zmax="0" />
72
73
  <Layer Name="REF_FOR_TRANSISTOR" Type="sheet" Reference="SiO2" ReferenceEdge="Bottom" Material="PEC" Layer="300" Zmin="0.4" Zmax="0.4" />
73
74
  <Layer Name="Activ" Type="conductor" Reference="SiO2" ReferenceEdge="Bottom" Material="Activ" Layer="1" Zmin="0" Zmax="0.4" />
75
+ <!-- Heat source targets for thermal models: z range and material of a heat source. Nothing is drawn on
76
+ these GDS layers, so they add no geometry to EM models. -->
77
+ <Layer Name="HEAT_TRANSISTOR" Type="conductor" Reference="Activ" ReferenceEdge="Top" Material="Activ" Layer="320" Zmin="-0.04" Zmax="0" />
78
+ <Layer Name="HEAT_RESISTOR" Type="conductor" Reference="Activ" ReferenceEdge="Top" Material="PolyRes" Layer="321" Zmin="0" Zmax="0.16" />
74
79
  <Layer Name="SUBGND" Type="sheet" Reference="EPI" ReferenceEdge="Top" Material="PEC" Layer="250" Zmin="0" Zmax="0" />
75
80
  <Layer Name="LBE" Type="dielectric" Reference="Substrate" ReferenceEdge="Bottom" Material="AIR" Layer="157" Zmin="0" Zmax="=bulk_thickness + 3.7500" />
76
81
  <Layer Name="BACKSIDEGND" Type="sheet" Reference="Substrate" ReferenceEdge="Bottom" Material="PEC" Layer="251" Zmin="0" Zmax="0" />
@@ -0,0 +1,197 @@
1
+ """Join the results of a split EM region into one .sNp of the whole region.
2
+
3
+ klayout_em_export's Export All writes a split region as <export>.simcfg (with a "pieces" section) and one model per
4
+ piece in <export>_pieces/. Each piece is simulated on its own; its ports on a cut to another piece are port wall
5
+ ports, calibrated with the reference plane on the cut (gds2palace port walls). So the two ports of a cut, one in
6
+ each piece, meet at the same plane, and their de-embedded S-parameters connect directly: this module connects them
7
+ (scikit-rf Circuit) and writes the joined result where a single model of the whole region would have it:
8
+
9
+ <sim_path>/palace_model/<export>_data/output/<export>/<export>_deembedded.sNp (and _dc_deembedded when all
10
+ pieces have a DC result)
11
+
12
+ The ports of the joined result are the outer ports, numbered as in <export>.simcfg; the header names each one's
13
+ piece. Not in the joined result: coupling between the pieces other than through the lines that cross the cuts.
14
+
15
+ python -m setupEM.join_pieces <export>.simcfg
16
+ """
17
+ import json
18
+ import os
19
+ import re
20
+ import sys
21
+
22
+ import numpy as np
23
+
24
+
25
+ class JoinError(Exception):
26
+ pass
27
+
28
+
29
+ def read_set(set_path):
30
+ """(set data, its "pieces" section)."""
31
+ with open(set_path, encoding="utf-8") as f:
32
+ data = json.load(f)
33
+ section = data.get("pieces")
34
+ if not isinstance(section, dict) or not section.get("pieces"):
35
+ raise JoinError(f"{os.path.basename(set_path)} is not a split region (no pieces section)")
36
+ return data, section
37
+
38
+
39
+ def _model_place(simcfg_path, data, default_name):
40
+ """(sim_path, model basename) of a model's .simcfg: as setupEM keeps them, else next to the file."""
41
+ values = data.get("saved_values", {}) if isinstance(data, dict) else {}
42
+ sim_path = values.get("sim_path")
43
+ if not sim_path or not os.path.isdir(sim_path):
44
+ # not set, or written on another machine (P:/... on Windows, /mnt/pub/... on Linux): the file's own folder
45
+ sim_path = os.path.dirname(os.path.abspath(simcfg_path))
46
+ name = values.get("model_basename") or default_name
47
+ return sim_path, name
48
+
49
+
50
+ def result_path(sim_path, name, ports, kind="_deembedded"):
51
+ return os.path.join(sim_path, "palace_model", f"{name}_data", "output", name, f"{name}{kind}.s{ports}p")
52
+
53
+
54
+ def piece_paths(set_path, section):
55
+ """{piece name: (simcfg path, sim_path, model basename, port count)}."""
56
+ base = os.path.dirname(os.path.abspath(set_path))
57
+ out = {}
58
+ for entry in section["pieces"]:
59
+ simcfg = os.path.join(base, entry["simcfg"])
60
+ try:
61
+ with open(simcfg, encoding="utf-8") as f:
62
+ data = json.load(f)
63
+ except (OSError, ValueError):
64
+ data = {}
65
+ sim_path, name = _model_place(simcfg, data, entry["name"])
66
+ out[entry["name"]] = (simcfg, sim_path, name, len(entry.get("ports", {})))
67
+ return out
68
+
69
+
70
+ def joined_path(set_path, data, ports, kind="_deembedded"):
71
+ sim_path, name = _model_place(set_path, data, os.path.splitext(os.path.basename(set_path))[0])
72
+ return result_path(sim_path, name, ports, kind)
73
+
74
+
75
+ def _calibrated_ports(path):
76
+ """{port number: header text} of the ports whose header line says they were calibrated at a port wall
77
+ (combine_extend_snp.py)."""
78
+ found = {}
79
+ with open(path, encoding="utf-8", errors="replace") as f:
80
+ for line in f:
81
+ if not line.startswith("!"):
82
+ if line.strip() and not line.startswith("#"):
83
+ break
84
+ continue
85
+ m = re.match(r"!\s*port\s+(\d+):\s*(calibrated at port wall.*)", line, re.IGNORECASE)
86
+ if m:
87
+ found[int(m.group(1))] = m.group(2).strip()
88
+ return found
89
+
90
+
91
+ def join(set_path, kind="_deembedded", write=True):
92
+ """Join the pieces' results of one kind ('_deembedded' or '_dc_deembedded'). Returns (path written or None,
93
+ the joined skrf Network, messages). Raises JoinError when a piece's result is missing, a port on a cut is not
94
+ calibrated, or the frequency grids differ."""
95
+ import skrf as rf
96
+ from skrf.circuit import Circuit
97
+ data, section = read_set(set_path)
98
+ places = piece_paths(set_path, section)
99
+ networks, messages = {}, []
100
+ for name, (simcfg, sim_path, model, ports) in places.items():
101
+ path = result_path(sim_path, model, ports, kind)
102
+ if not os.path.isfile(path):
103
+ raise JoinError(f"{name}: no result {os.path.basename(path)} (run {name} first)")
104
+ net = rf.Network(path)
105
+ net.name = name
106
+ networks[name] = (net, path)
107
+ for link in section.get("links", []):
108
+ for name, port in link["ports"]:
109
+ if name not in networks:
110
+ raise JoinError(f"the cut port {port} of {name} has no piece result")
111
+ calibrated = _calibrated_ports(networks[name][1])
112
+ if int(port) not in calibrated:
113
+ raise JoinError(f"{name} port {port} on a cut is not calibrated at a port wall (its result was made "
114
+ "without the port wall calibration): run it again with the current gds2palace")
115
+ text = calibrated[int(port)]
116
+ if "reference plane at the wall" not in text and "reference plane at the layout edge" not in text:
117
+ raise JoinError(f"{name} port {port} on a cut has its reference plane moved ({text}): the two pieces "
118
+ "of a cut meet only at the cut; set the reference plane shift of that port wall to 0")
119
+ first = next(iter(networks.values()))[0]
120
+ for name, (net, _) in networks.items():
121
+ if len(net.f) != len(first.f) or not np.allclose(net.f, first.f, rtol=1e-9, atol=1e-3):
122
+ raise JoinError(f"the frequencies of {name} differ from the other pieces: give all pieces the same "
123
+ "frequency settings")
124
+ external = sorted(section.get("external", []), key=lambda e: e["port"])
125
+ if not external:
126
+ raise JoinError("the split region has no outer ports")
127
+ connections = []
128
+ for e in external:
129
+ port = Circuit.Port(first.frequency, name=f"P{e['port']}", z0=50)
130
+ connections.append([(port, 0), (networks[e["piece"]][0], int(e["piece_port"]) - 1)])
131
+ for link in section.get("links", []):
132
+ (a, pa), (b, pb) = link["ports"]
133
+ connections.append([(networks[a][0], int(pa) - 1), (networks[b][0], int(pb) - 1)])
134
+ # every port of every piece must appear exactly once
135
+ used = {}
136
+ for conn in connections:
137
+ for net, index in conn:
138
+ if net.name in networks:
139
+ used.setdefault(net.name, set()).add(index)
140
+ for name, (net, _) in networks.items():
141
+ missing = set(range(net.nports)) - used.get(name, set())
142
+ if missing:
143
+ raise JoinError(f"{name} ports {', '.join(str(i + 1) for i in sorted(missing))} are neither outer ports "
144
+ "nor on a cut: export the split region again")
145
+ joined = Circuit(connections).network
146
+ out = None
147
+ if write:
148
+ out = joined_path(set_path, data, joined.nports, kind)
149
+ os.makedirs(os.path.dirname(out), exist_ok=True)
150
+ header = [f"! joined by setupEM from the pieces {', '.join(networks)} ({section.get('folder', '')}): "
151
+ "each piece simulated on its own, the ports on the cuts calibrated (port walls) and connected"]
152
+ for e in external:
153
+ header.append(f"!port {e['port']}: {e['piece']} port {e['piece_port']} (layout port {e['layout_port']})")
154
+ _write_touchstone(joined, out, header)
155
+ messages.append(f"joined {len(networks)} pieces into {out}")
156
+ return out, joined, messages
157
+
158
+
159
+ def _write_touchstone(network, path, header):
160
+ stem = os.path.splitext(path)[0]
161
+ network.write_touchstone(stem, form="ri")
162
+ written = stem + f".s{network.nports}p"
163
+ with open(written, encoding="utf-8") as f:
164
+ text = f.read()
165
+ with open(written, "w", encoding="utf-8", newline="\n") as f:
166
+ f.write("\n".join(header) + "\n" + text)
167
+ if os.path.normcase(written) != os.path.normcase(path):
168
+ os.replace(written, path)
169
+
170
+
171
+ def join_all(set_path):
172
+ """Join the de-embedded results, and the DC-extended ones when every piece has them. Returns messages."""
173
+ out, _, messages = join(set_path, "_deembedded")
174
+ try:
175
+ join(set_path, "_dc_deembedded")
176
+ messages.append("and the DC-extended results")
177
+ except JoinError:
178
+ pass
179
+ return messages
180
+
181
+
182
+ def main(argv=None):
183
+ argv = sys.argv[1:] if argv is None else argv
184
+ if len(argv) != 1:
185
+ print(__doc__)
186
+ return 2
187
+ try:
188
+ for message in join_all(argv[0]):
189
+ print(message)
190
+ except JoinError as e:
191
+ print(f"not joined: {e}")
192
+ return 1
193
+ return 0
194
+
195
+
196
+ if __name__ == "__main__":
197
+ sys.exit(main())