tidy3d.plugins.mode.ModeSolver#
- class ModeSolver[source]#
- Bases: - Tidy3dBaseModel- Interface for solving electromagnetic eigenmodes in a 2D plane with translational invariance in the third dimension. - Parameters:
- simulation (Simulation) – Simulation defining all structures and mediums. 
- plane (Box) – Cross-sectional plane in which the mode will be computed. 
- mode_spec (ModeSpec) – Container with specifications about the modes to be solved for. 
- freqs (Union[Tuple[float, ...], ArrayLike[dtype=float, ndim=1]]) – A list of frequencies at which to solve. 
- direction (Literal['+', '-'] = +) – Direction of waveguide mode propagation along the axis defined by its normal dimension. 
- colocate (bool = True) – Toggle whether fields should be colocated to grid cell boundaries (i.e. primal grid nodes). Default is - True.
 
 - See also - ModeSource:
- Injects current source to excite modal profile on finite extent plane. 
- Notebooks:
- Lectures:
 - Attributes - ModeSolverDatacontaining the field and effective index data.- ModeSolverDatacontaining the field and effective index on unexpanded grid.- The solver grid snapped to the plane normal and to simulation 0-sized dims if any. - Axis normal to the mode plane. - Strip objects not used by the mode solver from simulation object. - SimulationDataobject containing the- ModeSolverDatafor this object.- Get symmetry for solver for propagation along self.normal axis. - Methods - is_plane(val)- Raise validation error if not planar. - plane_in_sim_bounds(val, values)- Check that the plane is at least partially inside the simulation bounds. - plot_field(field_name[, val, scale, ...])- Plot the field for a - ModeSolverDatawith- Simulationplot overlaid.- Creates - Simulationfrom a- ModeSolver.- sim_with_monitor([freqs, name])- Creates - Simulationfrom a- ModeSolver.- sim_with_source(source_time[, direction, ...])- Creates - Simulationfrom a- ModeSolver.- solve()- ModeSolverDatacontaining the field and effective index data.- to_mode_solver_monitor(name[, colocate])- Creates - ModeSolverMonitorfrom a- ModeSolverinstance.- to_monitor([freqs, name])- Creates - ModeMonitorfrom a- ModeSolverinstance plus additional specifications.- to_source(source_time[, direction, mode_index])- Creates - ModeSourcefrom a- ModeSolverinstance plus additional specifications.- validate_pre_upload([source_required])- simulation#
 - plane#
 - mode_spec#
 - freqs#
 - direction#
 - colocate#
 - classmethod plane_in_sim_bounds(val, values)[source]#
- Check that the plane is at least partially inside the simulation bounds. 
 - property normal_axis#
- Axis normal to the mode plane. 
 - property solver_symmetry#
- Get symmetry for solver for propagation along self.normal axis. 
 - solve()[source]#
- ModeSolverDatacontaining the field and effective index data.- Returns:
- ModeSolverDataobject containing the effective index and mode fields.
- Return type:
 
 - property grid_snapped#
- The solver grid snapped to the plane normal and to simulation 0-sized dims if any. 
 - property data_raw#
- ModeSolverDatacontaining the field and effective index on unexpanded grid.- Returns:
- ModeSolverDataobject containing the effective index and mode fields.
- Return type:
 
 - property data#
- ModeSolverDatacontaining the field and effective index data.- Returns:
- ModeSolverDataobject containing the effective index and mode fields.
- Return type:
 
 - property sim_data#
- SimulationDataobject containing the- ModeSolverDatafor this object.- Returns:
- SimulationDataobject containing the effective index and mode fields.
- Return type:
 
 - to_source(source_time, direction=None, mode_index=0)[source]#
- Creates - ModeSourcefrom a- ModeSolverinstance plus additional specifications.- Parameters:
- source_time ( - SourceTime) – Specification of the source time-dependence.
- direction (Direction = None) – Whether source will inject in - "+"or- "-"direction relative to plane normal. If not specified, uses the direction from the mode solver.
- mode_index (int = 0) – Index into the list of modes returned by mode solver to use in source. 
 
- Returns:
- Mode source with specifications taken from the ModeSolver instance and the method inputs. 
- Return type:
 
 - to_monitor(freqs=None, name=None)[source]#
