Skip to content

Fabrication-Aware Simulation: Two Coupled Ring Resonator Filter

Download notebook (.zip)

In this notebook we demonstrate how we can perform fabrication-aware simulations in PhotonForge by modeling a 2-ring coupled resonator filter and running a Monte Carlo analysis on key process-variation parameters. We focus on variations in the coupler gap, silicon wafer thickness, and sidewall angle, then visualize their impact on spectral response.

We use the couple mode theory presented in [1] for the filter design.

References

  1. Little, Brent E., et al. “Microring resonator channel dropping filters.” Journal of lightwave technology 1997 15 (6), 998-1005, doi: 10.1109/50.588673.
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import photonforge as pf
import tidy3d as td
from scipy.signal import find_peaks
# Reduce non-critical Tidy3D logs to keep the notebook output clean
td.config.logging.level = "ERROR"

Setting Up Technology and Simulation Defaults

Section titled “Setting Up Technology and Simulation Defaults”

Here we load and configure the default technology, mesh, and wavelength settings that will be used throughout the notebook.
We start from PhotonForge’s basic technology, set it as the default, and define a bending radius and port specification. We also fix a mesh refinement level and specify the simulation wavelength range around 1.55 µm — the telecom C-band region where most silicon photonic devices operate.

# Load the basic technology
tech = pf.basic_technology()
# Set this as the default technology for all subsequent components
pf.config.default_technology = tech
# Extract the standard single-mode strip waveguide port specification
port_spec = tech.ports["Strip"]
# Set some default parameters for all components (e.g., bend radius)
pf.config.default_kwargs = {
"radius": 5, # bend radius in microns
"port_spec": port_spec,
}
# Define the default mesh refinement level
pf.config.default_mesh_refinement = 15
# Define the wavelength range for optical simulations [µm]
wavelengths = np.linspace(1.543, 1.557, 401)

We define a parametric function to build a two coupled ring resonator (2-RR) filter using PhotonForge primitives. The function instantiates two types of couplers — a bus-to-ring coupler and a ring-to-ring coupler — and then stitches them with a netlist that sets up instances, interconnects ports, and exposes the device I/O.

What we parameterize

  • coupling_length: the straight interaction length in the couplers, controlling the coupling coefficient.
  • bus_coupling_distance: the nominal gap between the bus waveguide and each ring.
  • ring_coupling_distance: the nominal gap between the two rings in the inter-ring coupler.

Netlist assembly We instantiate:

  • Two bus couplers (bus_coupler0, bus_coupler1)
  • One ring-to-ring coupler (ring_coupler0)

We then connect their ports to form the 2-RR filter topology and publish four external ports.

Finally, we build the component from the netlist and create a default instance for quick visualization.

Flat-Top (Maximally-Flat) Design Condition

Section titled “Flat-Top (Maximally-Flat) Design Condition”

To achieve a flat-top (maximally-flat) passband in the two-ring add–drop filter (with identical rings), we choose the coupling gaps such that the bus-to-ring and ring-to-ring coupling coefficients satisfy the synthesis relation derived in [1]:

κint=12κext2\kappa_{\text{int}} = \frac{1}{2} \kappa_{\text{ext}}^2

where:

  • κext\kappa_{\text{ext}} — bus-to-ring (external) power coupling coefficient (κext≈0.4\kappa_{\text{ext}} \approx 0.4 in our design)
  • κint\kappa_{\text{int}} — ring-to-ring (internal) power coupling coefficient (κint≈0.08\kappa_{\text{int}} \approx 0.08 in our design)

This condition ensures a maximally-flat spectral response by properly balancing external and internal coupling strengths.

@pf.parametric_component
def create_two_rr_filter(
*,
coupling_length: float = 13.5,
bus_coupling_distance: float = 0.7,
ring_coupling_distance: float = 0.81,
) -> pf.Component:
"""
Build a 2-ring (2RR) filter from parametric couplers and return the component.
"""
# Parametric subcomponents
bus_to_ring = pf.parametric.dual_ring_coupler(
coupling_distance=bus_coupling_distance,
coupling_length=coupling_length,
model=pf.Tidy3DModel(
verbose=False,
port_symmetries=[
("P1", "P0", "P3", "P2"),
("P2", "P3", "P0", "P1"),
("P3", "P2", "P1", "P0"),
],
),
)
ring_to_ring = bus_to_ring.copy().update(coupling_distance=ring_coupling_distance)
# Netlist for assembling the 2RR resonator
netlist_2RR = {
"name": "filter",
"instances": {
"bus_coupler0": bus_to_ring,
"bus_coupler1": bus_to_ring,
"ring_coupler0": ring_to_ring,
},
"connections": [
(("ring_coupler0", "P0"), ("bus_coupler0", "P1")),
(("bus_coupler1", "P3"), ("ring_coupler0", "P1")),
],
"ports": [
("bus_coupler0", "P0"),
("bus_coupler1", "P2"),
("bus_coupler0", "P2"),
("bus_coupler1", "P0"),
],
"models": [pf.CircuitModel()],
}
two_rr = pf.component_from_netlist(netlist_2RR)
return two_rr
two_rr = create_two_rr_filter()
two_rr
Layout
Schematic

