2D Grating Coupler
This notebook demonstrates 2D FDTD in the XZ cross-section plane using gsim.meep. Unlike the top-down XY effective-index sim, this one models the vertical stack (substrate / BOX / core / cladding) and a Gaussian-beam fiber source above the chip — the standard grating-coupler workflow.
Requirements: GDSFactory+ account for cloud simulation.
Select an active-PDK grating coupler and add a feed straight
import gdsfactoryplus as gfp
from pdk_component_picker import component_picker
pdk = gfp.get_pdk()
pdk.activate()
cell_names = sorted(pdk.cells)
component = component_picker("grating_coupler_elliptical", cell_names)
import gdsfactory as gf
from pdk_component_picker import get_component
c = gf.Component()
gc = get_component(component, "grating_coupler_elliptical", fiber_angle=0.0)
gc = gc.copy()
gc.auto_rename_ports()
optical_ports = [port for port in gc.ports if port.port_type == "optical"]
if not optical_ports:
raise ValueError("The selected active-PDK cell must have an optical port.")
gc_r = c.add_ref(gc)
s_r = c.add_ref(gf.components.straight(length=3))
s_r.connect("o1", gc_r.ports[optical_ports[0].name])
c.add_port("o2", port=s_r.ports["o2"])
c

Configure the XZ 2D simulation
Key differences from the XY notebook:
- sim.solver(mode="2d", y_cut="auto") picks the vertical XZ cross-section sim.
- sim.source_fiber(...) replaces the port-based mode source.
- sim.monitors = ["o2"] monitors the waveguide end (feed straight).
from gsim import meep
from gsim.common.stack import get_stack
from gsim.meep.models.api import Material
stack = get_stack() # auto-detects active PDK
sim = meep.Simulation()
sim.geometry(component=c, stack=stack)
sim.materials = {
"si": Material(refractive_index=3.47),
"SiO2": Material(refractive_index=1.44),
}
sim.solver(resolution=25, mode="2d", y_cut="auto")
sim.solver.stop_when_energy_decayed()
sim.source_fiber(
x=25.0,
z=2,
angle_deg=-6.0,
waist=5.2,
wavelength=1.55,
wavelength_span=0.06,
polarization="TE",
)
sim.monitors = ["o2"]
sim.domain(pml=1.0, margin_x=0.5, margin_y=0.5, margin_z=(1.5, 0))
sim.num_freqs = 21
print(sim.validate_config())
Stack validation: PASSED
Warnings:
- Stopping: energy_decay (dt=20.0, decay_by=0.01, cap=2000.0)
Preview the XZ cross-section
/home/runner/work/simulation-templates/simulation-templates/.venv/lib/python3.12/site-packages/gsim/meep/simulation.py:2085: FutureWarning: Use of domain.margin_z is deprecated and will be removed in a future release; replace it with domain.z_bounds=(-1.5, 4.6).
result = self.build_config()

Run the simulation
meep-f3b8dfc7 completed 0m 00s
Extracting results.tar.gz...
Downloaded 4 files to /home/runner/work/simulation-templates/simulation-templates/docs/notebooks/sim-data-meep-f3b8dfc7