fdtdx.calculate_sparam

fdtdx.calculate_sparam#

fdtdx.calculate_sparam(objects, arrays, config, input_port_name, show_progress=True, input_normalization_detector_name=None, key=None)[source]#

Run the FDTD simulation and extract S-parameters from mode-overlap detectors.

Intended to be called with the outputs of setup_sparams_simulation(). Each ModeOverlapDetector in objects contributes one entry to the returned dictionary. Because a single simulation (with one active input port) measures the transmission to all output ports simultaneously, the dictionary keys are (detector_name, input_port_name) tuples so that results from multiple calls can be merged into a full S-matrix.

To simulate all input ports in one call (multiple simulations), use calculate_sparams().

Parameters:
  • objects (ObjectContainer) – ObjectContainer from setup_sparams_simulation().

  • arrays (ArrayContainer) – ArrayContainer from setup_sparams_simulation().

  • config (SimulationConfig) – SimulationConfig from setup_sparams_simulation().

  • input_port_name (str) – Name of the active input port. Should match the name field of the corresponding PortSpec, or the auto-generated name "Source_<i>" when no name was supplied.

  • show_progress (bool) – Whether to display the simulation progress bar.

  • input_normalization_detector_name (str | None) – Name (or substring) of the detector used to normalise the input power. Defaults to a detector whose name contains input_port_name.

  • key (Array | None) – JAX random key. Defaults to PRNGKey(0).

Return type:

tuple[dict[tuple[str, str], Array], dict[str, dict[str, Array]]]

Returns:

A 2-tuple (sparams, detector_states) where sparams maps (detector_name, input_port_name) to a complex scattering-amplitude array indexed by frequency. For the single-frequency detectors created by setup_sparams_simulation(), each value has shape (1,). detector_states is the final DetectorState dict for every detector in the simulation.