Metadata-Version: 2.4
Name: gds2openEMS
Version: 0.8.0
Summary: Create and run openEMS FDTD model from RFIC GDSII layout file
Author-email: Volker Muehlhaus <volker@muehlhaus.com>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/VolkerMuehlhaus/gds2openEMS
Project-URL: Repository, https://github.com/VolkerMuehlhaus/gds2openEMS
Project-URL: Changelog, https://github.com/VolkerMuehlhaus/gds2openEMS/blob/main/doc/CHANGES.md
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gdstk
Requires-Dist: CSXCAD
Requires-Dist: openEMS
Requires-Dist: numpy
Requires-Dist: shapely
Requires-Dist: PySide6
Dynamic: license-file

# gds2openEMS: FDTD simulation workflow for RFIC

The files provided here enable openEMS EM simulation with layouts
created for the IHP SG13G2 RFIC technology.

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

## Install

    pip install gds2openEMS

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

## Recent changes

## 19-Nov-2026 (0.8.0)

**gdstk instead of gdspy:** the GDSII reader uses [gdstk](https://github.com/heitzmann/gdstk) instead of gdspy, which is no longer maintained and whose polygon fracturing could hang. `pip install gds2openEMS` installs gdstk. The results are the same: `read_gds()` on all GDS files shipped in `workflow/` and `more_examples/`, with and without via merging, gives every layer the same area as before. The mirror/offset options of `read_gds()` now also move paths; before, only polygons moved. The same port as gds2palace 0.11 and gds_prepare_for_EM 1.8.

**Changed behaviour, the cell read without a cell name:** with `cellname=""` (or a name not in the file), `read_gds()` reads the design cell: the top-level cell with the largest bounding box, never KLayout's `$$$CONTEXT_INFO$$$`. Before, it read the first top-level cell, which depends on the order in the file. gds2palace, gds_prepare_for_EM, setupEM and the gds2palace MCP server use the same rule (`select_design_cell()`).

**Fix, via array merging:** with `merge_polygon_size > 0`, merged vias no longer have strips cut out of them. A via array around an opening, e.g. a guard ring of contacts, came out cut open: shrinking back after merging opened the slit that encodes the hole, and, for large arrays, the lines along which the merged shape was split into pieces. The same for derived layers with a negative `Oversize`. Of the shipped layouts only `gsg_through_50ohm.gds` changes, by +0.003 % merged via area.

**Fix, model files with decimal commas:** openEMS and CSXCAD write the numbers of the model file (`sub-<n>/<model>.xml`) and of the CSX file for the model hash in the number format of the C library. When the program had set a locale with decimal commas (Qt does that from `LANG`, e.g. a model script that opens a Qt matplotlib window first, with `LANG=de_DE`), the files got numbers like `endCriteria="0,0001"`, which the openEMS binary does not read as the number, and the model hash changed. The files are now always written with decimal points. The simulation started from Python was not affected: it does not read these files.

## 17-Nov-2026 (0.7.1)

**Model file for the openEMS command line:** `sub-<n>/<model>.xml` is now the complete openEMS model, written with `FDTD.Write2XML()` (openEMS v0.37.0 and newer): besides geometry, mesh and ports, it has the excitation, the end criterion and the boundaries, so `openEMS <model>.xml` runs it without Python. Before, it held only the CSX (`CSX.Write2XML()`), which the openEMS program can't run. `runSimulation()` prints the command for each excitation, with the options the script passes to openEMS (`--engine`, `--gpu-device`, `--numThreads`, `--verbose`), since they are not part of the file. Nothing else changes: the simulation still starts from Python as before, and the hash that detects an unchanged model is still taken from the CSX alone, so existing results are not simulated again. With an older openEMS the file holds the CSX only, as before. Checked: the via port line run from the command line gives the same S-parameters as the run from the script.

**L6n2 study redone** ([`more_examples/measured_vs_simulated/more_accurate_models_L6n2`](../more_examples/measured_vs_simulated/more_accurate_models_L6n2/README.md)). All models were run again with a larger simulation box and today's software, so that all numbers and times in the README come from one setup:

- **The box:** the PEC walls were too close: 250 µm margin and no air beyond it, with the bottom wall directly under the 180 µm substrate. A sweep of the air around the model (step 0 of the README) shows L 1.8 % too low and the SRF 0.9 % too high with that box. All models now use 250 µm margin and 800 µm air on all sides.
- **The software:** gds2openEMS 0.7.0 and openEMS built from source (1d710c2), with its new CPU engine, on the same machine as before. The earlier runs used gds2openEMS 0.5.0 (the 1 µm models with the z mesh fix of 28-Sep-2026, which removed a 0.1 µm cell in TopMetal2) and openEMS v0.0.36 with its default engine; the 1 µm model took 34 min then, 7 min now.
- **The order of the steps:** the end criterion now comes before the mesh check, which runs at −60 dB. Before, the mesh was checked at −40 dB, where the low-frequency resistance still carries the truncation error of the end criterion. At −60 dB, peak Q changes by 6 % from 1 µm to 0.5 µm, so the final model now uses a 0.5 µm mesh (102 min).
- **What changed in the results:** the conclusions of all steps hold. Against the measurement, the earlier final model (1 µm mesh) was 3.9 % low in L, 8.9 % low in peak Q and within 0.1 % in SRF; the new final model (0.5 µm mesh, box far enough) is 2.1 % low in L, 2.4 % low in peak Q and 0.5 % high in SRF.
- **The comparison with Palace** now uses the gds2palace v5 model, whose boundary is far enough away too. The earlier comparison used the v2 model (100 µm margin) and agreed within 1.9 % in peak Q. With both boundaries far enough and the 0.5 µm mesh in openEMS, the two solvers agree within 1.4 % in peak Q and 0.5 % in SRF; L is 2.3 % lower in openEMS, not explained yet.

## 16-Nov-2026

**GPU device:** `settings['gpu_device']` selects the GPU of the GPU engine on a machine with more than one GPU (default: openEMS takes the best one). It is passed to openEMS only if the installed openEMS has this option; older ones would stop with an unknown-option error, so gds2openEMS prints a warning instead. See [Choosing the GPU](userguide_md_format/Using_OpenEMS_Python_with_IHP_SG13G2_v3.md#choosing-the-gpu) in the user's guide.

**More openEMS messages:** openEMS now runs at verbose level 1. Its output adds about 30 lines per excitation: the model statistics (cells, memory of operator and field data, PEC edges, timestep, excitation length, time to build the operator) and, for the GPU engine, the list of GPU devices.

**Engine from the environment:** without `settings['engine']`, current openEMS takes the engine from the environment variable `OPENEMS_ENGINE`. gds2openEMS now writes that engine to `time_information.txt` too, and warns for `OPENEMS_ENGINE=gpu` with an openEMS without the GPU engine, as for `settings['engine']`. Older openEMS ignores the variable; gds2openEMS warns about that. See [The engine from the environment](userguide_md_format/Using_OpenEMS_Python_with_IHP_SG13G2_v3.md#the-engine-from-the-environment) in the user's guide.

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

---

**Note:** the `gds2openEMS` PyPI package itself only requires:

- gdstk
- CSXCAD
- openEMS
- numpy
- shapely
- PySide6

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