We now compute and visualize the spectral characteristics of the designed 2-RR filter.

# Compute the scattering matrix (S-matrix) of the 2RR filter across wavelengths
s_matrix_2rr = two_rr.s_matrix(frequencies=pf.C_0 / wavelengths)
# Plot the S-matrix with input from port P0, showing response in dB
_ = pf.plot_s_matrix(s_matrix_2rr, input_ports=["P0"])
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-f3c3f61c-81f7-4d11-8fb4-dcbcd497148a
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-ad664edf-bfad-4310-96b4-f4d59873ae33
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…

To evaluate fabrication tolerance and yield, we perform a Monte Carlo simulation on the 2-RR filter.
Each sample randomly perturbs selected geometric and material parameters within specified distributions, emulating real-world process variations.

Parameters under variation

  • core_thickness (technology): silicon layer thickness, mean 0.22 µm with a 3 nm standard deviation
  • sidewall_angle (technology): etched sidewall deviation, uniformly sampled between 0° and 5°
  • bus_coupling_distance (component): coupling gap between bus and ring, mean 0.7 µm with 10 nm σ
  • ring_coupling_distance (component): gap between rings, mean 0.79 µm with 10 nm σ

We include both random and corner samples to span statistical variability and worst-case scenarios.
The resulting dataset contains a list of parameter realizations and their corresponding S-matrices.

