tidy3d.components.base_sim.simulation.AbstractSimulation#

class AbstractSimulation[source]#

Bases: Box, ABC

Base class for simulation classes of different solvers.

Parameters:
  • center (Optional[tuple[Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box]]] = None) – [units = um]. Center of object in x, y, and z.

  • size (tuple[Union[NonNegativeFloat, autograd.tracer.Box], Union[NonNegativeFloat, autograd.tracer.Box], Union[NonNegativeFloat, autograd.tracer.Box]]) – [units = um]. Size in x, y, and z directions.

  • medium (Union[Medium, AnisotropicMedium, PECMedium, PMCMedium, PoleResidue, Sellmeier, Lorentz, Debye, Drude, FullyAnisotropicMedium, CustomMedium, CustomPoleResidue, CustomSellmeier, CustomLorentz, CustomDebye, CustomDrude, CustomAnisotropicMedium, PerturbationMedium, PerturbationPoleResidue, LossyMetalMedium] = Medium()) – Background medium of simulation, defaults to vacuum if not specified.

  • structures (tuple[Structure, …] = ()) – Tuple of structures present in simulation. Note: Structures defined later in this list override the simulation material properties in regions of spatial overlap.

  • symmetry (tuple[Literal[0, -1, 1], Literal[0, -1, 1], Literal[0, -1, 1]] = (0, 0, 0)) – Tuple of integers defining reflection symmetry across a plane bisecting the simulation domain normal to the x-, y-, and z-axis at the simulation center of each axis, respectively.

  • sources (tuple[None, ...] = ()) – Sources in the simulation.

  • boundary_spec (Literal[None] = None) – Specification of boundary conditions.

  • monitors (tuple[None, ...] = ()) – Monitors in the simulation.

  • grid_spec (Literal[None] = None) – Specifications for the simulation grid.

  • version (str = 2.11.0.dev2) – String specifying the front end version number.

  • plot_length_units (Optional[Literal['nm', 'μm', 'um', 'mm', 'cm', 'm', 'mil', 'in']] = μm) – When set to a supported LengthUnit, plots will be produced with proper scaling of axes and include the desired unit specifier in labels.

  • structure_priority_mode (Literal['equal', 'conductor'] = equal) – This field only affects structures of priority=None. If equal, the priority of those structures is set to 0; if conductor, the priority of structures made of LossyMetalMedium is set to 90, PECMedium to 100, and others to 0.

Attributes

scene

Scene instance associated with the simulation.

simulation_bounds

Simulation bounds including auxiliary boundary zones such as PML layers.

simulation_geometry

The entire simulation domain including auxiliary boundary zones such as PML layers.

simulation_structure

Returns structure representing the domain of the simulation.

medium

Background medium of simulation, defaults to vacuum if not specified.

structures

Tuple of structures present in simulation.

symmetry

sources

boundary_spec

monitors

grid_spec

version

plot_length_units

structure_priority_mode

Validating setup

size

center

Methods

from_scene(scene, **kwargs)

Create a simulation from a Scene instance.

get_monitor_by_name(name)

Return monitor named 'name'.

plot([x, y, z, ax, source_alpha, ...])

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

plot_3d([width, height])

Render 3D plot of AbstractSimulation (in jupyter notebook only).

plot_boundaries([x, y, z, ax])

Plot the simulation boundary conditions as lines on a plane

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

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

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

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

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

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

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

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

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

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

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

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

validate_pre_upload()

Validate the fully initialized simulation is ok for upload to our servers.

medium#

Background medium of simulation, defaults to vacuum if not specified.

structures#

Tuple of structures present in simulation. Structures defined later in this list override the simulation material properties in regions of spatial overlap.

Example

Simple application reference:

Simulation(
    ...
    structures=[
         Structure(
         geometry=Box(size=(1, 1, 1), center=(0, 0, 0)),
         medium=Medium(permittivity=2.0),
         ),
    ],
    ...
)
symmetry#
sources#
boundary_spec#
monitors#
grid_spec#
version#
plot_length_units#
structure_priority_mode#

