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+ 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()
r = c.get_region(layer=LAYER.TopMetal2drawing)
r_sized = r.sized(+5000)
c.add_polygon(r_sized, layer=LAYER.Metal1drawing)
c.add_ports(r1.ports)
cc = c.copy()
cc.draw_ports()
cc
[32m2026-01-24 22:49:30.860[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m25[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.864[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m48[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.866[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m110[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.867[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m149[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.869[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m168[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.870[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m210[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.871[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m244[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.872[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m269[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m
[32m2026-01-24 22:49:30.874[0m | [33m[1mWARNING [0m | [36mdoroutes.pcells[0m:[36m<module>[0m:[36m294[0m - [33m[1mCannot determine output type ((D)KCell type)from annotation <class 'kfactory.kcell.DKCell'>. Trying to continue but likely this will fail.[0m

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())
Validation: PASSED
Warning : 1 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: 220.0 x 212.0 x 416.6 µm
Nodes: 261
Elements: 2,048
Tetrahedra: 1,352
Edge length: 0.40 - 220.00 µm
Quality: 0.439 (min: 0.001)
SICN: 0.481 (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)

PosixPath('palace-sim-microstrip/config.json')
Run simulation on GDSFactory+ Cloud¶
Uploading simulation...
done
Job started: dev-palace-simulation-f56efeb4
Created: 22:49:33 | Now: 22:49:33 | Status: created
Created: 22:49:33 | Now: 22:49:38 | Status: queued
Created: 22:49:33 | Now: 22:49:43 | Status: running
Created: 22:49:33 | Now: 22:49:48 | Status: running
Created: 22:49:33 | Now: 22:49:54 | Status: completed
Downloaded 6 files to /home/runner/work/gsim/gsim/nbs/dev-palace-simulation-f56efeb4
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()
