class CustomPoleResidue[source]#

Bases: CustomDispersiveMedium, PoleResidue

A spatially varying dispersive medium described by the pole-residue pair model.

  • 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().

  • name (Optional[str] = None) – Optional unique name for medium.

  • frequency_range (Optional[Tuple[float, float]] = None) – [units = (Hz, Hz)]. Optional range of validity for the medium.

  • allow_gain (bool = False) – Allow the medium to be active. Caution: simulations with a gain medium are unstable, and are likely to diverge.Simulations where ‘allow_gain’ is set to ‘True’ will still be charged even if diverged. Monitor data up to the divergence point will still be returned and can be useful in some cases.

  • nonlinear_spec (Union[NonlinearSpec, NonlinearSusceptibility] = None) – Nonlinear spec applied on top of the base medium properties.

  • modulation_spec (Optional[ModulationSpec] = None) – Modulation spec applied on top of the base medium properties.

  • heat_spec (Union[FluidSpec, SolidSpec, NoneType] = None) – Specification of the medium heat properties. They are used for solving the heat equation via the HeatSimulation interface. Such simulations can be used for investigating the influence of heat propagation on the properties of optical systems. Once the temperature distribution in the system is found using HeatSimulation object, Simulation.perturbed_mediums_copy() can be used to convert mediums with perturbation models defined into spatially dependent custom mediums. Otherwise, the heat_spec does not directly affect the running of an optical Simulation.

  • eps_inf (Union[SpatialDataArray, Annotated[Union[tidy3d.components.data.dataset.TriangularGridDataset, tidy3d.components.data.dataset.TetrahedralGridDataset], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})]]) – [units = None (relative permittivity)]. Relative permittivity at infinite frequency (\(\epsilon_\infty\)).

  • poles (Tuple[Tuple[Union[tidy3d.components.data.data_array.SpatialDataArray, Annotated[Union[tidy3d.components.data.dataset.TriangularGridDataset, tidy3d.components.data.dataset.TetrahedralGridDataset], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})]], Union[tidy3d.components.data.data_array.SpatialDataArray, Annotated[Union[tidy3d.components.data.dataset.TriangularGridDataset, tidy3d.components.data.dataset.TetrahedralGridDataset], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})]]], ...] = ()) – [units = (rad/sec, rad/sec)]. Tuple of complex-valued (\(a_i, c_i\)) poles for the model.

  • interp_method (Literal['nearest', 'linear'] = nearest) – Interpolation method to obtain permittivity values that are not supplied at the Yee grids; For grids outside the range of the supplied data, extrapolation will be applied. When the extrapolated value is smaller (greater) than the minimal (maximal) of the supplied data, the extrapolated value will take the minimal (maximal) of the supplied data.

  • subpixel (bool = False) – If True, apply the subpixel averaging method specified by Simulation’s field subpixel for this type of material on the interface of the structure, including exterior boundary and intersection interfaces with other structures.


In this method, the frequency-dependent permittivity \(\epsilon(\omega)\) is expressed as a sum of resonant material poles [1].

\[\epsilon(\omega) = \epsilon_\infty - \sum_i \left[\frac{c_i}{j \omega + a_i} + \frac{c_i^*}{j \omega + a_i^*}\right]\]

For each of these resonant poles identified by the index \(i\), an auxiliary differential equation is used to relate the auxiliary current \(J_i(t)\) to the applied electric field \(E(t)\). The sum of all these auxiliary current contributions describes the total dielectric response of the material.

\[\frac{d}{dt} J_i (t) - a_i J_i (t) = \epsilon_0 c_i \frac{d}{dt} E (t)\]

Hence, the computational cost increases with the number of poles.



>>> x = np.linspace(-1, 1, 5)
>>> y = np.linspace(-1, 1, 6)
>>> z = np.linspace(-1, 1, 7)
>>> coords = dict(x=x, y=y, z=z)
>>> eps_inf = SpatialDataArray(np.ones((5, 6, 7)), coords=coords)
>>> a1 = SpatialDataArray(-np.random.random((5, 6, 7)), coords=coords)
>>> c1 = SpatialDataArray(np.random.random((5, 6, 7)), coords=coords)
>>> a2 = SpatialDataArray(-np.random.random((5, 6, 7)), coords=coords)
>>> c2 = SpatialDataArray(np.random.random((5, 6, 7)), coords=coords)
>>> pole_res = CustomPoleResidue(eps_inf=eps_inf, poles=[(a1, c1), (a2, c2)])
>>> eps = pole_res.eps_model(200e12)



Whether the medium is spatially uniform.


Not implemented yet.




Compute adjoint derivatives for each of the fields given the multiplied E and D.


Permittivity array at frequency.


Convert a CustomMedium to a pole residue model.


Spatial profile of poles interpolated at the supplied coordinates.


Convert to a CustomMedium.

Inherited Common Usage

property is_spatially_uniform#

Whether the medium is spatially uniform.


Permittivity array at frequency.


frequency (float) – Frequency to evaluate permittivity at (Hz).



Spatial profile of poles interpolated at the supplied coordinates.


coords (Coords) – The grid point coordinates over which interpolation is performed.


The poles interpolated at the supplied coordinate.

Return type:

Tuple[Tuple[ArrayComplex3D, ArrayComplex3D], …]

classmethod from_medium(medium)[source]#

Convert a CustomMedium to a pole residue model.


medium (CustomMedium) – The medium with permittivity and conductivity to convert.


The pole residue equivalent.

Return type:



Convert to a CustomMedium. Requires the pole residue model to only have a pole at 0 frequency, corresponding to a constant conductivity term.


The non-dispersive equivalent with constant permittivity and conductivity.

Return type:


property loss_upper_bound#

Not implemented yet.


Compute adjoint derivatives for each of the fields given the multiplied E and D.


Hash method.