Validating setup

validate_pre_upload()[source]#

Validate the fully initialized simulation is ok for upload to our servers.

property scene#

Scene instance associated with the simulation.

get_monitor_by_name(name)[source]#

Return monitor named ‘name’.

property simulation_bounds#

Simulation bounds including auxiliary boundary zones such as PML layers.

property simulation_geometry#

The entire simulation domain including auxiliary boundary zones such as PML layers. It is identical to Simulation.geometry in the absence of such auxiliary zones.

property simulation_structure#

Returns structure representing the domain of the simulation. This differs from Simulation.scene.background_structure in that it has finite extent.

plot(x=None, y=None, z=None, ax=None, source_alpha=None, monitor_alpha=None, hlim=None, vlim=None, fill_structures=True, **patch_kwargs)[source]#

Plot each of simulation’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.

  • source_alpha (float = None) – Opacity of the sources. If None, uses Tidy3d default.

  • monitor_alpha (float = None) – Opacity of the monitors. If None, uses Tidy3d default.

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

  • fill_structures (bool = True) – Whether to fill structures with color or just draw outlines.

Returns:

The supplied or created matplotlib axes.

Return type:

matplotlib.axes._subplots.Axes

plot_sources(x=None, y=None, z=None, hlim=None, vlim=None, alpha=None, ax=None)[source]#

Plot each of simulation’s sources 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.

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

  • alpha (float = None) – Opacity of the sources, If None uses Tidy3d default.

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

Returns:

The supplied or created matplotlib axes.

Return type:

matplotlib.axes._subplots.Axes

plot_monitors(x=None, y=None, z=None, hlim=None, vlim=None, alpha=None, ax=None)[source]#

Plot each of simulation’s monitors 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.

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

  • alpha (float = None) – Opacity of the sources, If None uses Tidy3d default.

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

Returns:

The supplied or created matplotlib axes.

Return type:

matplotlib.axes._subplots.Axes

plot_symmetries(x=None, y=None, z=None, hlim=None, vlim=None, ax=None)[source]#

Plot each of simulation’s symmetries 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.

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

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

Returns:

The supplied or created matplotlib axes.

Return type:

matplotlib.axes._subplots.Axes

abstract plot_boundaries(x=None, y=None, z=None, ax=None, **kwargs)[source]#
Plot the simulation boundary conditions as lines 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.

  • **kwargs – Optional keyword arguments passed to the matplotlib LineCollection. For details on accepted values, refer to Matplotlib’s documentation.

Returns:

The supplied or created matplotlib axes.

Return type:

matplotlib.axes._subplots.Axes

plot_structures(x=None, y=None, z=None, ax=None, hlim=None, vlim=None, fill=True)[source]#

Plot each of simulation’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.

  • fill (bool = True) – Whether to fill structures with color or just draw outlines.

Returns:

The supplied or created matplotlib axes.

Return type:

matplotlib.axes._subplots.Axes

plot_structures_eps(x=None, y=None, z=None, freq=None, alpha=None, cbar=True, reverse=False, ax=None, hlim=None, vlim=None)[source]#

Plot each of simulation’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.

  • 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=None, y=None, z=None, alpha=None, cbar=True, reverse=False, ax=None, hlim=None, vlim=None)[source]#

Plot each of simulation’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.

  • 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

classmethod from_scene(scene, **kwargs)[source]#

Create a simulation from a Scene instance. Must provide additional parameters to define a valid simulation (for example, size, run_time, grid_spec, etc).

Parameters:
  • scene (Scene) – Scene containing structures information.

  • **kwargs – Other arguments

plot_3d(width=800, height=800)[source]#

Render 3D plot of AbstractSimulation (in jupyter notebook only). :param width: width of the 3d view dom’s size :type width: float = 800 :param height: height of the 3d view dom’s size :type height: float = 800