flex_rf.tidy3d.CustomMedium
Type: class │ Base(s): AbstractCustomMedium
Description
Section titled “Description”Medium with user-supplied permittivity distribution.
Practical Advice
Use CustomMedium when permittivity varies spatially — for example, graded-index
(GRIN) lenses or topology-optimized design regions. Define the permittivity on a
rectangular grid using SpatialDataArray:
from tidy3d import SpatialDataArrayimport numpy as np
x = np.linspace(-5, 5, 100)y = np.linspace(-5, 5, 100)z = [0] # 2D variationX, Y = np.meshgrid(x, y, indexing="ij")eps_data = 1 + 3 * np.exp(-(X**2 + Y**2) / 4)eps_data = eps_data[:, :, np.newaxis]
permittivity = SpatialDataArray(eps_data, coords=dict(x=x, y=y, z=z))custom_medium = CustomMedium(permittivity=permittivity)For uniform pixelated grids (e.g. topology optimization), consider the convenience method
from_permittivity_array, which creates a Structure with a CustomMedium
directly from a 3D numpy array and a geometry.
For wavelength-independent homogeneous materials, use Medium instead.
For dispersive materials, use FastDispersionFitter or an analytical model.
Example(s)
Section titled “Example(s)”Nx, Ny, Nz = 10, 9, 8X = 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)Parameters
Section titled “Parameters”name [str | None] = None |
|
Optional unique name for medium. |
frequency_range [FreqBound | None] = None |
|
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 |
nonlinear_spec [NonlinearSpec | NonlinearSusceptibility | None] = None |
|
Nonlinear spec applied on top of the base medium properties. |
modulation_spec [ModulationSpec | None] = None |
|
Modulation spec applied on top of the base medium properties. |
viz_spec [VisualizationSpec | None] = None |
|
Plotting specification for visualizing medium. |
heat_spec [ThermalSpecType | None] = None |
|
DEPRECATED: Use |
interp_method [InterpMethod] = '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 |
derived_from [PerturbationMediumType | None] = None |
|
If not |
eps_dataset [PermittivityDataset | None] = 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 |
permittivity [CustomSpatialDataTypeAnnotated | None] = None |
|
Spatial profile of relative permittivity. |
conductivity [CustomSpatialDataTypeAnnotated | None] = None |
|
Spatial profile Electric conductivity. Defined such that the imaginary part of the complex permittivity at angular frequency omega is given by conductivity/omega. |
Methods
Section titled “Methods”eps_dataarray_freq(frequency: float) |
|
Permittivity array at |
eps_diagonal(frequency: float) |
|
Main diagonal of the complex-valued permittivity tensor at |
eps_diagonal_on_grid(frequency: float, coords: Coords) |
|
Spatial profile of main diagonal of the complex-valued permittivity at |
eps_model(frequency: float) |
|
Spatial and polarizaiton average of complex-valued permittivity as a function of frequency. |
freqs() |
|
float array of frequencies. This field is to be deprecated in v3.0. |
from_eps_raw(eps: ScalarFieldDataArray | CustomSpatialDataType, freq: float | None = None, interp_method: InterpMethod = 'nearest', **kwargs: Any) |
|
Construct a |
from_nk(n: ScalarFieldDataArray | CustomSpatialDataType, k: ScalarFieldDataArray | CustomSpatialDataType | None = None, freq: float | None = None, interp_method: InterpMethod = 'nearest', **kwargs: Any) |
|
Construct a |
grids(bounds: Bound) |
|
Make a |
is_isotropic() |
|
Check if the medium is isotropic or anisotropic. |
is_spatially_uniform() |
|
Whether the medium is spatially uniform. |
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```. |