Tidy3DModel

class photonforge.Tidy3DModel(run_time=None, medium=None, symmetry=(0, 0, 0), boundary_spec=None, monitors=(), structures=(), grid_spec=None, shutoff=1.0e-5, subpixel=True, courant=0.99, port_symmetries=(), bounds=((None, None, None), (None, None, None)), verbose=True)

S matrix model based on Tidy3D FDTD calculation.

Parameters:
  • run_time (float | None) – Maximal simulation run-time (in seconds).

  • medium (Medium | AnisotropicMedium | PECMedium | PoleResidue | Sellmeier | Lorentz | Debye | Drude | FullyAnisotropicMedium | CustomMedium | CustomPoleResidue | CustomSellmeier | CustomLorentz | CustomDebye | CustomDrude | CustomAnisotropicMedium | PerturbationMedium | PerturbationPoleResidue | None) – Background medium. If None, the technology default is used.

  • symmetry (Sequence[int]) – Component symmetries.

  • boundary_spec (BoundarySpec | None) – Simulation boundary specifications (absorber by default).

  • monitors (Sequence[FieldMonitor | FieldTimeMonitor | PermittivityMonitor | FluxMonitor | FluxTimeMonitor | ModeMonitor | ModeSolverMonitor | FieldProjectionAngleMonitor | FieldProjectionCartesianMonitor | FieldProjectionKSpaceMonitor | DiffractionMonitor]) – Extra field monitors added to the simulation.

  • structures (Sequence[Structure]) – Additional structures included in the simulations.

  • grid_spec (float | GridSpec) – Simulation grid specification. A single float can be used to specify the min_steps_per_wvl for an auto grid.

  • shutoff (float) – Field decay factor for simulation termination.

  • subpixel (bool) – Flag controlling subpixel averaging in the simulation grid.

  • courant (float) – Courant stability factor.

  • port_symmetries (Sequence[tuple[str, str, dict[str, str]]]) – Port symmetries to reduce the number of simulation runs. See note below.

  • bounds (Sequence[Sequence[float | None]]) – Bound overrides for the final simulation.

  • verbose (bool) – Control solver verbosity.

If not set, the default values for the component simulations are defined based on the wavelengths used in the s_matrix call. In particular, boundary_spec is set to absorbers on all sides.

The start method accepts an inputs argument as a sequence or set of port names to limit the computation to those inputs. Instead of port names, {port}@{mode} specifications are also accepted.

Note

Each item in the port_symmetries sequence is a tuple (port1, port2, equivalents) indicating that the S matrix elements that have port2 as source are equal to those with port1 as source with destination ports replaced according to equivalents.

For example, ('1', '2', {'2':'3', '3':'1'}) in a 3-port component means all Sn2 (2nd column, with port 2 as source) have an equivalent in Sm1 (1st column, with port 1 as source), with m:n items in the equivalence dictionary, resulting in S22 = S11, S32 = S21, S12 = S31 (the equivalence '1':'2' is automatic). If ports are multimode, the symmetry applies to all modes, so equivalent port pairs must have the same number of modes.

Methods

batch_data_for(component)

Return the Tidy3D BatchData for a given component.

batch_file_for(component)

cache_size([size])

Get/set the runtime cache size for FDTD and mode simulations.

clear_cache()

Clear the runtime cache for FDTD and mode simulations, but not the file cache.

data_path_for(component)

from_bytes(byte_repr)

De-serialize this model.

get_simulations(component, frequencies[, ...])

Return all simulations required by this component.

s_matrix(component, frequencies[, ...])

Compute the S matrix for a component using this model.

start(component, frequencies, *[, inputs])

Start computing the S matrix response from a component.

update(*args, **kwargs)

Update this model.

Attributes

as_bytes

Serialize this model.

parametric_function

Function used to update a parametric component.

parametric_kwargs

Keyword arguments used to update a parametric component.

random_variables

List of monte_carlo.RandomVariable associated to this component's parameters.

property as_bytes: bytes

Serialize this model.

batch_data_for(component)

Return the Tidy3D BatchData for a given component.

Parameters:

component (Component)

Return type:

Any | None

static cache_size(size=None)

Get/set the runtime cache size for FDTD and mode simulations.

Parameters:

size (int | None) – Set a new cache size. A negative value removes the size limit.

Returns:

Current cache size.

Return type:

int

static clear_cache()

Clear the runtime cache for FDTD and mode simulations, but not the file cache.

Return type:

None

classmethod from_bytes(byte_repr)

De-serialize this model.

Parameters:

byte_repr (bytes)

Return type:

Tidy3DModel

get_simulations(component, frequencies, sources=())

Return all simulations required by this component.

Parameters:
  • component (Component) – Instance of Component for calculation.

  • frequencies (Sequence[float]) – Sequence of frequencies for the simulation.

  • sources (Sequence[str]) – Port names to be used as sources ({port}@{mode} specifications are also accepted). If empty, use all required sources based on this model’s port symmetries.

Returns:

Dictionary of tidy3d.Simulation indexed by source name or a single simulation if the component has no ports.

Return type:

Simulation

start(component, frequencies, *, inputs=(), **kwargs)

Start computing the S matrix response from a component.

Parameters:
  • component (Component) – Component from which to compute the S matrix.

  • frequencies (Sequence[float]) – Sequence of frequencies at which to perform the computation.

  • inputs (Sequence[str]) – Limit calculation to specific inputs. Each item must be a port name or a {port}@{mode} specification.

  • **kwargs – Unused.

Returns:

Result object with attributes status and s_matrix.

Return type:

_Tidy3DModelRunner

Important

When using geometry symmetry, the mode numbering in inputs is relative to the solver run with the symmetry applied, not the mode number presented in the final S matrix.