tidy3d.CustomMedium
tidy3d.CustomMedium#
- class tidy3d.CustomMedium#
Medium
with user-supplied permittivity distribution.- Parameters
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.
eps_dataset (PermittivityDataset) – 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
.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.
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) >>> freqs = [2e14] >>> data = np.ones((Nx, Ny, Nz, 1)) >>> eps_diagonal_data = ScalarFieldDataArray(data, coords=dict(x=X, y=Y, z=Z, f=freqs)) >>> eps_components = {f"eps_{d}{d}": eps_diagonal_data for d in "xyz"} >>> eps_dataset = PermittivityDataset(**eps_components) >>> dielectric = CustomMedium(eps_dataset=eps_dataset, name='my_medium') >>> eps = dielectric.eps_model(200e12)
Show JSON schema
{ "title": "CustomMedium", "description": ":class:`.Medium` with user-supplied permittivity distribution.\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\neps_dataset : PermittivityDataset\n 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``.\ninterp_method : Literal['nearest', 'linear'] = nearest\n 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.\n\nExample\n-------\n>>> Nx, Ny, Nz = 10, 9, 8\n>>> X = np.linspace(-1, 1, Nx)\n>>> Y = np.linspace(-1, 1, Ny)\n>>> Z = np.linspace(-1, 1, Nz)\n>>> freqs = [2e14]\n>>> data = np.ones((Nx, Ny, Nz, 1))\n>>> eps_diagonal_data = ScalarFieldDataArray(data, coords=dict(x=X, y=Y, z=Z, f=freqs))\n>>> eps_components = {f\"eps_{d}{d}\": eps_diagonal_data for d in \"xyz\"}\n>>> eps_dataset = PermittivityDataset(**eps_components)\n>>> dielectric = CustomMedium(eps_dataset=eps_dataset, name='my_medium')\n>>> eps = dielectric.eps_model(200e12)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "CustomMedium", "enum": [ "CustomMedium" ], "type": "string" }, "eps_dataset": { "title": "Permittivity Dataset", "description": "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``.", "allOf": [ { "$ref": "#/definitions/PermittivityDataset" } ] }, "interp_method": { "title": "Interpolation method", "description": "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.", "default": "nearest", "enum": [ "nearest", "linear" ], "type": "string" } }, "required": [ "eps_dataset" ], "additionalProperties": false, "definitions": { "PermittivityDataset": { "title": "PermittivityDataset", "description": "Dataset storing the diagonal components of the permittivity tensor.\n\nParameters\n----------\neps_xx : ScalarFieldDataArray\n Spatial distribution of the xx-component of the relative permittivity.\neps_yy : ScalarFieldDataArray\n Spatial distribution of the yy-component of the relative permittivity.\neps_zz : ScalarFieldDataArray\n Spatial distribution of the zz-component of the relative permittivity.\n\nExample\n-------\n>>> x = [-1,1]\n>>> y = [-2,0,2]\n>>> z = [-3,-1,1,3]\n>>> f = [2e14, 3e14]\n>>> coords = dict(x=x, y=y, z=z, f=f)\n>>> sclr_fld = ScalarFieldDataArray((1+1j) * np.random.random((2,3,4,2)), coords=coords)\n>>> data = PermittivityDataset(eps_xx=sclr_fld, eps_yy=sclr_fld, eps_zz=sclr_fld)", "type": "object", "properties": { "type": { "title": "Type", "default": "PermittivityDataset", "enum": [ "PermittivityDataset" ], "type": "string" }, "eps_xx": { "title": "DataArray", "description": "Spatial distribution of the xx-component of the relative permittivity.", "type": "xr.DataArray", "properties": { "_dims": { "title": "_dims", "type": "Tuple[str, ...]" } }, "required": [ "_dims" ] }, "eps_yy": { "title": "DataArray", "description": "Spatial distribution of the yy-component of the relative permittivity.", "type": "xr.DataArray", "properties": { "_dims": { "title": "_dims", "type": "Tuple[str, ...]" } }, "required": [ "_dims" ] }, "eps_zz": { "title": "DataArray", "description": "Spatial distribution of the zz-component of the relative permittivity.", "type": "xr.DataArray", "properties": { "_dims": { "title": "_dims", "type": "Tuple[str, ...]" } }, "required": [ "_dims" ] } }, "required": [ "eps_xx", "eps_yy", "eps_zz" ], "additionalProperties": false } } }
- attribute eps_dataset: tidy3d.components.data.dataset.PermittivityDataset [Required]#
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
.- Validated by
_eps_inf_greater_no_less_than_one_sigma_positive
_single_frequency
- attribute 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.
- eps_dataset_freq(frequency: float) tidy3d.components.data.dataset.PermittivityDataset #
Permittivity dataset at
frequency
. The dispersion comes from DC conductivity that results in nonzero Im[eps].- Parameters
frequency (float) – Frequency to evaluate permittivity at (Hz).
- Returns
The permittivity evaluated at
frequency
.- Return type
- eps_diagonal(frequency: float) Tuple[complex, complex, complex] #
Main diagonal of the complex-valued permittivity tensor at
frequency
. Spatially, we take max{||eps||}, so that autoMesh generation works appropriately.
- eps_diagonal_on_grid(frequency: float, coords: tidy3d.components.grid.grid.Coords) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] #
Spatial profile of main diagonal of the complex-valued permittivity at
frequency
interpolated 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
frequency
interpolated at the supplied coordinate.- Return type
Tuple[Numpy, Numpy, Numpy]
- eps_model(frequency: float) complex #
Spatial and poloarizaiton average of complex-valued permittivity as a function of frequency.
- classmethod from_eps_raw(eps: tidy3d.components.data.data_array.ScalarFieldDataArray, interp_method: Literal['nearest', 'linear'] = 'nearest') tidy3d.components.medium.CustomMedium #
Construct a
CustomMedium
from datasets containing raw permittivity values.- Parameters
eps (
ScalarFieldDataArray
) – Dataset containing complex-valued permittivity as a function of space.interp_method (
InterpMethod
, optional) – Interpolation method to obtain permittivity values that are not supplied at the Yee grids.
- Returns
Medium containing the spatially varying permittivity data.
- Return type
- classmethod from_nk(n: tidy3d.components.data.data_array.ScalarFieldDataArray, k: Optional[tidy3d.components.data.data_array.ScalarFieldDataArray] = None, interp_method: Literal['nearest', 'linear'] = 'nearest') tidy3d.components.medium.CustomMedium #
Construct a
CustomMedium
from datasets containing n and k values.- Parameters
n (
ScalarFieldDataArray
) – Real part of refractive index.k (
ScalarFieldDataArray
= None) – Imaginary part of refrative index.interp_method (
InterpMethod
, optional) – Interpolation method to obtain permittivity values that are not supplied at the Yee grids.
- Returns
Medium containing the spatially varying permittivity data.
- Return type