tidy3d.SimulationDataMap#

class SimulationDataMap[source]#

Bases: ValueMap, Mapping[str, SimulationData | HeatChargeSimulationData | HeatSimulationData | EMESimulationData | MicrowaveModeSolverData | ModeSolverData | ModeSimulationData | VolumeMesherData]

An immutable dictionary-like container for simulation data.

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().

  • keys_tuple (Tuple[str, ...]) – A tuple of unique string identifiers for each simulation data object.

  • values_tuple (Tuple[Union[SimulationData, HeatChargeSimulationData, HeatSimulationData, EMESimulationData, MicrowaveModeSolverData, ModeSolverData, ModeSimulationData, VolumeMesherData], ...]) – A tuple of SimulationDataType objects, each corresponding to a key at the same index.

  • dictionary (It provides standard)

  • (data["key"]) (behaviors like item access)

  • data) (iteration (for key in)

  • and

  • (len(data)). (length checking)

  • values (It automatically validates that the keys and)

  • instantiation. (tuples have matching lengths upon)

keys#

A tuple of unique string identifiers for each simulation data object.

Type:

tuple[str, …]

values#

A tuple of SimulationDataType objects, each corresponding to a key at the same index.

Type:

tuple[SimulationDataType, …]

Example

>>> from tidy3d import (
...     Simulation,
...     SimulationData,
...     SimulationDataMap,
...     Structure,
...     Box,
...     Medium,
...     UniformCurrentSource,
...     GaussianPulse,
...     FieldMonitor,
...     GridSpec,
...     BoundarySpec,
...     Boundary,
...     PML,
... )
>>> import tidy3d as td
>>> # Simple minimal simulation
>>> sim1 = Simulation(
...     size=(4, 3, 3),
...     grid_spec=GridSpec.auto(min_steps_per_wvl=25),
...     structures=[
...         Structure(
...             geometry=Box(size=(1, 1, 1), center=(0, 0, 0)),
...             medium=Medium(permittivity=2.0),
...         ),
...     ],
...     sources=[
...         UniformCurrentSource(
...             size=(0, 0, 0),
...             center=(0, 0.5, 0),
...             polarization="Hx",
...             source_time=GaussianPulse(freq0=2e14, fwidth=4e13),
...         )
...     ],
...     monitors=[
...         FieldMonitor(
...             size=(1, 1, 0),
...             center=(0, 0, 0),
...             freqs=[2e14],
...             name='field'
...         ),
...     ],
...     run_time=1e-12,
...     boundary_spec=BoundarySpec.all_sides(boundary=PML()),
... )
>>> sim2 = sim1.updated_copy(run_time=2e-12)
>>>
>>> sim_data_1 = td.SimulationData(
...     simulation=sim1,
...     data=()  # Empty tuple for minimal case
... )
>>> sim_data_2 = td.SimulationData(
...     simulation=sim2,
...     data=()  # Empty tuple for minimal case
... )
>>> # Instantiate the map
>>> simulation_data_map = SimulationDataMap(
...     keys=("data_1", "data_2"),
...     values=(sim_data_1, sim_data_2),
... )
>>>
>>> # Access a simulation data like a dictionary
>>> # print(simulation_data_map["data_2"])

Attributes

Methods

Inherited Common Usage

keys_tuple#
values_tuple#
__hash__()#

Hash method.