Running Palace Simulations: Microstrip#

Palace is an open-source 3D electromagnetic simulator supporting eigenmode, driven (S-parameter), and electrostatic simulations. This notebook demonstrates using the gsim.palace API to run a driven simulation on a microstrip transmission line with via ports.

Requirements:

  • IHP PDK: uv pip install ihp-gdsfactory

  • GDSFactory Simulation SDK: uv pip install gsim

  • GDSFactory+ account for cloud simulation

Load a pcell from IHP PDK#

import gdsfactory as gf

from ihp import LAYER, PDK, cells

PDK.activate()

c = gf.Component()
r1 = c << cells.straight_metal(length=200, width=15)

r = c.get_region(layer=LAYER.TopMetal2drawing)
r_sized = r.sized(+50000)
c.add_polygon(r_sized, layer=LAYER.Metal1drawing)


c.add_ports(r1.ports)

cc = c.copy()
cc.draw_ports()
cc
2026-02-06 09:06:23.254 | WARNING  | doroutes.pcells:<module>:25 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.258 | WARNING  | doroutes.pcells:<module>:48 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.260 | WARNING  | doroutes.pcells:<module>:109 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.262 | WARNING  | doroutes.pcells:<module>:146 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.263 | WARNING  | doroutes.pcells:<module>:161 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.265 | WARNING  | doroutes.pcells:<module>:201 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.267 | WARNING  | doroutes.pcells:<module>:235 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.268 | WARNING  | doroutes.pcells:<module>:260 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
2026-02-06 09:06:23.270 | WARNING  | doroutes.pcells:<module>:285 - Cannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.
_images/9802923f2201062dd2743e229c1ed7afdb60c0b0dac6fae64ee996ca544e98c4.png

Configure and run simulation with DrivenSim#

from gsim.palace import DrivenSim

# Create simulation object
sim = DrivenSim()

# Set output directory
sim.set_output_dir("./palace-sim-microstrip")

# Set the component geometry
sim.set_geometry(c)

# Configure layer stack from active PDK
sim.set_stack(substrate_thickness=2.0, air_above=300.0)

# Configure via ports (Metal1 ground plane to TopMetal2 signal)
for port in c.ports:
    sim.add_port(port.name, from_layer="metal1", to_layer="topmetal2", geometry="via")

# Configure driven simulation (frequency sweep for S-parameters)
sim.set_driven(fmin=1e9, fmax=100e9, num_points=40)

# Validate configuration
print(sim.validate_config())
Validation: PASSED
# Generate mesh (presets: "coarse", "default", "fine")
sim.mesh(preset="default")
Warning : 43 ill-shaped tets are still in the mesh
Warning : ------------------------------
Warning : Mesh generation error summary
Warning :     1 warning
Warning :     0 errors
Warning : Check the full log for details
Warning : ------------------------------
Mesh Summary
========================================
Dimensions: 500.0 x 315.0 x 416.6 µm
Nodes:      2,613
Elements:   20,559
Tetrahedra: 14,757
Edge length: 0.40 - 327.46 µm
Quality:    0.394 (min: 0.001)
SICN:       0.440 (all valid)
----------------------------------------
Volumes (4):
  - air [1]
  - passive [2]
  - SiO2 [3]
  - airbox [4]
Surfaces (7):
  - metal1_xy [5]
  - metal1_z [6]
  - topmetal2_xy [7]
  - topmetal2_z [8]
  - P1 [9]
  - P2 [10]
  - Absorbing_boundary [11]
----------------------------------------
Mesh:   palace-sim-microstrip/palace.msh
# Static PNG
sim.plot_mesh(show_groups=["metal", "P"], interactive=False)

# Interactive
# sim.plot_mesh(show_groups=["metal", "P"], interactive=True)

2026-02-06 09:06:25.418 (   1.518s) [    7FDBF3D00B80]vtkXOpenGLRenderWindow.:1458  WARN| bad X server connection. DISPLAY=
2026-02-06 09:06:25.418 (   1.518s) [    7FDBF3D00B80]vtkOpenGLRenderWindow.c:649   WARN| Failed to load EGL! Please install the EGL library from your distribution's package manager.
2026-02-06 09:06:25.429 (   1.529s) [    7FDBF3D00B80]vtkOpenGLRenderWindow.c:649   WARN| Failed to load EGL! Please install the EGL library from your distribution's package manager.
_images/b4d9d512c77c5d30929f3c420cc823bfec83040520c0bd20b1b0d945194c14c8.png
# Generate Palace config file
sim.write_config()
PosixPath('palace-sim-microstrip/config.json')

Run simulation on GDSFactory+ Cloud#

# Run simulation on GDSFactory+ cloud
results = sim.simulate()
Uploading simulation... 
done
Job started: palace-323c6f29

Created: 09:06:26 | Now: 09:06:26 | Status: queued
Created: 09:06:26 | Now: 09:06:32 | Status: queued
Created: 09:06:26 | Now: 09:06:37 | Status: queued
Created: 09:06:26 | Now: 09:06:42 | Status: running
Created: 09:06:26 | Now: 09:06:47 | Status: running
Created: 09:06:26 | Now: 09:06:53 | Status: running
Created: 09:06:26 | Now: 09:06:58 | Status: running
Created: 09:06:26 | Now: 09:07:03 | Status: running
Created: 09:06:26 | Now: 09:07:09 | Status: running
Created: 09:06:26 | Now: 09:07:14 | Status: running
Created: 09:06:26 | Now: 09:07:19 | Status: running
Created: 09:06:26 | Now: 09:07:25 | Status: completed
Extracting results.tar.gz...
Downloaded 6 files to /home/runner/work/IHP/IHP/docs/sim-data-palace-323c6f29/results/palace
import matplotlib.pyplot as plt
import pandas as pd

df = pd.read_csv(results["port-S.csv"])
df.columns = df.columns.str.strip()  # Remove whitespace from column names

freq = df["f (GHz)"]

fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(6, 6))

# Magnitude plot
ax1.plot(freq, df["|S[1][1]| (dB)"], marker=".", label="S11")
ax1.plot(freq, df["|S[2][1]| (dB)"], marker=".", label="S21")
ax1.set_xlabel("Frequency (GHz)")
ax1.set_ylabel("Magnitude (dB)")
ax1.set_title("S-Parameters")
ax1.legend()
ax1.grid(True)

# Phase plot
ax2.plot(freq, df["arg(S[1][1]) (deg.)"], marker=".", label="S11")
ax2.plot(freq, df["arg(S[2][1]) (deg.)"], marker=".", label="S21")
ax2.set_xlabel("Frequency (GHz)")
ax2.set_ylabel("Phase (deg)")
ax2.legend()
ax2.grid(True)

plt.tight_layout()
_images/662d161c8d140907beca004b649821290663e630af28354375210fefc812fc45.png