TIDY3D
LEARNING CENTER

Bayesian optimization of a SOI vertical grating coupler

Grating couplers are photonic devices that couple light efficiently between optical fibers and integrated photonic waveguides. They work by diffracting light incident from above into the plane of the chip, enabling vertical fiber-to-chip coupling—a key functionality for scalable photonic integrated circuits. Vertical grating couplers are widely used because they simplify packaging and alignment compared to edge coupling, and can be designed with high efficiency for target wavelengths, such as the telecom band around 1.55 μm.

This notebook demonstrates the design optimization of a vertical grating coupler using the Bayesian optimizer from Tidy3D’s design plugin. The optimized design achieves a < 2dB coupling efficiency. The design is based on the work T. Watanabe, M. Ayata, U. Koch, Y. Fedoryshyn and J. Leuthold, "Perpendicular Grating Coupler Based on a Blazed Antiback-Reflection Structure," in Journal of Lightwave Technology, vol. 35, no. 21, pp. 4663-4669, 1 Nov.1, 2017. DOI: 10.1109/JLT.2017.2755673.

schematic

# Standard library imports
import matplotlib.pyplot as plt
import numpy as np

# Tidy3D imports
import tidy3d as td
import tidy3d.plugins.design as tdd
import tidy3d.web as web

Simulation Setup

We define the simulation parameters, including the wavelength range, fixed geometric parameters, and the materials (silicon and silicon oxide).

# Define frequency and wavelength range
lda0 = 1.55  # Central wavelength
freq0 = td.C_0 / lda0  # Central frequency
ldas = np.linspace(1.5, 1.6, 101)  # Wavelength range
freqs = td.C_0 / ldas  # Frequency range
fwidth = 0.5 * (np.max(freqs) - np.min(freqs))  # Frequency width of the source
# Geometric parameters
h_si = 0.22  # Silicon thickness
h_etch = 0.07  # Etch depth
h_box = 3  # Buried oxide thickness
h_clad = 1.5  # Cladding thickness
n = 20  # Number of grating periods
mfd = 10.4  # Mode field diameter
ly = 15  # Grating size in y

# Materials
n_si = 3.45
mat_si = td.Medium(permittivity=n_si**2)

n_sio2 = 1.45
mat_sio2 = td.Medium(permittivity=n_sio2**2)

The grating coupler geometry is parameterized by the thickness and width of the grating teeth (t1, t2, w1, w2, w3). The make_grating function constructs the grating geometry, and make_sim_2d creates the full Tidy3D simulation, including the waveguide, substrate, source, and monitors. We will start our optimization in 2D since it’s much faster and cheaper. Then we will verify the optimal design with the full 3D simulation.

schematic

def make_grating(t1, t2, w1, w2, w3):
    """Constructs the grating geometry based on parameters."""
    p = t1 + t2 + w1 + w2 + w3  # Grating period
    grating = 0
    for i in range(n):
        # First tooth section
        grating += td.Box.from_bounds(
            rmin=(i * p + t1, -ly / 2, 0), rmax=(i * p + t1 + w1, ly / 2, h_si)
        )

        # Etched section
        grating += td.Box.from_bounds(
            rmin=(i * p + t1 + w1 + t2, -ly / 2, 0),
            rmax=(i * p + t1 + w1 + t2 + w2, ly / 2, h_si - h_etch),
        )

        # Second tooth section
        grating += td.Box.from_bounds(
            rmin=(i * p + t1 + w1 + t2 + w2, -ly / 2, 0),
            rmax=(i * p + t1 + w1 + t2 + w2 + w3, ly / 2, h_si),
        )

    return td.Structure(geometry=grating, medium=mat_si)
def make_sim_2d(t1, t2, w1, w2, w3):
    """Creates the Tidy3D simulation."""
    grating = make_grating(t1, t2, w1, w2, w3)

    p = t1 + t2 + w1 + w2 + w3  # Grating period
    lx = p * n  # Grating size in x
    inf_eff = 1e3  # effective infinity

    # Waveguide
    waveguide = td.Structure(
        geometry=td.Box.from_bounds(rmin=(-inf_eff, -ly / 2, 0), rmax=(0, ly / 2, h_si)),
        medium=mat_si,
    )

    # Cladding and buried oxide
    box_clad = td.Structure(
        geometry=td.Box.from_bounds(
            rmin=(-inf_eff, -inf_eff, -h_box), rmax=(inf_eff, inf_eff, h_clad + h_si)
        ),
        medium=mat_sio2,
    )

    # Substrate
    substrate = td.Structure(
        geometry=td.Box.from_bounds(
            rmin=(-inf_eff, -inf_eff, -h_box - inf_eff), rmax=(inf_eff, inf_eff, -h_box)
        ),
        medium=mat_si,
    )

    # Gaussian beam source
    gaussian_beam = td.GaussianBeam(
        center=(lx / 2, 0, h_clad + lda0 / 2),
        size=(2 * mfd, 2 * mfd, 0),
        source_time=td.GaussianPulse(freq0=freq0, fwidth=fwidth),
        pol_angle=np.pi / 2,
        angle_theta=0,
        angle_phi=0,
        direction="-",
        waist_radius=mfd / 2,
        waist_distance=0,
    )

    # Mode monitor
    mode_monitor = td.ModeMonitor(
        center=(-lda0 / 2, 0, h_si / 2),
        size=(0, 1.5 * ly, 5 * h_si),
        freqs=freqs,
        mode_spec=td.ModeSpec(num_modes=1, target_neff=n_si),
        name="mode",
    )

    # Simulation domain box
    sim_box = td.Box.from_bounds(
        rmin=(-0.6 * lda0, 0, -h_box - 0.6 * lda0),
        rmax=(lx + 0.6 * lda0, 0, h_clad + h_si + 0.6 * lda0),
    )

    # Define the simulation
    sim = td.Simulation(
        center=sim_box.center,
        size=sim_box.size,
        grid_spec=td.GridSpec.auto(min_steps_per_wvl=20),
        run_time=1e-11,
        structures=[substrate, box_clad, grating, waveguide],
        sources=[gaussian_beam],
        monitors=[mode_monitor],
        boundary_spec=td.BoundarySpec(
            x=td.Boundary.pml(),
            y=td.Boundary.periodic(),  # set the boundary to periodic in y since it's a 2D simulation
            z=td.Boundary.pml(),
        ),
    )
    return sim
# Create a simulation instance with some arbitrary parameters
sim = make_sim_2d(t1=0.1, t2=0.1, w1=0.1, w2=0.25, w3=0.1)

# Visualize the permittivity distribution
sim.plot_eps(y=0)
plt.show()

Optimization

Bayesian optimization is a powerful strategy for optimizing expensive-to-evaluate functions, using a probabilistic model to efficiently explore the parameter space and identify optimal solutions with fewer simulations.

To optimize the grating design for maximal coupling efficiency at 1550 nm, we configure the Bayesian optimization using MethodBayOpt.

We define the design space for the grating parameters and specify the objective function compute_transmission, which calculates the transmission efficiency based on the mode monitor data.

def compute_transmission(sim_data):
    """Calculates the coupling efficiency from the simulation data."""
    # Extract mode amplitude data at 1550 nm
    T = np.abs(sim_data["mode"].amps.sel(mode_index=0, f=freq0, direction="-").values) ** 2
    # Return coupling efficiency in dB
    return 10 * np.log10(T)

To ensure fabrication constraint, we limit the minimal feature size to 50 nm. All design parameters have a range from 50 nm to 250 nm.

After running the optimization, we achieved a design with sub 2dB coupling efficiency.

# Define optimization method (Bayesian optimization)
method = tdd.MethodBayOpt(
    initial_iter=50,
    n_iter=150,
    acq_func="ucb",
    kappa=1,
    seed=4,
)

span = (0.05, 0.25)  # Parameter value range

# Define optimization parameters
parameters = [
    tdd.ParameterFloat(name="t1", span=span),
    tdd.ParameterFloat(name="t2", span=span),
    tdd.ParameterFloat(name="w1", span=span),
    tdd.ParameterFloat(name="w2", span=span),
    tdd.ParameterFloat(name="w3", span=span),
]

# Define a design space
design_space = tdd.DesignSpace(
    method=method, parameters=parameters, task_name="bay_opt", path_dir="./data"
)

# Run the design optimization
results = design_space.run(make_sim_2d, compute_transmission, verbose=True)

Final Design

After the optimization runs, we extract the best parameters and then run a 3D final simulation with these optimal parameters to verify the design from the previous 2D simulations. The 3D simulation can be made by copying the 2D simulation and updating the simulation domain size and boundary condition. To help with visualization, we also added two FieldMonitors in the \(xy\) and \(xz\) planes. Also note that the 3D simulation has a symmetry in the \(y\) direction that we can utilize to reduce the computational cost and time.

# Define field monitors for visualization
field_xy = td.FieldMonitor(
    center=(0, 0, h_si / 2), size=(td.inf, td.inf, 0), freqs=[freq0], name="field_xy"
)

