tidy3d.Scene#

class tidy3d.Scene(*, medium: Union[tidy3d.components.medium.Medium, tidy3d.components.medium.AnisotropicMedium, tidy3d.components.medium.PECMedium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude, tidy3d.components.medium.FullyAnisotropicMedium, tidy3d.components.medium.CustomMedium, tidy3d.components.medium.CustomPoleResidue, tidy3d.components.medium.CustomSellmeier, tidy3d.components.medium.CustomLorentz, tidy3d.components.medium.CustomDebye, tidy3d.components.medium.CustomDrude, tidy3d.components.medium.CustomAnisotropicMedium, tidy3d.components.medium.PerturbationMedium, tidy3d.components.medium.PerturbationPoleResidue] = Medium(name=None, frequency_range=None, allow_gain=False, nonlinear_spec=None, modulation_spec=None, heat_spec=None, type='Medium', permittivity=1.0, conductivity=0.0), structures: Tuple[tidy3d.components.structure.Structure, ...] = (), type: Literal['Scene'] = 'Scene')#

Bases: tidy3d.components.base.Tidy3dBaseModel

Contains generic information about the geometry and medium properties common to all types of simulations.

Parameters

Example

>>> sim = Scene(
...     structures=[
...         Structure(
...             geometry=Box(size=(1, 1, 1), center=(0, 0, 0)),
...             medium=Medium(permittivity=2.0),
...         ),
...     ],
...     medium=Medium(permittivity=3.0),
... )
__init__(**kwargs)#

Init method, includes post-init validators.

Methods

__init__(**kwargs)

Init method, includes post-init validators.

add_type_field()

Automatically place "type" field with model name in the model field dictionary.

construct([_fields_set])

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.

copy(**kwargs)

Copy a Tidy3dBaseModel.

dict(*[, include, exclude, by_alias, ...])

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

dict_from_file(fname[, group_path])

Loads a dictionary containing the model from a .yaml, .json, .hdf5, or .hdf5.gz file.

dict_from_hdf5(fname[, group_path, ...])

Loads a dictionary containing the model contents from a .hdf5 file.

dict_from_hdf5_gz(fname[, group_path, ...])

Loads a dictionary containing the model contents from a .hdf5.gz file.

dict_from_json(fname)

Load dictionary of the model from a .json file.

dict_from_yaml(fname)

Load dictionary of the model from a .yaml file.

eps_bounds([freq])

Compute range of (real) permittivity present in the scene at frequency "freq".

from_file(fname[, group_path])

Loads a Tidy3dBaseModel from .yaml, .json, .hdf5, or .hdf5.gz file.

from_hdf5(fname[, group_path, custom_decoders])

Loads Tidy3dBaseModel instance to .hdf5 file.

from_hdf5_gz(fname[, group_path, ...])

Loads Tidy3dBaseModel instance to .hdf5.gz file.

from_json(fname, **parse_obj_kwargs)

Load a Tidy3dBaseModel from .json file.

from_orm(obj)

from_yaml(fname, **parse_obj_kwargs)

Loads Tidy3dBaseModel from .yaml file.

generate_docstring()

Generates a docstring for a Tidy3D mode and saves it to the __doc__ of the class.

get_sub_model(group_path, model_dict)

Get the sub model for a given group path.

get_submodels_by_hash()

Return a dictionary of this object's sub-models indexed by their hash values.

get_tuple_group_name(index)

Get the group name of a tuple element.

get_tuple_index(key_name)

Get the index into the tuple based on its group name.

heat_conductivity_bounds()

Compute range of thermal conductivities present in the scene.

help([methods])

Prints message describing the fields and methods of a Tidy3dBaseModel.

intersecting_media(test_object, structures)

From a given list of structures, returns a list of AbstractMedium associated with those structures that intersect with the test_object, if it is a surface, or its surfaces, if it is a volume.

intersecting_structures(test_object, structures)

