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.
Load a grating coupler + feed straight¶
import gdsfactory as gf
gf.gpdk.PDK.activate()
c = gf.Component()
gc = gf.components.grating_coupler_elliptical(fiber_angle=0.0)
gc_r = c.add_ref(gc)
s_r = c.add_ref(gf.components.straight(length=3))
s_r.connect("o1", gc_r.ports["o1"])
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", save_animation=True)
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¶

Run the simulation¶
meep-fa90ef3e completed 4m 17s
Extracting results.tar.gz...
Downloaded 325 files to sim-data-meep-fa90ef3e