tidy3d.plugins.smatrix.ModalComponentModeler#
- class ModalComponentModeler[source]#
Bases:
AbstractComponentModelerA tool for modeling devices and computing scattering matrix elements.
- Parameters:
name (str =)
simulation (
Simulation) – Simulation describing the device without any sources present.ports (tuple[Union[
Port,GaussianPort,AstigmaticGaussianPort], …] = ()) – Collection of ports describing the scattering matrix elements. For each input mode, one simulation will be run with a modal source.freqs (ArrayLike[dtype=float, ndim=1]) – [units = Hz]. Array or list of frequencies at which to compute port parameters.
remove_dc_component (bool = True) – Whether to remove the DC component in the Gaussian pulse spectrum. If
True, the Gaussian pulse is modified at low frequencies to zero out the DC component, which is usually desirable so that the fields will decay. However, for broadband simulations, it may be better to have non-vanishing source power near zero frequency. Setting this toFalseresults in an unmodified Gaussian pulse spectrum which can have a nonzero DC component.run_only (Optional[tuple[tuple[str, NonNegativeInt], ...]] = None) – Set of matrix indices that define the simulations to run. If
None, simulations will be run for all indices in the scattering matrix. If a tuple is given, simulations will be run only for the given matrix indices.element_mappings (tuple[tuple[tuple[tuple[str, NonNegativeInt], tuple[str, NonNegativeInt]], tuple[tuple[str, NonNegativeInt], tuple[str, NonNegativeInt]], complex], ...] = ()) – Tuple of S matrix element mappings, each described by a tuple of (input_element, output_element, coefficient), where the coefficient is the element_mapping coefficient describing the relationship between the input and output matrix element. If all elements of a given column of the scattering matrix are defined by
element_mappings, the simulation corresponding to this column is skipped automatically.custom_source_time (Optional[Union[
GaussianPulse,ContinuousWave,CustomSourceTime,BroadbandPulse,BasebandStep,BasebandGaussianPulse,BasebandRectangularPulse,BasebandCustomSourceTime]] = None) – If provided, this will be used as specification of the source time-dependence in simulations. Otherwise, a default source time will be constructed.
Notes
This class orchestrates the process of running multiple simulations to derive the scattering matrix (S-matrix) of a component. It uses modal or Gaussian sources and monitors defined by a set of ports.
See also
Attributes
The base simulation.
Returns a tuple of all possible matrix indices for monitoring.
Tuple of all the matrix indices that will be used to run simulations.
Tuple of all the source matrix indices, which may be less than the total number of ports.
Returns the maximum mode indices for the in and out ports.
Returns lists of port names for inputs and outputs.
Generates all
Simulationobjects for the S-matrix calculation.namesimulationfreqsremove_dc_componentcustom_source_timeMethods
plot_sim([x, y, z, ax])Plots the simulation with all sources added for troubleshooting.
plot_sim_eps([x, y, z, ax])Plots the permittivity of the simulation with all sources.
shift_port(port)Generates a new port shifted slightly in the normal direction.
task_name_from_index(matrix_index)Compute task name for a given (port_name, mode_index) without constructing simulations.
to_monitor(port)Creates an overlap monitor from a given port (modal or gaussian).
to_source(port, mode_index[, num_freqs])Creates a source from a given port (modal or gaussian).
- ports#
- run_only#
- element_mappings#
- property base_sim#
The base simulation.
- property sim_dict#
Generates all
Simulationobjects for the S-matrix calculation.- Returns:
A dictionary where keys are task names and values are the corresponding
Simulationobjects. Each simulation is configured to excite a specific mode at a specific port and includes all necessary monitors.- Return type:
Dict[str, Simulation]
- property matrix_indices_monitor#
Returns a tuple of all possible matrix indices for monitoring.
Each matrix index is a tuple of (port_name, mode_index).
- Returns:
A tuple of all possible matrix indices for the monitoring ports.
- Return type:
Tuple[MatrixIndex, …]
- property matrix_indices_source#
Tuple of all the source matrix indices, which may be less than the total number of ports.
- property matrix_indices_run_sim#
Tuple of all the matrix indices that will be used to run simulations.
- property port_names#
Returns lists of port names for inputs and outputs.
- to_source(port, mode_index, num_freqs=1, **kwargs)[source]#
Creates a source from a given port (modal or gaussian).
- shift_port(port)[source]#
Generates a new port shifted slightly in the normal direction.
This is to ensure that the source is placed just inside the simulation domain, away from the PML.
- plot_sim(x=None, y=None, z=None, ax=None)[source]#
Plots the simulation with all sources added for troubleshooting.
This method creates a temporary simulation with all mode sources activated to help visualize the setup.
- Parameters:
x (float, optional) – The x-coordinate of the cross-section, by default None.
y (float, optional) – The y-coordinate of the cross-section, by default None.
z (float, optional) – The z-coordinate of the cross-section, by default None.
ax (Ax, optional) – The matplotlib axes to plot on, by default None.
- Returns:
The matplotlib axes with the plot.
- Return type:
Ax
- plot_sim_eps(x=None, y=None, z=None, ax=None, **kwargs)[source]#
Plots the permittivity of the simulation with all sources.
This method is useful for visualizing the device geometry along with the placement of the sources.
- Parameters:
x (float, optional) – The x-coordinate of the cross-section, by default None.
y (float, optional) – The y-coordinate of the cross-section, by default None.
z (float, optional) – The z-coordinate of the cross-section, by default None.
ax (Ax, optional) – The matplotlib axes to plot on, by default None.
**kwargs – Additional keyword arguments passed to the plotter.
- Returns:
The matplotlib axes with the plot.
- Return type:
Ax
- property max_mode_index#
Returns the maximum mode indices for the in and out ports.