From a given list of structures, returns a list of Structure that intersect with the test_object, if it is a surface, or its surfaces, if it is a volume.

json(*[, include, exclude, by_alias, ...])

Generate a JSON representation of the model, include and exclude arguments as per dict().

parse_file(path, *[, content_type, ...])

parse_obj(obj)

parse_raw(b, *[, content_type, encoding, ...])

perturbed_mediums_copy([temperature, ...])

Return a copy of the scene with heat and/or charge data applied to all mediums that have perturbation models specified.

plot([x, y, z, ax, hlim, vlim])

Plot each of scene's components on a plane defined by one nonzero x,y,z coordinate.

plot_eps([x, y, z, freq, alpha, ax, hlim, vlim])

Plot each of scene's components on a plane defined by one nonzero x,y,z coordinate.

plot_heat_conductivity([x, y, z, alpha, ...])

Plot each of scebe's components on a plane defined by one nonzero x,y,z coordinate.

plot_structures([x, y, z, ax, hlim, vlim])

Plot each of scene's structures on a plane defined by one nonzero x,y,z coordinate.

plot_structures_eps([x, y, z, freq, alpha, ...])

Plot each of scene's structures on a plane defined by one nonzero x,y,z coordinate.

plot_structures_heat_conductivity([x, y, z, ...])

Plot each of scene's structures on a plane defined by one nonzero x,y,z coordinate.

schema([by_alias, ref_template])

schema_json(*[, by_alias, ref_template])

to_file(fname)

Exports Tidy3dBaseModel instance to .yaml, .json, or .hdf5 file

to_hdf5(fname[, custom_encoders])

Exports Tidy3dBaseModel instance to .hdf5 file.

to_hdf5_gz(fname[, custom_encoders])

Exports Tidy3dBaseModel instance to .hdf5.gz file.

to_json(fname)

Exports Tidy3dBaseModel instance to .json file

to_yaml(fname)

Exports Tidy3dBaseModel instance to .yaml file.

tuple_to_dict(tuple_values)

How we generate a dictionary mapping new keys to tuple values for hdf5.

update_forward_refs(**localns)

Try to update ForwardRefs on fields based on this Model, globalns and localns.

updated_copy(**kwargs)

Make copy of a component instance with **kwargs indicating updated field values.

validate(value)

Attributes

background_structure

Returns structure representing the background of the Scene.

bounds

Automatically defined scene's bounds based on present structures.

box

Automatically defined scene's Box.

center

Automatically defined scene's center.

medium_map

Returns dict mapping medium to index in material.

mediums

Returns set of distinct AbstractMedium in scene.

size

Automatically defined scene's size.

medium

structures

Validating setup

class Config#

Bases: object

Sets config for all Tidy3dBaseModel objects.

allow_population_by_field_namebool = True

Allow properties to stand in for fields(?).

arbitrary_types_allowedbool = True

Allow types like numpy arrays.

extrastr = ‘forbid’

Forbid extra kwargs not specified in model.

json_encodersDict[type, Callable]

Defines how to encode type in json file.

validate_allbool = True

Validate default values just to be safe.

validate_assignmentbool

Re-validate after re-assignment of field in model.

__eq__(other)#

Define == for two Tidy3DBaseModels.

__ge__(other)#

define >= for getting unique indices based on hash.

__gt__(other)#

define > for getting unique indices based on hash.

__hash__() int#

Hash method.

classmethod __init_subclass__() None#

Things that are done to each of the models.

__iter__() TupleGenerator#

so dict(model) works

__le__(other)#

define <= for getting unique indices based on hash.

__lt__(other)#

define < for getting unique indices based on hash.

__pretty__(fmt: Callable[[Any], Any], **kwargs: Any) Generator[Any, None, None]#

