Waveguide plugin demonstration
Contents
Waveguide plugin demonstration#
This notebook demosntrates the use of the waveguide plugin to quickly set-up waveguide simulations from usual geometries.
[1]:
import tidy3d as td
import tidy3d.web as web
from tidy3d.plugins import waveguide
import numpy as np
from matplotlib import pyplot
[2]:
# Media used in the examples
si = td.material_library["cSi"]["Li1993_293K"]
sio2 = td.material_library["SiO2"]["Horiba"]
Strip and Rib Geometries#
The class RectangularDielectric
allows the creation of a variety of dielectric waveguide geometries common in integrated photonics.
First we take a look at a strip silicon waveguide and plot the fundamental quasi-TE and quasi-TM modes, along with their effective indices:
[3]:
strip = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.22,
core_medium=si,
clad_medium=sio2,
mode_spec=td.ModeSpec(num_modes=2, precision="double", group_index_step=True),
)
# Take a look at the waveguide cross-section
_ = strip.plot_structures(x=0)
[4]:
strip.plot_field("Ex", mode_index=0)
[5]:
# Mode data
print(f"Effective indices: {strip.n_eff.values}")
print(f"Effective mode areas (µm²): {strip.mode_area.values}")
print(f"Group index: {strip.n_group.values}")
fig, ax = pyplot.subplots(1, 2, figsize=(10, 4), tight_layout=True)
# quasi-TE mode
strip.plot_field("Ey", mode_index=0, ax=ax[0])
# quasi-TM mode
strip.plot_field("Ez", mode_index=1, ax=ax[1])
Effective indices: [[2.53287852 1.89256577]]
Effective mode areas (µm²): [[0.18517123 0.30873644]]
Group index: [[4.17741743 4.18908857]]
It is possible to define waveguides with different substrate and cladding, angled sidewalls, and rib geometry:
[6]:
fig, ax = pyplot.subplots(1, 2, figsize=(10, 4), tight_layout=True)
undercut = strip = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.22,
sidewall_angle=-np.pi / 12,
core_medium=si,
clad_medium=td.Medium(permittivity=1.0),
box_medium=sio2,
)
undercut.plot_structures(x=0, ax=ax[0])
_ = ax[0].set_title("Uncladded undercut channel")
rib = strip = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.4,
core_thickness=0.22,
slab_thickness=0.07,
sidewall_angle=np.pi / 6,
core_medium=si,
clad_medium=sio2,
)
rib.plot_structures(x=0, ax=ax[1])
_ = ax[1].set_title("Rib waveguide")
FDTD Simulation#
The waveguide structures can be used in Tidy3D simulations as conventinal structures. The origin, lenght, and orientation of the waveguides can be selected at creation to fit the most common simulation configurations.
In the following example, we simulate the effect of directly coupling strip and rib geometries without any tapering and compare the result with the modal overlap calclulation between the two modes.
[7]:
length = 6.0
strip, rib = [
waveguide.RectangularDielectric(
wavelength=np.linspace(1.5, 1.6, 11),
core_width=0.45,
core_thickness=0.22,
core_medium=si,
clad_medium=sio2,
slab_thickness=0.07 if slab else 0,
length=length,
origin=(0.5 * length if slab else -0.5 * length, 0, 0),
sidewall_angle=np.pi / 12,
) for slab in (False, True)
]
fig, ax = pyplot.subplots(1, 2, figsize=(10, 4), tight_layout=True)
strip.plot_structures(x=-0.5 * length, ax=ax[0])
rib.plot_structures(x=0.5 * length, ax=ax[1])
pyplot.show()
[8]:
# Calculate the mode overlap between waveguides
overlap = strip.mode_solver.data.outer_dot(rib.mode_solver.data, False)
# Show the overlap at the central frequency
f = strip.mode_solver.freqs[strip.wavelength.size // 2]
fig, ax = pyplot.subplots(1, 1, figsize=(3, 3), tight_layout=True)
ax.matshow(overlap.sel(f=f).abs.values, cmap="gray")
ax.grid(False)
for mi0 in overlap.coords["mode_index_0"]:
for mi1 in overlap.coords["mode_index_1"]:
ovl_dB = 20 * np.log10(overlap.sel(f=f, mode_index_0=mi0, mode_index_1=mi1).abs.item())
ax.text(mi0, mi1, f"{ovl_dB:.2g} dB", ha="center", va="center", color="tab:red")
ax.set_ylabel("Rib mode index")
ax.set_xlabel("Strip mode index")
ax.xaxis.set_label_position('top')
[9]:
freqs = strip.mode_solver.freqs
source_time = td.GaussianPulse(freq0=0.5 * (freqs[0] + freqs[-1]), fwidth=abs(freqs[0] - freqs[-1]))
src_gap = 0.5
mode_src = td.ModeSource(
center=(-0.5 * length - src_gap, 0, 0),
size=(0, td.inf, td.inf),
source_time=source_time,
num_freqs=5,
direction="+",
mode_spec=strip.mode_spec,
mode_index=0,
)
strip_mnt = strip.mode_solver.to_monitor(freqs=freqs, name="strip")
rib_mnt = rib.mode_solver.to_monitor(freqs=freqs, name="rib")
field_mnt = td.FieldMonitor(
center=(0, 0, 0.5 * strip.core_thickness),
size=(td.inf, td.inf, 0),
freqs=freqs,
name="field",
)
sim_size = (length + 2 * src_gap, strip.width, strip.height)
sim_center = (0, 0, strip.mode_solver.plane.center[2])
sim = td.Simulation(
size=sim_size,
center=sim_center,
grid_spec=td.GridSpec.auto(min_steps_per_wvl=20),
structures=strip.structures + rib.structures,
sources=[mode_src],
monitors=[strip_mnt, rib_mnt, field_mnt],
run_time=1e-12,
boundary_spec=td.BoundarySpec.all_sides(boundary=td.PML()),
)
fig, ax = pyplot.subplots(2, 2, figsize=(11, 10), tight_layout=True)
sim.plot(z=0.5 * strip.core_thickness, ax=ax[0, 0])
sim.plot(z=0.5 * rib.slab_thickness, ax=ax[0, 1])
sim.plot(x=-0.5 * length, ax=ax[1, 0])
sim.plot(x=0.5 * length, ax=ax[1, 1])
pyplot.show()
[10]:
# Run the simulation and download the resulting data
data = web.run(sim, task_name="untapered", verbose=True)
View task using web UI at webapi.py:141 'https://tidy3d.simulation.cloud/workbench?taskId=fdve-28ced38d-a679-4142-bb90-9aded21b7c8 dv1'.
[11]:
_ = data.plot_field("field", "Hz", val="abs", f=f)
Looking at the power transmisison, we see almost the same result as obtained from the overlap calculation:
[12]:
rib_transmission = data["rib"].amps.sel(direction="+", mode_index=0)
fig, ax = pyplot.subplots(1, 1)
ax.plot(rib.wavelength, 20 * np.log10(rib_transmission.abs.values), '.-')
ax.set(
xlabel="Wavelength (μm)",
ylabel="Transmission (dB)",
ylim=(-0.1, 0),
)
ax.grid()
We can look at the first quasi-TM mode as well:
[13]:
# mode_src_tm = mode_src.copy(update={"mode_index": 1})
mode_src_tm = td.ModeSource(
center=(-0.5 * length - src_gap, 0, 0),
size=(0, td.inf, td.inf),
source_time=source_time,
num_freqs=5,
direction="+",
mode_spec=strip.mode_spec,
mode_index=1,
)
sim_tm = sim.copy(update={"sources": [mode_src_tm]})
data_tm = td.web.run(sim_tm, task_name="untapered_tm", verbose=True)
_ = data_tm.plot_field("field", "Ez", val="abs", f=f)
View task using web UI at webapi.py:141 'https://tidy3d.simulation.cloud/workbench?taskId=fdve-cc1467cf-b55d-413d-aa5e-7ab1e7d24bb 4v1'.
[14]:
rib_transmission = data_tm["rib"].amps.sel(direction="+", mode_index=1)
strip_reflection = data_tm["strip"].amps.sel(direction="-", mode_index=1)
fig, ax = pyplot.subplots(1, 1)
ax.plot(rib.wavelength, 20 * np.log10(rib_transmission.abs.values), '.-', label="Transmission")
ax.plot(rib.wavelength, 20 * np.log10(strip_reflection.abs.values), '.-', label="Reflection")
ax.set(
xlabel="Wavelength (μm)",
ylabel="Power (dB)",
ylim=(None, 0),
)
ax.legend()
ax.grid()
Waveguide Bends#
Waveguide bends can be modeled by setting the appropriate attributes in the mode specification.
[15]:
bend = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.22,
core_medium=si,
clad_medium=sio2,
mode_spec=td.ModeSpec(
num_modes=1,
bend_radius=5,
bend_axis=1,
num_pml=(12, 12),
precision="double",
),
)
fig, ax = pyplot.subplots(1, 1, tight_layout=True)
bend.plot_field("Ey", mode_index=0, ax=ax)
print(f"Complex effective index: {bend.n_complex.item():g}")
Complex effective index: 2.53244+4.25036e-05j
Let’s create a helper function to convert the imaginary part of the complex effective index into loss in dB/cm:
[16]:
def loss_dB_per_cm(wg):
alpha = 2 * np.pi * wg.n_complex.imag / wg.wavelength # µm⁻¹
return 1e4 * 20 * np.log10(np.e) * alpha # dB/cm
print(f"Curvature loss: {loss_dB_per_cm(bend).item():.1f} dB/cm")
Curvature loss: 15.0 dB/cm
We can put it all together to plot loss as a function of bend radius:
[17]:
radii = 5 * 10 ** np.linspace(0, 1, 10)
bends = [
waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.22,
core_medium=si,
clad_medium=sio2,
mode_spec=td.ModeSpec(
num_modes=1,
bend_radius=radius,
bend_axis=1,
num_pml=(12, 12),
precision="double",
),
) for radius in radii
]
[18]:
fig, ax = pyplot.subplots(1, 2, figsize=(11, 4), tight_layout=True)
ax[0].plot(radii, [wg.n_eff.item() for wg in bends], ".-")
ax[0].set_xlabel("Bend radius (μm)")
ax[0].set_ylabel("Effective index")
ax[0].grid()
ax[1].plot(radii, [loss_dB_per_cm(wg).item() for wg in bends], ".-")
ax[1].set_xlabel("Bend radius (μm)")
ax[1].set_ylabel("Curvature loss (dB/cm)")
ax[1].grid()
Coupled Waveguides#
The RectangularDielectric
class supports modeling coupled waveiguides by passing an array of core widths (and a corresponding array of gaps between adjacent cores).
[19]:
coupled = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=(0.5, 0.5),
core_thickness=0.22,
core_medium=si,
clad_medium=sio2,
gap = 0.15,
sidewall_angle=np.pi / 18,
mode_spec=td.ModeSpec(
num_modes=4,
precision="double",
),
)
_ = coupled.plot_structures(x=0)
[20]:
# Mode data
print(f"Effective indices: {coupled.n_eff.values}")
print(f"Effective mode areas (µm²): {coupled.mode_area.values}")
fig, ax = pyplot.subplots(2, 2, figsize=(10, 7), tight_layout=True)
coupled.plot_field("Ey", mode_index=0, ax=ax[0, 0])
ax[0, 0].set_title("Ey (q-TE symmetric)")
coupled.plot_field("Ey", mode_index=1, ax=ax[0, 1])
ax[0, 1].set_title("Ey (q-TE anti-symmetric)")
coupled.plot_field("Ez", mode_index=2, ax=ax[1, 0])
ax[1, 0].set_title("Ez (q-TM symmetric)")
coupled.plot_field("Ez", mode_index=3, ax=ax[1, 1])
ax[1, 1].set_title("Ez (q-TM anti-symmetric)")
pyplot.show()
Effective indices: [[2.58790025 2.55348271 1.98156471 1.85005072]]
Effective mode areas (µm²): [[0.36718224 0.35510481 0.60730776 0.58347975]]
In a similar fashion, vertical slot waveguides can also be simulated easily:
[21]:
slot = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=(0.22, 0.22),
core_thickness=0.22,
core_medium=si,
clad_medium=sio2,
gap = 0.06,
mode_spec=td.ModeSpec(
num_modes=1,
precision="double",
),
)
fig, ax = pyplot.subplots(1, 3, figsize=(11, 4), tight_layout=True)
slot.plot_structures(x=0, ax=ax[0])
# We use 'robust=False' because we're interested in the large values at the slot
slot.plot_field("E", val="abs", ax=ax[1], robust=False)
# Plot a cross-section of the field component normal to the gap
ey = slot.mode_solver.data.Ey
_ = ey.squeeze(drop=True).sel(z=0.55 * slot.core_thickness, method='nearest').real.plot(ax=ax[2])
Surface Models#
Besides using lossy materials for all waveguide regions (core, and upper and lower claddings), it is also possible to create separate medium layers along the sidewalls and top surfaces of the waveguide to model localized losses independently.
In the following models, we exagerate those regions and decrease the domain size only to show a close-up of the resulting geometry. Decreasing the domain size is only advisable if we know the modes will have properly decaied to insignificant values at the domain boundaries. Also note that the colors in each plot correspond to different materials.
[22]:
fig, ax = pyplot.subplots(2, 2, figsize=(10, 7), tight_layout=True)
lossy0 = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.25,
core_medium=si,
box_medium=sio2,
clad_medium=td.Medium(permittivity=1.0),
gap = 0.15,
sidewall_angle=np.pi / 12,
surface_thickness=0.03,
surface_medium=td.Medium.from_nk(n=3.4, k=0.008, freq=td.C_0 / 1.55),
side_margin=0.3,
clad_thickness=0.3,
box_thickness=0.3,
)
lossy0.plot_structures(x=0, ax=ax[0, 0])
ax[0, 0].set_title("Strip with surface layer")
lossy1 = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.25,
slab_thickness=0.1,
core_medium=si,
box_medium=sio2,
clad_medium=td.Medium(permittivity=1.0),
gap = 0.15,
sidewall_angle=np.pi / 12,
surface_thickness=0.03,
surface_medium=td.Medium.from_nk(n=3.4, k=0.008, freq=td.C_0 / 1.55),
side_margin=0.3,
clad_thickness=0.3,
box_thickness=0.3,
)
lossy1.plot_structures(x=0, ax=ax[0, 1])
ax[0, 1].set_title("Rib with surface layer")
lossy2 = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.25,
core_medium=si,
box_medium=sio2,
clad_medium=td.Medium(permittivity=1.0),
gap = 0.15,
sidewall_angle=np.pi / 12,
sidewall_thickness=0.05,
sidewall_medium=td.Medium.from_nk(n=3.2, k=0.01, freq=td.C_0 / 1.55),
side_margin=0.3,
clad_thickness=0.3,
box_thickness=0.3,
)
lossy2.plot_structures(x=0, ax=ax[1, 0])
ax[1, 0].set_title("Strip with sidewall layer")
lossy3 = waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.25,
slab_thickness=0.1,
core_medium=si,
box_medium=sio2,
clad_medium=td.Medium(permittivity=1.0),
gap = 0.15,
sidewall_angle=np.pi / 12,
sidewall_thickness=0.05,
sidewall_medium=td.Medium.from_nk(n=3.2, k=0.01, freq=td.C_0 / 1.55),
surface_thickness=0.03,
surface_medium=td.Medium.from_nk(n=3.4, k=0.008, freq=td.C_0 / 1.55),
side_margin=0.3,
clad_thickness=0.3,
box_thickness=0.3,
)
lossy3.plot_structures(x=0, ax=ax[1, 1])
_ = ax[1, 1].set_title("Rib with both layers")
A Note about Accuracy#
By default, the waveguide class uses grid_resolution = 15
. This value is enough for quick mode solving with effective indices relatively accurate (usually within 10% of the best estimate). If higher accuracy is desired, grid_resolution
can be increased to higher values, for example, to improve the calculation of derived values (group index, coupling length, mode losses, etc.).
[23]:
grid_resolution = np.arange(15, 46, 3)
n_eff = np.squeeze(
[
waveguide.RectangularDielectric(
wavelength=1.55,
core_width=0.5,
core_thickness=0.22,
core_medium=si,
clad_medium=sio2,
grid_resolution=res,
).n_eff.values
for res in grid_resolution
]
)
[24]:
_, ax = pyplot.subplots(1, 1)
ax.plot(grid_resolution, n_eff, ".-")
ax.legend(["TE", "TM"])
ax.set(xlabel="Grid resolution", ylabel="Effective index")
ax.grid()
Note that even for higher resolutions, the local mode solver will still oscillate around the best esimate. That’s an effect of the grid discretization of the simulation domain, which varies with the resolution. For the best results, the server-side mode solver should be prefered.