This notebook is inspired by the work Y. Yao, et al., "Compact and Low-Insertion-Loss 1×N Power Splitter in Silicon Photonics," J. Lightwave Technol. 39, 6253-6259 (2021)DOI: 10.1109/JLT.2021.3098346. The device is a 1×8 multimode interference (MMI) power splitter on a 220 nm silicon-on-insulator (SOI) platform. Its input and output tapers are made of 10 segments of equal length, and the widths at the segment boundaries are the design variables. The paper optimizes these widths with a particle swarm optimization (PSO) driven by 3D FDTD simulations.
We reproduce the PSO of the paper and then optimize the same device with the adjoint method (inverse design), which also adjusts the length and the width of the MMI body. Both optimizations use the same FDTD simulation, the same starting point and the same number of iterations, so that the two methods can be compared on cost and on the quality of the result.
The device uses 220 nm SOI, 10 segments of 1 µm, an input width of 0.45 µm, widths bounded in [0.45, 1.20] µm and 8 outputs, at 1550 nm with the TE0 mode. The output tapers are centered at the N-fold self-imaging positions, \(y_q = (9/2 - q)\,W_\text{MMI}/8\), for the output ports \(q = 1, \dots, 8\).
import osimport timeimport autograd.numpy as anpfrom autograd.tracer import getvalimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport tidy3d as tdimport tidy3d.web as webimport tidy3d.plugins.design as tddfrom tidy3d.plugins.autograd import adam, optimize
Device and Simulation
The input taper starts as a 0.45 µm wide waveguide, changes width over 10 segments of 1 µm and ends at the MMI body. The eight output tapers are copies of the input taper rotated by 180 degrees. The widths \(w_{11}\) to \(w_{19}\) at the segment boundaries are the design variables, and \(w_{10} = 0.45\) µm is fixed. The width varies linearly inside each segment, and the last segment keeps the width \(w_{19}\). The tapers are built as PolySlab objects. The simulation uses a uniform \(\text{SiO}_2\) background (no substrate), a TE0 mode source, one ModeMonitor per output port, 10 grid points per wavelength and a symmetry plane at \(z = 0\).
The geometry functions accept both NumPy arrays and autograd arrays, so the same make_sim serves the PSO and the inverse design.
# device (Yao et al. 2021, Sec. II and Table I)N_OUT =8L_MMI0, W_MMI0 =27.7, 11.35# µmSEG_LEN =1.0# µm, segment lengthN_SEG =10# segments per taperL_TAPER = N_SEG * SEG_LENW_IN =0.45# µm, first segment (input waveguide width), fixedW_MIN, W_MAX =0.45, 1.20# µm, bounds of the free widths w11..w19H_SI =0.22# µmW_TABLE1 = np.array([0.45, 0.52, 0.68, 0.83, 0.85, 1.12, 0.87, 0.92, 0.91, 1.20]) # paper, 1x8# materialsN_SI, N_SIO2 =3.48, 1.444SI = td.Medium(permittivity=N_SI**2, name="Si")SIO2 = td.Medium(permittivity=N_SIO2**2, name="SiO2")# simulationLDA0 =1.55FREQ0 = td.C_0 / LDA0SPW =10# grid points per wavelengthRUN_TIME =5e-12L_IN =100.0# access waveguides extended into the PMLX_MIN, X_SRC =-1.0, -0.5Z_MIN, Z_MAX =-H_SI /2-2.0, H_SI /2+2.0# uniform SiO2 cladding, 2 µm above and below the SiY_PAD =2.0SYMMETRY = (0, 0, 1) # TE0: Ey even at z = 0MODE_SPEC = td.ModeSpec(num_modes=1, target_neff=N_SI)K_OUT = np.arange(N_OUT)[::-1] - (N_OUT -1) /2# +3.5 ... -3.5 (O1 at the top)FOLDER ="mmi1x8_pso_vs_invdes"
We plot the simulation with the widths of Table I of the paper, in the \(xy\) plane at \(z = 0\) and in the \(yz\) plane of the output monitors, and estimate the cost of one simulation.
cost of one simulation (FlexCredit): 0.2966706872592254
Particle Swarm Optimization
This is the method of the paper, run with the MethodParticleSwarm of the Tidy3D Design plugin, with the paper’s hyperparameters: 30 particles, inertia \(w = 1\), cognitive and social coefficients \(c_1 = c_2 = 2\), and widths bounded in [0.45, 1.20] µm. The objective is the paper’s figure of merit (Eq. 1),
where \(P_q\) is the TE0 power in output port \(q\). The numerator is the transmitted power and the denominator is the squared deviation from an equal split, so the FoM grows as the split becomes uniform and lossless.
Particles that leave the bounds are clipped to them (bh_strategy="nearest"), the velocity is limited to ±0.02 µm per iteration (velocity_clamp), and the initial positions and velocities are set explicitly (init_pos, init_velocity).
Each iteration runs the 30 simulations as one Batch. Every evaluation is appended to a CSV file, and pso_pre returns the stored value when a position has already been evaluated. The optimization is deterministic for a given seed, so a rerun replays the stored iterations without any simulation and only runs the missing ones; with the files saved with this notebook, the cell below runs no simulation.
N_PARTICLES, N_ITER =30, 55SEED =1DIM = N_SEG -1PSO_DIR ="assets/mmi1x8_pso"PSO_CSV = os.path.join(PSO_DIR, "evaluations.csv")os.makedirs(PSO_DIR, exist_ok=True)WCOLS = [f"w1{k +1}"for k inrange(DIM)]np.random.seed(SEED)X0 = np.random.uniform(W_MIN, W_MAX, (N_PARTICLES, DIM)) # initial swarm; X0[0] is also the inverse design startV0 = np.random.uniform(0, 1, (N_PARTICLES, DIM))cache = {} # position -> FoM, for the iterations stored completely in the CSVif os.path.exists(PSO_CSV): stored = pd.read_csv(PSO_CSV).drop_duplicates(["iter", "particle"], keep="first") complete = stored.groupby("iter").particle.count() == N_PARTICLESfor _, r in stored[stored["iter"].isin(complete[complete].index)].iterrows(): cache[tuple(np.round(r[WCOLS].to_numpy(float), 8))] =float(r.FoM)print("stored evaluations:", len(cache), f"({len(cache) // N_PARTICLES} complete iterations)")state_pso = {"n_eval": 0, "pending": []}def pso_pre(**w): pos =tuple(np.round([w[c] for c in WCOLS], 8)) state_pso["n_eval"] +=1if pos in cache:return cache[pos] state_pso["pending"].append((state_pso["n_eval"] -1, pos))return make_sim(np.concatenate([[W_IN], pos]))def pso_post(x):ifisinstance(x, float):return x P = port_powers(x) idx, pos = state_pso["pending"].pop(0) row = {"time": time.time(), "iter": idx // N_PARTICLES, "particle": idx % N_PARTICLES, "FoM": fom(P),"sumP": float(P.sum()), "w10": W_IN, **dict(zip(WCOLS, pos))} pd.DataFrame([row]).to_csv(PSO_CSV, mode="a", header=not os.path.exists(PSO_CSV), index=False) cache[pos] = row["FoM"]return row["FoM"]
The second method optimizes the same device with gradients. Tidy3D computes the gradient of the objective with respect to all design parameters from one forward and one adjoint simulation, whatever the number of parameters. Here the parameters are the nine free widths plus \(L_\text{MMI}\) and \(W_\text{MMI}\), which are left free so that the MMI body and the position of the output tapers can adjust together with the taper profile. The widths are mapped to [0.45, 1.20] µm through a hyperbolic tangent, and the parameters are updated with Adam (learning rate 0.1) through the optimize function of the autograd plugin.
Objective. The paper’s FoM is not a good objective for a gradient method. It is a ratio whose denominator goes to zero at the solution, so the FoM and its gradient grow without bound as the split becomes uniform. Instead, we use the squared deviation from an equal split,
\[J = -\sum_q (P_q - 1/N)^2,\]
which is bounded, has zero gradient at the solution and keeps the meaning of the denominator of the FoM. The transmitted power \(\sum_q P_q\) does not appear explicitly, but since each \(P_q\) is pushed toward \(1/N\), maximizing \(J\) also drives \(\sum_q P_q\) toward 1. The FoM of Eq. 1 is still computed at every step for comparison with the PSO.
The starting point is the first particle of the PSO swarm, with \(L_\text{MMI} = 27.7\) µm and \(W_\text{MMI} = 11.35\) µm.
It is interesting to note that both methods converge in a similar way during the first iterations. The inverse design is much cheaper, since each step costs only 2 simulations (one forward and one adjoint), but because it follows the gradient from the starting point, it can get trapped in a local minimum. The PSO is more expensive, with 30 simulations per iteration, but since its particles are spread over the design space, it can find other minima.
We use necessary cookies to run this website. With your permission, we
also use analytics cookies to understand site usage and marketing
cookies for advertising, retargeting, and HubSpot tracking.
Learn more about our cookie policy.
Privacy choices
Choose which optional cookies Flexcompute may use. Necessary cookies
are always on because they support core website behavior, security, and
saving your consent record.
Your browser is sending a Global Privacy Control signal, so marketing
cookies are disabled.
Subscribe
Publish Your Notebook
Thank you for publishingA confirmation email has been sent to your inbox. Your notebook will be available within the next 48 hours.
Community Library
TERMS & CONDITIONS
EFFECTIVE DATE: January 1, 2025
Terms and Conditions for User-Submitted Content
By submitting content to Flexcompute, you agree to the following terms:
1. Ownership and Copyright
All content, including but not limited to text, data, images, and other materials submitted by users,
remains the sole property of the original creator. Flexcompute does not claim ownership of the submitted
content or any intellectual property rights associated with it.
Users affirm that they own the copyright or have obtained all necessary permissions for the submitted
content and are fully responsible for ensuring that their submissions do not infringe on any third-party
rights.
2. Responsibility for Content
Users are solely responsible for the content they submit. Flexcompute does not endorse, guarantee,
or verify the accuracy, legality, or appropriateness of any submitted content. Users are responsible
for ensuring that their content complies with all applicable laws and regulations.
Users declare that they have obtained authorization from all co-authors and collaborators associated
with the submitted content, granting them the right to submit and sign on behalf of all contributors.
Users agree not to submit content that is illegal, defamatory, obscene, or violates the rights
of others, including privacy and intellectual property rights.
3. Modification and Presentation
Flexcompute reserves the right to review, edit, or modify submitted content to improve clarity,
formatting, and presentation while maintaining the original intent and message.
These modifications are made to enhance the overall quality and readability of the published material.
Users acknowledge that Flexcompute may format or present the content in a way
that aligns with our editorial and visual standards.
4. Liability Disclaimer
Flexcompute shall not be held liable for any disputes arising from user-submitted content, including
but not limited to copyright claims, inaccuracies, or damages resulting from the publication of user content.
Users agree to indemnify Flexcompute against any claims or legal actions resulting from their submitted content.
5. Content Use Rights
By submitting content, users grant Flexcompute a non-exclusive, royalty-free, worldwide license to publish, distribute,
and promote the content for the purposes of showcasing user contributions and marketing our services.
This license does not transfer ownership of the content or any copyright to Flexcompute.
Users retain the right to withdraw their submissions at any time.
Upon request, Flexcompute will remove the content from its platform.
6. Privacy and Confidentiality
Users acknowledge that submitted content may be publicly accessible and therefore waive any
rights to confidentiality or privacy regarding the published material.
Flexcompute will not share personal information of users without
their consent, in accordance with our privacy policy.
Community Library
How the process works:
You submit your notebook.
You will get a permanent URL to promote your work.
Cite the URL as a reference for others in your upcoming papers to enhance the impact.
When someone clicks your URL, your notebook will be displayed.
Enter your email address below to receive the presentation slides. In the future, we’ll share you very few emails when we have new tutorial release, development updates, valuable toolkits and technical guidance . You can unsubscribe at any time by clicking the link at the bottom of every email. We’ll never share your information.