tidy3d.EMESimulationData#
- class EMESimulationData[source]#
Bases:
AbstractYeeGridSimulationDataData associated with an EME simulation.
- Parameters:
simulation (
EMESimulation) – EME simulation associated with this data.data (tuple[Union[
EMEModeSolverData,EMEFieldData,EMECoefficientData,ModeSolverData,PermittivityData,MediumData], …]) – List of EME monitor data associated with the monitors of the originalEMESimulation.log (Optional[str] = None) – A string containing the log information from the simulation run.
smatrix (Optional[
EMESMatrixDataset] = None) – Scattering matrix of the EME simulation.coeffs (Optional[Union[
EMECoefficientData,EMECoefficientDataset]] = None) – Coefficients from the EME simulation. Useful for debugging and optimization.diagnostics (Optional[
EMEDiagnosticsData] = None) – Diagnostic quantities from the EME simulation.port_modes_raw (Optional[
EMEModeSolverData] = None) – Modes associated with the two ports of the EME device. The scattering matrix is expressed in this basis. Note: these modes are not symmetry expanded; use ‘port_modes’ instead.
Notes
Contains the results of an
EMESimulation, including the scattering matrix (smatrix), diagnostics (diagnostics), port modes (port_modes), mode coefficients (coeffs), and any monitor data recorded during the simulation.The scattering matrix is expressed in the basis of the port modes. Use
smatrix_in_basis()to re-express it in a different modal basis, for example to compute transmission into a specific mode of an output waveguide. Similarly, usefield_in_basis()to re-express the propagated field.Accessing Results
Fundamental-mode transmission and reflection:
T = sim_data.smatrix.S21.isel(mode_index_in=0, mode_index_out=0).abs ** 2 R = sim_data.smatrix.S11.isel(mode_index_in=0, mode_index_out=0).abs ** 2
Monitor data recorded by an
EMEFieldMonitororEMECoefficientMonitorcan be accessed by name:field_data = sim_data["field_monitor_name"]
To express the scattering matrix in a custom modal basis (e.g., modes of individual output waveguides), add an
EMEModeSolverMonitorat the output port and usesmatrix_in_basis():smatrix_custom = sim_data.smatrix_in_basis(modes2=sim_data["output_monitor"])
See also
EMESimulationThe simulation object that produces this data.
EMESMatrixDatasetThe scattering matrix dataset.
Example
>>> import tidy3d as td >>> sim = td.EMESimulation( ... size=(2, 2, 6), ... freqs=[2e14], ... axis=2, ... eme_grid_spec=td.EMEUniformGrid( ... num_cells=3, mode_spec=td.EMEModeSpec(num_modes=2) ... ), ... grid_spec=td.GridSpec.auto(wavelength=1.55), ... ) >>> sim_data = EMESimulationData(simulation=sim, data=())
Attributes
Modes associated with the two ports of the EME device.
Port modes as a list of tuples, one per sweep index.
Port modes as a tuple
(port_modes_1, port_modes_2).logMethods
field_in_basis(field[, modes, port_index, ...])Express the electromagnetic field in the provided basis.
smatrix_in_basis([modes1, modes2, ...])Express the scattering matrix in the provided basis.
- simulation#
- data#
- smatrix#
- coeffs#
- diagnostics#
- port_modes_raw#
- property port_modes#
Modes associated with the two ports of the EME device. The scattering matrix is expressed in this basis. Note: these modes are symmetry expanded.
- property port_modes_tuple#
Port modes as a tuple
(port_modes_1, port_modes_2).- Returns:
A pair of
ModeSolverDatafor port 1 and port 2, respectively. RaisesSetupErrorifstore_port_modeswas not enabled, or if port modes vary with sweep index (useport_modes_list_sweepinstead).- Return type:
tuple[
ModeSolverData,ModeSolverData]
- property port_modes_list_sweep#
Port modes as a list of tuples, one per sweep index.
- Returns:
A list with one
(port_modes_1, port_modes_2)tuple per sweep index. If the sweep does not change the modes (e.g.EMELengthSweep), the list contains a single entry.- Return type:
list[tuple[
ModeSolverData,ModeSolverData]]
- smatrix_in_basis(modes1=None, modes2=None, skip_gram_normalization=False)[source]#
Express the scattering matrix in the provided basis. Change of basis is done by computing overlaps between provided modes and port modes.
- Parameters:
modes1 (Union[FieldData, ModeData]) – New modal basis for port 1. If
None, useport_modes.modes2 (Union[FieldData, ModeData]) – New modal basis for port 2. If
None, useport_modes.skip_gram_normalization (bool = False) – If
False(default), normalize the change of basis so it is correct even for bases that are not orthonormal (linear combinations of port modes, modes on a different grid, or custom fields). IfTrue, skip the Gram normalization and use the plain overlap contraction; this is correct only when the port and new bases each have identity self-overlap in this method’s overlap convention, and otherwise merely recovers the pre-normalization behavior (which may be incorrect).
- Returns:
The scattering matrix of the EME simulation, but expressed in the basis of the provided modes, rather than in the basis of
port_modesused in computation.- Return type:
Notes
This is useful when the computational port modes do not match the modes of interest. For example, in a waveguide splitter the output port spans multiple waveguides, so the EME port modes are super-modes of the combined structure. To obtain the scattering matrix in the basis of individual waveguide modes, place an
EMEModeSolverMonitorover each output waveguide and pass the resulting data here.store_port_modesmust beTruein theEMESimulationfor this method to work.The change of basis is computed in the port modes’ integration convention – native Yee for EME, matching how the scattering matrix was computed. A target basis’s own
use_colocated_integrationis not honored; onlycolocate=Trueforces colocated integration (boundary-stored fields cannot be integrated on the staggered Yee grid). Note thatEMEModeSolverMonitordefaults tocolocate=True, so the workflow below uses colocated integration unless you setcolocate=Falseon the target monitor to get the Yee path.Typical workflow:
# 1. Add a monitor over the output waveguide(s) output_mon = td.EMEModeSolverMonitor( size=output_size, center=output_center, name="output", ... ) # 2. After running, re-express the S-matrix smatrix_custom = sim_data.smatrix_in_basis(modes2=sim_data["output"]) T_custom = smatrix_custom.S21.isel(mode_index_in=0, mode_index_out=0).abs ** 2
- field_in_basis(field, modes=None, port_index=0, skip_gram_normalization=False)[source]#
Express the electromagnetic field in the provided basis. Change of basis is done by computing overlaps between provided modes and port modes.
The overlaps use the port modes’ integration convention – native Yee for EME, matching how the simulation was computed and
smatrix_in_basis(). A target basis’s ownuse_colocated_integrationis not honored; onlycolocate=Trueforces colocated integration (boundary-stored fields cannot be integrated on the staggered Yee grid). Monitor-based target bases (e.g.EMEModeSolverMonitor) default tocolocate=True, so setcolocate=Falsefor the Yee path.- Parameters:
field (EMEFieldData) – EME field to express in new basis.
modes (Union[FieldData, ModeData]) – New modal basis. If None, use port_modes.
port_index (Literal[0, 1]) – Port to excite.
skip_gram_normalization (bool = False) – If
False(default), normalize the change of basis by the port-mode Gram inverse so it is correct even when the port modes are not orthonormal in this overlap convention. IfTrue, use the plain overlap contraction (the previous behavior), exact only when the port modes are already orthonormal in this convention.
- Returns:
The propagated electromagnetic field expressed in the basis of the provided modes, rather than in the basis of
port_modesused in computation.- Return type: