tidy3d.EMESimulation#
- class EMESimulation[source]#
Bases:
AbstractYeeGridSimulationEigenMode Expansion (EME) simulation.
- Parameters:
center (tuple[Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box]] = (0.0, 0.0, 0.0)) β [units = um]. Center of object in x, y, and z.
size (tuple[Union[NonNegativeFloat, autograd.tracer.Box], Union[NonNegativeFloat, autograd.tracer.Box], Union[NonNegativeFloat, autograd.tracer.Box]]) β [units = um]. Size in x, y, and z directions.
medium (Union[
Medium,AnisotropicMedium,PECMedium,PMCMedium,PoleResidue,Sellmeier,Lorentz,Debye,Drude,FullyAnisotropicMedium,CustomMedium,CustomPoleResidue,CustomSellmeier,CustomLorentz,CustomDebye,CustomDrude,CustomAnisotropicMedium,PerturbationMedium,PerturbationPoleResidue,LossyMetalMedium] = Medium()) β Background medium of simulation, defaults to vacuum if not specified.structures (tuple[
Structure, β¦] = ()) β Tuple of structures present in simulation. Note: Structures defined later in this list override the simulation material properties in regions of spatial overlap.symmetry (tuple[Literal[0, -1, 1], Literal[0, -1, 1], Literal[0, -1, 1]] = (0, 0, 0)) β Tuple of integers defining reflection symmetry across a plane bisecting the simulation domain normal to the x-, y-, and z-axis at the simulation center of each axis, respectively.
sources (tuple[None, ...] = ()) β Sources in the simulation. NOTE: sources are not currently supported for EME simulations. Instead, the simulation performs full bidirectional propagation in the βport_modeβ basis. After running the simulation, use βsmatrix_in_basisβ to use another set of modes or input field.
boundary_spec (
BoundarySpec= BoundarySpec(x=Boundary(plus=PECBoundary(), minus=PECBoundary()), y=Boundary(plus=PECBoundary(), minus=PECBoundary()), z=Boundary(plus=PECBoundary(), minus=PECBoundary()))) β Specification of boundary conditions along each dimension. By default, PEC boundary conditions are applied on all sides. This field is for consistency with FDTD simulations; however, please note that regardless of the βboundary_specβ, the mode solver terminates the mode plane with PEC boundary. The βEMEModeSpecβ can be used to apply PML layers in the mode solver.monitors (tuple[Union[
EMEModeSolverMonitor,EMEFieldMonitor,EMECoefficientMonitor,ModeSolverMonitor,PermittivityMonitor,MediumMonitor], β¦] = ()) β Tuple of monitors in the simulation. Supported types: βEMEModeSolverMonitorβ, βEMEFieldMonitorβ, βEMECoefficientMonitorβ, βModeSolverMonitorβ, βPermittivityMonitorβ, and βMediumMonitorβ. Note: monitor names are used to access data after simulation is run.grid_spec (
GridSpec= GridSpec()) β Specifications for the simulation grid along each of the three directions. This is distinct from βeme_grid_specβ, which defines the 1D EME grid in the propagation direction.version (str = 2.11.2) β String specifying the front end version number.
plot_length_units (Optional[Literal['nm', 'ΞΌm', 'um', 'mm', 'cm', 'm', 'mil', 'in']] = ΞΌm) β When set to a supported
LengthUnit, plots will be produced with proper scaling of axes and include the desired unit specifier in labels.structure_priority_mode (Literal['equal', 'conductor'] = equal) β This field only affects structures of priority=None. If equal, the priority of those structures is set to 0; if conductor, the priority of structures made of
LossyMetalMediumis set to 90,PECMediumto 100, and others to 0.lumped_elements (tuple[Union[
LumpedResistor,CoaxialLumpedResistor,LinearLumpedElement], β¦] = ()) β Tuple of lumped elements in the simulation. Note: onlyLumpedResistoris supported currently.subpixel (Union[bool,
SubpixelSpec] = SubpixelSpec()) β Apply subpixel averaging methods of the permittivity on structure interfaces to result in much higher accuracy for a given grid size. Supply aSubpixelSpecto this field to select subpixel averaging methods separately on dielectric, metal, and PEC material interfaces. Alternatively, user may supply a boolean value:Trueto apply the default subpixel averaging methods corresponding toSubpixelSpec(), orFalseto apply staircasing.simulation_type (Optional[Literal['autograd_fwd', 'autograd_bwd', 'tidy3d']] = tidy3d) β Tag used internally to distinguish types of simulations for
autogradgradient processing.post_norm (Union[float, FreqDataArray] = 1.0) β Factor to multiply the fields by after running, given the adjoint source pipeline used. Note: this is used internally only.
internal_absorbers (tuple = ()) β Planes with the first order absorbing boundary conditions placed inside the computational domain. Note: absorbers are not supported in EME simulations.
freqs (ArrayLike[dtype=float, ndim=1]) β Frequencies for the EME simulation. The field is propagated independently at each provided frequency, but the modes are only computed at a few sampling points and interpolated. To change this behavior, you can use βEMEModeSpec.interp_specβ.
axis (Literal[0, 1, 2]) β Propagation axis (0, 1, or 2) for the EME simulation.
eme_grid_spec (Union[
EMEUniformGrid,EMECompositeGrid,EMEExplicitGrid]) β Specification for the EME propagation grid. The simulation is divided into cells in the propagation direction; this parameter specifies the layout of those cells. Mode solving is performed in each cell, and then propagation between cells is performed to determine the complete solution. This is distinct from βgrid_specβ, which defines the grid in the two tangential directions, as well as the grid used for field monitors.store_port_modes (bool = True) β Whether to store the modes associated with the two ports. Required to find scattering matrix in basis besides the computational basis.
store_coeffs (bool = False) β Whether to store the internal coefficients from the EME simulation. The results are stored in βEMESimulationData.coeffsβ.
normalize (bool = True) β Whether to normalize the port modes to unity flux, thereby normalizing the scattering matrix and expansion coefficients.
port_offsets (tuple[NonNegativeFloat, NonNegativeFloat] = (0, 0)) β Offsets for the two ports, relative to the simulation bounds along the propagation axis.
sweep_spec (Optional[Union[
EMELengthSweep,EMEModeSweep,EMEFreqSweep,EMEPeriodicitySweep]] = None) β Specification for a parameter sweep to be performed during the EME propagation step. The results are stored in βsim_data.smatrixβ. Other simulation monitor data is not included in the sweep.constraint (Optional[Literal['passive', 'unitary']] = passive) β Constraint for EME propagation, imposed at cell interfaces. A constraint of βpassiveβ means that energy can be dissipated but not created at interfaces. A constraint of βunitaryβ means that energy is conserved at interfaces (but not necessarily within cells). The option βnoneβ may be faster for a large number of modes. The option βpassiveβ can serve as regularization for the field continuity requirement and give more physical results.
Notes
EME is a frequency-domain method for propagating the electromagnetic field along a specified axis. The method is well-suited for propagation of guided waves. The electromagnetic fields are expanded locally in the basis of eigenmodes of the waveguide; they are then propagated by imposing continuity conditions in this basis.
The solver computes the full bidirectional scattering matrix, accounting for reflections and mode coupling at every cell interface, with optional passivity or unitarity constraints. Supported features include bent waveguides (via
bend_radiusinEMEModeSpec), diagonal anisotropy (AnisotropicMedium), reciprocal full anisotropy (FullyAnisotropicMediumwith symmetric permittivity and conductivity tensors), broadband frequency interpolation, and efficient parameter sweeps over cell lengths, number of modes, and periodic repetitions.Bent-cell material interpretation is controlled by
EMEModeSpec.bend_medium_frame. With"global", material tensors remain fixed in physical space; with"co_rotating", the material profile bends with the local waveguide frame. Bent custom media, includingCustomAnisotropicMedium, are only supported withbend_medium_frame="co_rotating". For bent anisotropic media in the global-frame interpretation, reusing a single cell throughnum_repsorEMEPeriodicitySweepis only valid when the reused mode sees the same local tensor orientation; similarly,EMELengthSweepis rejected when changing bent cell lengths would require anisotropic modes to be recomputed at new absolute bend angles. When such bends are instead resolved with multiple cells, check convergence with respect to the number of EME cells.The EME simulation is performed along the propagation axis
axisat frequenciesfreqs. The simulation is divided into cells along the propagation axis, as defined byeme_grid_spec. Mode solving is performed at cell centers, and boundary conditions are imposed between cells. The EME ports are defined to be the boundaries of the first and last cell in the EME grid. These can be moved usingport_offsets.An EME simulation always computes the full scattering matrix of the structure. Additional data can be recorded by adding βmonitorsβ to the simulation.
Monitors
The following monitor types are supported:
EMEModeSolverMonitorβ record the eigenmodes at each EME cell.EMEFieldMonitorβ record the propagated E and H fields.EMECoefficientMonitorβ record forward/backward mode coefficients and related diagnostic quantities.ModeSolverMonitorβ solve modes at a cross-section (e.g. for use withEMESimulationData.smatrix_in_basis()).PermittivityMonitorβ record the complex relative permittivity tensor.MediumMonitorβ record the complex relative permittivity and permeability tensors.
Other Bases
By default, the scattering matrix is expressed in the basis of EME modes at the two ports. It is sometimes useful to use alternative bases. For example, in a waveguide splitter, we might want the scattering matrix in the basis of modes of the individual waveguides. The functions smatrix_in_basis and field_in_basis in
EMESimulationDatacan be used for this purpose after the simulation has been run.Frequency Sweeps
Frequency sweeps are supported by including multiple frequencies in the freqs field. To avoid recomputing the modes at each frequency, the modes are interpolated according to the EMEModeSpec.interp_spec in the cells eme_grid_spec. By setting this interp_spec, the interpolation can be changed or disabled (repeating the solve at each frequency, which can be slow).
Passivity and Unitarity Constraints
Passivity and unitarity constraints can be imposed via the constraint field. These constraints are imposed at interfaces between cells, possibly at the expense of field continuity. Passivity means that the interface can only dissipate energy, and unitarity means the interface will conserve energy (energy may still be dissipated inside cells when the propagation constant is complex). Adding constraints can slow down the simulation significantly, especially for a large number of modes (more than 30 or 40).
Too Many Modes
It is important to use enough modes to capture the physics of the device and to ensure that the results have converged (see below). However, using too many modes can slow down the simulation and result in numerical issues. If too many modes are used, it is common to see a warning about invalid modes in the simulation log. While these modes are not included in the EME propagation, this can indicate some other issue with the setup, especially if the results have not converged. In this case, extending the simulation size in the transverse directions and increasing the grid resolution may help by creating more valid modes that can be used in convergence testing.
Mode Convergence Sweeps
It is a good idea to check that the number of modes is large enough by running a mode convergence sweep. This can be done using
EMEModeSweep.Example
>>> from tidy3d import Box, Medium, Structure, C_0, inf >>> from tidy3d import EMEModeSpec, EMEUniformGrid, GridSpec >>> from tidy3d import EMEFieldMonitor >>> lambda0 = 1550e-9 >>> freq0 = C_0 / lambda0 >>> sim_size = 3*lambda0, 3*lambda0, 3*lambda0 >>> waveguide_size = (lambda0/2, lambda0, inf) >>> waveguide = Structure( ... geometry=Box(center=(0,0,0), size=waveguide_size), ... medium=Medium(permittivity=2) ... ) >>> eme_grid_spec = EMEUniformGrid(num_cells=5, mode_spec=EMEModeSpec(num_modes=10)) >>> grid_spec = GridSpec(wavelength=lambda0) >>> field_monitor = EMEFieldMonitor( ... size=(0, sim_size[1], sim_size[2]), ... name="field_monitor" ... ) >>> sim = EMESimulation( ... size=sim_size, ... monitors=[field_monitor], ... structures=[waveguide], ... axis=2, ... freqs=[freq0], ... eme_grid_spec=eme_grid_spec, ... grid_spec=grid_spec ... )
See also
- Notebooks:
Attributes
Adjacent EME cell pairs needed for interface computation.
EME coefficient monitor for storing all coefficients without downsampling.
The EME grid as defined by 'eme_grid_spec'.
Grid spatial locations and information as defined by grid_spec.
Max number of modes in the simulation.
Max number of modes at the two ports.
One
ModeSimulationper EME cell, at full mode count.A list of mode solver monitors at the cell centers.
Dictionary mapping monitor names to their estimated storage size in bytes.
EME Mode solver monitor for only the port modes.
Per-axis bounds where mode solver field data is physically valid.
Specifications for the simulation grid along each of the three directions.
lumped_elementsTuple of lumped elements in the simulation.
subpixelSupply
SubpixelSpecto select subpixel averaging methods separately for dielectric, metal, and PEC material interfaces.simulation_typepost_normmediumBackground medium of simulation, defaults to vacuum if not specified.
structuresTuple of structures present in simulation.
symmetryversionplot_length_unitsstructure_priority_modeValidating setup
sizecenterMethods
compute_cell_overlap(cell_modes)Compute self-overlap, complex refractive index, and flux for one cell.
compute_cell_smatrix(cell_overlap[,Β sweep_index])Compute homogeneous propagation S-matrix for one cell at one sweep point.
compute_interface_overlap(left_modes,Β ...)Compute cross-cell overlaps for one interface.
compute_interface_smatrix(left_overlap,Β ...)Compute interface S-matrix for one interface at one sweep point.
compute_overlaps(mode_data)Stage modes and compute all per-cell and per-interface overlaps.
compute_smatrix(cell_overlaps,Β ...[,Β ...])Stack cell and interface S-matrices into the final device S-matrix.
from_scene(scene,Β **kwargs)Create an EME simulation from a :.Scene instance.
plot([x,Β y,Β z,Β ax,Β source_alpha,Β ...])Plot each of simulation's components on a plane defined by one nonzero x,y,z coordinate.
plot_eme_grid([x,Β y,Β z,Β ax,Β hlim,Β vlim])Plot the EME cell boundaries on a cross-sectional plane.
plot_eme_ports([x,Β y,Β z,Β ax,Β hlim,Β vlim])Plot the EME port locations on a cross-sectional plane.
plot_eme_subgrid_boundaries(eme_grid_spec[,Β ...])Plot the EME subgrid boundaries on a cross-sectional plane.
propagate(mode_data)Propagate modes through the device to compute the full S-matrix.
propagate_from_overlaps(cell_overlaps,Β ...)Propagate to the device S-matrix using pre-computed overlaps.
smatrix_in_basis(smatrix,Β port_modes[,Β ...])Express a locally propagated S-matrix in another modal basis.
stage_cell_modes(mode_data,Β cell_index)Validate, filter, and stamp mode data for one cell.
subsection(region[,Β grid_spec,Β ...])Generate a simulation instance containing only the
region.Validate the fully initialized EME simulation is ok for upload to our servers.
- freqs#
- axis#
- eme_grid_spec#
- monitors#
- boundary_spec#
- sources#
- internal_absorbers#
- grid_spec#
Specifications for the simulation grid along each of the three directions.
Example
Simple application reference:
Simulation( ... grid_spec=GridSpec( grid_x = AutoGrid(min_steps_per_wvl = 20), grid_y = AutoGrid(min_steps_per_wvl = 20), grid_z = AutoGrid(min_steps_per_wvl = 20) ), ... )
See also
GridSpecCollective grid specification for all three dimensions.
UniformGridUniform 1D grid.
AutoGridSpecification for non-uniform grid along a given dimension.
- Notebooks:
- store_port_modes#
- store_coeffs#
- normalize#
- port_offsets#
- sweep_spec#
- constraint#
- plot_eme_ports(x=None, y=None, z=None, ax=None, hlim=None, vlim=None, **kwargs)[source]#
Plot the EME port locations on a cross-sectional plane.
- Parameters:
x (float = None) β Position of plane in x direction, only one of x, y, z must be specified to define plane.
y (float = None) β Position of plane in y direction, only one of x, y, z must be specified to define plane.
z (float = None) β Position of plane in z direction, only one of x, y, z must be specified to define plane.
ax (matplotlib.axes._subplots.Axes = None) β Matplotlib axes to plot on, if not specified, one is created.
hlim (tuple[float, float] = None) β The x range if plotting on xy or xz planes, y range if plotting on yz plane.
vlim (tuple[float, float] = None) β The z range if plotting on xz or yz planes, y range if plotting on xy plane.
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes
- plot_eme_subgrid_boundaries(eme_grid_spec, x=None, y=None, z=None, ax=None, hlim=None, vlim=None, **kwargs)[source]#
Plot the EME subgrid boundaries on a cross-sectional plane.
Does nothing if
eme_grid_specis notEMECompositeGrid. Operates recursively on nested subgrids.- Parameters:
eme_grid_spec (
EMEGridSpec) β The EME grid spec whose subgrid boundaries to plot.x (float = None) β Position of plane in x direction, only one of x, y, z must be specified to define plane.
y (float = None) β Position of plane in y direction, only one of x, y, z must be specified to define plane.
z (float = None) β Position of plane in z direction, only one of x, y, z must be specified to define plane.
ax (matplotlib.axes._subplots.Axes = None) β Matplotlib axes to plot on, if not specified, one is created.
hlim (tuple[float, float] = None) β The x range if plotting on xy or xz planes, y range if plotting on yz plane.
vlim (tuple[float, float] = None) β The z range if plotting on xz or yz planes, y range if plotting on xy plane.
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes
- plot_eme_grid(x=None, y=None, z=None, ax=None, hlim=None, vlim=None, **kwargs)[source]#
Plot the EME cell boundaries on a cross-sectional plane.
- Parameters:
x (float = None) β Position of plane in x direction, only one of x, y, z must be specified to define plane.
y (float = None) β Position of plane in y direction, only one of x, y, z must be specified to define plane.
z (float = None) β Position of plane in z direction, only one of x, y, z must be specified to define plane.
ax (matplotlib.axes._subplots.Axes = None) β Matplotlib axes to plot on, if not specified, one is created.
hlim (tuple[float, float] = None) β The x range if plotting on xy or xz planes, y range if plotting on yz plane.
vlim (tuple[float, float] = None) β The z range if plotting on xz or yz planes, y range if plotting on xy plane.
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes
- plot(x=None, y=None, z=None, ax=None, source_alpha=None, monitor_alpha=None, hlim=None, vlim=None, **patch_kwargs)[source]#
Plot each of simulationβs components on a plane defined by one nonzero x,y,z coordinate.
- Parameters:
x (float = None) β position of plane in x direction, only one of x, y, z must be specified to define plane.
y (float = None) β position of plane in y direction, only one of x, y, z must be specified to define plane.
z (float = None) β position of plane in z direction, only one of x, y, z must be specified to define plane.
source_alpha (float = None) β Opacity of the sources. If
None, uses Tidy3d default.monitor_alpha (float = None) β Opacity of the monitors. If
None, uses Tidy3d default.ax (matplotlib.axes._subplots.Axes = None) β Matplotlib axes to plot on, if not specified, one is created.
hlim (tuple[float, float] = None) β The x range if plotting on xy or xz planes, y range if plotting on yz plane.
vlim (tuple[float, float] = None) β The z range if plotting on xz or yz planes, y plane if plotting on xy plane.
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes
- property eme_grid#
The EME grid as defined by βeme_grid_specβ. An EME grid is a 1D grid aligned with the propagation axis, dividing the simulation into cells. Modes and mode coefficients are defined at the central plane of each cell. Typically, cell boundaries are aligned with interfaces between structures in the simulation.
This is distinct from βgridβ, which is the grid used in the tangential directions as well as the grid used for field monitors.
- property solver_field_bounds#
Per-axis bounds where mode solver field data is physically valid.
EME always colocates symmetry-expanded data, so symmetry is not passed here; the bounds represent only the physical (PEC) domain edges, not the symmetry centre.
- classmethod from_scene(scene, **kwargs)[source]#
Create an EME simulation from a :.Scene instance. Must provide additional parameters to define a valid EME simulation (for example,
size,grid_spec, etc).- Parameters:
scene (
Scene) β Scene containing structures information.**kwargs β Other arguments passed to the
EMESimulationconstructor.
- Returns:
An EME simulation with structures and medium from the provided scene.
- Return type:
- property mode_solver_monitors#
A list of mode solver monitors at the cell centers. Each monitor has a mode spec. The cells and mode specs are specified by βeme_grid_specβ.
- property port_modes_monitor#
EME Mode solver monitor for only the port modes.
- property coeffs_full_monitor#
EME coefficient monitor for storing all coefficients without downsampling.
- validate_pre_upload()[source]#
Validate the fully initialized EME simulation is ok for upload to our servers.
- property monitors_data_size#
Dictionary mapping monitor names to their estimated storage size in bytes.
- property max_num_modes#
Max number of modes in the simulation.
- property max_port_modes#
Max number of modes at the two ports.
- property grid#
Grid spatial locations and information as defined by grid_spec. This is the grid used in the tangential directions as well as the grid used for field monitors. This is distinct from βeme_gridβ, which is the grid used for mode solving and EME propagation.
- subsection(region, grid_spec=None, eme_grid_spec=None, symmetry=None, warn_symmetry_expansion=True, monitors=None, remove_outside_structures=True, remove_outside_custom_mediums=False, **kwargs)[source]#
Generate a simulation instance containing only the
region. Same as inAbstractYeeGridSimulation, except also restricting EME grid.- Parameters:
region (
Box) β New simulation domain.grid_spec (
GridSpec= None) β New grid specification. IfNone, then it is inherited from the original simulation. Ifidentical, then the original grid is transferred directly as aCustomGrid. Note that in the latter case the region of the new simulation is snapped to the original grid lines.eme_grid_spec (
EMEGridSpec= None) β New EME grid specification. IfNone, then it is inherited from the original simulation. Ifidentical, then the original grid is transferred directly as aEMEExplicitGrid. Noe that in the latter case the region of the new simulation is expanded to contain full EME cells.symmetry (tuple[Literal[0, -1, 1], Literal[0, -1, 1], Literal[0, -1, 1]] = None) β New simulation symmetry. If
None, then it is inherited from the original simulation. Note that in this case the size and placement of new simulation domain must be commensurate with the original symmetry.warn_symmetry_expansion (bool = True) β Whether to warn when the subsection is expanded to preserve symmetry.
monitors (tuple[MonitorType, ...] = None) β New list of monitors. If
None, then the monitors intersecting the new simulation domain are inherited from the original simulation.remove_outside_structures (bool = True) β Remove structures outside of the new simulation domain.
remove_outside_custom_mediums (bool = True) β Remove custom medium data outside of the new simulation domain.
**kwargs β Other arguments passed to new simulation instance.
- property cell_index_pairs#
Adjacent EME cell pairs needed for interface computation.
Returns a sorted list of
(left, right)tuples covering all sweep indices. Use this to iterate when building the explicit staged pipeline.
- property mode_simulations#
One
ModeSimulationper EME cell, at full mode count.Call
.run_local()on each returned simulation and pass the results topropagate():mode_data = [ms.run_local() for ms in sim.mode_simulations] smatrix = sim.propagate(mode_data)
The returned tuple is in canonical EME cell order. Each simulation shares the parent geometry and grid specification, with the mode plane and mode spec set per cell. Modes are always solved at the full (untruncated) count; sweep-dependent truncation is applied at the S-matrix computation stage.
All simulations use
direction="+"andcolocate=False. Direction is irrelevant for EME (modes are bidirectional); colocation is handled internally by the overlap integrals.Bent anisotropic media in
bend_medium_frame="global"are not supported by the local path because subpixel averaging is applied before the bend rotation and does not yet handle fully anisotropic tensors. Usebend_medium_frame="co_rotating"or the remote backend path instead.- Return type:
tuple[
ModeSimulation, β¦]
- stage_cell_modes(mode_data, cell_index)[source]#
Validate, filter, and stamp mode data for one cell.
Checks that frequencies match, drops NaN and increasing modes, and returns a stamped
EMEStageCellModes. Seepropagate()for the one-shot alternative.- Parameters:
mode_data (
ModeSimulationDataorModeSolverData) β Result ofmode_simulations[cell_index].run_local().cell_index (int) β EME cell index (0-based).
- Return type:
- compute_cell_overlap(cell_modes)[source]#
Compute self-overlap, complex refractive index, and flux for one cell.
The result feeds into
compute_cell_smatrix()andcompute_smatrix(). Seepropagate()for the one-shot alternative.- Parameters:
cell_modes (
EMEStageCellModes)- Return type:
- compute_interface_overlap(left_modes, right_modes)[source]#
Compute cross-cell overlaps for one interface.
The result feeds into
compute_interface_smatrix(). Seepropagate()for the one-shot alternative.- Parameters:
left_modes (
EMEStageCellModes) β Staged modes for the two cells forming this interface, matching a pair fromcell_index_pairs.right_modes (
EMEStageCellModes) β Staged modes for the two cells forming this interface, matching a pair fromcell_index_pairs.
- Return type:
- compute_overlaps(mode_data)[source]#
Stage modes and compute all per-cell and per-interface overlaps.
Convenience wrapper around
stage_cell_modes(),compute_cell_overlap(), andcompute_interface_overlap(). Under the supported sweep types (EMELengthSweep,EMEModeSweep,EMEPeriodicitySweep) the returned overlaps are sweep-invariant, so compute them once and pass the results topropagate_from_overlaps()as many times as you want β one per iterative design probe.- Parameters:
mode_data (Sequence[
ModeSimulationData|ModeSolverData]) β One mode result per EME cell, in cell order. Typically[ms.run_local() for ms in sim.mode_simulations].- Returns:
cell_overlaps (list[
EMEStageCellOverlap]) β One per EME cell, in cell order.interface_overlaps (list[
EMEStageInterfaceOverlap]) β One per interface, in the order ofcell_index_pairs.
- compute_cell_smatrix(cell_overlap, sweep_index=0)[source]#
Compute homogeneous propagation S-matrix for one cell at one sweep point.
See
propagate()for the one-shot alternative.- Parameters:
cell_overlap (
EMEStageCellOverlap)sweep_index (int) β Index into the sweep (
0tosweep_spec.num_sweep - 1). Ignored when nosweep_specis set.
- Return type:
- compute_interface_smatrix(left_overlap, right_overlap, interface_overlap, sweep_index=0)[source]#
Compute interface S-matrix for one interface at one sweep point.
See
propagate()for the one-shot alternative.- Parameters:
left_overlap (
EMEStageCellOverlap) β Cell overlaps for the two cells forming this interface, matching a pair fromcell_index_pairs.right_overlap (
EMEStageCellOverlap) β Cell overlaps for the two cells forming this interface, matching a pair fromcell_index_pairs.interface_overlap (
EMEStageInterfaceOverlap)sweep_index (int) β Index into the sweep (
0tosweep_spec.num_sweep - 1). Ignored when nosweep_specis set.
- Return type:
- compute_smatrix(cell_overlaps, cell_smatrices, interface_smatrices, sweep_index=0)[source]#
Stack cell and interface S-matrices into the final device S-matrix.
See
propagate()for the one-shot alternative.- Parameters:
cell_overlaps (list[
EMEStageCellOverlap] or None) β One per cell. Required whenself.normalizeis True (port flux normalization); may beNoneotherwise.cell_smatrices (list[
EMEStageCellSMatrix]) β One per cell.interface_smatrices (list[
EMEStageInterfaceSMatrix]) β One per interface, ordered to matchcell_index_pairs.sweep_index (int) β Index into the sweep (
0tosweep_spec.num_sweep - 1). Ignored when nosweep_specis set.
- Return type:
- propagate_from_overlaps(cell_overlaps, interface_overlaps)[source]#
Propagate to the device S-matrix using pre-computed overlaps.
Runs the S-matrix stages (cell / interface / stack) for every sweep point of
self.sweep_specand concatenates the results. Use this instead ofpropagate()when you want to reuse overlap integrals across several sweeps on the same modal basis β the overlaps are sweep-invariant underEMELengthSweep,EMEModeSweep, andEMEPeriodicitySweep, so recomputing them per sweep wastes work.EMEFreqSweepis not supported; specify target frequencies inEMESimulation.freqsinstead.- Parameters:
cell_overlaps (list[
EMEStageCellOverlap]) β One per EME cell, typically fromcompute_overlaps().interface_overlaps (list[
EMEStageInterfaceOverlap]) β One per interface, in the order ofcell_index_pairs, typically fromcompute_overlaps().
- Return type:
- propagate(mode_data)[source]#
Propagate modes through the device to compute the full S-matrix.
One-shot helper around
compute_overlaps()andpropagate_from_overlaps(). If you plan to run several sweeps against the same modal basis (e.g. coarse length scan, then zoom in), callcompute_overlaps()once andpropagate_from_overlaps()per sweep instead β overlaps are sweep-invariant under the supported sweep types, sopropagatewould redo that work each time.Supports
EMELengthSweep,EMEModeSweep, andEMEPeriodicitySweep.EMEFreqSweepis not supported; specify target frequencies inEMESimulation.freqsinstead.To override constraint, normalize, or sweep_spec, use
sim.updated_copy(...)before calling.- Parameters:
mode_data (Sequence[
ModeSimulationData|ModeSolverData]) β One mode result per EME cell, in cell order. Typically[ms.run_local() for ms in sim.mode_simulations].- Return type:
- smatrix_in_basis(smatrix, port_modes, modes1=None, modes2=None)[source]#
Express a locally propagated S-matrix in another modal basis.
Pass the mode data for the left and right EME ports, typically
(mode_data[0], mode_data[-1])from the sequence used bypropagate(). Ifmodes1ormodes2isNone, that port is left unchanged.- Parameters:
smatrix (
EMESMatrixDataset) β Device S-matrix in the port-mode basis, as returned bypropagate(),propagate_from_overlaps(), orcompute_smatrix().port_modes (tuple[
ModeSimulationData|ModeSolverData, β¦]) β Mode results at the two EME ports.modes1 (
ElectromagneticFieldData,ModeSolverData, or) βModeSimulationData, optional New modal bases at port 1 and port 2.modes2 (
ElectromagneticFieldData,ModeSolverData, or) βModeSimulationData, optional New modal bases at port 1 and port 2.
- Returns:
S-matrix in the new basis.
- Return type: