Metadata-Version: 2.4
Name: setupEM
Version: 0.18.1
Summary: Python tool for configuration of gds2palace workflow with GUI.
Author-email: Volker Muehlhaus <volker@muehlhaus.com>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/VolkerMuehlhaus/setupEM
Project-URL: Repository, https://github.com/VolkerMuehlhaus/setupEM
Project-URL: Changelog, https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gds2palace>=0.10.1
Requires-Dist: gds_prepare_for_EM>=1.6.0
Requires-Dist: PySide6
Requires-Dist: shiboken6
Requires-Dist: scipy
Requires-Dist: requests
Requires-Dist: scikit-rf
Requires-Dist: matplotlib
Requires-Dist: numpy
Requires-Dist: gdspy
Requires-Dist: meshio
Requires-Dist: pyvista
Requires-Dist: pyvistaqt
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# Python GUI for gds2palace 

![Intro](https://raw.githubusercontent.com/VolkerMuehlhaus/setupEM/main/doc/png/setupEM_banner.png)

## Install

    pip install setupEM

**Full documentation, installation guide, and usage walkthrough:**
https://github.com/VolkerMuehlhaus/setupEM

## Recent changes

# What's New - November 11, 2026 (setupEM 0.18.1)

**Command line fixes** (from issue #52, use without a display):
- `--help`, `--version` and a wrong argument of `setupEM`, `setupThermal`, `stackupEditor`, `resultViewer` and `fieldViewer` no longer need a display: the arguments are read before Qt starts. All five have `--version` now.
- `setupEM -simcfg <file>` opens a settings file of an Elmer model in Elmer mode. It opened in Palace mode unless `--elmer` was given, also when started from the KLayout plug-in.
- A `-simcfg`, `-gdsfile` or `-xmlfile` that does not exist, or a settings file of the other application, ends `setupEM` / `setupThermal` with a message on stderr and exit code 2 instead of an empty window. In the GUI, a settings file that is gone is reported as "File not found", not as "Unknown data format".
- Loading a settings file no longer shows a "Loaded" box: the log says "Config loaded from ...", with a GDS or stackup file that was not found at its saved path and was taken from the settings file's folder instead.
- Opening a `.simcfg` continues with the model script only when the file is linked to it, and asks only when the two have other settings (the question lists them). Create Model links: besides `<model>.simcfg` it writes the script's name (`"model_script"`) into the `.simcfg` the model was opened from, e.g. the KLayout plug-in's export, which keeps it on the next export. A script that only reads the same GDSII file is no longer taken for the model; the log names it. New options `--continue-with-script` and `--start-from-config` answer the question on the command line.
- `fieldViewer --screenshot` needs no display and no `QT_QPA_PLATFORM=offscreen`.
- `python -m setupEM.join_pieces` and `python -m setupEM.thermal_results` have `--help` and `--version`, write their errors to stderr, and a missing file is a message, not a traceback.
- The modules without a GUI (`join_pieces`, `thermal_results`, `script_model`, ...) can be imported without loading Qt.
- User guide: Model Fit starts snp2le with the result file loaded (the text said it has to be loaded by hand).

**Split regions, fix:**a side of the region made a port wall in setupEM after the export (e.g. with via ports of the layout on the region's edge) was a plain PEC wall in every piece and in the full check model: the wall shorted those ports, and the joined result and the full model were both wrong, in the same way. The pieces' port walls on the region's edge are now found from the ports on the edge of each piece's layout; the full model has all of the region's port walls. Where the region has a port wall but a piece none of its ports, that stretch stays PEC and now moves outward with the region's port wall extension (a length; written as `settings['wall_extension']`, needs gds2palace 0.10.1), so that all pieces and the full model have the same box.

# What's New - November 10, 2026 (setupEM 0.18.0)

**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.

**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.

**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.

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.

**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.

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.

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.

# What's New - November 5, 2026 (setupEM 0.17.0)

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`):
- **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`.
- 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.
- 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.
- **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`.

**Changes:**
- **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.
- 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).

**Fixes:**
- 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).

Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)

---

**Note:** the `setupEM` PyPI package itself requires:

- gds2palace>=0.10.1
- gds_prepare_for_EM>=1.6.0
- PySide6
- shiboken6
- scipy
- requests
- scikit-rf
- matplotlib
- numpy
- gdspy
- meshio
- pyvista
- pyvistaqt

(Other Python modules mentioned above are only needed to run standalone helper scripts in this repository, not to use the installed package.)
