tidy3d.SimulationMap#

class SimulationMap[source]#

Bases: ValueMap, Mapping[str, Simulation | HeatChargeSimulation | HeatSimulation | EMESimulation | ModeSolver | ModeSimulation | VolumeMesher]

An immutable dictionary-like container for simulations.

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.

  • values_tuple (Tuple[Union[Simulation, HeatChargeSimulation, HeatSimulation, EMESimulation, ModeSolver, ModeSimulation, VolumeMesher], ...]) – A tuple of Simulation objects, each corresponding to a key at the same index.

  • objects. (This class maps unique string keys to corresponding Simulation)

  • collections.abc.Mapping (By inheriting from)

  • dictionary (it provides standard)

  • (sims["sim_A"]) (behaviors like item access)

  • sims) (iteration (for name in)

  • and

  • (len(sims)). (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.

Type:

tuple[str, …]

values#

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

Type:

tuple[SimulationType, …]

Example

>>> from tidy3d import (
...     Simulation,
...     SimulationMap,
...     Structure,
...     Box,
...     Medium,
...     UniformCurrentSource,
...     GaussianPulse,
...     FieldMonitor,
...     GridSpec,
...     BoundarySpec,
...     PML,
... )
>>> # 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)
>>>
>>> # Instantiate the map
>>> simulation_map = SimulationMap(
...     keys=("sim_1", "sim_2"),
...     values=(sim1, sim2),
... )
>>>
>>> # Access a simulation like a dictionary
>>> # print(simulation_map["sim_1"])

Attributes

Methods

Inherited Common Usage

keys_tuple#
values_tuple#
__hash__()#

Hash method.