field_xz = td.FieldMonitor(
    center=(0, 0, 0), size=(td.inf, 0, td.inf), freqs=[freq0], name="field_xz"
)

# Extract optimal parameters from the results
optimal_params = results.optimizer.max["params"]

# Make a 2D simulation with the optimal parameters
sim_opt = make_sim_2d(**optimal_params)

# Update simulation with monitors and new domain size to make it 3D
sim_opt = sim_opt.updated_copy(
    size=(sim_opt.size[0], ly + 1.2 * lda0, sim_opt.size[2]),
    monitors=[sim_opt.monitors[0], field_xy, field_xz],
    boundary_spec=td.BoundarySpec.all_sides(boundary=td.PML()),
    symmetry=(0, -1, 0),
)

# Plot the permittivity distribution of the optimal design
fig, ax = plt.subplots(2, 1, figsize=(8, 8), tight_layout=True)

# Plot the permittivity distribution in the xy plane
sim_opt.plot_eps(z=h_si / 2, ax=ax[0], monitor_alpha=0.1)

# Add a circle to indicate the mode field diameter
lx = sum(optimal_params.values()) * n
circle = plt.Circle((lx / 2, 0), mfd / 2, color="red", alpha=0.6, fill=True)
ax[0].add_patch(circle)

# Plot the permittivity distribution in the xz plane
sim_opt.plot_eps(y=0, ax=ax[1], monitor_alpha=0.1)
plt.show()

Run the 3D simulation and plot the coupling efficiency spectrum.

# Run the 3D simulation
sim_data_opt = web.run(sim_opt, "optimal design")

# extract coupling efficiency and plot it
amp = sim_data_opt["mode"].amps.sel(mode_index=0, direction="-")
T = np.abs(amp) ** 2
plt.plot(ldas, 10 * np.log10(T), c="red", linewidth=2)
plt.ylim(-12, 0)
plt.xlabel("Wavelength (μm)")
plt.ylabel("Coupling efficiency (dB)")
plt.grid()
plt.show()
             Created task 'optimal design' with resource_id                     
             'fdve-f6bf73ef-a3af-4d2e-a973-34631e882951' and task_type 'FDTD'.  
             View task using web UI at                                          
             'https://tidy3d.simulation.cloud/workbench?taskId=fdve-f6bf73ef-a3a
             f-4d2e-a973-34631e882951'.                                         
             Task folder: 'default'.                                            
↑ simulation.hdf5.gz ━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3.7/3.7 kB • ? • 0:00:00

23:11:36 UTC Estimated FlexCredit cost: 3.645. This assumes the FDTD solver runs
             for the full simulation time; if early shutoff is reached, the     
             billed cost can be lower. Use 'web.real_cost(task_id)' to get the  
             billed FlexCredit cost after a simulation run.                     
23:11:37 UTC status = queued                                                    
             To cancel the simulation, use 'web.abort(task_id)' or              
             'web.delete(task_id)' or abort/delete the task in the web UI.      
             Terminating the Python script will not stop the job running on the 
             cloud.                                                             
23:11:48 UTC status = preprocess                                                
23:11:53 UTC starting up solver                                                 
             running solver                                                     
23:13:48 UTC early shutoff detected at 5%, exiting.                             
solver progress (field decay = 1.08e-05) ━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00

23:13:49 UTC status = postprocess                                               
23:13:56 UTC status = success                                                   
23:13:58 UTC View simulation result at                                          
             'https://tidy3d.simulation.cloud/workbench?taskId=fdve-f6bf73ef-a3a
             f-4d2e-a973-34631e882951'.                                         
↓ simulation_data.hdf5.gz ━━━━━━━━━━━ 100.0% • 11.9/11.9   • 16.7 MB/s • 0:00:00
                                               MB                               

23:14:00 UTC Loading results from simulation_data.hdf5                          

Finally, plot the field distribution to visualize the mode coupling.

fig, ax = plt.subplots(2, 1, figsize=(6, 8), tight_layout=True)
sim_data_opt.plot_field("field_xy", "E", "abs", ax=ax[0])
sim_data_opt.plot_field("field_xz", "E", "abs", ax=ax[1])
plt.show()

Final Notes

The grating coupler is typically connected to a waveguide taper, which enables an adiabatic transition into a single-mode waveguide. In our simulation, we omit the taper to reduce computational cost. The taper itself can be optimized independently to ensure minimal loss, thereby maintaining a high overall coupling efficiency for the complete device.

In addition to Bayesian optimization, alternative optimization strategies, such as particle swarm optimization (PSO) and adjoint-based inverse design, can also be used to further improve device performance, for example through apodization.