tidy3d.rf.MicrowaveModeSolverData#

class MicrowaveModeSolverData[source]#

Bases: MicrowaveModeDataBase, ModeSolverData

Data associated with a ModeSolverMonitor for microwave and RF applications: scalar components of E and H fields plus characteristic impedance data.

Parameters:
  • attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • Ex (Optional[ScalarModeFieldDataArray] = None) – Spatial distribution of the x-component of the electric field of the mode.

  • Ey (Optional[ScalarModeFieldDataArray] = None) – Spatial distribution of the y-component of the electric field of the mode.

  • Ez (Optional[ScalarModeFieldDataArray] = None) – Spatial distribution of the z-component of the electric field of the mode.

  • Hx (Optional[ScalarModeFieldDataArray] = None) – Spatial distribution of the x-component of the magnetic field of the mode.

  • Hy (Optional[ScalarModeFieldDataArray] = None) – Spatial distribution of the y-component of the magnetic field of the mode.

  • Hz (Optional[ScalarModeFieldDataArray] = None) – Spatial distribution of the z-component of the magnetic field of the mode.

  • monitor (MicrowaveModeSolverMonitor) – Mode monitor associated with the data.

  • symmetry (Tuple[Literal[0, -1, 1], Literal[0, -1, 1], Literal[0, -1, 1]] = (0, 0, 0)) – Symmetry eigenvalues of the original simulation in x, y, and z.

  • symmetry_center (Optional[Tuple[float, float, float]] = None) – Center of the symmetry planes of the original simulation in x, y, and z. Required only if any of the symmetry field are non-zero.

  • grid_expanded (Optional[Grid] = None) – Grid discretization of the associated monitor in the simulation which created the data. Required if symmetries are present, as well as in order to use some functionalities like getting Poynting vector and flux.

  • grid_primal_correction (Union[float, FreqDataArray, TimeDataArray, FreqModeDataArray, EMEFreqModeDataArray] = 1.0) – Correction factor that needs to be applied for data corresponding to a 2D monitor to take into account the finite grid in the normal direction in the simulation in which the data was computed. The factor is applied to fields defined on the primal grid locations along the normal direction.

  • grid_dual_correction (Union[float, FreqDataArray, TimeDataArray, FreqModeDataArray, EMEFreqModeDataArray] = 1.0) – Correction factor that needs to be applied for data corresponding to a 2D monitor to take into account the finite grid in the normal direction in the simulation in which the data was computed. The factor is applied to fields defined on the dual grid locations along the normal direction.

  • n_complex (ModeIndexDataArray) – Complex-valued effective propagation constants associated with the mode.

  • n_group_raw (Optional[GroupIndexDataArray] = None) – Index associated with group velocity of the mode.

  • dispersion_raw (Optional[ModeDispersionDataArray] = None) – [units = ps/(nm km)]. Dispersion parameter for the mode.

  • amps (Optional[ModeAmpsDataArray] = None) – Unused for ModeSolverData.

  • eps_spec (Optional[List[Literal['diagonal', 'tensorial_real', 'tensorial_complex']]] = None) – Characterization of the permittivity profile on the plane where modes are computed. Possible values are ‘diagonal’, ‘tensorial_real’, ‘tensorial_complex’.

  • grid_distances_primal (Union[tuple[float], tuple[float, float]] = (0.0,)) – Relative distances to the primal grid locations along the normal direction in the original simulation grid. Needed to recalculate grid corrections after interpolating in frequency.

  • grid_distances_dual (Union[tuple[float], tuple[float, float]] = (0.0,)) – Relative distances to the dual grid locations along the normal direction in the original simulation grid. Needed to recalculate grid corrections after interpolating in frequency.

  • transmission_line_data (Optional[TransmissionLineDataset] = None) – Additional data relevant to transmission lines in RF and microwave applications, like characteristic impedance. This field is populated when a MicrowaveModeSpec has been used to set up the monitor or mode solver.

Notes

This class extends ModeSolverData with additional microwave-specific data including characteristic impedance, voltage coefficients, and current coefficients. The data is stored as DataArray objects using the xarray package.

The microwave mode solver data contains all field components (Ex, Ey, Ez, Hx, Hy, Hz) and effective indices from ModeSolverData, plus impedance calculations performed using voltage and current line integrals as specified in the MicrowaveModeSpec.

Example

