Running Palace Simulations#
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 CPW (coplanar waveguide) structure.
Requirements:
IHP PDK:
uv pip install ihp-gdsfactoryGDSFactory Simulation SDK:
uv pip install gsimGDSFactory+ account for cloud simulation
Load a pcell from IHP PDK#
import gdsfactory as gf
from ihp import LAYER, PDK
PDK.activate()
@gf.cell
def gsg_electrode(
length: float = 300,
s_width: float = 20,
g_width: float = 40,
gap_width: float = 15,
layer=LAYER.TopMetal2drawing,
) -> gf.Component:
"""
Create a GSG (Ground-Signal-Ground) electrode.
Args:
length: horizontal length of the electrodes
s_width: width of the signal (center) electrode
g_width: width of the ground electrodes
gap_width: gap between signal and ground electrodes
layer: layer for the metal
"""
c = gf.Component()
# Top ground electrode
r1 = c << gf.c.rectangle((length, g_width), centered=True, layer=layer)
r1.move((0, (g_width + s_width) / 2 + gap_width))
# Center signal electrode
_r2 = c << gf.c.rectangle((length, s_width), centered=True, layer=layer)
# Bottom ground electrode
r3 = c << gf.c.rectangle((length, g_width), centered=True, layer=layer)
r3.move((0, -(g_width + s_width) / 2 - gap_width))
# Add ports at the gaps
c.add_port(
name="P1",
center=(-length / 2, -(s_width + gap_width) / 2),
width=gap_width,
orientation=0,
port_type="electrical",
layer=layer,
)
c.add_port(
name="P2",
center=(-length / 2, (s_width + gap_width) / 2),
width=gap_width,
orientation=0,
port_type="electrical",
layer=layer,
)
c.add_port(
name="P3",
center=(length / 2, (s_width + gap_width) / 2),
width=gap_width,
orientation=180,
port_type="electrical",
layer=layer,
)
c.add_port(
name="P4",
center=(length / 2, -(s_width + gap_width) / 2),
width=gap_width,
orientation=180,
port_type="electrical",
layer=layer,
)
return c
c = gsg_electrode()
cc = c.copy()
cc.draw_ports()
cc
2026-02-22 16:32:53.417 | 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-22 16:32:53.420 | 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-22 16:32:53.423 | 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-22 16:32:53.425 | 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-22 16:32:53.426 | 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-22 16:32:53.428 | 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-22 16:32:53.430 | 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-22 16:32:53.432 | 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-22 16:32:53.434 | 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.
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-cpw")
# 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 left CPW port (P1 lower, P2 upper)
sim.add_cpw_port("P2", "P1", layer="topmetal2", length=5.0)
# Configure right CPW port (P4 lower, P3 upper)
sim.add_cpw_port("P3", "P4", layer="topmetal2", length=5.0)
# 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 : 5 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 330.0 x 418.3 µm
Nodes: 4,049
Elements: 31,726
Tetrahedra: 23,222
Edge length: 0.40 - 323.88 µm
Quality: 0.481 (min: 0.001)
SICN: 0.535 (all valid)
----------------------------------------
Volumes (4):
- air [1]
- passive [2]
- SiO2 [3]
- airbox [4]
Surfaces (7):
- topmetal2_xy [5]
- topmetal2_z [6]
- P1_E0 [7]
- P1_E1 [8]
- P2_E0 [9]
- P2_E1 [10]
- Absorbing_boundary [11]
----------------------------------------
Mesh: palace-sim-cpw/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-22 16:32:57.024 ( 2.653s) [ 7FF783335B80]vtkXOpenGLRenderWindow.:1460 WARN| bad X server connection. DISPLAY=
2026-02-22 16:32:57.025 ( 2.653s) [ 7FF783335B80]vtkOpenGLRenderWindow.c:645 WARN| Failed to load EGL! Please install the EGL library from your distribution's package manager.
2026-02-22 16:32:59.072 ( 4.700s) [ 7FF783335B80]vtkOpenGLRenderWindow.c:645 WARN| Failed to load EGL! Please install the EGL library from your distribution's package manager.
Run simulation on cloud#
# Generate Palace config file
sim.write_config()
PosixPath('palace-sim-cpw/config.json')
# Run simulation on GDSFactory+ cloud
results = sim.simulate()
Uploading simulation...
done
Job started: palace-e3d5c4b8
Created: 16:33:01 | Now: 16:33:02 | Status: queued
Created: 16:33:01 | Now: 16:33:07 | Status: queued
Created: 16:33:01 | Now: 16:33:12 | Status: running
Created: 16:33:01 | Now: 16:33:18 | Status: running
Created: 16:33:01 | Now: 16:33:23 | Status: running
Created: 16:33:01 | Now: 16:33:28 | Status: running
Created: 16:33:01 | Now: 16:33:33 | Status: running
Created: 16:33:01 | Now: 16:33:39 | Status: running
Created: 16:33:01 | Now: 16:33:44 | Status: running
Created: 16:33:01 | Now: 16:33:49 | Status: running
Created: 16:33:01 | Now: 16:33:54 | Status: running
Created: 16:33:01 | Now: 16:34:00 | Status: running
Created: 16:33:01 | Now: 16:34:05 | Status: running
Created: 16:33:01 | Now: 16:34:10 | Status: running
Created: 16:33:01 | Now: 16:34:16 | Status: running
Created: 16:33:01 | Now: 16:34:21 | Status: running
Created: 16:33:01 | Now: 16:34:26 | Status: running
Created: 16:33:01 | Now: 16:34:31 | Status: running
Created: 16:33:01 | Now: 16:34:37 | Status: running
Created: 16:33:01 | Now: 16:34:42 | Status: running
Created: 16:33:01 | Now: 16:34:47 | Status: running
Created: 16:33:01 | Now: 16:34:53 | Status: running
Created: 16:33:01 | Now: 16:34:58 | Status: running
Created: 16:33:01 | Now: 16:35:04 | Status: completed
Extracting results.tar.gz...
Downloaded 6 files to /home/runner/work/IHP/IHP/docs/sim-data-palace-e3d5c4b8/results/output/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()