- Creates - ModeMonitorfrom a- ModeSolverinstance plus additional specifications.- Parameters:
- freqs (List[float]) – Frequencies to include in Monitor (Hz). If not specified, passes - self.freqs.
- name (str) – Required name of monitor. 
 
- Returns:
- Mode monitor with specifications taken from the ModeSolver instance and the method inputs. 
- Return type:
 
 - to_mode_solver_monitor(name, colocate=None)[source]#
- Creates - ModeSolverMonitorfrom a- ModeSolverinstance.- Parameters:
- name (str) – Name of the monitor. 
- colocate (bool) – Whether to colocate fields or compute on the Yee grid. If not provided, the value set in the - ModeSolverinstance is used.
 
- Returns:
- Mode monitor with specifications taken from the ModeSolver instance and - name.
- Return type:
 
 - sim_with_source(source_time, direction=None, mode_index=0)[source]#
- Creates - Simulationfrom a- ModeSolver. Creates a copy of the ModeSolver’s original simulation with a ModeSource added corresponding to the ModeSolver parameters.- Parameters:
- source_time ( - SourceTime) – Specification of the source time-dependence.
- direction (Direction = None) – Whether source will inject in - "+"or- "-"direction relative to plane normal. If not specified, uses the direction from the mode solver.
- mode_index (int = 0) – Index into the list of modes returned by mode solver to use in source. 
 
- Returns:
- Copy of the simulation with a - ModeSourcewith specifications taken from the ModeSolver instance and the method inputs.
- Return type:
 
 - sim_with_monitor(freqs=None, name=None)[source]#
- Creates - Simulationfrom a- ModeSolver. Creates a copy of the ModeSolver’s original simulation with a mode monitor added corresponding to the ModeSolver parameters.- Parameters:
- freqs (List[float] = None) – Frequencies to include in Monitor (Hz). If not specified, uses the frequencies from the mode solver. 
- name (str) – Required name of monitor. 
 
- Returns:
- Copy of the simulation with a - ModeMonitorwith specifications taken from the ModeSolver instance and the method inputs.
- Return type:
 
 - sim_with_mode_solver_monitor(name)[source]#
- Creates - Simulationfrom a- ModeSolver. Creates a copy of the ModeSolver’s original simulation with a mode solver monitor added corresponding to the ModeSolver parameters.- Parameters:
- name (str) – Name of the monitor. 
- Returns:
- Copy of the simulation with a - ModeSolverMonitorwith specifications taken from the ModeSolver instance and- name.
- Return type:
 
 - plot_field(field_name, val='real', scale='lin', eps_alpha=0.2, robust=True, vmin=None, vmax=None, ax=None, **sel_kwargs)[source]#
- Plot the field for a - ModeSolverDatawith- Simulationplot overlaid.- Parameters:
- field_name (str) – Name of - fieldcomponent to plot (eg.- 'Ex'). Also accepts- 'E'and- 'H'to plot the vector magnitudes of the electric and magnetic fields, and- 'S'for the Poynting vector.
- val (Literal['real', 'imag', 'abs', 'abs^2', 'dB'] = 'real') – Which part of the field to plot. 
- eps_alpha (float = 0.2) – Opacity of the structure permittivity. Must be between 0 and 1 (inclusive). 
- robust (bool = True) – If True and vmin or vmax are absent, uses the 2nd and 98th percentiles of the data to compute the color limits. This helps in visualizing the field patterns especially in the presence of a source. 
- vmin (float = None) – The lower bound of data range that the colormap covers. If - None, they are inferred from the data and other keyword arguments.
- vmax (float = None) – The upper bound of data range that the colormap covers. If - None, they are inferred from the data and other keyword arguments.
- ax (matplotlib.axes._subplots.Axes = None) – matplotlib axes to plot on, if not specified, one is created. 
- sel_kwargs (keyword arguments used to perform - .sel()selection in the monitor data.) – These kwargs can select over the spatial dimensions (- x,- y,- z), frequency or time dimensions (- f,- t) or mode_index, if applicable. For the plotting to work appropriately, the resulting data after selection must contain only two coordinates with len > 1. Furthermore, these should be spatial coordinates (- x,- y, or- z).
 
- Returns:
- The supplied or created matplotlib axes. 
- Return type:
- matplotlib.axes._subplots.Axes 
 
 - property reduced_simulation_copy#
- Strip objects not used by the mode solver from simulation object. This might significantly reduce upload time in the presence of custom mediums. 
 - __hash__()#
- Hash method.