>>> import tidy3d as td
>>> import numpy as np
>>> from tidy3d import Grid, Coords
>>> from tidy3d.components.data.data_array import (
...     CurrentFreqModeDataArray,
...     ImpedanceFreqModeDataArray,
...     ScalarModeFieldDataArray,
...     ModeIndexDataArray,
...     VoltageFreqModeDataArray,
... )
>>> from tidy3d.components.microwave.data.dataset import TransmissionLineDataset
>>> x = [-1, 1, 3]
>>> y = [-2, 0]
>>> z = [-3, -1, 1, 3, 5]
>>> f = [2e14, 3e14]
>>> mode_index = np.arange(3)
>>> grid = Grid(boundaries=Coords(x=x, y=y, z=z))
>>> field_coords = dict(x=x[:-1], y=y[:-1], z=z[:-1], f=f, mode_index=mode_index)
>>> field = ScalarModeFieldDataArray((1+1j)*np.random.random((2,1,4,2,3)), coords=field_coords)
>>> index_coords = dict(f=f, mode_index=mode_index)
>>> index_data = ModeIndexDataArray((1+1j) * np.random.random((2,3)), coords=index_coords)
>>> impedance_data = ImpedanceFreqModeDataArray(50 * np.ones((2, 3)), coords=index_coords)
>>> voltage_data = VoltageFreqModeDataArray((1+1j) * np.random.random((2, 3)), coords=index_coords)
>>> current_data = CurrentFreqModeDataArray((0.02+0.01j) * np.random.random((2, 3)), coords=index_coords)
>>> tl_data = TransmissionLineDataset(
...     Z0=impedance_data,
...     voltage_coeffs=voltage_data,
...     current_coeffs=current_data
... )
>>> monitor = td.MicrowaveModeSolverMonitor(
...    center=(0, 0, 0),
...    size=(2, 0, 6),
...    freqs=[2e14, 3e14],
...    mode_spec=td.MicrowaveModeSpec(num_modes=3, impedance_specs=td.AutoImpedanceSpec()),
...    name='microwave_mode_solver',
... )
>>> data = MicrowaveModeSolverData(
...     monitor=monitor,
...     Ex=field,
...     Ey=field,
...     Ez=field,
...     Hx=field,
...     Hy=field,
...     Hz=field,
...     n_complex=index_data,
...     grid_expanded=grid,
...     transmission_line_data=tl_data
... )

Attributes

Methods

interp_in_freq(freqs[, method, renormalize, ...])

Interpolate mode data to new frequency points.

Inherited Common Usage

monitor#
interp_in_freq(freqs, method='linear', renormalize=True, recalculate_grid_correction=True, assume_sorted=False)[source]#

Interpolate mode data to new frequency points.

Interpolates all stored mode data (effective indices, field components, group indices, and dispersion) from the current frequency grid to a new set of frequencies. This is useful for obtaining mode data at many frequencies from computations at fewer frequencies, when modes vary smoothly with frequency.

Parameters:
  • freqs (FreqArray) – New frequency points to interpolate to. Should generally span a similar range as the original frequencies to avoid extrapolation.

  • method (Literal["linear", "cubic", "cheb"]) – Interpolation method. "linear" for linear interpolation (requires 2+ source frequencies), "cubic" for cubic spline interpolation (requires 4+ source frequencies), "cheb" for Chebyshev polynomial interpolation using barycentric formula (requires 3+ source frequencies at Chebyshev nodes). For complex-valued data, real and imaginary parts are interpolated independently.

  • renormalize (Optional[bool] = True) – Whether to renormalize the mode profiles to unity power after interpolation.

  • recalculate_grid_correction (bool = True) – Whether to recalculate the grid correction factors after interpolation or use interpolated grid corrections.

  • assume_sorted (bool = False,) – Whether to assume the frequency points are sorted.

Returns:

New ModeSolverData object with data interpolated to the requested frequencies.

Return type:

ModeSolverData

Raises:

DataError – If interpolation parameters are invalid (e.g., too few source frequencies for the chosen method, or source frequencies not at Chebyshev nodes for ‘cheb’ method).

Note

Interpolation assumes modes vary smoothly with frequency. Results may be inaccurate near mode crossings or regions of rapid mode variation. Use frequency tracking (mode_spec.sort_spec.track_freq) to help maintain mode ordering consistency.

For Chebyshev interpolation, source frequencies must be at Chebyshev nodes of the second kind within the frequency range.

Example

>>> # Compute modes at 5 frequencies
>>> import numpy as np
>>> freqs_sparse = np.linspace(1e14, 2e14, 5)
>>> # ... create mode_solver and compute modes ...
>>> # mode_data = mode_solver.solve()
>>> # Interpolate to 50 frequencies
>>> freqs_dense = np.linspace(1e14, 2e14, 50)
>>> # mode_data_interp = mode_data.interp(freqs=freqs_dense, method='linear')
__hash__()#

Hash method.