How do I set the mode solver?

How do I set the mode solver?#



2023-12-18 11:05:43

Mode Solver

Use the Tidy3D mode solver to perform optical mode analysis and obtain information such as mode effective index (real and imaginary parts), group index, effective area, polarization fraction, and field distribution. To illustrate how to set up a mode solver, let’s consider the case of a silicon-on-insulator (SOI) waveguide operating at 1.55 \(\mu\)m.

# Define the waveguide.
waveguide = tidy3d.Structure(
    geometry=tidy3d.Box(size=(tidy3d.inf, 0.5, 0.22)),

# Build a simulation object including the waveguide.
sim = tidy3d.Simulation(
    size=(10, 2.5, 1.5),, wavelength=1.55),

You can use a Box object to define the plane where you want to solve the modes. In this example, we use a plane perpendicular to the waveguide propagation axis. Symmetries are applied if they are defined in the simulation and the mode plane center sits on the simulation center. Then, use the tidy3d.ModeSpec object to specify the number of modes (num_modes), the initial effective index guess (target_neff), polarization, and other characteristics of the modes you are looking for. Make group_index_step=True to enable mode group index calculation.

# Plane we want to solve the modes.
plane = tidy3d.Box(center=(0, 0, 0), size=(0, 2.5, 1.5))

# Mode specification.
mode_spec = tidy3d.ModeSpec(

Now you can create and execute the mode solver, which returns the results in a ModeSolverData object. For more details on how to set up, run, and visualize the solver results, please refer to this notebook.

from tidy3d.plugins.mode import ModeSolver
from tidy3d.plugins.mode.web import run as run_mode_solver

# Build the mode solver.
freq0 = tidy3d.C_0 / 1.55
mode_solver = ModeSolver(

# Run the server-side mode solver.
mode_data = run_mode_solver(mode_solver)

If you prefer, you can run the local version of mode solver through the code mode_data=mode_solver.solve(). This means that the solver will run on your own computer and will not require any credits. However, it’s important to note that the local version will not include the group index calculation or subpixel smoothing, even if these options are specified in the simulation. As a result, the local version’s results will not perfectly match the server-side ones.