Skip to content

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

png

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),
    extend_into_pml=True,
)
sim.num_freqs = 21

print(sim.validate_config())
pyvirtualdisplay not available; continuing without Xvfb


Stack validation: PASSED
Warnings:
  - Stopping: energy_decay (dt=20.0, decay_by=0.01, cap=2000.0)

Preview the XZ cross-section

sim.plot_2d(slices="y", aspect="auto")
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()

png

Run the simulation

result = sim.run(check_cache=True)
  meep-b62e4404  completed  3m 21s


Extracting results.tar.gz...
Downloaded 325 files to sim-data-meep-b62e4404
result.plot_interactive()
result.show_animation()