setupEM 0.16.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.
- setupem-0.18.0/PKG-INFO +112 -0
- {setupem-0.16.0 → setupem-0.18.0}/README.md +8 -0
- setupem-0.18.0/README_pypi.md +83 -0
- {setupem-0.16.0 → setupem-0.18.0}/pyproject.toml +1 -1
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/__init__.py +1 -1
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/config_update.py +3 -3
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/data/SG13CMOS5L_200um.xml +6 -1
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_FEM_200um.xml +6 -1
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_FEM_200um_passi3D.xml +6 -1
- setupem-0.18.0/src/setupEM/join_pieces.py +197 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/layout_preview.py +388 -1
- setupem-0.18.0/src/setupEM/piece_set.py +509 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/result_viewer.py +62 -3
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/run_with_overrides.py +10 -1
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/setupEM.py +913 -242
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/setupThermal.py +262 -18
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/setup_common.py +758 -40
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/thermal_results.py +198 -3
- setupem-0.18.0/src/setupEM.egg-info/PKG-INFO +112 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM.egg-info/SOURCES.txt +12 -1
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM.egg-info/requires.txt +1 -1
- {setupem-0.16.0 → setupem-0.18.0}/tests/test_config_update_gui.py +16 -0
- setupem-0.18.0/tests/test_deembedded_view.py +71 -0
- setupem-0.18.0/tests/test_join_pieces.py +132 -0
- setupem-0.18.0/tests/test_margin_per_side.py +346 -0
- setupem-0.18.0/tests/test_piece_set.py +420 -0
- setupem-0.18.0/tests/test_port_walls.py +440 -0
- setupem-0.18.0/tests/test_qt_platform_noise.py +23 -0
- {setupem-0.16.0 → setupem-0.18.0}/tests/test_run_with_overrides.py +52 -0
- setupem-0.18.0/tests/test_table_rows.py +102 -0
- setupem-0.18.0/tests/test_thermal_powers.py +233 -0
- setupem-0.18.0/tests/test_thermal_results.py +156 -0
- setupem-0.16.0/PKG-INFO +0 -97
- setupem-0.16.0/README_pypi.md +0 -68
- setupem-0.16.0/src/setupEM.egg-info/PKG-INFO +0 -97
- {setupem-0.16.0 → setupem-0.18.0}/LICENSE +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/setup.cfg +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/__main__.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_100um.xml +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_200um.xml +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/data/SG13G2_nosub.xml +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/field_viewer.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/gds_hierarchy_scan.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/momentum_import.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/palace_results.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/script_model.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/script_probe.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/simplify_gds.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/stackupEditor.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM/stackup_writer.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM.egg-info/dependency_links.txt +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM.egg-info/entry_points.txt +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/src/setupEM.egg-info/top_level.txt +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/tests/test_config_update.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/tests/test_script_model.py +0 -0
- {setupem-0.16.0 → setupem-0.18.0}/tests/test_script_probe.py +0 -0
setupem-0.18.0/PKG-INFO
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: setupEM
|
|
3
|
+
Version: 0.18.0
|
|
4
|
+
Summary: Python tool for configuration of gds2palace workflow with GUI.
|
|
5
|
+
Author-email: Volker Muehlhaus <volker@muehlhaus.com>
|
|
6
|
+
License-Expression: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/VolkerMuehlhaus/setupEM
|
|
8
|
+
Project-URL: Repository, https://github.com/VolkerMuehlhaus/setupEM
|
|
9
|
+
Project-URL: Changelog, https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: gds2palace>=0.10.0
|
|
14
|
+
Requires-Dist: gds_prepare_for_EM>=1.6.0
|
|
15
|
+
Requires-Dist: PySide6
|
|
16
|
+
Requires-Dist: shiboken6
|
|
17
|
+
Requires-Dist: scipy
|
|
18
|
+
Requires-Dist: requests
|
|
19
|
+
Requires-Dist: scikit-rf
|
|
20
|
+
Requires-Dist: matplotlib
|
|
21
|
+
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: gdspy
|
|
23
|
+
Requires-Dist: meshio
|
|
24
|
+
Requires-Dist: pyvista
|
|
25
|
+
Requires-Dist: pyvistaqt
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest; extra == "test"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Python GUI for gds2palace
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
pip install setupEM
|
|
37
|
+
|
|
38
|
+
**Full documentation, installation guide, and usage walkthrough:**
|
|
39
|
+
https://github.com/VolkerMuehlhaus/setupEM
|
|
40
|
+
|
|
41
|
+
## Recent changes
|
|
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
|
+
|
|
59
|
+
# What's New - November 5, 2026 (setupEM 0.17.0)
|
|
60
|
+
|
|
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`):
|
|
62
|
+
- **Load powers...** below the Thermal Sources + Boundaries list sets the powers from a file of your circuit simulation, by instance name. Needs gds2palace with `util_thermal_map`.
|
|
63
|
+
- The list names the device of each heat source (instance and pcell) and the region outline. Heat source layers above 299 count as present in the layout.
|
|
64
|
+
- The export's placeholder boundary (constant temperature on the region outline, no target layer) is listed as "region outline: choose the target layer"; Create Model refuses a boundary without a target layer.
|
|
65
|
+
- **Temperature per device**: after a run, the log lists the average and peak temperature of each heat source and their rise above the fixed temperature, and `<model>_temperatures.csv` next to the model script has the same per instance. Command line: `python -m setupEM.thermal_results <model>.tsimcfg`.
|
|
66
|
+
|
|
67
|
+
**Changes:**
|
|
68
|
+
- **Create Model also writes the settings file**, `<model>.simcfg` / `<model>.tsimcfg` next to the model script (as Save Config would), so that a layout tool's next export keeps your settings and the KLayout plug-in finds the layout's stackup, datatypes and thermal objects. It overwrites only a settings file of the same application. Opening a `.simcfg` that Create Model wrote with a script continues that script without asking.
|
|
69
|
+
- The Mesh tab's "Mesh refinement at metal edges" is now **"Mesh size at heat sources"**, which is what it sets in a thermal model (metal edges are not refined there).
|
|
70
|
+
|
|
71
|
+
**Fixes:**
|
|
72
|
+
- ElmerSolver no longer hangs at start on a Linux desktop where an X display does not accept connections ("Authorization required, but no authorization protocol specified"): setupThermal starts it with hwloc's OpenGL plug-in off (`HWLOC_COMPONENTS=-gl`, unless you set that variable).
|
|
73
|
+
|
|
74
|
+
# What's New - October 31, 2026 (setupEM 0.16.0)
|
|
75
|
+
|
|
76
|
+
**After a new export from the layout tool** (setupEM): a layout tool such as the KLayout plug-in klayout_em_export writes the GDSII file and a `.simcfg`, and writes both again when the layout changes. The settings you made in setupEM since are only in your model script, because Create Model writes the script, not the `.simcfg`. setupEM now takes from such a `.simcfg` only the ports, GDSII file, stackup, cell and purpose, and keeps everything else as in the script:
|
|
77
|
+
- Opening a `.simcfg` when a model script for the same GDSII file exists next to it asks whether to **Continue with the script** (edit it in place, ports and layout settings from the `.simcfg`) or **Start from the config**.
|
|
78
|
+
- Loading a `.simcfg` while editing a script in place lists the ports and layout settings that differ and asks whether to **Update the script from it** or **Open it as a new model**. Before, loading it ended editing in place and replaced all settings.
|
|
79
|
+
- While editing a script in place, the bar below the menu points out a newer `.simcfg` of the same GDSII file with other ports or layout settings, with **Update from it**.
|
|
80
|
+
|
|
81
|
+
**Load Config, Import from \*.py model and Edit \*.py model in place** start in the folder of the model you are working on (the config or script loaded last, else the GDSII file). Before, they started in the folder setupEM was launched from, e.g. KLayout's when the KLayout plug-in opened setupEM.
|
|
82
|
+
|
|
83
|
+
setupEM 0.16.0 needs gds2palace 0.9.3 or later: a layout with several shapes on one port layer (e.g. a transistor terminal on several fingers, from the KLayout plug-in) makes one port with several elements there; older gds2palace versions used only the last shape.
|
|
84
|
+
|
|
85
|
+
**Fixes:**
|
|
86
|
+
- `scripts/combine_extend_snp.py` is the same as gds2palace's again. It had missed three fixes made there in September: the port impedance lookup for AMR iterations, the missing `.sNp` extension for a model name that contains a dot, and Touchstone output after an interrupted Palace run.
|
|
87
|
+
- On Linux with GNOME (Wayland), the mouse cursor no longer keeps spinning for about 10 seconds after setupEM starts. setupEM briefly opened three invisible windows while building the Input Files tab, and GNOME waited for them to finish starting.
|
|
88
|
+
- Via ports with direction `-Z` keep their from and to layers. Before, loading a `.simcfg` dropped them, and Create Model wrote such a port as an in-plane port.
|
|
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.
|
|
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.
|
|
91
|
+
|
|
92
|
+
Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
**Note:** the `setupEM` PyPI package itself requires:
|
|
97
|
+
|
|
98
|
+
- gds2palace>=0.10.0
|
|
99
|
+
- gds_prepare_for_EM>=1.6.0
|
|
100
|
+
- PySide6
|
|
101
|
+
- shiboken6
|
|
102
|
+
- scipy
|
|
103
|
+
- requests
|
|
104
|
+
- scikit-rf
|
|
105
|
+
- matplotlib
|
|
106
|
+
- numpy
|
|
107
|
+
- gdspy
|
|
108
|
+
- meshio
|
|
109
|
+
- pyvista
|
|
110
|
+
- pyvistaqt
|
|
111
|
+
|
|
112
|
+
(Other Python modules mentioned above are only needed to run standalone helper scripts in this repository, not to use the installed package.)
|
|
@@ -106,6 +106,12 @@ The package now includes setupThermal also, which is the equivalent of setupEM f
|
|
|
106
106
|
|
|
107
107
|
AWS Palace is not used/required in thermal workflow, although we use the same gds2palace package.
|
|
108
108
|
|
|
109
|
+
**Powers from a circuit simulation.** The thermal export of the KLayout EM Export plug-in makes one heat source per transistor and resistor and writes `<layout>_thermalmap.json` next to the GDSII file, which says which device each heat source layer belongs to and, from LVS, its schematic instance name. The Thermal Sources + Boundaries list then shows that name next to each heat source, and **Load powers...** below the list sets the powers from a file of your circuit simulation: one line per device with the instance name (as in the LVS netlist, e.g. `Q1` or `Xcore.Q1`) and the power in W, separated by a comma, semicolon, tab or spaces (`Xcore.Q1, 2.5m`). Heat sources without a power keep theirs; names that match no heat source, or several, are listed and not used. Without setupThermal: `python -m gds2palace.util_thermal_map <layout>_thermalmap.json powers.csv <layout>.tsimcfg`. Needs a gds2palace with `util_thermal_map`.
|
|
110
|
+
|
|
111
|
+
**Boundary of a thermal export.** The export also writes the outline of the exported region on a layer of its own (201) and, as long as the model has no boundary yet, a constant-temperature row on it without a target layer. The list shows it as "region outline: choose the target layer"; pick the stackup layer where the temperature is fixed (e.g. the substrate backside) and Apply. Create Model refuses a boundary without a target layer.
|
|
112
|
+
|
|
113
|
+
**Temperature per device.** After each run, setupThermal lists the temperature of every heat source below the results summary and writes it to `<model>_temperatures.csv` next to the model script: instance name (from the thermal map), device, layer, power, the average temperature over the heat source and its hottest point, and both as rise above the fixed temperature of the model (for a circuit simulator's temperature rise per instance, e.g. `trise` / `dtemp`). Without setupThermal: `python -m setupEM.thermal_results <model>.tsimcfg`.
|
|
114
|
+
|
|
109
115
|
|
|
110
116
|
## User Interface
|
|
111
117
|
|
|
@@ -152,6 +158,8 @@ As explained in the [gds2palace documentation](https://github.com/VolkerMuehlhau
|
|
|
152
158
|
|
|
153
159
|
In the upper part of the tab, you make your settings and then need to apply to the port list below.
|
|
154
160
|
|
|
161
|
+
The port list grows with the ports: it always keeps a few empty rows below the last port, so there is no fixed maximum number of ports. Versions up to 0.16.0 had a fixed list of 32 rows and silently dropped port 33 and higher when loading a config or model script; load such a model again with this version to get all its ports back. The same applies to the Thermal Sources + Boundaries list in setupThermal.
|
|
162
|
+
|
|
155
163
|
<img src="./doc/png/ports1.png" alt="ports" width="700">
|
|
156
164
|
|
|
157
165
|
Palace does not evaluate the port voltage parameter, but we use it internally to specify if ports are "active" during S-parameter simulation. To get the full S-parameters, all ports must be simulated with non-zero voltage, which means that all ports are excited one after another. If you want to simulate only selected excitations, for faster total simulation time, you can set ports to zero voltage. In that case, you will **not** get full S-parameters data and the missing paths are set to 0 in the output file.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Python GUI for gds2palace
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
pip install setupEM
|
|
8
|
+
|
|
9
|
+
**Full documentation, installation guide, and usage walkthrough:**
|
|
10
|
+
https://github.com/VolkerMuehlhaus/setupEM
|
|
11
|
+
|
|
12
|
+
## Recent changes
|
|
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
|
+
|
|
30
|
+
# What's New - November 5, 2026 (setupEM 0.17.0)
|
|
31
|
+
|
|
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`):
|
|
33
|
+
- **Load powers...** below the Thermal Sources + Boundaries list sets the powers from a file of your circuit simulation, by instance name. Needs gds2palace with `util_thermal_map`.
|
|
34
|
+
- The list names the device of each heat source (instance and pcell) and the region outline. Heat source layers above 299 count as present in the layout.
|
|
35
|
+
- The export's placeholder boundary (constant temperature on the region outline, no target layer) is listed as "region outline: choose the target layer"; Create Model refuses a boundary without a target layer.
|
|
36
|
+
- **Temperature per device**: after a run, the log lists the average and peak temperature of each heat source and their rise above the fixed temperature, and `<model>_temperatures.csv` next to the model script has the same per instance. Command line: `python -m setupEM.thermal_results <model>.tsimcfg`.
|
|
37
|
+
|
|
38
|
+
**Changes:**
|
|
39
|
+
- **Create Model also writes the settings file**, `<model>.simcfg` / `<model>.tsimcfg` next to the model script (as Save Config would), so that a layout tool's next export keeps your settings and the KLayout plug-in finds the layout's stackup, datatypes and thermal objects. It overwrites only a settings file of the same application. Opening a `.simcfg` that Create Model wrote with a script continues that script without asking.
|
|
40
|
+
- The Mesh tab's "Mesh refinement at metal edges" is now **"Mesh size at heat sources"**, which is what it sets in a thermal model (metal edges are not refined there).
|
|
41
|
+
|
|
42
|
+
**Fixes:**
|
|
43
|
+
- ElmerSolver no longer hangs at start on a Linux desktop where an X display does not accept connections ("Authorization required, but no authorization protocol specified"): setupThermal starts it with hwloc's OpenGL plug-in off (`HWLOC_COMPONENTS=-gl`, unless you set that variable).
|
|
44
|
+
|
|
45
|
+
# What's New - October 31, 2026 (setupEM 0.16.0)
|
|
46
|
+
|
|
47
|
+
**After a new export from the layout tool** (setupEM): a layout tool such as the KLayout plug-in klayout_em_export writes the GDSII file and a `.simcfg`, and writes both again when the layout changes. The settings you made in setupEM since are only in your model script, because Create Model writes the script, not the `.simcfg`. setupEM now takes from such a `.simcfg` only the ports, GDSII file, stackup, cell and purpose, and keeps everything else as in the script:
|
|
48
|
+
- Opening a `.simcfg` when a model script for the same GDSII file exists next to it asks whether to **Continue with the script** (edit it in place, ports and layout settings from the `.simcfg`) or **Start from the config**.
|
|
49
|
+
- Loading a `.simcfg` while editing a script in place lists the ports and layout settings that differ and asks whether to **Update the script from it** or **Open it as a new model**. Before, loading it ended editing in place and replaced all settings.
|
|
50
|
+
- While editing a script in place, the bar below the menu points out a newer `.simcfg` of the same GDSII file with other ports or layout settings, with **Update from it**.
|
|
51
|
+
|
|
52
|
+
**Load Config, Import from \*.py model and Edit \*.py model in place** start in the folder of the model you are working on (the config or script loaded last, else the GDSII file). Before, they started in the folder setupEM was launched from, e.g. KLayout's when the KLayout plug-in opened setupEM.
|
|
53
|
+
|
|
54
|
+
setupEM 0.16.0 needs gds2palace 0.9.3 or later: a layout with several shapes on one port layer (e.g. a transistor terminal on several fingers, from the KLayout plug-in) makes one port with several elements there; older gds2palace versions used only the last shape.
|
|
55
|
+
|
|
56
|
+
**Fixes:**
|
|
57
|
+
- `scripts/combine_extend_snp.py` is the same as gds2palace's again. It had missed three fixes made there in September: the port impedance lookup for AMR iterations, the missing `.sNp` extension for a model name that contains a dot, and Touchstone output after an interrupted Palace run.
|
|
58
|
+
- On Linux with GNOME (Wayland), the mouse cursor no longer keeps spinning for about 10 seconds after setupEM starts. setupEM briefly opened three invisible windows while building the Input Files tab, and GNOME waited for them to finish starting.
|
|
59
|
+
- Via ports with direction `-Z` keep their from and to layers. Before, loading a `.simcfg` dropped them, and Create Model wrote such a port as an in-plane port.
|
|
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.
|
|
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.
|
|
62
|
+
|
|
63
|
+
Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
**Note:** the `setupEM` PyPI package itself requires:
|
|
68
|
+
|
|
69
|
+
- gds2palace>=0.10.0
|
|
70
|
+
- gds_prepare_for_EM>=1.6.0
|
|
71
|
+
- PySide6
|
|
72
|
+
- shiboken6
|
|
73
|
+
- scipy
|
|
74
|
+
- requests
|
|
75
|
+
- scikit-rf
|
|
76
|
+
- matplotlib
|
|
77
|
+
- numpy
|
|
78
|
+
- gdspy
|
|
79
|
+
- meshio
|
|
80
|
+
- pyvista
|
|
81
|
+
- pyvistaqt
|
|
82
|
+
|
|
83
|
+
(Other Python modules mentioned above are only needed to run standalone helper scripts in this repository, not to use the installed package.)
|
|
@@ -161,9 +161,9 @@ def _reads_gds(script_path, gds_path):
|
|
|
161
161
|
|
|
162
162
|
def model_scripts(gds_path, folders):
|
|
163
163
|
"""Model scripts (*.py) in folders that read gds_path, newest first. Their age says nothing against a settings
|
|
164
|
-
file of the same layout: a layout tool writes that file again on every export, also after the script was made
|
|
165
|
-
|
|
166
|
-
settings
|
|
164
|
+
file of the same layout: a layout tool writes that file again on every export, also after the script was made.
|
|
165
|
+
The script is the model; Create Model also writes the settings to <model>.simcfg, but another settings file of
|
|
166
|
+
the layout (or one saved before) does not have the settings made in setupEM since."""
|
|
167
167
|
seen, out = set(), []
|
|
168
168
|
for folder in folders:
|
|
169
169
|
if not folder or not os.path.isdir(folder):
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<Variable Name="bulk_thickness" Value="=total_thickness-13.05" />
|
|
12
12
|
</Variables>
|
|
13
13
|
<Materials>
|
|
14
|
-
<Material Name="Activ" Type="Conductor" Conductivity="357141.0"
|
|
14
|
+
<Material Name="Activ" Type="Conductor" Conductivity="357141.0" ThermalConductivityTable="Si_vs_T_IHP" Color="00ff00" />
|
|
15
15
|
<Material Name="Metal1" Type="Conductor" Conductivity="21640000.0" ThermalConductivity="237" Color="39bfff" />
|
|
16
16
|
<Material Name="Metal2" Type="Conductor" Conductivity="23190000.0" ThermalConductivity="237" Color="ccccd9" />
|
|
17
17
|
<Material Name="Metal3" Type="Conductor" Conductivity="23190000.0" ThermalConductivity="237" Color="d80000" />
|
|
@@ -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" />
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<!-- selects which <Table> below Substrate's ThermalConductivityTable resolves to -->
|
|
13
13
|
</Variables>
|
|
14
14
|
<Materials>
|
|
15
|
-
<Material Name="Activ" Type="Conductor" Conductivity="357141.0"
|
|
15
|
+
<Material Name="Activ" Type="Conductor" Conductivity="357141.0" ThermalConductivityTable="Si_vs_T_IHP" Color="00ff00" />
|
|
16
16
|
<Material Name="Metal1" Type="Conductor" Conductivity="21640000.0" ThermalConductivity="237" Color="39bfff" />
|
|
17
17
|
<Material Name="Metal2" Type="Conductor" Conductivity="23190000.0" ThermalConductivity="237" Color="ccccd9" />
|
|
18
18
|
<Material Name="Metal3" Type="Conductor" Conductivity="23190000.0" ThermalConductivity="237" Color="d80000" />
|
|
@@ -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" />
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<Variable Name="bulk_thickness" Value="=total_thickness-19.88" />
|
|
12
12
|
</Variables>
|
|
13
13
|
<Materials>
|
|
14
|
-
<Material Name="Activ" Type="Conductor" Conductivity="357141.0"
|
|
14
|
+
<Material Name="Activ" Type="Conductor" Conductivity="357141.0" ThermalConductivityTable="Si_vs_T_IHP" Color="00ff00" />
|
|
15
15
|
<Material Name="Metal1" Type="Conductor" Conductivity="21640000.0" ThermalConductivity="237" Color="39bfff" />
|
|
16
16
|
<Material Name="Metal2" Type="Conductor" Conductivity="23190000.0" ThermalConductivity="237" Color="ccccd9" />
|
|
17
17
|
<Material Name="Metal3" Type="Conductor" Conductivity="23190000.0" ThermalConductivity="237" Color="d80000" />
|
|
@@ -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())
|