Palace CPW Simulation — Lumped Ports¶
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 with lumped ports.
Requirements:
- IHP PDK:
uv pip install ihp-gdsfactory - GDSFactory+ account for cloud simulation
Define GSG electrode¶
# Config: filepaths, PDK activation, package imports and selected source
import gdsfactoryplus as gfp
pdk = gfp.get_pdk()
pdk.activate()
import gdsfactory as gf
from ihp import LAYER, PDK
PDK.activate()
@gf.cell
def gsg_electrode(
length: float = 800,
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()
r1 = c << gf.c.rectangle((length, g_width), centered=True, layer=layer)
r1.move((0, (g_width + s_width) / 2 + gap_width))
_r2 = c << gf.c.rectangle((length, s_width), centered=True, layer=layer)
r3 = c << gf.c.rectangle((length, g_width), centered=True, layer=layer)
r3.move((0, -(g_width + s_width) / 2 - gap_width))
c.add_port(
name="o1",
center=(-length / 2, 0),
width=s_width,
orientation=180,
port_type="electrical",
layer=layer,
)
c.add_port(
name="o2",
center=(length / 2, 0),
width=s_width,
orientation=0,
port_type="electrical",
layer=layer,
)
return c
c = gsg_electrode()
cc = c.copy()
cc.draw_ports()
cc

Configure simulation¶
import warnings
from gsim.common.stack import get_stack
from gsim.palace import DrivenSim
# pyvista>=0.49 ships its trame notebook backend in the separate `trame-pyvista`
# package; without it, interactive views fall back to a static image and warn.
warnings.filterwarnings(
"ignore",
message='No handler registered for notebook backend "trame"',
category=UserWarning,
)
sim = DrivenSim()
sim.set_output_dir("./palace-sim-cpw-lumped")
sim.set_geometry(c)
stack = get_stack() # auto-detects active PDK
sim.set_stack(stack)
# CPW lumped ports — offset defaults to length/2 (flush with conductor edge)
sim.add_cpw_port("o1", layer="topmetal2", s_width=20, gap_width=15, excited=True)
sim.add_cpw_port("o2", layer="topmetal2", s_width=20, gap_width=15, excited=False)
sim.set_driven(fmin=1e9, fmax=100e9, num_points=300)
print(sim.validate_config())
Generate mesh¶
sim.set_airbox(margin_x=50, margin_y=0, z_above=100, z_below=100)
sim.mesh(
preset="coarse",
# refined_mesh_size=2.0,
# max_mesh_size=40.0,
# fmax=150e9,
margin_x=50.0,
margin_y=0,
)
21:16:19 | WARNING | Small conductor feature detected (15.000 um) may be under-resolved by refined_mesh_size=10.000 um. The heuristic target is <= 7.500 um (2 cells/feature). Pass auto_size=True to scale the mesh down.
Mesh Summary
========================================
Dimensions: 900.0 x 130.0 x 217.9 µm
Nodes: 3,630
Elements: 27,731
Tetrahedra: 18,593
Edge length: 1.90 - 114.52 µm
Quality: 0.505 (min: 0.048)
SICN: 0.558 (all valid)
Worst element distortion, κ: 20.1958 (tet centers; 1 is ideal)
Estimated Field DOFs: 122,604 (order 2; before Palace preprocessing)
Mesh hash: sha256:1afd70d33f466f1c (gmsh 4.15.2, gsim 0.9.0)
Mesher: 2D algorithm 5, 3D algorithm 1, threads 1 (1D/2D/3D limits 1/1/1)
----------------------------------------
Volumes (3):
- sio2 [1]
- sin [2]
- air [3]
Surfaces (12):
- topmetal2_xy [4]
- topmetal2_z [5]
- P1_E0 [6]
- P1_E1 [7]
- P2_E0 [8]
- P2_E1 [9]
- air__sio2 [10]
- sio2__None [11]
- sin__sio2 [12]
- air__sin [13]
- sin__None [14]
- air__None [15]
----------------------------------------
Mesh: palace-sim-cpw-lumped/palace.msh
sim.plot_mesh(
style="solid",
transparent_groups=["air__None", "SiO2__None", "SiO2__passive", "air__passive"],
interactive=True,
)

Run simulation¶
palace-b1ebf77c [####################] Job completed elapsed 0m 00s
Extracting results.tar.gz...
Downloaded 12 files to /home/runner/work/simulation-templates/simulation-templates/docs/notebooks/sim-data-palace-b1ebf77c