tidy3d.CustomMedium#
- class CustomMedium[source]#
Bases:
AbstractCustomMediumMediumwith user-supplied permittivity distribution.- 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,
attrsare mutable. For example, the following is allowed for setting anattrobj.attrs['foo'] = bar. Also note that Tidy3D` will raise aTypeErrorifattrscontain objects that can not be serialized. One can check ifattrsare serializable by callingobj.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.
viz_spec (Optional[VisualizationSpec] = None) – Plotting specification for visualizing medium.
heat_spec (Union[FluidSpec, SolidSpec, SolidMedium, FluidMedium, NoneType] = None) – DEPRECATED: Use td.MultiPhysicsMedium. Specification of the medium heat properties. They are used for solving the heat equation via the
HeatSimulationinterface. Such simulations can beused for investigating the influence of heat propagation on the properties of optical systems. Once the temperature distribution in the system is found usingHeatSimulationobject,Simulation.perturbed_mediums_copy()can be used to convert mediums with perturbation models defined into spatially dependent custom mediums. Otherwise, theheat_specdoes not directly affect the running of an opticalSimulation.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 bySimulation’s fieldsubpixelfor this type of material on the interface of the structure, including exterior boundary and intersection interfaces with other structures.eps_dataset (Optional[PermittivityDataset] = None) – [To be deprecated] User-supplied dataset containing complex-valued permittivity as a function of space. Permittivity distribution over the Yee-grid will be interpolated based on
interp_method.permittivity (Union[SpatialDataArray, Annotated[Union[tidy3d.components.data.unstructured.triangular.TriangularGridDataset, tidy3d.components.data.unstructured.tetrahedral.TetrahedralGridDataset], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})], NoneType] = None) – [units = None (relative permittivity)]. Spatial profile of relative permittivity.
conductivity (Union[SpatialDataArray, Annotated[Union[tidy3d.components.data.unstructured.triangular.TriangularGridDataset, tidy3d.components.data.unstructured.tetrahedral.TetrahedralGridDataset], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})], NoneType] = None) – [units = S/um]. Spatial profile Electric conductivity. Defined such that the imaginary part of the complex permittivity at angular frequency omega is given by conductivity/omega.
Example
>>> Nx, Ny, Nz = 10, 9, 8 >>> X = np.linspace(-1, 1, Nx) >>> Y = np.linspace(-1, 1, Ny) >>> Z = np.linspace(-1, 1, Nz) >>> coords = dict(x=X, y=Y, z=Z) >>> permittivity= SpatialDataArray(np.ones((Nx, Ny, Nz)), coords=coords) >>> conductivity= SpatialDataArray(np.ones((Nx, Ny, Nz)), coords=coords) >>> dielectric = CustomMedium(permittivity=permittivity, conductivity=conductivity) >>> eps = dielectric.eps_model(200e12)
Attributes
float array of frequencies.
Check if the medium is isotropic or anisotropic.
Whether the medium is spatially uniform.
This property computes the index of refraction related to CFL condition, so that the FDTD with this medium is stable when the time step size that doesn't take material factor into account is multiplied by
n_cfl`.Methods
eps_dataarray_freq(frequency)Permittivity array at
frequency.eps_diagonal(frequency)Main diagonal of the complex-valued permittivity tensor at
frequency.eps_diagonal_on_grid(frequency, coords)Spatial profile of main diagonal of the complex-valued permittivity at
frequencyinterpolated at the supplied coordinates.eps_model(frequency)Spatial and polarizaiton average of complex-valued permittivity as a function of frequency.
from_eps_raw(eps[, freq, interp_method])Construct a
CustomMediumfrom datasets containing raw permittivity values.from_nk(n[, k, freq, interp_method])Construct a
CustomMediumfrom datasets containing n and k values.grids(bounds)Make a
Gridcorresponding to the data in eacheps_iicomponent.Inherited Common Usage
- eps_dataset#
- permittivity#
- conductivity#
- property is_isotropic#
Check if the medium is isotropic or anisotropic.
- property is_spatially_uniform#
Whether the medium is spatially uniform.
- property freqs#
float array of frequencies. This field is to be deprecated in v3.0.
- property n_cfl#
This property computes the index of refraction related to CFL condition, so that the FDTD with this medium is stable when the time step size that doesn’t take material factor into account is multiplied by
n_cfl`.For dispersiveless custom medium, it equals
min[sqrt(eps_inf)], whereminis performed over all components and spatial points.
- eps_dataarray_freq(frequency)[source]#
Permittivity array at
frequency. ()- Parameters:
frequency (float) – Frequency to evaluate permittivity at (Hz).
- Returns:
Tuple[ –
], Union[
], Union[
],
] – The permittivity evaluated at
frequency.
- eps_diagonal_on_grid(frequency, coords)[source]#
Spatial profile of main diagonal of the complex-valued permittivity at
frequencyinterpolated at the supplied coordinates.- Parameters:
frequency (float) – Frequency to evaluate permittivity at (Hz).
coords (
Coords) – The grid point coordinates over which interpolation is performed.
- Returns:
The complex-valued permittivity tensor at
frequencyinterpolated at the supplied coordinate.- Return type:
Tuple[ArrayComplex3D, ArrayComplex3D, ArrayComplex3D]
- eps_diagonal(frequency)[source]#
Main diagonal of the complex-valued permittivity tensor at
frequency. Spatially, we take max{|eps|}, so that autoMesh generation works appropriately.
- eps_model(frequency)[source]#
Spatial and polarizaiton average of complex-valued permittivity as a function of frequency.
- classmethod from_eps_raw(eps, freq=None, interp_method='nearest', **kwargs)[source]#
Construct a
CustomMediumfrom datasets containing raw permittivity values.- Parameters:
eps (Union[) –
] Dataset containing complex-valued permittivity as a function of space.
freq (float, optional) – Frequency at which
epsare defined.interp_method (
InterpMethod, optional) – Interpolation method to obtain permittivity values that are not supplied at the Yee grids.
Notes
For lossy medium that has a complex-valued
eps, ifepsis supplied throughSpatialDataArray, which doesn’t contain frequency information, thefreqkwarg will be used to evaluate the permittivity and conductivity. Alternatively,epscan be supplied throughScalarFieldDataArray, which contains a frequency coordinate. In this case, leavefreqkwarg as the default ofNone.- Returns:
Medium containing the spatially varying permittivity data.
- Return type:
- classmethod from_nk(n, k=None, freq=None, interp_method='nearest', **kwargs)[source]#
Construct a
CustomMediumfrom datasets containing n and k values.- Parameters:
n (Union[) –
] Real part of refractive index.
k (Union[) –
], optional Imaginary part of refrative index for lossy medium.
freq (float, optional) – Frequency at which
nandkare defined.interp_method (
InterpMethod, optional) – Interpolation method to obtain permittivity values that are not supplied at the Yee grids.kwargs (dict) – Keyword arguments passed to the medium construction.
Note
For lossy medium, if both
nandkare supplied throughSpatialDataArray, which doesn’t contain frequency information, thefreqkwarg will be used to evaluate the permittivity and conductivity. Alternatively,nandkcan be supplied throughScalarFieldDataArray, which contains a frequency coordinate. In this case, leavefreqkwarg as the default ofNone.- Returns:
Medium containing the spatially varying permittivity data.
- Return type:
- grids(bounds)[source]#
Make a
Gridcorresponding to the data in eacheps_iicomponent. The min and max coordinates along each dimension are bounded bybounds.
- __hash__()#
Hash method.