PhotonicComponents

class lightworks.sdk.circuit.photonic_components.Barrier(modes: list[int])

Adds a barrier across selected circuit modes.

get_unitary(n_modes: int) ndarray[Any, dtype[complex128]]

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

serialize() None

Creates a serializable tuple of details for the current component.

class lightworks.sdk.circuit.photonic_components.BeamSplitter(mode_1: int, mode_2: int, reflectivity: float | Parameter[float], convention: str)

Configurable beam splitter element between two assigned modes, with support for a number of different conventions.

get_unitary(n_modes: int) ndarray[Any, dtype[complex128]]

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

serialize() tuple[str, dict[str, Any]]

Creates a serializable tuple of details for the current component.

validate() None

Validates that convention and reflectivity values of the beam splitter are valid.

class lightworks.sdk.circuit.photonic_components.Component

Generic baseclass for all components. Implements a number of useful methods.

fields() list[str]

Returns a list of all field from the component dataclass.

abstract get_unitary(n_modes: int) ndarray[Any, dtype[complex128]]

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

abstract serialize() tuple[str, dict[str, Any]] | None

Creates a serializable tuple of details for the current component.

values() list[Any]

Returns a list of all values from the component dataclass.

class lightworks.sdk.circuit.photonic_components.Group(circuit_spec: list[Component], name: str, mode_1: int, mode_2: int, heralds: dict[str, dict[int, int]])

Stores a group of components which have been added to a circuit.

get_unitary(n_modes: int) None

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

serialize() None

Creates a serializable tuple of details for the current component.

class lightworks.sdk.circuit.photonic_components.Loss(mode: int, loss: float | Parameter[float])

Induces a loss on the selected circuit mode. This requires creation of additional loss modes in the unitary matrix.

get_unitary(n_modes: int) ndarray[Any, dtype[complex128]]

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

serialize() tuple[str, dict[str, Any]]

Creates a serializable tuple of details for the current component.

validate() None

Validates loss value is within allowed range.

class lightworks.sdk.circuit.photonic_components.ModeSwaps(swaps: dict[int, int])

Performs ideal swaps between selected modes of the circuit.

get_unitary(n_modes: int) ndarray[Any, dtype[complex128]]

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

serialize() tuple[str, dict[str, Any]]

Creates a serializable tuple of details for the current component.

validate() None

Performs validation of all properties of the mode swaps.

class lightworks.sdk.circuit.photonic_components.PhaseShifter(mode: int, phi: float | Parameter[float])

Implements a phase shift on the assigned mode.

get_unitary(n_modes: int) ndarray[Any, dtype[complex128]]

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

serialize() tuple[str, dict[str, Any]]

Creates a serializable tuple of details for the current component.

validate() None

Performs validation of all properties of the phase shifters.

class lightworks.sdk.circuit.photonic_components.UnitaryMatrix(mode: int, unitary: ndarray[Any, dtype[complex128]] | ParameterizedUnitary, label: str)

Implements a unitary transformation across a subset of circuit modes.

get_unitary(n_modes: int) ndarray[Any, dtype[complex128]]

Returns a unitary matrix corresponding to the transformation implemented by the component with size n_modes.

serialize() tuple[str, dict[str, Any]]

Creates a serializable tuple of details for the current component.

validate() None

Performs validation of all properties of the unitary matrix.

lightworks.sdk.circuit.photonic_components.is_real(value: Any) bool

General function for checking if a value is a real number.