tidy3d.HeatSimulationData#

class HeatSimulationData[source]#

Bases: AbstractSimulationData

Stores results of a heat simulation.

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, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • simulation (HeatSimulation) – Original HeatSimulation associated with the data.

  • data (Tuple[TemperatureData, ...]) – List of MonitorData instances associated with the monitors of the original Simulation.

  • log (Optional[str] = None) – A string containing the log information from the simulation run.

Example

>>> from tidy3d import Medium, SolidSpec, FluidSpec, UniformUnstructuredGrid, SpatialDataArray
>>> from tidy3d import Structure, Box, UniformUnstructuredGrid, UniformHeatSource
>>> from tidy3d import StructureBoundary, TemperatureBC, TemperatureMonitor, TemperatureData
>>> from tidy3d import HeatBoundarySpec
>>> import numpy as np
>>> temp_mnt = TemperatureMonitor(size=(1, 2, 3), name="sample")
>>> heat_sim = HeatSimulation(
...     size=(3.0, 3.0, 3.0),
...     structures=[
...         Structure(
...             geometry=Box(size=(1, 1, 1), center=(0, 0, 0)),
...             medium=Medium(
...                 permittivity=2.0, heat_spec=SolidSpec(
...                     conductivity=1,
...                     capacity=1,
...                 )
...             ),
...             name="box",
...         ),
...     ],
...     medium=Medium(permittivity=3.0, heat_spec=FluidSpec()),
...     grid_spec=UniformUnstructuredGrid(dl=0.1),
...     sources=[UniformHeatSource(rate=1, structures=["box"])],
...     boundary_spec=[
...         HeatBoundarySpec(
...             placement=StructureBoundary(structure="box"),
...             condition=TemperatureBC(temperature=500),
...         )
...     ],
...     monitors=[temp_mnt],
... )
>>> x = [1,2]
>>> y = [2,3,4]
>>> z = [3,4,5,6]
>>> coords = dict(x=x, y=y, z=z)
>>> temp_array = SpatialDataArray(300 * np.abs(np.random.random((2,3,4))), coords=coords)
>>> temp_mnt_data = TemperatureData(monitor=temp_mnt, temperature=temp_array)
>>> heat_sim_data = HeatSimulationData(
...     simulation=heat_sim, data=[temp_mnt_data],
... )

Attributes

data

log

Custom logger to avoid the complexities of the logging module

attrs

Methods

plot_field(monitor_name[,Β val,Β scale,Β ...])

Plot the data for a monitor with simulation plot overlaid.

Inherited Common Usage

simulation#
data#
plot_field(monitor_name, val='real', scale='lin', structures_alpha=0.2, robust=True, vmin=None, vmax=None, ax=None, **sel_kwargs)[source]#

Plot the data for a monitor with simulation plot overlaid.

Parameters:
  • field_monitor_name (str) – Name of TemperatureMonitorData to plot.

  • val (Literal['real', 'abs', 'abs^2'] = 'real') – Which part of the field to plot.

  • scale (Literal['lin', 'log']) – Plot in linear or logarithmic scale.

  • structures_alpha (float = 0.2) – Opacity of the structure permittivity. Must be between 0 and 1 (inclusive).

  • robust (bool = True) – If True and vmin or vmax are absent, uses the 2nd and 98th percentiles of the data to compute the color limits. This helps in visualizing the field patterns especially in the presence of a source.

  • vmin (float = None) – The lower bound of data range that the colormap covers. If None, they are inferred from the data and other keyword arguments.

  • vmax (float = None) – The upper bound of data range that the colormap covers. If None, they are inferred from the data and other keyword arguments.

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

  • sel_kwargs (keyword arguments used to perform .sel() selection in the monitor data.) – These kwargs can select over the spatial dimensions (x, y, z), or time dimension (t) if applicable. For the plotting to work appropriately, the resulting data after selection must contain only two coordinates with len > 1. Furthermore, these should be spatial coordinates (x, y, or z).

Returns:

The supplied or created matplotlib axes.

Return type:

matplotlib.axes._subplots.Axes

__hash__()#

Hash method.