# Run a Monte Carlo S-matrix analysis to capture fabrication-induced variations
var, results = pf.monte_carlo.s_matrix(
two_rr,
pf.C_0 / wavelengths,
("core_thickness", "technology", {"value": 0.22, "stdev": 0.003}),
("sidewall_angle", "technology", {"value_range": [0, 5]}),
("bus_coupling_distance", two_rr, {"value": 0.7, "stdev": 0.01}),
("ring_coupling_distance", two_rr, {"value": 0.81, "stdev": 0.01}),
random_samples=20, # number of random samples
corner_samples=2, # corner cases (extreme combinations)
random_seed=0,
show_progress=True,
)
Starting sample 1 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Starting sample 2 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Starting sample 3 of 22…
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-575d7f01-ca91-4e13-bc3d-e2c923bfe5e7
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-83abcf21-10de-48ec-806e-dc408dbb7f66
Uploading task 'Mode-Stripwaveguide…'
Starting sample 4 of 22…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-7fc363e2-1295-4080-942b-0610ec2aa92b
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-bc9de9a7-ee70-45da-b66a-13d8a3664493
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Starting sample 5 of 22…
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-f78de62a-1d44-4994-8e34-15d0f8a37604
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-032653e6-2f86-4339-8cc0-619e1db38085
Starting sample 6 of 22…
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-0847d749-00fa-4312-9dc7-c4ec51953699
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-f3b0d750-2f43-4f00-84cf-227e089bb99f
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting sample 7 of 22…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-d31a0dae-7534-44ea-99d7-6ce082922dd4
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-e5e2e168-099e-44a7-a8f2-2bdd82d4d637
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-946910af-0d0b-4924-b529-1121d16b8c0b
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-be4fba47-e55e-42aa-b93a-e55155e20f49
Downloading data from 'Mode-Stripwaveguide'…
Starting sample 8 of 22…
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-2f5b5bd2-e24d-4e80-bbc6-c26363f8d68a
Starting sample 9 of 22…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-12056518-33b5-47ba-bec3-c1ea2b1339b2
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-1f48d1fc-9607-4ac3-bff9-f17893509cd2
Starting sample 10 of 22…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-7b094350-d777-4051-b9bf-208efa2d706d
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting sample 11 of 22…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-d93c58ea-9471-416b-aaf7-19ef9c4c221d
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-f18a9714-30bf-4838-9515-b69de7cc8758
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-bbaf67a7-9380-40df-b190-5f7290687e86
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-a76d6c46-358a-4dce-abac-e08f24aebabd
Starting sample 12 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-2731cb82-ebd4-4b9e-b962-c31d3125893f
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-8ad2d9f8-fc20-4114-9881-f9685f623093
Starting sample 13 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-858b1841-c8b7-49f3-8f26-6db82899f641
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-f1cf542e-7859-45dd-be80-4613055eb030
Starting sample 14 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-29875823-8202-4c5e-aa82-4755a1697f0b
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-0077f4e5-bc88-41b1-a5c5-27baa89dab63
Starting sample 15 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-51de80c5-f1f6-4812-ad4a-32e3123a7661
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-4fb704e1-b6cb-4d43-949c-5ff95880b3ee
Starting sample 16 of 22…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-eebde97c-c9a0-4734-92b3-a49030d68d89
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-e0cd59f5-f201-477c-9c2d-feec5849ebdb
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Starting sample 17 of 22…
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-0bae2bb4-8e7d-469c-b906-8254ec1454c4
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-e0668bc1-79df-4437-aef5-6293275f0282
Starting sample 18 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-df9dcea2-d466-416c-ad8e-25b2d009b0f2
Starting sample 19 of 22…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-332b6337-5a0a-4a02-9f89-5683617418ce
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-6bbeacdf-9ed5-4f2e-b8d1-24986a023faf
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-fe2bf4cd-5fd8-4abe-850c-9f05336f95e8
Downloading data from 'Mode-Stripwaveguide'…
Starting sample 20 of 22…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Downloading data from 'Mode-Stripwaveguide'…Downloading data from 'Mode-Stripwaveguide'…
Starting sample 21 of 22…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-f898902b-c3ed-4e2a-87b0-8b0bac462362
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-0d5633f1-7315-4b60-88df-da97b36b7d92
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Starting sample 22 of 22…
Downloading data from 'Mode-Stripwaveguide'…
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-7be33bd9-f9dc-4187-a979-0d474a6b50e6
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-1883c29d-1331-4905-9fd3-d2c483cffbb9
Downloading data from 'Mode-Stripwaveguide'…
Uploading task 'Mode-Stripwaveguide…'
Uploading task 'Mode-Stripwaveguide…'
Sample 1 done.
Sample 2 done.
Sample 3 done.
Sample 4 done.
Sample 5 done.
Sample 6 done.
Sample 7 done.
Sample 8 done.
Sample 9 done.
Sample 10 done.
Sample 11 done.
Sample 12 done.
Sample 13 done.
Sample 14 done.
Sample 15 done.
Sample 16 done.
Sample 17 done.
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-6eeb2aea-47e9-4697-87af-db4622c6821e
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-e82a59f1-b7f2-498e-98fc-142afade2ba8
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Sample 18 done.
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-16121d69-f2fe-4643-9447-400e5ba5e41c
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Sample 19 done.
Starting task 'Mode-Stripwaveguide': https://tidy3d.simulation.cloud/workbench?taskId=mo-cb4a5411-4f98-40f4-87b7-4efcf8ec2972
Downloading data from 'Mode-Stripwaveguide'…
Downloading data from 'Mode-Stripwaveguide'…
Sample 20 done.
Sample 21 done.
Sample 22 done.
All samples done!

We now plot the transmission spectra from port P0 (input) to port P3 (drop port) for all Monte Carlo samples.
Each curve represents one possible fabricated instance of the 2-RR filter, allowing us to observe the spread in resonance wavelength and insertion loss due to process variations.

fig, ax = plt.subplots(1, 1)
for *_, s_matrix in results:
ax.plot(
s_matrix.wavelengths,
20 * np.log10(np.abs(s_matrix[("P0@0", "P3@0")])),
alpha=0.5,
color="tab:orange",
)
_ = ax.set(ylim=(-20, 0), xlabel="λ (µm)", ylabel="Transmission (dB)")

The Monte Carlo simulation shows that fabrication variations can significantly impact the spectral response of the 2-RR filter:

  • Resonance wavelength drift:
    The resonance positions vary substantially between samples, indicating that small deviations in silicon thickness, sidewall angle, or coupling gaps lead to noticeable phase shifts and effective index changes.
    This explains why thermal tuning (via integrated heaters) is almost always required in fabricated ring filters to fine-tune or align the resonance wavelengths post-fabrication.

  • Insertion loss variation:
    The simulated through-port transmission fluctuates between approximately 0.3 dB and 1.0 dB, demonstrating that while loss performance changes slightly, the filter remains fairly robust to process deviations in this respect.

