EMEModel
EMEModel( eme_grid_spec: Annotated[ tidy3d.components.eme.grid.EMEUniformGrid | tidy3d.components.eme.grid.EMEExplicitGrid | ForwardRef('EMECompositeGrid'), _, ], medium: Annotated[ tidy3d.components.medium.Medium | tidy3d.components.medium.AnisotropicMedium | tidy3d.components.medium.PECMedium | tidy3d.components.medium.PMCMedium | tidy3d.components.medium.PoleResidue | tidy3d.components.medium.Sellmeier | tidy3d.components.medium.Lorentz | tidy3d.components.medium.Debye | tidy3d.components.medium.Drude | tidy3d.components.medium.FullyAnisotropicMedium | tidy3d.components.medium.CustomMedium | tidy3d.components.medium.CustomPoleResidue | tidy3d.components.medium.CustomSellmeier | tidy3d.components.medium.CustomLorentz | tidy3d.components.medium.CustomDebye | tidy3d.components.medium.CustomDrude | tidy3d.components.medium.CustomAnisotropicMedium | tidy3d.components.medium.PerturbationMedium | tidy3d.components.medium.PerturbationPoleResidue | tidy3d.components.medium.LossyMetalMedium, _, ] | None = None, symmetry: Annotated[collections.abc.Sequence[int], _] = (0, 0, 0), monitors: collections.abc.Sequence[ typing.Annotated[ tidy3d.components.monitor.FieldMonitor | tidy3d.components.monitor.FieldTimeMonitor | tidy3d.components.monitor.AuxFieldTimeMonitor | tidy3d.components.monitor.MediumMonitor | tidy3d.components.monitor.PermittivityMonitor | tidy3d.components.monitor.FluxMonitor | tidy3d.components.monitor.FluxTimeMonitor | tidy3d.components.monitor.ModeMonitor | tidy3d.components.monitor.ModeSolverMonitor | tidy3d.components.monitor.ModeTimeMonitor | tidy3d.components.monitor.FieldProjectionAngleMonitor | tidy3d.components.monitor.FieldProjectionCartesianMonitor | tidy3d.components.monitor.FieldProjectionKSpaceMonitor | tidy3d.components.monitor.DiffractionMonitor | tidy3d.components.monitor.DirectivityMonitor | tidy3d.components.microwave.monitor.MicrowaveModeMonitor | tidy3d.components.microwave.monitor.MicrowaveModeSolverMonitor | tidy3d.components.monitor.GaussianOverlapMonitor | tidy3d.components.monitor.AstigmaticGaussianOverlapMonitor | tidy3d.components.monitor.ThinLensOverlapMonitor | tidy3d.components.monitor.DipoleEmissionMonitor | tidy3d.components.monitor.PointCloudFieldMonitor | tidy3d.components.monitor.PointCloudPermittivityMonitor | tidy3d.components.monitor.SurfaceFieldMonitor | tidy3d.components.monitor.SurfaceFieldTimeMonitor, _, ] ] = (), structures: collections.abc.Sequence[ tidy3d.components.structure.Structure ] = (), grid_spec: Annotated[float, exclusiveMinimum=0] | tidy3d.components.grid.grid_spec.GridSpec | None = None, subpixel: tidy3d.components.subpixel_spec.SubpixelSpec | bool = True, bounds: Annotated[ collections.abc.Sequence[collections.abc.Sequence[float | None]], _ ] = ((None, None, None), (None, None, None)), constraint: Literal['passive', 'unitary'] | None = 'passive', simulation_updates: dict[str, object] | None = None, verbose: bool = True, _use_interface_matrix=False, _grid_transform_matrix=((1.0, 0.0), (0.0, 1.0), (0.0, 0.0)),) -> NoneS matrix model based on Eigenmode Expansion calculation.
Args
- eme_grid_spec: 1D grid in the that specifies the EME cells where mode solving is performed along the propagation direction.
- medium: Background medium. If
None, the technology default is used. - symmetry: Component symmetries.
- monitors: Extra field monitors added to the simulation.
- structures: Additional structures included in the simulations.
- grid_spec: Simulation grid specification. A single float can be used to specify the
min_steps_per_wvlfor an auto grid. - subpixel: Flag controlling subpixel averaging in the simulation grid or an instance of
tidy3d.SubpixelSpec. - bounds: Bound overrides for the final simulation.
- constraint: Constraint for EME propagation. Possible values are
"passive"and"unitary". - simulation_updates: Dictionary of updates applied to the simulation generated by this model. See example in
Tidy3DModel. - verbose: Control solver verbosity.
If not set, the default values for the component simulations are defined
based on the wavelengths used in the s_matrix call.
Methods
Section titled “Methods”| Method | Description |
|---|---|
autograd_smatrix | Compute an autograd-compatible S matrix for traced parameters. |
estimate_cost | Estimate the cost for S matrix computation. |
get_simulation | Create an EME simulation for a component. |
s_matrix | Compute the S matrix for a component using this model. |
setup_time_stepper | Obtain a time stepper for a component using this model. |
simulation_data | Return the EME simulation data for a given component. |
start | Start computing the S matrix response from a component. |
transform | Apply a transformation to this model. |
update | Update this model. |
autograd_smatrix
Section titled “autograd_smatrix”autograd_smatrix( self, *, component, traced_params, frequencies, component_for_params, param_names, show_progress=True, model_kwargs=None,)Compute an autograd-compatible S matrix for traced parameters.
Important
This is an abstract method that must be implemented by derived classes that support autograd-based S-matrix computation.
Args
- component (Component): Nominal component associated with this autograd evaluation.
- traced_params (ndarray): Traced parameter vector used by autograd.
- frequencies (Sequence[float]): Frequency values at which to calculate the scattering parameters (in Hz).
- component_for_params (Callable[[ndarray], Component]): Callback that returns the component for a given traced parameter vector.
- param_names (Sequence[str]): Flattened traced parameter names aligned with
traced_params. - show_progress (bool): Progress display hint from
Component.s_matrix. - model_kwargs (dict[str, Any] | None): Model-specific keyword arguments forwarded from
Component.s_matrix.
Returns
AutogradSMatrix: Autograd-compatible S matrix.
estimate_cost
Section titled “estimate_cost”estimate_cost(self, *args, **kwargs)Estimate the cost for S matrix computation.
All arguments are passed to the model’s start method with the
addition of the keyword argument cost_estimation=True.
Returns
float: Cost estimation.
get_simulation
Section titled “get_simulation”get_simulation( self, component: photonforge.Component, frequencies: collections.abc.Sequence[float],) -> tuple[ tidy3d.components.eme.simulation.EMESimulation, tuple[tuple[str], tuple[str]],]Create an EME simulation for a component.
Args
- component: Instance of Component for calculation.
- frequencies: Sequence of frequencies for the simulation.
Returns
EME simulation and 2 tuples with the names of the ports on each side of the domain.
s_matrix
Section titled “s_matrix”s_matrix(self, component, frequencies, show_progress=True, model_kwargs={})Compute the S matrix for a component using this model.
Args
- component (Component): Component to perform the calculation.
- frequencies (Sequence[float]): Frequency values at which to calculate the scattering parameters (in Hz).
- show_progress (bool): If
True, show computation progress. - model_kwargs (dict[str, object]): Keyword arguments passed to
Model.start. Accepted arguments depend on the model type.
Returns
SMatrix: Computed S matrix.
Example
Compute only the responses from mode 0 of P0 with Tidy3D to
reduce the number and cost of simulations:
>>> model = pf.Tidy3DModel()>>> s_matrix = model.s_matrix( # doctest: +SKIP... component,... frequencies,... model_kwargs={"inputs": ("P0@0",)},... )A port name such as ("P0",) selects all modes of that port. All
outputs for the selected inputs are returned; responses from
unselected inputs are not computed. Use Model.estimate_cost
with the same inputs passed directly to estimate the reduced run.
setup_time_stepper
Section titled “setup_time_stepper”setup_time_stepper( self, component, time_step, carrier_frequency=0, show_progress=True, time_stepper_kwargs={},)Obtain a time stepper for a component using this model.
Args
- component (Component): Component for the time stepper.
- time_step (float): The interval between time steps (in seconds).
- carrier_frequency (float): The carrier frequency used to construct the time stepper. The carrier should be omitted from the input signals, as it is handled automatically by the time stepper.
- show_progress (bool): If
True, show computation progress. - time_stepper_kwargs (dict[str, object]): Keyword arguments passed to
TimeStepper.setup. Each time stepper type can accept a different set of arguments. Check the documentation for the each time stepper’ssetup_statemethod for more information.
Returns
TimeStepper: Initialized time stepper.
simulation_data
Section titled “simulation_data”simulation_data( self, component: photonforge.Component, frequencies: collections.abc.Sequence[float], *, verbose: bool | None = None, show_progress: bool = True, **kwargs: object,) -> tidy3d.components.eme.data.sim_data.EMESimulationData | NoneReturn the EME simulation data for a given component.
Uses the same arguments as EMEModel.start.
start( self, component: photonforge.Component, frequencies: collections.abc.Sequence[float], *, verbose: bool | None = None, cost_estimation: bool = False, **kwargs: object,) -> photonforge.models.tidy3d._EMEModelRunnerStart computing the S matrix response from a component.
Args
- component: Component from which to compute the S matrix.
- frequencies: Sequence of frequencies at which to perform the computation.
- verbose: If set, overrides the model’s
verboseattribute. - cost_estimation: If set, simulations are uploaded, but not executed. S matrix will not be computed.
- **kwargs: Unused.
Returns
Result object with attributes status and s_matrix.
Important
When using geometry symmetry, the mode numbering in inputs
is relative to the solver run with the symmetry applied, not
the mode number presented in the final S matrix.
transform
Section titled “transform”transform( self, translation: collections.abc.Sequence[float] | complex = (0, 0), rotation: float = 0, scaling: float = 1, x_reflection: bool = False,) -> 'EMEModel'Apply a transformation to this model.
The base implementation is a no-op and returns self. Derived classes
can override this method to transform model-specific geometry settings.
Args
- translation (Sequence[float] | complex): Translation vector.
- rotation (float): Rotation angle in degrees.
- scaling (float): Magnification factor.
- x_reflection (bool): Mirror across the horizontal axis.
Returns
Model: This object with transformations applied.
update
Section titled “update”update(self, *args, **kwargs)Update this model.
All contents of the model are updated with the contents from the updated version. object contents or modifications introduced after the model creation (outside of the original parametric function) are not propagated.
The model’s time stepper does not participate in the update, unless
the __init__ method of the derived model class replaces it via
set_time_stepper.
Args
- *args (object): Positional arguments to the parametric model.
- **kwargs (object): Keyword arguments to the parametric model.
Returns
Model: This model.
Note
The original keyword arguments used to generate the model are stored
and updated with the passed kwargs. This updated version is used
in the function call and will be stored for future updates.
Positional arguments are not stored.
Attributes
Section titled “Attributes”| Attribute | Description |
|---|---|
parametric_function | str: Function used to update the model. |
parametric_kwargs | dict[str, object]: Keyword arguments used to update the model. |
properties | Properties: Object properties. |
random_variables | list[RandomVariable]: Random variables associated to the model’s parameters. |
time_stepper | TimeStepper | None: Time stepper associated with this model. |
parametric_function
Section titled “parametric_function”str: Function used to update the model.
parametric_kwargs
Section titled “parametric_kwargs”dict[str, object]: Keyword arguments used to update the model.
properties
Section titled “properties”Properties: Object properties.
random_variables
Section titled “random_variables”list[RandomVariable]: Random variables associated to the model’s parameters.
time_stepper
Section titled “time_stepper”TimeStepper | None: Time stepper associated with this model.