OpticalSimulatorMODE
The OpticalSimulatorMODE is a mode solver built around the well-known commercial software Lumerical MODE. With this tool we can calculate the optical modes supported by our structure. We can retrieve the effective index, group index, and field profiles of the modes supported by our waveguide structure.
- class imodulator.OpticalSimulator.OpticalSimulatorMODE(device, simulation_window=None, include_metals=False, save_sim=False)
Base class for Mode simulation of a PhotonicDevice based on Lumerical MODE
- __init__(device, simulation_window=None, include_metals=False, save_sim=False)
Initialize the OpticalSimulatorMODE class for MODE simulation.
Creates geometry and material entities from the photonic device.
With every function call the state of the simulation after the function applied will be saved to the file quicksave.lms. quicksave.lms helps with chenking the state of the simulation and prevents multiple of mode simulations to reduce the system memory.
Way of working:
__init__(); runs
create_geometry(): creates polygons
create_materials(): creates the material in lumerical material library for each geometry object and assigns them accordingly. The rest will be run by the user to control the simulation parameters
create_fde(): sets the required simulation parameters & creates the simulation region”
compute_modes(): runs the simulation
select_modes() #select TE and TM mode index or it will be automatically chosen if the top two modes are the fundamental TE and TM mode
plot_modes() #plots the electric field magnitudes for TE and TM modes
- Args:
device: The photonic device to simulate simulation_window: The simulation window bounds. If None, uses device bounds include_metals: Whether to include metal polygons in simulation. Defaults to True save_sim: Whether to save simulation files. Defaults to False
Todo
Permitivity tensor to input n,k values? Not sure if necesary
- compute_modes()
Compute optical modes using the FDE solver.
- Parameters:
wavelength (float) – Operating wavelength in microns. Defaults to 1.55
voltage_idx (int) – Voltage index for electro-optic simulations. Defaults to 0
num_modes (int) – Number of modes to compute. Defaults to 4
order (int) – Mode order. Defaults to 1
return_modes (bool) – Whether to return mode data. Defaults to False
auto_select (bool) – Whether to auto-select TE/TM modes. Defaults to True
Runs the MODE findmodes() solver and optionally saves the simulation file with the device class name used.
- create_fde(num_modes=4, dx=2e-08, dy=1e-08, background_index=1, bc={'x max bc': 'PML', 'x min bc': 'PML', 'y max bc': 'PML', 'y min bc': 'PML'}, bounds=None)
Create and configure the Finite Difference Eigenmode (FDE) solver in Lumerical MODE.
Sets up a 2D Z-normal FDE solver with specified mesh parameters, boundary conditions, and simulation region. The solver will find eigenmode solutions for the waveguide cross-section defined by the device geometry.
- Parameters:
num_modes (int, optional) – Number of trial modes to calculate. The solver will attempt to find this many eigenmodes. Defaults to 4.
dx (float, optional) – Maximum mesh step size in the x-direction in meters. Smaller values give more accurate results but increase computation time. Defaults to 20e-9 (20 nm).
dy (float, optional) – Maximum mesh step size in the y-direction in meters. Smaller values give more accurate results but increase computation time. Defaults to 10e-9 (10 nm).
background_index (float, optional) – Background refractive index used as the initial guess for the mode search. Should be close to the expected effective index of the fundamental mode. Defaults to 1.
bc (dict, optional) – Boundary conditions for each edge of the simulation region. Keys should be “x min bc”, “x max bc”, “y min bc”, “y max bc”. Values can be “PML” (Perfectly Matched Layer), “Metal”, or “PMC” (Perfect Magnetic Conductor). Defaults to PML on all boundaries.
bounds (list or tuple, optional) – Custom simulation region bounds as [x_min, y_min, x_max, y_max] in meters. If None, automatically sets bounds based on the background polygon with 1 μm padding on all sides. Defaults to None.
- Returns:
Configures the FDE solver in the Lumerical MODE session.
- Return type:
None
Notes
The solver is configured for 2D Z-normal geometry (cross-section analysis)
Mesh is defined by maximum step size (“maximum mesh step” method)
Mode search uses “near n” method with the background_index as target
The “use max index” option is enabled for better convergence
Simulation state is automatically saved as “quicksave.lms”
Example
>>> # Basic usage with defaults >>> Mode.create_fde()
>>> # Custom mesh and more modes >>> Mode.create_fde(num_modes=8, dx=10e-9, dy=5e-9, background_index=3.2)
>>> # Custom boundary conditions >>> bc_custom = {"x min bc": "Metal", "x max bc": "Metal", ... "y min bc": "PML", "y max bc": "PML"} >>> Mode.create_fde(bc=bc_custom)
>>> # Custom simulation bounds (in meters) >>> bounds = [-10e-6, -5e-6, 10e-6, 5e-6] # 20x10 μm region >>> Mode.create_fde(bounds=bounds)
- plot_mode(figsize=(10, 5), color_polygons='white', show_polygons=True, aspect=None)
Plot TE and TM mode intensity distributions.
- Parameters:
figsize (
tuple[float,float] (default:(10, 5))) – Figure size (width, height). Defaults to (10,5)color_polygons (
str(default:'white')) – Color for polygon overlays. Defaults to “white”show_polygons (
bool(default:True)) – Whether to overlay device geometry. Defaults to Trueaspect (default:
None) – The aspect ratio of the Axes (‘equal’, ‘auto’, float, or None). This parameter is particularly relevant for images since it determines whether data pixels are square. Defaults to None.
- Returns:
(figure, (ax1, ax2)) - matplotlib figure and axes objects
- Return type:
tuple
Creates side-by-side plots of \(|E|^2\) intensity for TE and TM modes with optional device geometry overlay and colorbars.
- select_modes(auto_select=False, TE_TM_idx=None)
Select and extract TE and TM mode field data from simulation results.
- Parameters:
auto_select (bool) – If True, automatically selects TE/TM based on polarization fraction. If False, uses provided indices. Defaults to True
TE_TM_idx (tuple[int,int]) – Mode indices for TE and TM modes when auto_select=False. Defaults to (1,2)
- Returns:
The selected TE and TM mode indices
- Return type:
tuple[int,int]
Extracts Ex, Ey, Ez, Hx, Hy, Hz field components and coordinate arrays, storing them in self.modefields dictionary structure.
- transfer_results_to_device()
This function will transfer the results from the simulation into the self.device.mode dictionary.
- Returns:
photonicdevice.mode