Overall, the analysis illustrates how PhotonForge’s fabrication-aware modeling can predict both resonance misalignment and performance spread, allowing designers to anticipate tuning requirements and optimize yield.

Monte Carlo analysis allows for the extraction of correlations between a device’s response and its input variables. This section demonstrates the correlation analysis process. Critically, accurate results with four input variables require hundreds of data points. The findings presented here are, therefore, purely illustrative and not statistically significant.

In this section we extract three filter features from each simulated S-matrix so we can study their correlation with fabrication variables. We target the resonance closest to a reference wavelength λ0\lambda_0 (default 1.55μ1.55 \mum) and compute:

  • Center wavelength λc\lambda_c: the midpoint between the two 3-dB crossing wavelengths around the chosen resonance.
  • Insertion loss IL (in dB): transmission value at the center wavelength.
  • 3-dB bandwidth Δλ3,dB\Delta\lambda_{3,\text{dB}}: difference between the right and left 3-dB crossing wavelengths.
def extract_filter_features(s_matrix, target_wavelength=1.55):
"""
Extracts key features (insertion loss, center wavelength, bandwidth)
from an optical filter's S-matrix data.
This function identifies the resonance dip closest to a target wavelength
and calculates its characteristics.
Args:
s_matrix: The S-matrix object from the simulation.
target_wavelength (float): The wavelength (in µm) around which to
search for the primary resonance.
Defaults to 1.55 µm.
Returns:
dict: A dictionary containing the calculated 'center_wavelength',
'insertion_loss' (in dB), and 'bandwidth' (in µm).
Returns None if no resonance is found.
"""
wavelengths = s_matrix.wavelengths
# Calculate transmission in dB
transmission_db = 20 * np.log10(np.abs(s_matrix[("P0@0", "P3@0")]))
# The 'prominence' parameter helps ignore minor ripples and noise.
peak_indices, _ = find_peaks(transmission_db, prominence=1)
if peak_indices.size == 0:
print("Warning: No resonance peaks found.")
return None
# Find the peak/resonance closest to the target wavelength
resonant_wavelengths = wavelengths[peak_indices]
closest_peak_index = peak_indices[
np.argmin(np.abs(resonant_wavelengths - target_wavelength))
]
# --- 1. Calculate Maximum Transmission Wavelength and Insertion Loss ---
max_wavelength = wavelengths[closest_peak_index]
insertion_loss = transmission_db[closest_peak_index]
# --- 2. Calculate 3-dB Bandwidth ---
# The 3-dB level is 3 dB below the maximum transmission value (the IL)
three_db_level = insertion_loss - 3
# Find where the transmission crosses the 3-dB level on both sides of the resonance
# Split the transmission data at the resonance point
left_side = transmission_db[:closest_peak_index]
right_side = transmission_db[closest_peak_index:]
# Find the indices where the transmission is greater than the 3-dB level
left_indices_below_3db = np.where(left_side < three_db_level)[0]
right_indices_below_3db = np.where(right_side < three_db_level)[0]
if left_indices_below_3db.size == 0 or right_indices_below_3db.size == 0:
bandwidth = np.nan # Use NaN for cases where bandwidth can't be found
else:
# Get the points just before and after the crossing
left_cross_idx = left_indices_below_3db[-1]
right_cross_idx = right_indices_below_3db[0] + closest_peak_index
# Interpolate to find the exact wavelength at the 3dB crossing for better accuracy
w_left = np.interp(
three_db_level,
[transmission_db[left_cross_idx], transmission_db[left_cross_idx + 1]],
[wavelengths[left_cross_idx], wavelengths[left_cross_idx + 1]],
)
w_right = np.interp(
three_db_level,
[transmission_db[right_cross_idx - 1], transmission_db[right_cross_idx]],
[wavelengths[right_cross_idx - 1], wavelengths[right_cross_idx]],
)
# Compute bandwidth and center wavelength from crossings
bandwidth = w_right - w_left
center_wavelength = (w_right + w_left) / 2
insertion_loss = transmission_db[(left_cross_idx + right_cross_idx) // 2]
return {
"center_wavelength": center_wavelength,
"insertion_loss": insertion_loss,
"bandwidth": bandwidth,
}

In this section we take the Monte Carlo results and visually explore how each fabrication parameter affects the main filter features.
We generate a grid of scatter plots, one for each input–output pair, annotated with the Pearson correlation coefficient (R).

Interpretation

  • R ≈ +1: Strong positive correlation — as the fabrication parameter increases, the feature value increases.
  • R ≈ -1: Strong negative correlation — the feature decreases as the parameter increases.
  • R ≈ 0: Weak or no linear correlation.

This visualization allows us to directly identify which fabrication tolerances most strongly impact spectral behavior such as resonance shift, insertion loss, or bandwidth broadening.

Important note: The correlation results shown here are intended for demonstration only and are not statistically valid because of small number of data points.

def run_correlation_analysis(variables, simulation_results, target_wavelength=1.55):
"""
Processes Monte Carlo simulation results to visualize the relationship
and correlation between each input variable and each output filter feature.
Args:
variables (list): The list of RandomVariable objects from the simulation.
simulation_results (list): The list of result tuples from the simulation.
Each tuple contains the input values and the s_matrix.
target_wavelength (float): The target wavelength in micrometers.
"""
data = []
variable_names = [v.name for v in variables]
print("Processing simulation results...")
for result in simulation_results:
s_matrix = result[-1]
input_values = result[:-1]
features = extract_filter_features(
s_matrix, target_wavelength=target_wavelength
)
if features:
run_data = {name: val for name, val in zip(variable_names, input_values)}
run_data.update(features)
data.append(run_data)
if not data:
print("Could not extract features from any simulation run. Aborting.")
return
print(f"Successfully processed {len(data)} data points.")
df = pd.DataFrame(data)
df["center_wavelength"] *= 1e3
df["bandwidth"] *= 1e3
df = df.rename(
columns={
"center_wavelength": "center_wavelength_nm",
"bandwidth": "bandwidth_nm",
}
)
print("\n--- Data Head ---")
print(df.head())
output_feature_names = ["insertion_loss", "center_wavelength_nm", "bandwidth_nm"]
print("\n--- Generating Custom Scatter Plot Grid with Correlation Values ---")
n_outputs = len(output_feature_names)
n_inputs = len(variable_names)
fig, axes = plt.subplots(
n_outputs, n_inputs, figsize=(10, 8), sharex="col", sharey="row"
)
if n_outputs == 1 or n_inputs == 1:
axes = np.array(axes).reshape(n_outputs, n_inputs)
for i, out_feature in enumerate(output_feature_names):
for j, in_variable in enumerate(variable_names):
ax = axes[i, j]
ax.scatter(
df[in_variable],
df[out_feature],
alpha=0.6,
s=30,
edgecolor="k",
linewidth=0.5,
)
corr = df[in_variable].corr(df[out_feature])
corr_text = f"R = {corr:.2f}"
ax.text(
0.05,
0.95,
corr_text,
transform=ax.transAxes,
fontsize=12,
verticalalignment="top",
bbox=dict(boxstyle="round,pad=0.3", facecolor="wheat", alpha=0.5),
)
if j == 0:
ax.set_ylabel(out_feature, fontsize=12)
if i == n_outputs - 1:
ax.set_xlabel(in_variable, fontsize=12)
ax.tick_params(axis="x", rotation=45)
ax.grid(True, linestyle="--", alpha=0.6)
fig.suptitle("Output Features vs. Input Variables", fontsize=20)
plt.tight_layout(rect=[0, 0.03, 1, 0.97])
plt.show()
run_correlation_analysis(var, results)
Processing simulation results...
Successfully processed 22 data points.
--- Data Head ---
sidewall_angle core_thickness ring_coupling_distance \
0 5.000000 0.225880 0.829600
1 0.000000 0.214120 0.790400
2 4.517759 0.218700 0.817602
3 4.244655 0.219547 0.792679
4 2.785838 0.219909 0.808466
bus_coupling_distance center_wavelength_nm insertion_loss bandwidth_nm
0 0.719600 1551.269666 -0.437801 0.960668
1 0.680400 1553.621434 -0.432439 1.577132
2 0.699238 1549.720321 -0.360124 1.189357
3 0.713226 1550.306584 -0.744145 1.416833
4 0.703479 1548.111936 -0.212000 1.256127
--- Generating Custom Scatter Plot Grid with Correlation Values ---