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(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

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)

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-f4aa3c12

Created: 21:44:42 | Now: 21:44:43 | Status: queued

Created: 21:44:42 | Now: 21:44:48 | Status: queued

Created: 21:44:42 | Now: 21:44:53 | Status: running

Created: 21:44:42 | Now: 21:44:58 | Status: running

Created: 21:44:42 | Now: 21:45:03 | Status: running

Created: 21:44:42 | Now: 21:45:08 | Status: running

Created: 21:44:42 | Now: 21:45:14 | Status: running

Created: 21:44:42 | Now: 21:45:19 | Status: running

Created: 21:44:42 | Now: 21:45:24 | Status: running

Created: 21:44:42 | Now: 21:45:29 | Status: running

Created: 21:44:42 | Now: 21:45:34 | Status: running

Created: 21:44:42 | Now: 21:45:39 | Status: running

Created: 21:44:42 | Now: 21:45:45 | Status: completed Extracting results.tar.gz... Downloaded 6 files to /home/runner/work/gsim/gsim/nbs/sim-data-palace-f4aa3c12/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()

png