Used by devtools (https://python-devtools.helpmanual.io/) to provide a human readable representations of objects

__repr_name__() str#

Name of the instance’s class, used in __repr__.

__rich_repr__() RichReprResult#

Get fields for Rich library

classmethod __try_update_forward_refs__(**localns: Any) None#

Same as update_forward_refs but will not raise exception when forward references are not defined.

classmethod add_type_field() None#

Automatically place “type” field with model name in the model field dictionary.

property background_structure: tidy3d.components.structure.Structure#

Returns structure representing the background of the Scene.

property bounds: Tuple[Tuple[float, float, float], Tuple[float, float, float]]#

Automatically defined scene’s bounds based on present structures. Infinite dimensions are ignored. If the scene contains no strucutres, the bounds are set to (-1, -1, -1), (1, 1, 1). Similarly, if along a given axis all structures extend infinitely, the bounds along that axis are set from -1 to 1.

Returns

Min and max bounds packaged as (minx, miny, minz), (maxx, maxy, maxz).

Return type

Tuple[float, float, float], Tuple[float, float, float]

property box: tidy3d.components.geometry.base.Box#

Automatically defined scene’s Box.

Returns

Scene’s box.

Return type

Box

property center: Tuple[float, float, float]#

Automatically defined scene’s center.

Returns

Scene’s center.

Return type

Tuple[float, float, float]

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

copy(**kwargs) tidy3d.components.base.Tidy3dBaseModel#

Copy a Tidy3dBaseModel. With deep=True as default.

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

classmethod dict_from_file(fname: str, group_path: Optional[str] = None) dict#

Loads a dictionary containing the model from a .yaml, .json, .hdf5, or .hdf5.gz file.

Parameters
  • fname (str) – Full path to the file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to use as the base level.

Returns

A dictionary containing the model.

Return type

dict

Example

>>> simulation = Simulation.from_file(fname='folder/sim.json') 
classmethod dict_from_hdf5(fname: str, group_path: str = '', custom_decoders: Optional[List[Callable]] = None) dict#

Loads a dictionary containing the model contents from a .hdf5 file.

Parameters
  • fname (str) – Full path to the .hdf5 file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only.

  • custom_decoders (List[Callable]) – List of functions accepting (fname: str, group_path: str, model_dict: dict, key: str, value: Any) that store the value in the model dict after a custom decoding.

Returns

Dictionary containing the model.

Return type

dict

Example

>>> sim_dict = Simulation.dict_from_hdf5(fname='folder/sim.hdf5') 
classmethod dict_from_hdf5_gz(fname: str, group_path: str = '', custom_decoders: Optional[List[Callable]] = None) dict#

Loads a dictionary containing the model contents from a .hdf5.gz file.

Parameters
  • fname (str) – Full path to the .hdf5.gz file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only.

  • custom_decoders (List[Callable]) – List of functions accepting (fname: str, group_path: str, model_dict: dict, key: str, value: Any) that store the value in the model dict after a custom decoding.

Returns

Dictionary containing the model.

Return type

dict

Example

>>> sim_dict = Simulation.dict_from_hdf5(fname='folder/sim.hdf5.gz') 
classmethod dict_from_json(fname: str) dict#

Load dictionary of the model from a .json file.

Parameters

fname (str) – Full path to the .json file to load the Tidy3dBaseModel from.

Returns

A dictionary containing the model.

Return type

dict

Example

>>> sim_dict = Simulation.dict_from_json(fname='folder/sim.json') 
classmethod dict_from_yaml(fname: str) dict#

Load dictionary of the model from a .yaml file.

Parameters

fname (str) – Full path to the .yaml file to load the Tidy3dBaseModel from.

Returns

A dictionary containing the model.

Return type

dict

Example

>>> sim_dict = Simulation.dict_from_yaml(fname='folder/sim.yaml') 
eps_bounds(freq: Optional[float] = None) Tuple[float, float]#

Compute range of (real) permittivity present in the scene at frequency “freq”.

Parameters

freq (float = None) – Frequency to evaluate the relative permittivity of all mediums. If not specified, evaluates at infinite frequency.

Returns

Minimal and maximal values of relative permittivity in scene.

Return type

Tuple[float, float]

classmethod from_file(fname: str, group_path: Optional[str] = None, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Loads a Tidy3dBaseModel from .yaml, .json, .hdf5, or .hdf5.gz file.

Parameters
  • fname (str) – Full path to the file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to use as the base level. Only for hdf5 files. Starting / is optional.

  • **parse_obj_kwargs – Keyword arguments passed to either pydantic’s parse_obj function when loading model.

Returns

An instance of the component class calling load.

Return type

Tidy3dBaseModel

Example

>>> simulation = Simulation.from_file(fname='folder/sim.json') 
classmethod from_hdf5(fname: str, group_path: str = '', custom_decoders: Optional[List[Callable]] = None, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Loads Tidy3dBaseModel instance to .hdf5 file.

Parameters
  • fname (str) – Full path to the .hdf5 file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only. Starting / is optional.

  • custom_decoders (List[Callable]) – List of functions accepting (fname: str, group_path: str, model_dict: dict, key: str, value: Any) that store the value in the model dict after a custom decoding.

  • **parse_obj_kwargs – Keyword arguments passed to pydantic’s parse_obj method.

Example

>>> simulation = Simulation.from_hdf5(fname='folder/sim.hdf5') 
classmethod from_hdf5_gz(fname: str, group_path: str = '', custom_decoders: Optional[List[Callable]] = None, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Loads Tidy3dBaseModel instance to .hdf5.gz file.

Parameters
  • fname (str) – Full path to the .hdf5.gz file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only. Starting / is optional.

  • custom_decoders (List[Callable]) – List of functions accepting (fname: str, group_path: str, model_dict: dict, key: str, value: Any) that store the value in the model dict after a custom decoding.

  • **parse_obj_kwargs – Keyword arguments passed to pydantic’s parse_obj method.

Example

>>> simulation = Simulation.from_hdf5_gz(fname='folder/sim.hdf5.gz') 
classmethod from_json(fname: str, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Load a Tidy3dBaseModel from .json file.

Parameters

fname (str) – Full path to the .json file to load the Tidy3dBaseModel from.

Returns

  • Tidy3dBaseModel – An instance of the component class calling load.

  • **parse_obj_kwargs – Keyword arguments passed to pydantic’s parse_obj method.

Example

>>> simulation = Simulation.from_json(fname='folder/sim.json') 
classmethod from_yaml(fname: str, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Loads Tidy3dBaseModel from .yaml file.

Parameters
  • fname (str) – Full path to the .yaml file to load the Tidy3dBaseModel from.

  • **parse_obj_kwargs – Keyword arguments passed to pydantic’s parse_obj method.

Returns

An instance of the component class calling from_yaml.

Return type

Tidy3dBaseModel

Example

>>> simulation = Simulation.from_yaml(fname='folder/sim.yaml') 
classmethod generate_docstring() str#

Generates a docstring for a Tidy3D mode and saves it to the __doc__ of the class.

classmethod get_sub_model(group_path: str, model_dict: dict | list) dict#

Get the sub model for a given group path.

get_submodels_by_hash() Dict[int, List[Union[str, Tuple[str, int]]]]#

Return a dictionary of this object’s sub-models indexed by their hash values.

static get_tuple_group_name(index: int) str#

Get the group name of a tuple element.

static get_tuple_index(key_name: str) int#

Get the index into the tuple based on its group name.

heat_conductivity_bounds() Tuple[float, float]#

Compute range of thermal conductivities present in the scene.

Returns

Minimal and maximal values of thermal conductivity in scene.

Return type

Tuple[float, float]

help(methods: bool = False) None#

Prints message describing the fields and methods of a Tidy3dBaseModel.

Parameters

methods (bool = False) – Whether to also print out information about object’s methods.

Example

>>> simulation.help(methods=True) 
static intersecting_media(test_object: tidy3d.components.geometry.base.Box, structures: Tuple[tidy3d.components.structure.Structure, ...]) Tuple[Union[tidy3d.components.medium.Medium, tidy3d.components.medium.AnisotropicMedium, tidy3d.components.medium.PECMedium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude, tidy3d.components.medium.FullyAnisotropicMedium, tidy3d.components.medium.CustomMedium, tidy3d.components.medium.CustomPoleResidue, tidy3d.components.medium.CustomSellmeier, tidy3d.components.medium.CustomLorentz, tidy3d.components.medium.CustomDebye, tidy3d.components.medium.CustomDrude, tidy3d.components.medium.CustomAnisotropicMedium, tidy3d.components.medium.PerturbationMedium, tidy3d.components.medium.PerturbationPoleResidue, tidy3d.components.medium.Medium2D], ...]#

From a given list of structures, returns a list of AbstractMedium associated with those structures that intersect with the test_object, if it is a surface, or its surfaces, if it is a volume.

Parameters
  • test_object (Box) – Object for which intersecting media are to be detected.

  • structures (List[AbstractMedium]) – List of structures whose media will be tested.

Returns

Set of distinct mediums that intersect with the given planar object.

Return type

List[AbstractMedium]

static intersecting_structures(test_object: tidy3d.components.geometry.base.Box, structures: Tuple[tidy3d.components.structure.Structure, ...]) Tuple[tidy3d.components.structure.Structure, ...]#

From a given list of structures, returns a list of Structure that intersect with the test_object, if it is a surface, or its surfaces, if it is a volume.

Parameters
  • test_object (Box) – Object for which intersecting media are to be detected.

  • structures (List[AbstractMedium]) – List of structures whose media will be tested.

Returns

Set of distinct structures that intersect with the given surface, or with the surfaces of the given volume.

Return type

List[Structure]

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) str#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

property medium_map: Dict[Union[tidy3d.components.medium.Medium, tidy3d.components.medium.AnisotropicMedium, tidy3d.components.medium.PECMedium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude, tidy3d.components.medium.FullyAnisotropicMedium, tidy3d.components.medium.CustomMedium, tidy3d.components.medium.CustomPoleResidue, tidy3d.components.medium.CustomSellmeier, tidy3d.components.medium.CustomLorentz, tidy3d.components.medium.CustomDebye, tidy3d.components.medium.CustomDrude, tidy3d.components.medium.CustomAnisotropicMedium, tidy3d.components.medium.PerturbationMedium, tidy3d.components.medium.PerturbationPoleResidue, tidy3d.components.medium.Medium2D], pydantic.v1.types.NonNegativeInt]#

Returns dict mapping medium to index in material. medium_map[medium] returns unique global index of AbstractMedium in scene.

Returns

Mapping between distinct mediums to index in scene.

Return type

Dict[AbstractMedium, int]

property mediums: Set[Union[tidy3d.components.medium.Medium, tidy3d.components.medium.AnisotropicMedium, tidy3d.components.medium.PECMedium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude, tidy3d.components.medium.FullyAnisotropicMedium, tidy3d.components.medium.CustomMedium, tidy3d.components.medium.CustomPoleResidue, tidy3d.components.medium.CustomSellmeier, tidy3d.components.medium.CustomLorentz, tidy3d.components.medium.CustomDebye, tidy3d.components.medium.CustomDrude, tidy3d.components.medium.CustomAnisotropicMedium, tidy3d.components.medium.PerturbationMedium, tidy3d.components.medium.PerturbationPoleResidue, tidy3d.components.medium.Medium2D]]#

Returns set of distinct AbstractMedium in scene.

Returns

Set of distinct mediums in the scene.

Return type

List[AbstractMedium]

perturbed_mediums_copy(temperature: Optional[tidy3d.components.data.data_array.SpatialDataArray] = None, electron_density: Optional[tidy3d.components.data.data_array.SpatialDataArray] = None, hole_density: Optional[tidy3d.components.data.data_array.SpatialDataArray] = None, interp_method: Literal['nearest', 'linear'] = 'linear') tidy3d.components.scene.Scene#

Return a copy of the scene with heat and/or charge data applied to all mediums that have perturbation models specified. That is, such mediums will be replaced with spatially dependent custom mediums that reflect perturbation effects. Any of temperature, electron_density, and hole_density can be None. All provided fields must have identical coords.

Parameters
  • temperature (SpatialDataArray = None) – Temperature field data.

  • electron_density (SpatialDataArray = None) – Electron density field data.

  • hole_density (SpatialDataArray = None) – Hole density field data.

  • interp_method (InterpMethod, optional) – Interpolation method to obtain heat and/or charge values that are not supplied at the Yee grids.

Returns

Simulation after application of heat and/or charge data.

Return type

Scene

plot(x: float = None, y: float = None, z: float = None, ax: matplotlib.axes._axes.Axes = None, hlim: Tuple[float, float] = None, vlim: Tuple[float, float] = None, **patch_kwargs) matplotlib.axes._axes.Axes#

Plot each of scene’s components on a plane defined by one nonzero x,y,z coordinate.

Parameters
  • x (float = None) – position of plane in x direction, only one of x, y, z must be specified to define plane.

  • y (float = None) – position of plane in y direction, only one of x, y, z must be specified to define plane.

  • z (float = None) – position of plane in z direction, only one of x, y, z must be specified to define plane.

  • ax (matplotlib.axes._subplots.Axes = None) – Matplotlib axes to plot on, if not specified, one is created.

  • hlim (Tuple[float, float] = None) – The x range if plotting on xy or xz planes, y range if plotting on yz plane.

  • vlim (Tuple[float, float] = None) – The z range if plotting on xz or yz planes, y plane if plotting on xy plane.

Returns

The supplied or created matplotlib axes.

Return type

matplotlib.axes._subplots.Axes

plot_eps(x: float = None, y: float = None, z: float = None, freq: float = None, alpha: float = None, ax: matplotlib.axes._axes.Axes = None, hlim: Tuple[float, float] = None, vlim: Tuple[float, float] = None) matplotlib.axes._axes.Axes#

Plot each of scene’s components on a plane defined by one nonzero x,y,z coordinate. The permittivity is plotted in grayscale based on its value at the specified frequency.

Parameters
  • x (float = None) – position of plane in x direction, only one of x, y, z must be specified to define plane.

  • y (float = None) – position of plane in y direction, only one of x, y, z must be specified to define plane.

  • z (float = None) – position of plane in z direction, only one of x, y, z must be specified to define plane.

  • freq (float = None) – Frequency to evaluate the relative permittivity of all mediums. If not specified, evaluates at infinite frequency.

  • alpha (float = None) – Opacity of the structures being plotted. Defaults to the structure default alpha.

  • ax (matplotlib.axes._subplots.Axes = None) – Matplotlib axes to plot on, if not specified, one is created.

  • hlim (Tuple[float, float] = None) – The x range if plotting on xy or xz planes, y range if plotting on yz plane.

  • vlim (Tuple[float, float] = None) – The z range if plotting on xz or yz planes, y plane if plotting on xy plane.

Returns

The supplied or created matplotlib axes.

Return type

matplotlib.axes._subplots.Axes

plot_heat_conductivity(x: float = None, y: float = None, z: float = None, alpha: float = None, cbar: bool = True, ax: matplotlib.axes._axes.Axes = None, hlim: Tuple[float, float] = None, vlim: Tuple[float, float] = None) matplotlib.axes._axes.Axes#

Plot each of scebe’s components on a plane defined by one nonzero x,y,z coordinate. The thermal conductivity is plotted in grayscale based on its value.

Parameters
  • x (float = None) – position of plane in x direction, only one of x, y, z must be specified to define plane.

  • y (float = None) – position of plane in y direction, only one of x, y, z must be specified to define plane.

  • z (float = None) – position of plane in z direction, only one of x, y, z must be specified to define plane.

  • alpha (float = None) – Opacity of the structures being plotted. Defaults to the structure default alpha.

  • cbar (bool = True) – Whether to plot a colorbar for the thermal conductivity.

  • ax (matplotlib.axes._subplots.Axes = None) – Matplotlib axes to plot on, if not specified, one is created.

  • hlim (Tuple[float, float] = None) – The x range if plotting on xy or xz planes, y range if plotting on yz plane.

  • vlim (Tuple[float, float] = None) – The z range if plotting on xz or yz planes, y plane if plotting on xy plane.

Returns

The supplied or created matplotlib axes.

Return type

matplotlib.axes._subplots.Axes

plot_structures(x: float = None, y: float = None, z: float = None, ax: matplotlib.axes._axes.Axes = None, hlim: Tuple[float, float] = None, vlim: Tuple[float, float] = None) matplotlib.axes._axes.Axes#

Plot each of scene’s structures on a plane defined by one nonzero x,y,z coordinate.

Parameters
  • x (float = None) – position of plane in x direction, only one of x, y, z must be specified to define plane.

  • y (float = None) – position of plane in y direction, only one of x, y, z must be specified to define plane.

  • z (float = None) – position of plane in z direction, only one of x, y, z must be specified to define plane.

  • ax (matplotlib.axes._subplots.Axes = None) – Matplotlib axes to plot on, if not specified, one is created.

  • hlim (Tuple[float, float] = None) – The x range if plotting on xy or xz planes, y range if plotting on yz plane.

  • vlim (Tuple[float, float] = None) – The z range if plotting on xz or yz planes, y plane if plotting on xy plane.

Returns

The supplied or created matplotlib axes.

Return type

matplotlib.axes._subplots.Axes

plot_structures_eps(x: float = None, y: float = None, z: float = None, freq: float = None, alpha: float = None, cbar: bool = True, reverse: bool = False, eps_lim: Tuple[Optional[float], Optional[float]] = (None, None), ax: matplotlib.axes._axes.Axes = None, hlim: Tuple[float, float] = None, vlim: Tuple[float, float] = None, grid: tidy3d.components.grid.grid.Grid = None) matplotlib.axes._axes.Axes#

Plot each of scene’s structures on a plane defined by one nonzero x,y,z coordinate. The permittivity is plotted in grayscale based on its value at the specified frequency.

Parameters
  • x (float = None) – position of plane in x direction, only one of x, y, z must be specified to define plane.

  • y (float = None) – position of plane in y direction, only one of x, y, z must be specified to define plane.

  • z (float = None) – position of plane in z direction, only one of x, y, z must be specified to define plane.

  • freq (float = None) – Frequency to evaluate the relative permittivity of all mediums. If not specified, evaluates at infinite frequency.

  • reverse (bool = False) – If False, the highest permittivity is plotted in black. If True, it is plotteed in white (suitable for black backgrounds).

  • cbar (bool = True) – Whether to plot a colorbar for the relative permittivity.

  • alpha (float = None) – Opacity of the structures being plotted. Defaults to the structure default alpha.

  • eps_lim (Tuple[float, float] = None) – Custom limits for eps coloring.

  • ax (matplotlib.axes._subplots.Axes = None) – Matplotlib axes to plot on, if not specified, one is created.

  • hlim (Tuple[float, float] = None) – The x range if plotting on xy or xz planes, y range if plotting on yz plane.

  • vlim (Tuple[float, float] = None) – The z range if plotting on xz or yz planes, y plane if plotting on xy plane.

Returns

The supplied or created matplotlib axes.

Return type

matplotlib.axes._subplots.Axes

plot_structures_heat_conductivity(x: float = None, y: float = None, z: float = None, alpha: float = None, cbar: bool = True, reverse: bool = False, ax: matplotlib.axes._axes.Axes = None, hlim: Tuple[float, float] = None, vlim: Tuple[float, float] = None) matplotlib.axes._axes.Axes#

Plot each of scene’s structures on a plane defined by one nonzero x,y,z coordinate. The thermal conductivity is plotted in grayscale based on its value.

Parameters
  • x (float = None) – position of plane in x direction, only one of x, y, z must be specified to define plane.

  • y (float = None) – position of plane in y direction, only one of x, y, z must be specified to define plane.

  • z (float = None) – position of plane in z direction, only one of x, y, z must be specified to define plane.

  • reverse (bool = False) – If False, the highest permittivity is plotted in black. If True, it is plotteed in white (suitable for black backgrounds).

  • cbar (bool = True) – Whether to plot a colorbar for the relative permittivity.

  • alpha (float = None) – Opacity of the structures being plotted. Defaults to the structure default alpha.

  • ax (matplotlib.axes._subplots.Axes = None) – Matplotlib axes to plot on, if not specified, one is created.

  • hlim (Tuple[float, float] = None) – The x range if plotting on xy or xz planes, y range if plotting on yz plane.

  • vlim (Tuple[float, float] = None) – The z range if plotting on xz or yz planes, y plane if plotting on xy plane.

Returns

The supplied or created matplotlib axes.

Return type

matplotlib.axes._subplots.Axes

property size: Tuple[pydantic.v1.types.NonNegativeFloat, pydantic.v1.types.NonNegativeFloat, pydantic.v1.types.NonNegativeFloat]#

Automatically defined scene’s size.

Returns

Scene’s size.

Return type

Tuple[float, float, float]

structures: Tuple[Structure, ...]#

Validating setup

to_file(fname: str) None#

Exports Tidy3dBaseModel instance to .yaml, .json, or .hdf5 file

Parameters

fname (str) – Full path to the .yaml or .json file to save the Tidy3dBaseModel to.

Example

>>> simulation.to_file(fname='folder/sim.json') 
to_hdf5(fname: str, custom_encoders: Optional[List[Callable]] = None) None#

Exports Tidy3dBaseModel instance to .hdf5 file.

Parameters
  • fname (str) – Full path to the .hdf5 file to save the Tidy3dBaseModel to.

  • custom_encoders (List[Callable]) – List of functions accepting (fname: str, group_path: str, value: Any) that take the value supplied and write it to the hdf5 fname at group_path.

Example

>>> simulation.to_hdf5(fname='folder/sim.hdf5') 
to_hdf5_gz(fname: str, custom_encoders: Optional[List[Callable]] = None) None#

Exports Tidy3dBaseModel instance to .hdf5.gz file.

Parameters
  • fname (str) – Full path to the .hdf5.gz file to save the Tidy3dBaseModel to.

  • custom_encoders (List[Callable]) – List of functions accepting (fname: str, group_path: str, value: Any) that take the value supplied and write it to the hdf5 fname at group_path.

Example

>>> simulation.to_hdf5_gz(fname='folder/sim.hdf5.gz') 
to_json(fname: str) None#

Exports Tidy3dBaseModel instance to .json file

Parameters

fname (str) – Full path to the .json file to save the Tidy3dBaseModel to.

Example

>>> simulation.to_json(fname='folder/sim.json') 
to_yaml(fname: str) None#

Exports Tidy3dBaseModel instance to .yaml file.

Parameters

fname (str) – Full path to the .yaml file to save the Tidy3dBaseModel to.

Example

>>> simulation.to_yaml(fname='folder/sim.yaml') 
classmethod tuple_to_dict(tuple_values: tuple) dict#

How we generate a dictionary mapping new keys to tuple values for hdf5.

classmethod update_forward_refs(**localns: Any) None#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

updated_copy(**kwargs) tidy3d.components.base.Tidy3dBaseModel#

Make copy of a component instance with **kwargs indicating updated field values.